diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/mapper/UserMapper.java b/continew-admin-system/src/main/java/top/continew/admin/system/mapper/UserMapper.java index 6a571925..55e6c6e9 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/mapper/UserMapper.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/mapper/UserMapper.java @@ -26,6 +26,8 @@ import top.continew.admin.system.model.entity.UserDO; import top.continew.starter.data.mybatis.plus.datapermission.DataPermission; import top.continew.starter.security.crypto.annotation.FieldEncrypt; +import java.util.List; + /** * 用户 Mapper * @@ -41,10 +43,19 @@ public interface UserMapper extends DataPermissionMapper { * @param queryWrapper 查询条件 * @return 分页列表信息 */ - @DataPermission + @DataPermission("t1") IPage selectUserPage(@Param("page") IPage page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); + /** + * 查询列表 + * + * @param queryWrapper 查询条件 + * @return 列表信息 + */ + @DataPermission("t1") + List selectUserList(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); + /** * 根据用户名查询 * diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/model/entity/UserDO.java b/continew-admin-system/src/main/java/top/continew/admin/system/model/entity/UserDO.java index d8f0d3d2..e3ec4834 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/model/entity/UserDO.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/model/entity/UserDO.java @@ -16,6 +16,8 @@ package top.continew.admin.system.model.entity; +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import top.continew.admin.common.config.mybatis.BCryptEncryptor; @@ -65,12 +67,14 @@ public class UserDO extends BaseDO { * 邮箱 */ @FieldEncrypt + @TableField(insertStrategy = FieldStrategy.NOT_EMPTY) private String email; /** * 手机号码 */ @FieldEncrypt + @TableField(insertStrategy = FieldStrategy.NOT_EMPTY) private String phone; /** diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/UserDetailResp.java b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/UserDetailResp.java index e410132c..e82dacc5 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/UserDetailResp.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/model/resp/UserDetailResp.java @@ -32,6 +32,7 @@ import top.continew.admin.common.util.helper.LoginHelper; import top.continew.admin.system.service.DeptService; import top.continew.starter.extension.crud.converter.ExcelBaseEnumConverter; import top.continew.starter.extension.crud.model.resp.BaseDetailResp; +import top.continew.starter.file.excel.converter.ExcelListConverter; import java.io.Serial; import java.time.LocalDateTime; @@ -57,83 +58,43 @@ public class UserDetailResp extends BaseDetailResp { * 用户名 */ @Schema(description = "用户名", example = "zhangsan") - @ExcelProperty(value = "用户名") + @ExcelProperty(value = "用户名", order = 2) private String username; /** * 昵称 */ @Schema(description = "昵称", example = "张三") - @ExcelProperty(value = "昵称") + @ExcelProperty(value = "昵称", order = 3) private String nickname; - /** - * 性别 - */ - @Schema(description = "性别(0:未知;1:男;2:女)", type = "Integer", allowableValues = {"0", "1", "2"}, example = "1") - @ExcelProperty(value = "性别", converter = ExcelBaseEnumConverter.class) - private GenderEnum gender; - - /** - * 邮箱 - */ - @Schema(description = "邮箱", example = "123456789@qq.com") - @ExcelProperty(value = "邮箱") - private String email; - - /** - * 手机号码 - */ - @Schema(description = "手机号码", example = "13811111111") - @ExcelProperty(value = "手机号码") - private String phone; - - /** - * 头像地址 - */ - @Schema(description = "头像地址", example = "https://himg.bdimg.com/sys/portrait/item/public.1.81ac9a9e.rf1ix17UfughLQjNo7XQ_w.jpg") - @ExcelProperty(value = "头像地址") - private String avatar; - /** * 状态 */ @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") - @ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class) + @ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class, order = 4) private DisEnableStatusEnum status; /** - * 是否为系统内置数据 + * 性别 */ - @Schema(description = "系统内置", example = "false") - @ExcelProperty(value = "系统内置") - private Boolean isSystem; - - /** - * 描述 - */ - @Schema(description = "描述", example = "张三描述信息") - @ExcelProperty(value = "描述") - private String description; - - /** - * 最后一次修改密码时间 - */ - @Schema(description = "最后一次修改密码时间", example = "2023-08-08 08:08:08", type = "string") - private LocalDateTime pwdResetTime; + @Schema(description = "性别(0:未知;1:男;2:女)", type = "Integer", allowableValues = {"0", "1", "2"}, example = "1") + @ExcelProperty(value = "性别", converter = ExcelBaseEnumConverter.class, order = 5) + private GenderEnum gender; /** * 部门 ID */ @Schema(description = "部门 ID", example = "5") @AssembleMethod(props = @Mapping(src = "name", ref = "deptName"), targetType = DeptService.class, method = @ContainerMethod(bindMethod = "get", resultType = DeptResp.class)) + @ExcelProperty(value = "部门 ID", order = 6) private Long deptId; /** * 所属部门 */ @Schema(description = "所属部门", example = "测试部") - @ExcelProperty(value = "所属部门") + @ExcelProperty(value = "所属部门", order = 7) private String deptName; /** @@ -141,15 +102,57 @@ public class UserDetailResp extends BaseDetailResp { */ @Schema(description = "角色 ID 列表", example = "2") @Assemble(prop = ":roleNames", container = ContainerConstants.USER_ROLE_NAME_LIST, handlerType = ManyToManyAssembleOperationHandler.class) + @ExcelProperty(value = "角色 ID 列表", converter = ExcelListConverter.class, order = 8) private List roleIds; /** * 角色名称列表 */ @Schema(description = "角色名称列表", example = "测试人员") - @ExcelProperty(value = "角色") + @ExcelProperty(value = "角色", converter = ExcelListConverter.class, order = 9) private List roleNames; + /** + * 手机号码 + */ + @Schema(description = "手机号码", example = "13811111111") + @ExcelProperty(value = "手机号码", order = 10) + private String phone; + + /** + * 邮箱 + */ + @Schema(description = "邮箱", example = "123456789@qq.com") + @ExcelProperty(value = "邮箱", order = 11) + private String email; + + /** + * 是否为系统内置数据 + */ + @Schema(description = "系统内置", example = "false") + @ExcelProperty(value = "系统内置", order = 12) + private Boolean isSystem; + + /** + * 描述 + */ + @Schema(description = "描述", example = "张三描述信息") + @ExcelProperty(value = "描述", order = 13) + private String description; + + /** + * 头像地址 + */ + @Schema(description = "头像地址", example = "https://himg.bdimg.com/sys/portrait/item/public.1.81ac9a9e.rf1ix17UfughLQjNo7XQ_w.jpg") + @ExcelProperty(value = "头像地址", order = 14) + private String avatar; + + /** + * 最后一次修改密码时间 + */ + @Schema(description = "最后一次修改密码时间", example = "2023-08-08 08:08:08", type = "string") + private LocalDateTime pwdResetTime; + @Override public Boolean getDisabled() { return this.getIsSystem() || Objects.equals(this.getId(), LoginHelper.getUserId()); diff --git a/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java b/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java index edec4574..1f290d3c 100644 --- a/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java +++ b/continew-admin-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java @@ -55,6 +55,7 @@ import top.continew.admin.system.service.*; import top.continew.starter.core.constant.StringConstants; import top.continew.starter.core.util.validate.CheckUtils; import top.continew.starter.extension.crud.model.query.PageQuery; +import top.continew.starter.extension.crud.model.query.SortQuery; import top.continew.starter.extension.crud.model.resp.PageResp; import top.continew.starter.extension.crud.service.CommonUserService; import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; @@ -282,6 +283,18 @@ public class UserServiceImpl extends BaseServiceImpl List list(UserQuery query, SortQuery sortQuery, Class targetClass) { + QueryWrapper queryWrapper = this.buildQueryWrapper(query); + // 设置排序 + super.sort(queryWrapper, sortQuery); + List entityList = baseMapper.selectUserList(queryWrapper); + if (entityClass == targetClass) { + return (List)entityList; + } + return BeanUtil.copyToList(entityList, targetClass); + } + @Override protected QueryWrapper buildQueryWrapper(UserQuery query) { String description = query.getDescription(); diff --git a/continew-admin-system/src/main/resources/mapper/UserMapper.xml b/continew-admin-system/src/main/resources/mapper/UserMapper.xml index 44af8a5c..2966bd3a 100644 --- a/continew-admin-system/src/main/resources/mapper/UserMapper.xml +++ b/continew-admin-system/src/main/resources/mapper/UserMapper.xml @@ -2,10 +2,36 @@ - + + ${ew.customSqlSegment} + + +