Example #1
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <LoginUser> Login(EmployeeRequestDto input)
        {
            var userAccount = await _employeeAppService.EmployeeLogin(input.UserId);

            if (userAccount == null)
            {
                var _loginUser = new LoginUser()
                {
                    IsSucceed = false, Message = "用户名不存在!"
                };
                return(await Task.FromResult(_loginUser));
            }
            var encryptPassword = AESCryption.EncryptText(input.Password, userAccount.Salt);

            if (!string.Equals(encryptPassword, userAccount.Password))
            {
                var _loginUser = new LoginUser()
                {
                    IsSucceed = false, Message = "密码错误!"
                };
                return(await Task.FromResult(_loginUser));
            }
            //var menuIds = await GetEmployeeMenuAsync(userAccount.Id);
            var elements = await GetEmployeeModuleElementAsync(userAccount.Id);

            var elementIds  = elements.Select(e => e.Id).ToList();
            var elementDtos = await _moduleElementAppService.GetElementByIds(elementIds);

            var routePaths = elementDtos.Select(r => r.RoutePath).ToList();

            return(await Task.FromResult(new LoginUser()
            {
                RoutePaths = routePaths,
                IsSucceed = true,
                Name = userAccount.Name,
                Account = userAccount.UserId,
                ExpireDateTime = DateTime.Now.AddHours(8),
                UserId = userAccount.Id,
            }));
        }