mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-04 10:57:10 +08:00 
			
		
		
		
	fix: 修复导出用户报错
This commit is contained in:
		@@ -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.data.mybatis.plus.datapermission.DataPermission;
 | 
				
			||||||
import top.continew.starter.security.crypto.annotation.FieldEncrypt;
 | 
					import top.continew.starter.security.crypto.annotation.FieldEncrypt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 用户 Mapper
 | 
					 * 用户 Mapper
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -41,10 +43,19 @@ public interface UserMapper extends DataPermissionMapper<UserDO> {
 | 
				
			|||||||
     * @param queryWrapper 查询条件
 | 
					     * @param queryWrapper 查询条件
 | 
				
			||||||
     * @return 分页列表信息
 | 
					     * @return 分页列表信息
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @DataPermission
 | 
					    @DataPermission("t1")
 | 
				
			||||||
    IPage<UserDO> selectUserPage(@Param("page") IPage<UserDO> page,
 | 
					    IPage<UserDO> selectUserPage(@Param("page") IPage<UserDO> page,
 | 
				
			||||||
                                 @Param(Constants.WRAPPER) QueryWrapper<UserDO> queryWrapper);
 | 
					                                 @Param(Constants.WRAPPER) QueryWrapper<UserDO> queryWrapper);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询列表
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param queryWrapper 查询条件
 | 
				
			||||||
 | 
					     * @return 列表信息
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @DataPermission("t1")
 | 
				
			||||||
 | 
					    List<UserDO> selectUserList(@Param(Constants.WRAPPER) QueryWrapper<UserDO> queryWrapper);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 根据用户名查询
 | 
					     * 根据用户名查询
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
package top.continew.admin.system.model.entity;
 | 
					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 com.baomidou.mybatisplus.annotation.TableName;
 | 
				
			||||||
import lombok.Data;
 | 
					import lombok.Data;
 | 
				
			||||||
import top.continew.admin.common.config.mybatis.BCryptEncryptor;
 | 
					import top.continew.admin.common.config.mybatis.BCryptEncryptor;
 | 
				
			||||||
@@ -65,12 +67,14 @@ public class UserDO extends BaseDO {
 | 
				
			|||||||
     * 邮箱
 | 
					     * 邮箱
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @FieldEncrypt
 | 
					    @FieldEncrypt
 | 
				
			||||||
 | 
					    @TableField(insertStrategy = FieldStrategy.NOT_EMPTY)
 | 
				
			||||||
    private String email;
 | 
					    private String email;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 手机号码
 | 
					     * 手机号码
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @FieldEncrypt
 | 
					    @FieldEncrypt
 | 
				
			||||||
 | 
					    @TableField(insertStrategy = FieldStrategy.NOT_EMPTY)
 | 
				
			||||||
    private String phone;
 | 
					    private String phone;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,7 @@ import top.continew.admin.common.util.helper.LoginHelper;
 | 
				
			|||||||
import top.continew.admin.system.service.DeptService;
 | 
					import top.continew.admin.system.service.DeptService;
 | 
				
			||||||
import top.continew.starter.extension.crud.converter.ExcelBaseEnumConverter;
 | 
					import top.continew.starter.extension.crud.converter.ExcelBaseEnumConverter;
 | 
				
			||||||
import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
 | 
					import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
 | 
				
			||||||
 | 
					import top.continew.starter.file.excel.converter.ExcelListConverter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.Serial;
 | 
					import java.io.Serial;
 | 
				
			||||||
import java.time.LocalDateTime;
 | 
					import java.time.LocalDateTime;
 | 
				
			||||||
@@ -57,83 +58,43 @@ public class UserDetailResp extends BaseDetailResp {
 | 
				
			|||||||
     * 用户名
 | 
					     * 用户名
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Schema(description = "用户名", example = "zhangsan")
 | 
					    @Schema(description = "用户名", example = "zhangsan")
 | 
				
			||||||
    @ExcelProperty(value = "用户名")
 | 
					    @ExcelProperty(value = "用户名", order = 2)
 | 
				
			||||||
    private String username;
 | 
					    private String username;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 昵称
 | 
					     * 昵称
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Schema(description = "昵称", example = "张三")
 | 
					    @Schema(description = "昵称", example = "张三")
 | 
				
			||||||
    @ExcelProperty(value = "昵称")
 | 
					    @ExcelProperty(value = "昵称", order = 3)
 | 
				
			||||||
    private String nickname;
 | 
					    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")
 | 
					    @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;
 | 
					    private DisEnableStatusEnum status;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 是否为系统内置数据
 | 
					     * 性别
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Schema(description = "系统内置", example = "false")
 | 
					    @Schema(description = "性别(0:未知;1:男;2:女)", type = "Integer", allowableValues = {"0", "1", "2"}, example = "1")
 | 
				
			||||||
    @ExcelProperty(value = "系统内置")
 | 
					    @ExcelProperty(value = "性别", converter = ExcelBaseEnumConverter.class, order = 5)
 | 
				
			||||||
    private Boolean isSystem;
 | 
					    private GenderEnum gender;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 描述
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @Schema(description = "描述", example = "张三描述信息")
 | 
					 | 
				
			||||||
    @ExcelProperty(value = "描述")
 | 
					 | 
				
			||||||
    private String description;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 最后一次修改密码时间
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @Schema(description = "最后一次修改密码时间", example = "2023-08-08 08:08:08", type = "string")
 | 
					 | 
				
			||||||
    private LocalDateTime pwdResetTime;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 部门 ID
 | 
					     * 部门 ID
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Schema(description = "部门 ID", example = "5")
 | 
					    @Schema(description = "部门 ID", example = "5")
 | 
				
			||||||
    @AssembleMethod(props = @Mapping(src = "name", ref = "deptName"), targetType = DeptService.class, method = @ContainerMethod(bindMethod = "get", resultType = DeptResp.class))
 | 
					    @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;
 | 
					    private Long deptId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 所属部门
 | 
					     * 所属部门
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Schema(description = "所属部门", example = "测试部")
 | 
					    @Schema(description = "所属部门", example = "测试部")
 | 
				
			||||||
    @ExcelProperty(value = "所属部门")
 | 
					    @ExcelProperty(value = "所属部门", order = 7)
 | 
				
			||||||
    private String deptName;
 | 
					    private String deptName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -141,15 +102,57 @@ public class UserDetailResp extends BaseDetailResp {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Schema(description = "角色 ID 列表", example = "2")
 | 
					    @Schema(description = "角色 ID 列表", example = "2")
 | 
				
			||||||
    @Assemble(prop = ":roleNames", container = ContainerConstants.USER_ROLE_NAME_LIST, handlerType = ManyToManyAssembleOperationHandler.class)
 | 
					    @Assemble(prop = ":roleNames", container = ContainerConstants.USER_ROLE_NAME_LIST, handlerType = ManyToManyAssembleOperationHandler.class)
 | 
				
			||||||
 | 
					    @ExcelProperty(value = "角色 ID 列表", converter = ExcelListConverter.class, order = 8)
 | 
				
			||||||
    private List<Long> roleIds;
 | 
					    private List<Long> roleIds;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 角色名称列表
 | 
					     * 角色名称列表
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Schema(description = "角色名称列表", example = "测试人员")
 | 
					    @Schema(description = "角色名称列表", example = "测试人员")
 | 
				
			||||||
    @ExcelProperty(value = "角色")
 | 
					    @ExcelProperty(value = "角色", converter = ExcelListConverter.class, order = 9)
 | 
				
			||||||
    private List<String> roleNames;
 | 
					    private List<String> 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
 | 
					    @Override
 | 
				
			||||||
    public Boolean getDisabled() {
 | 
					    public Boolean getDisabled() {
 | 
				
			||||||
        return this.getIsSystem() || Objects.equals(this.getId(), LoginHelper.getUserId());
 | 
					        return this.getIsSystem() || Objects.equals(this.getId(), LoginHelper.getUserId());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,6 +55,7 @@ import top.continew.admin.system.service.*;
 | 
				
			|||||||
import top.continew.starter.core.constant.StringConstants;
 | 
					import top.continew.starter.core.constant.StringConstants;
 | 
				
			||||||
import top.continew.starter.core.util.validate.CheckUtils;
 | 
					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.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.model.resp.PageResp;
 | 
				
			||||||
import top.continew.starter.extension.crud.service.CommonUserService;
 | 
					import top.continew.starter.extension.crud.service.CommonUserService;
 | 
				
			||||||
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
 | 
					import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
 | 
				
			||||||
@@ -282,6 +283,18 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
 | 
				
			|||||||
        return baseMapper.selectNicknameById(id);
 | 
					        return baseMapper.selectNicknameById(id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected <E> List<E> list(UserQuery query, SortQuery sortQuery, Class<E> targetClass) {
 | 
				
			||||||
 | 
					        QueryWrapper<UserDO> queryWrapper = this.buildQueryWrapper(query);
 | 
				
			||||||
 | 
					        // 设置排序
 | 
				
			||||||
 | 
					        super.sort(queryWrapper, sortQuery);
 | 
				
			||||||
 | 
					        List<UserDO> entityList = baseMapper.selectUserList(queryWrapper);
 | 
				
			||||||
 | 
					        if (entityClass == targetClass) {
 | 
				
			||||||
 | 
					            return (List<E>)entityList;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return BeanUtil.copyToList(entityList, targetClass);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected QueryWrapper<UserDO> buildQueryWrapper(UserQuery query) {
 | 
					    protected QueryWrapper<UserDO> buildQueryWrapper(UserQuery query) {
 | 
				
			||||||
        String description = query.getDescription();
 | 
					        String description = query.getDescription();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,10 +2,36 @@
 | 
				
			|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 | 
					<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 | 
				
			||||||
<mapper namespace="top.continew.admin.system.mapper.UserMapper">
 | 
					<mapper namespace="top.continew.admin.system.mapper.UserMapper">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <select id="selectUserPage" resultType="top.continew.admin.system.model.entity.UserDO">
 | 
					    <sql id="selectUser">
 | 
				
			||||||
        SELECT t1.*
 | 
					        SELECT
 | 
				
			||||||
 | 
					            t1.id,
 | 
				
			||||||
 | 
					            t1.create_user,
 | 
				
			||||||
 | 
					            t1.create_time,
 | 
				
			||||||
 | 
					            t1.update_user,
 | 
				
			||||||
 | 
					            t1.update_time,
 | 
				
			||||||
 | 
					            t1.username,
 | 
				
			||||||
 | 
					            t1.nickname,
 | 
				
			||||||
 | 
					            t1.password,
 | 
				
			||||||
 | 
					            t1.gender,
 | 
				
			||||||
 | 
					            t1.email,
 | 
				
			||||||
 | 
					            t1.phone,
 | 
				
			||||||
 | 
					            t1.avatar,
 | 
				
			||||||
 | 
					            t1.description,
 | 
				
			||||||
 | 
					            t1.status,
 | 
				
			||||||
 | 
					            t1.is_system,
 | 
				
			||||||
 | 
					            t1.pwd_reset_time,
 | 
				
			||||||
 | 
					            t1.dept_id
 | 
				
			||||||
        FROM sys_user AS t1
 | 
					        FROM sys_user AS t1
 | 
				
			||||||
        LEFT JOIN sys_dept AS t2 ON t2.id = t1.dept_id
 | 
					        LEFT JOIN sys_dept AS t2 ON t2.id = t1.dept_id
 | 
				
			||||||
 | 
					    </sql>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <select id="selectUserPage" resultType="top.continew.admin.system.model.entity.UserDO">
 | 
				
			||||||
 | 
					        <include refid="selectUser" />
 | 
				
			||||||
 | 
					        ${ew.customSqlSegment}
 | 
				
			||||||
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <select id="selectUserList" resultType="top.continew.admin.system.model.entity.UserDO">
 | 
				
			||||||
 | 
					        <include refid="selectUser" />
 | 
				
			||||||
        ${ew.customSqlSegment}
 | 
					        ${ew.customSqlSegment}
 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user