| | |
| | | using WMS.IBLL.ISysServer; |
| | | using Wms.Tools; |
| | | using Utility; |
| | | using Model.ModelDto.SysDto; |
| | | |
| | | namespace Wms.Controllers |
| | | { |
| | |
| | | /// <param name="model">登录名</param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public async Task<string> Login(LoginVm model) |
| | | public async Task<UserDto> Login(LoginVm model) |
| | | { |
| | | if (ModelState.IsValid) |
| | | { |
| | | var userId = await _userMan.LoginAdmin(model.LoginName, model.LoginPwd); |
| | | var user = await _userMan.LoginAdmin(model.LoginName, model.LoginPwd); |
| | | UserDto dto = new UserDto(); |
| | | |
| | | if (userId != -1 && userId != -2) // |
| | | if (user.Id != -1 && user.Id != -2) // |
| | | { |
| | | if (userId != 0) //正确返回 |
| | | if (user.Id != 0) //正确返回 |
| | | { |
| | | Dictionary<string, string> keyValuePairs = new Dictionary<string, string> |
| | | { |
| | | {"loginID", userId.ToString()}, |
| | | {"LoginName", model.LoginName} |
| | | }; |
| | | { |
| | | {"loginID", user.Id.ToString()}, |
| | | {"LoginName", model.LoginName} |
| | | }; |
| | | var tnToken = tokenHelper.CreateToken(keyValuePairs); |
| | | return tnToken.TokenStr; |
| | | |
| | | dto.Token = tnToken.TokenStr; |
| | | dto.RealName = user.RealName; |
| | | |
| | | return dto; |
| | | } |
| | | else //当前账号被禁用 |
| | | { |
| | |
| | | throw Oops.Bah("当前账号已被禁用"); |
| | | } |
| | | } |
| | | else if (userId == -1) //账号密码错误 |
| | | else if (user.Id == -1) //账号密码错误 |
| | | { |
| | | throw Oops.Bah("当前账号或密码错误"); |
| | | } |