refactor: 优化用户管理相关 API
This commit is contained in:
parent
df59cee985
commit
5269608c61
@ -42,11 +42,11 @@ public class UserQuery implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
* 关键词
|
||||
*/
|
||||
@Schema(description = "用户名", example = "zhangsan")
|
||||
@Query(columns = {"username", "nickname"}, type = QueryType.LIKE)
|
||||
private String username;
|
||||
@Schema(description = "关键词", example = "zhangsan")
|
||||
@Query(columns = {"username", "nickname", "description"}, type = QueryType.LIKE)
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
|
@ -16,15 +16,13 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.resp;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import lombok.Data;
|
||||
import top.charles7c.continew.admin.common.enums.DataScopeEnum;
|
||||
import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum;
|
||||
import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp;
|
||||
import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
@ -34,7 +32,7 @@ import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "角色信息")
|
||||
public class RoleResp extends BaseResp {
|
||||
public class RoleResp extends BaseDetailResp {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -142,10 +142,10 @@ public class UserDetailResp extends BaseDetailResp {
|
||||
private List<Long> roleIds;
|
||||
|
||||
/**
|
||||
* 所属角色
|
||||
* 角色
|
||||
*/
|
||||
@Schema(description = "所属角色", example = "测试人员")
|
||||
@ExcelProperty(value = "所属角色")
|
||||
@Schema(description = "角色", example = "测试人员")
|
||||
@ExcelProperty(value = "角色")
|
||||
private String roleNames;
|
||||
|
||||
@Override
|
||||
|
@ -16,12 +16,16 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.resp;
|
||||
|
||||
import cn.crane4j.annotation.AssembleMethod;
|
||||
import cn.crane4j.annotation.ContainerMethod;
|
||||
import cn.crane4j.annotation.Mapping;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum;
|
||||
import top.charles7c.continew.admin.common.enums.GenderEnum;
|
||||
import top.charles7c.continew.admin.common.util.helper.LoginHelper;
|
||||
import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp;
|
||||
import top.charles7c.continew.admin.system.service.DeptService;
|
||||
import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp;
|
||||
import top.charles7c.continew.starter.security.mask.annotation.JsonMask;
|
||||
import top.charles7c.continew.starter.security.mask.enums.MaskType;
|
||||
|
||||
@ -36,7 +40,7 @@ import java.util.Objects;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户信息")
|
||||
public class UserResp extends BaseResp {
|
||||
public class UserResp extends BaseDetailResp {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -97,6 +101,19 @@ public class UserResp extends BaseResp {
|
||||
@Schema(description = "描述", example = "张三描述信息")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 部门 ID
|
||||
*/
|
||||
@Schema(description = "部门 ID", example = "5")
|
||||
@AssembleMethod(targetType = DeptService.class, method = @ContainerMethod(bindMethod = "get", resultType = DeptResp.class), props = @Mapping(src = "name", ref = "deptName"))
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@Schema(description = "所属部门", example = "测试部")
|
||||
private String deptName;
|
||||
|
||||
@Override
|
||||
public Boolean getDisabled() {
|
||||
return this.getIsSystem() || Objects.equals(this.getId(), LoginHelper.getUserId());
|
||||
|
@ -122,7 +122,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
.getNickname());
|
||||
Collection<Long> disjunctionRoleIds = CollUtil.disjunction(req.getRoleIds(), userRoleService
|
||||
.listRoleIdByUserId(id));
|
||||
CheckUtils.throwIfNotEmpty(disjunctionRoleIds, "[{}] 是系统内置用户,不允许变更所属角色", oldUser.getNickname());
|
||||
CheckUtils.throwIfNotEmpty(disjunctionRoleIds, "[{}] 是系统内置用户,不允许变更角色", oldUser.getNickname());
|
||||
}
|
||||
// 更新信息
|
||||
super.update(req, id);
|
||||
|
@ -67,7 +67,7 @@ public class UserController extends BaseController<UserService, UserResp, UserDe
|
||||
return R.ok("新增成功", id);
|
||||
}
|
||||
|
||||
@Operation(summary = "重置密码", description = "重置用户登录密码为默认密码")
|
||||
@Operation(summary = "重置密码", description = "重置用户登录密码")
|
||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||
@SaCheckPermission("system:user:password:reset")
|
||||
@PatchMapping("/{id}/password")
|
||||
|
Loading…
Reference in New Issue
Block a user