From 6bb36b15547fb56a5b3bc82047333be4dcae35b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Wed, 22 Jul 2026 14:09:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(user):=20=E6=B7=BB=E5=8A=A0=E8=AE=BE?= =?UTF-8?q?=E4=B8=BA=E5=BC=80=E5=8F=91=E8=80=85=E5=8A=9F=E8=83=BD=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=92=8C=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在UserController中新增设为开发者的接口,支持审核通过时标记用户 - 在UserService接口中新增markAsDeveloper方法声明 - 在UserServiceImpl中实现markAsDeveloper方法,将用户标记为开发者状态 - 标记成功后通过消息队列异步同步用户数据到websopy系统 - 添加接口权限校验,操作日志记录及接口文档说明 --- .../system/controller/UserController.java | 14 +++++++++++++ .../common/system/service/UserService.java | 8 +++++++ .../system/service/impl/UserServiceImpl.java | 21 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/src/main/java/com/gxwebsoft/common/system/controller/UserController.java b/src/main/java/com/gxwebsoft/common/system/controller/UserController.java index c342b94..1d7e2b2 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/UserController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/UserController.java @@ -364,6 +364,20 @@ public class UserController extends BaseController { return fail("修改失败"); } + @PreAuthorize("hasAuthority('sys:userRole:save')") + @OperationLog + @Operation(summary = "设为开发者(审核通过时标记,不新增角色)") + @PutMapping("/developer/{userId}") + public ApiResult setDeveloper(@PathVariable("userId") Integer userId) { + if (userId == null) { + return fail("参数不正确"); + } + if (userService.markAsDeveloper(userId)) { + return success("已设为开发者"); + } + return fail("操作失败"); + } + @PreAuthorize("hasAuthority('sys:user:update')") @OperationLog @Operation(summary = "批量修改用户状态") diff --git a/src/main/java/com/gxwebsoft/common/system/service/UserService.java b/src/main/java/com/gxwebsoft/common/system/service/UserService.java index fd8d8d7..7dd41c1 100644 --- a/src/main/java/com/gxwebsoft/common/system/service/UserService.java +++ b/src/main/java/com/gxwebsoft/common/system/service/UserService.java @@ -76,6 +76,14 @@ public interface UserService extends IService, UserDetailsService { */ boolean updateUser(User user); + /** + * 将用户标记为开发者(审核通过时调用,直接更新用户标记位,不新增角色) + * + * @param userId 用户id + * @return boolean + */ + boolean markAsDeveloper(Integer userId); + /** * 比较用户密码 * diff --git a/src/main/java/com/gxwebsoft/common/system/service/impl/UserServiceImpl.java b/src/main/java/com/gxwebsoft/common/system/service/impl/UserServiceImpl.java index 37f1091..3057326 100644 --- a/src/main/java/com/gxwebsoft/common/system/service/impl/UserServiceImpl.java +++ b/src/main/java/com/gxwebsoft/common/system/service/impl/UserServiceImpl.java @@ -213,6 +213,27 @@ public class UserServiceImpl extends ServiceImpl implements Us return result; } + @Override + @Transactional(rollbackFor = Exception.class) + public boolean markAsDeveloper(Integer userId) { + if (userId == null) { + return false; + } + User user = new User(); + user.setUserId(userId); + user.setIsDeveloper(true); + boolean result = updateById(user); + // 标记开发者后,通过MQ异步同步用户数据到 websopy + if (result && syncMessageProducer != null) { + User updatedUser = getAllByUserId(String.valueOf(userId)); + if (updatedUser != null) { + syncMessageProducer.sendUserSyncMessage("websopy", "UPDATE", updatedUser); + log.info("用户设为开发者后同步到websopy: userId={}", userId); + } + } + return result; + } + @Override public boolean comparePassword(String dbPassword, String inputPassword) { return bCryptPasswordEncoder.matches(inputPassword, dbPassword);