Exemplo n.º 1
0
        /// <summary>
        /// 更新指定用户的密码
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public async Task <IResponseEntity> UserChangePasswordAsync(UserChangePasswordRequest req)
        {
            if (req == null || req?.Id == "")
            {
                return(ResponseEntity.Error("更新的实体主键丢失"));
            }

            if (req.Password != req.ConfirmPassword)
            {
                return(ResponseEntity.Error("两次密码不一致,请重新输入"));
            }
            var password = MD5Encrypt.Encrypt32(req.Password);
            var item     = new SysUserEntity()
            {
                Id = req.Id, Revision = req.Revision
            };

            _sysUserRepository.Attach(item);            //此时快照 item
            item.Password = password;
            await _sysUserRepository.UpdateAsync(item); //对比快照时的变化


            return(ResponseEntity.Ok("更新成功"));
        }