using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Threading.Tasks; using System.Web.Http; using log4net; using UFIDA.U8.Framework.Api.ControlObject.Common; using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.U8M; using UFIDA.U8.Framework.Api.Models; using UFIDA.U8.Framework.Api.Unit; namespace UFIDA.U8.Framework.Api.Controllers.U8 { public class DPController : ApiController { /// /// 日志组件 /// protected readonly ILog logInfo = LogManager.GetLogger("logInfo"); /// /// U8登录接口 /// /// /// [HttpPost] [Route("api/U8/DP/Login")] public async Task> Login( [FromBody] LoginParamter input) { try { var logn = new BaseLogin(); logn.Init(input, false); var userToken = logn.userToken; if (!string.IsNullOrWhiteSpace(userToken)) { return new BaseResult() { bSuccess = true, message = "登录成功", result = userToken }; } await Task.Delay(1); throw new Exception("未知错误,请检查系统日志"); } catch (Exception ex) { logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "登录失败", result = ex.Message }; } } /// /// 获取U8密码 /// /// /// [HttpGet] [Route("api/U8/DP/GetPassword")] public async Task> GetPassword(string cPwd) { try { return new BaseResult() { bSuccess = true, message = "加密成功", result = CommonHelper.U8Encrypt(cPwd) }; } catch (Exception ex) { logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "登录失败", result = ex.Message }; } } /// /// 获取对接账套设置 /// /// /// [HttpPost] [Route("api/U8/DP/GetAccountConfig")] public async Task> GetAccountConfig([FromBody] U8AccountConfigInput input) { try { var db = CommUnit.GetDbClient(); var res = await db.Queryable() .Where(a => a.cAccountNo == input.cAccId) .FirstAsync(); return new BaseResult { bSuccess = true, message = "查询成功", result = res }; } catch (Exception ex) { logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "查询失败", result = ex.Message }; } } } }