Example #1
0
        public async Task <IActionResult> Get()
        {
            var apiData = new ApiResultModel();
            var userId  = UserHttpInfo.GetValueByToken(Common.Utility.Models.Config.TokenInfoType.UserId);
            var user    = await sysUsersService.GetModelAsync(userId);//根据id获取用户信息

            var requestAuth = new RequestAuthModel()
            {
                Key    = user.user_account,
                Secret = user.user_pwd
            };
            //通过用户信息获取最新的token
            var responesToken = await new ToKenService().GetTokenAsync(requestAuth);

            if (responesToken.IsError)
            {
                apiData.Code = ErrorCodeType.ServerError;
                apiData.SetErrorCodeTypeMsg();
            }
            else
            {
                apiData.Result = responesToken;
            }
            return(Ok(apiData));
        }
Example #2
0
        public async Task <IActionResult> Post([FromBody] RequestAuthModel authModel)
        {
            var apiData       = new ApiResultModel();
            var responesToken = await new ToKenService().GetTokenAsync(authModel);

            if (responesToken.IsError)
            {
                apiData.Code = ErrorCodeType.KeyOrSecretError;
                apiData.SetErrorCodeTypeMsg();
            }
            else
            {
                apiData.Result = responesToken;
            }
            return(Ok(apiData));
        }