feat: 用户管理模块
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import com.inspur.llm.chat.base.base.BaseController;
|
||||
import com.inspur.llm.chat.gpt.constant.SysLogTypeConstant;
|
||||
import com.inspur.llm.chat.gpt.enums.BusinessTypeEnum;
|
||||
import com.inspur.llm.chat.gpt.pojo.annotation.Log;
|
||||
import com.inspur.llm.chat.gpt.pojo.command.SysUserPasswordCommand;
|
||||
import com.inspur.llm.chat.gpt.pojo.command.UserCommand;
|
||||
import com.inspur.llm.chat.gpt.pojo.entity.IPageInfo;
|
||||
import com.inspur.llm.chat.gpt.pojo.entity.Query;
|
||||
@@ -105,6 +106,19 @@ public class UserController extends BaseController {
|
||||
return userService.updateUser(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员重置用户密码
|
||||
*
|
||||
* @author: Auto
|
||||
* @date: 2026-04-08
|
||||
* @version: 1.0.0
|
||||
*/
|
||||
@PutMapping("/password/reset")
|
||||
@Log(type = SysLogTypeConstant.DEFAULT, businessType = BusinessTypeEnum.UPDATE)
|
||||
public ResponseInfo resetPassword(@RequestBody SysUserPasswordCommand command) {
|
||||
return userService.resetPassword(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除会员用户
|
||||
*
|
||||
|
||||
@@ -104,6 +104,11 @@ public class User extends BaseEntity {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否管理员 0否 1是
|
||||
*/
|
||||
private Boolean admind;
|
||||
|
||||
/**
|
||||
* 是否删除 0->未删除;1->已删除
|
||||
*/
|
||||
|
||||
@@ -108,4 +108,9 @@ public class UserVO implements Serializable {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否管理员 0否 1是
|
||||
*/
|
||||
private Boolean admind;
|
||||
|
||||
}
|
||||
|
||||
@@ -119,4 +119,12 @@ public interface IUserService extends IService<User> {
|
||||
*/
|
||||
ResponseInfo removeUserById(Long id);
|
||||
|
||||
/**
|
||||
* 管理员重置用户密码
|
||||
*
|
||||
* @param command 包含用户id和新密码
|
||||
* @return 结果
|
||||
*/
|
||||
ResponseInfo resetPassword(SysUserPasswordCommand command);
|
||||
|
||||
}
|
||||
|
||||
@@ -108,10 +108,17 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
}
|
||||
user = DozerUtil.convertor(command, User.class);
|
||||
user.setCreateUser(command.getOperater());
|
||||
String name = "手机用户" + RandomUtil.randomString(6);
|
||||
user.setUid(UUID.fastUUID().toString());
|
||||
user.setName(name);
|
||||
user.setNickName(name);
|
||||
if (ValidatorUtil.isNull(user.getName()) || user.getName().isEmpty()) {
|
||||
String name = "手机用户" + RandomUtil.randomString(6);
|
||||
user.setName(name);
|
||||
user.setNickName(name);
|
||||
} else if (ValidatorUtil.isNull(user.getNickName()) || user.getNickName().isEmpty()) {
|
||||
user.setNickName(user.getName());
|
||||
}
|
||||
if (ValidatorUtil.isNotNull(command.getPassword()) && !command.getPassword().isEmpty()) {
|
||||
user.setPassword(JWTPasswordEncoder.bcryptEncode(command.getPassword()));
|
||||
}
|
||||
user.setType(UserTypeEnum.TEL.getValue());
|
||||
userMapper.insert(user);
|
||||
return ResponseInfo.success();
|
||||
@@ -185,4 +192,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
return ResponseInfo.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "masterTransactionManager")
|
||||
public ResponseInfo resetPassword(SysUserPasswordCommand command) {
|
||||
User user = getUser(command.getId());
|
||||
user.setPassword(JWTPasswordEncoder.bcryptEncode(command.getNewPassword()));
|
||||
userMapper.updateById(user);
|
||||
return ResponseInfo.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
<result column="share_id" property="shareId"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="admind" property="admind"/>
|
||||
<result column="deleted" property="deleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
t.id, t.create_user, t.create_time, t.update_user, t.update_time, t.login_time, t.uid, t.name, t.nick_name, t.tel, t.password,
|
||||
t.avatar, t.openid, t.unionid, t.ip, t.context, t.num, t.share_id, t.type, t.status, t.deleted
|
||||
t.avatar, t.openid, t.unionid, t.ip, t.context, t.num, t.share_id, t.type, t.status, t.admind, t.deleted
|
||||
</sql>
|
||||
|
||||
<!-- 通用查询条件 -->
|
||||
|
||||
Reference in New Issue
Block a user