public async Task <MessageModel <string> > ChangeData([FromBody] ChangeDataVO changeData)
        {
            var data = new MessageModel <string>();

            try
            {
                if (changeData.UserId == Guid.Empty)
                {
                    changeData.UserId = UserId.Value;
                }
                data.success = await _userserver.ChangeData(changeData);

                if (data.success)
                {
                    data.msg = "密码修改成功";
                }
                else
                {
                    data.msg = "密码修改失败";
                }
                return(data);
            }
            catch (Exception ex)
            {
                data.msg = ex.Message;
                return(data);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 用户个人资料修改
        /// </summary>
        /// <param name="sysUser"></param>
        /// <returns></returns>
        public async Task <bool> ChangeData(ChangeDataVO changeData)
        {
            try
            {
                var model = await _userRepositoty.GetModelAsync(changeData.UserId);

                if (model == null)
                {
                    throw new Exception("用户信息不存在,不可修改密码!");
                }
                model = MyMappers.ObjectMapper.Map <ChangeDataVO, SysUser>(changeData, model);
                return(await _userRepositoty.UpdateAsync(model));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }