From 67e43c656b75d8bf27f1d4f7441e116e2cea25c5 Mon Sep 17 00:00:00 2001 From: lijianyou Date: Tue, 14 Oct 2025 22:17:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=B4=A6=E6=88=B7=E4=BB=BB?= =?UTF-8?q?=E6=84=8F=E5=A1=AB=E5=86=99=E9=83=BD=E8=83=BD=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/AuthController.cs | 2 +- README.md | 4 ++-- repository/UserRepository.cs | 11 +++++++++-- service/UserService.cs | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Controllers/AuthController.cs b/Controllers/AuthController.cs index c79a22c..ccd5ae7 100644 --- a/Controllers/AuthController.cs +++ b/Controllers/AuthController.cs @@ -112,7 +112,7 @@ namespace dy.net.Controllers } else { - var user = await _userService.GetUser(); + var user = await _userService.GetUser(loginUserInfo.UserName); if (user == null) { diff --git a/README.md b/README.md index 5b9fd4f..cc701c2 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ docker run -d --restart=always \ -v /你的/本地/数据库/路径:/app/db \ -p 18101:10101 \ --name dysync2025 \ - registry.cn-hangzhou.aliyuncs.com/jianzhichu/dysync.net:v1.0.3 + registry.cn-hangzhou.aliyuncs.com/jianzhichu/dysync.net ###-p 后面的第二个端口 必须10101(源码里面写死了) ``` @@ -73,7 +73,7 @@ version: '3.8' services: dysync: - image: registry.cn-hangzhou.aliyuncs.com/jianzhichu/dysync.net:v1.0.3 + image: registry.cn-hangzhou.aliyuncs.com/jianzhichu/dysync.net container_name: dysync2025 # 容器名称,可自定义 restart: always # 容器异常退出时自动重启 ports: diff --git a/repository/UserRepository.cs b/repository/UserRepository.cs index e6fabd6..5291571 100644 --- a/repository/UserRepository.cs +++ b/repository/UserRepository.cs @@ -50,9 +50,16 @@ namespace dy.net.repository } - public async Task GetUser() + public async Task GetUser(string userName=null) { - return await this.GetFirstAsync(x=>!string.IsNullOrWhiteSpace(x.Id)); + if (string.IsNullOrWhiteSpace(userName)) + { + return await this.GetFirstAsync(x=>!string.IsNullOrWhiteSpace(x.Id)); + } + else + { + return await this.GetFirstAsync(x => x.UserName == userName); + } } diff --git a/service/UserService.cs b/service/UserService.cs index 1442a10..e4ae5f6 100644 --- a/service/UserService.cs +++ b/service/UserService.cs @@ -20,9 +20,9 @@ namespace dy.net.service return await _userRepository.UpdatePwd(loginUser); } - public async Task GetUser() + public async Task GetUser(string userName=null) { - return await _userRepository.GetUser(); + return await _userRepository.GetUser(userName); } public async Task UpdateAvatar(string avatar)