From f862e5ea1ba01a1bb1529fa484dab908a9418c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Sun, 25 Sep 2022 20:04:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8E=BB=E9=87=8D=E5=88=A4?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UserController.cs | 11 ++++++++++- .../yi-sqlsugar-dev.db | Bin 172032 -> 172032 bytes 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs index f8406471..c57b935e 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -87,6 +87,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPut] public async Task Update(UserInfoDto userDto) { + if (await _iUserService._repository.IsAnyAsync(u => userDto.User.UserName.Equals(u.UserName)&&!userDto.User.Id.Equals(u.Id))) + { + return Result.Error("用户名已存在,修改失败!"); + } return Result.Success().SetStatus(await _iUserService.UpdateInfo(userDto)); } @@ -109,7 +113,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [HttpPost] public async Task Add(UserInfoDto userDto) - { + { + if (await _iUserService._repository.IsAnyAsync(u => userDto.User.UserName.Equals(u.UserName))) + { + return Result.Error("用户已经存在,添加失败!"); + } + return Result.Success().SetStatus(await _iUserService.AddInfo(userDto)); } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index f907f23a990a9fa099122a05bac281313ba651b8..503721e86ad6e1ffa5b0bfa0390d7e4bd386da40 100644 GIT binary patch delta 242 zcmZoTz}0YoYl1XmkBcYxtS?3^wx#DDl-d8Zk?w0V!!+%UvEDXM`ttt zw8Q{UH%o(J6ANAcg1`uO&k!^BqKw2q=j5VLlYkU+|EgTe@{~Zc(qxlTr*vCeLnC8D kqs>p{G#D9gZRS%r&(FpSc4zZr{r1QDjN2dUGszYJ0DU?~mH+?% delta 72 zcmV-O0Jr~uzzTrC3XmHCSCJe;0avkLtPcVQS+fohA`X)f9~766bO8mEKp&j5