From b53678eec74cadc4d8d5773343b10ffa2adc5330 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期二, 03 九月 2024 09:50:27 +0800 Subject: [PATCH] 最新代码 --- cylsg/cylsg.Application/Users/UserAppService.cs | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-) diff --git a/cylsg/cylsg.Application/Users/UserAppService.cs b/cylsg/cylsg.Application/Users/UserAppService.cs index bac83be..a3f0c08 100644 --- a/cylsg/cylsg.Application/Users/UserAppService.cs +++ b/cylsg/cylsg.Application/Users/UserAppService.cs @@ -285,6 +285,60 @@ } - + + + /// <summary> + /// 淇濆瓨鐢ㄦ埛淇℃伅 + /// </summary> + /// <returns></returns> + public async Task<bool> saveUser(UserDto userDto) + { + + var UserID = App.User?.FindFirstValue("UserID"); + int userid = 0; + string NickName = App.User?.FindFirstValue("NickName"); + if (!string.IsNullOrEmpty(UserID)) + { + userid = int.Parse(UserID); + } + if (!string.IsNullOrEmpty(userDto.Nickname) && userDto.Nickname.Length > 100) + { + throw Oops.Oh("鏄电О闀垮害杩囬暱锛�"); + } + if (!string.IsNullOrEmpty(userDto.Avatar) && userDto.Avatar.Length > 500) + { + throw Oops.Oh("澶村儚闀垮害杩囬暱锛�"); + } + + + var userRes = new BaseRepository<User>(); + bool res; + + var user = await userRes.GetByIdAsync(userid); + + if (!string.IsNullOrEmpty(userDto.Nickname)) + user.Nickname = userDto.Nickname; + if (!string.IsNullOrEmpty(userDto.Avatar)) + user.Avatar = userDto.Avatar; + + + user.UpDataBy = NickName; + user.UpDataTime = DateTime.Now; + res = await userRes.UpdateAsync(user); + + + + + + + + + + + return res; + } + + + } } -- Gitblit v1.9.1