Ejemplo n.º 1
0
        public async Task <IResponseEntity> UpdateAsync(UserEditRequest req)
        {
            if (req == null || req?.Id == "")
            {
                return(ResponseEntity.Error("更新的实体主键丢失"));
            }
            var entity = await _sysUserRepository.GetAsync(req.Id);

            if (entity == null || entity.Id == "")
            {
                return(ResponseEntity.Error("用户不存在!"));
            }

            if (entity.PermissionId != req.PermissionId)
            {
                //清除权限模板的资源缓存
                await _cache.RemoveByPatternAsync(CacheKeyTemplate.PermissionResourceList);

                //清除权限模板的API缓存
                await _cache.RemoveByPatternAsync(CacheKeyTemplate.PermissionApiList);
            }

            _mapper.Map(req, entity);
            //var entity = _mapper.Map<SysUserEntity>(req);
            await _sysUserRepository.UpdateAsync(entity);

            return(ResponseEntity.Ok("更新成功"));
        }
Ejemplo n.º 2
0
        public async Task <IResponseEntity> LoginAsync(AuthLoginRequest req)
        {
            var           password = MD5Encrypt.Encrypt32(req.Password);
            SysUserEntity user     = new SysUserEntity();

            using (_userRepository.DataFilter.Disable("Group"))
            {
                user = await _userRepository.GetAsync(a => a.UserName == req.UserName && a.Password == password);
            }

            if (user?.Id == "")
            {
                return(ResponseEntity.Error("账号或密码错误!"));
            }

            var res = await getUserItem(user);

            return(ResponseEntity.Ok(res));
        }