public Result Authenticate([FromBody] AuthenticationInfo authInfo) { Result res = new Result(); try { if (authInfo.UserName == null || authInfo.Password == null) { res.State = 1; res.Message = "验证信息不合法"; } else { var user = this._privilegeService.GetUsers() .Find(user => user.LoginName == authInfo.UserName && user.Password.ToUpper() == authInfo.Password.ToUpper()); if (user == null) { res.State = 2; res.Message = "当前用户不合法"; } else { res.Data = new { token = JWTHelper.CreateJWTToken(), user = _mapper.Map <UserDTO>(user) }; //res.Data = _mapper.Map<UserDTO>(user); res.Message = "当前用户验证成功"; } } } catch (System.Exception e) { _logger.LogError("验证用户失败:{0}", e.Message); res.Data = e; res.State = -1; //throw; } return(res); }