feat(user): 添加设为开发者功能接口和业务逻辑
- 在UserController中新增设为开发者的接口,支持审核通过时标记用户 - 在UserService接口中新增markAsDeveloper方法声明 - 在UserServiceImpl中实现markAsDeveloper方法,将用户标记为开发者状态 - 标记成功后通过消息队列异步同步用户数据到websopy系统 - 添加接口权限校验,操作日志记录及接口文档说明
This commit is contained in:
@@ -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 = "批量修改用户状态")
|
||||
|
||||
@@ -76,6 +76,14 @@ public interface UserService extends IService<User>, UserDetailsService {
|
||||
*/
|
||||
boolean updateUser(User user);
|
||||
|
||||
/**
|
||||
* 将用户标记为开发者(审核通过时调用,直接更新用户标记位,不新增角色)
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return boolean
|
||||
*/
|
||||
boolean markAsDeveloper(Integer userId);
|
||||
|
||||
/**
|
||||
* 比较用户密码
|
||||
*
|
||||
|
||||
@@ -213,6 +213,27 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> 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);
|
||||
|
||||
Reference in New Issue
Block a user