mirror of https://gitee.com/stylefeng/roses
【8.0】【system】初始化历史密码表
parent
2adba4d04b
commit
5ac15fb6f4
|
@ -0,0 +1,60 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.security.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户历史密码记录实例类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
@TableName("sys_user_password_record")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysUserPasswordRecord extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "record_id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("主键")
|
||||
private Long recordId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
@ChineseDescription("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 历史密码记录
|
||||
*/
|
||||
@TableField("history_password")
|
||||
@ChineseDescription("历史密码记录")
|
||||
private String historyPassword;
|
||||
|
||||
/**
|
||||
* 历史密码记录盐值
|
||||
*/
|
||||
@TableField("history_password_salt")
|
||||
@ChineseDescription("历史密码记录盐值")
|
||||
private String historyPasswordSalt;
|
||||
|
||||
/**
|
||||
* 修改密码时间
|
||||
*/
|
||||
@TableField("update_password_time")
|
||||
@ChineseDescription("修改密码时间")
|
||||
private Date updatePasswordTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.security.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 用户历史密码记录异常相关枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
@Getter
|
||||
public enum SysUserPasswordRecordExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
SYS_USER_PASSWORD_RECORD_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
SysUserPasswordRecordExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.security.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.entity.SysUserPasswordRecord;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.pojo.request.SysUserPasswordRecordRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.pojo.response.SysUserPasswordRecordVo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户历史密码记录 Mapper 接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
public interface SysUserPasswordRecordMapper extends BaseMapper<SysUserPasswordRecord> {
|
||||
|
||||
/**
|
||||
* 获取自定义查询列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
List<SysUserPasswordRecordVo> customFindList(@Param("page") Page page, @Param("param")SysUserPasswordRecordRequest request);
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.sys.modular.security.mapper.SysUserPasswordRecordMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.stylefeng.roses.kernel.sys.modular.security.entity.SysUserPasswordRecord">
|
||||
<id column="record_id" property="recordId" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="history_password" property="historyPassword" />
|
||||
<result column="history_password_salt" property="historyPasswordSalt" />
|
||||
<result column="update_password_time" property="updatePasswordTime" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="create_user" property="createUser" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="update_user" property="updateUser" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
record_id,user_id,history_password,history_password_salt,update_password_time,create_time,create_user,update_time,update_user
|
||||
</sql>
|
||||
|
||||
<resultMap id="customResultMap" type="cn.stylefeng.roses.kernel.sys.modular.security.pojo.response.SysUserPasswordRecordVo" extends="BaseResultMap">
|
||||
</resultMap>
|
||||
|
||||
<select id="customFindList" resultMap="customResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_user_password_record tbl
|
||||
WHERE
|
||||
<where>
|
||||
<if test="param.recordId != null and param.recordId != ''">
|
||||
and tbl.record_id like concat('%',#{param.recordId},'%')
|
||||
</if>
|
||||
<if test="param.userId != null and param.userId != ''">
|
||||
and tbl.user_id like concat('%',#{param.userId},'%')
|
||||
</if>
|
||||
<if test="param.historyPassword != null and param.historyPassword != ''">
|
||||
and tbl.history_password like concat('%',#{param.historyPassword},'%')
|
||||
</if>
|
||||
<if test="param.historyPasswordSalt != null and param.historyPasswordSalt != ''">
|
||||
and tbl.history_password_salt like concat('%',#{param.historyPasswordSalt},'%')
|
||||
</if>
|
||||
<if test="param.updatePasswordTime != null and param.updatePasswordTime != ''">
|
||||
and tbl.update_password_time like concat('%',#{param.updatePasswordTime},'%')
|
||||
</if>
|
||||
<if test="param.createTime != null and param.createTime != ''">
|
||||
and tbl.create_time like concat('%',#{param.createTime},'%')
|
||||
</if>
|
||||
<if test="param.createUser != null and param.createUser != ''">
|
||||
and tbl.create_user like concat('%',#{param.createUser},'%')
|
||||
</if>
|
||||
<if test="param.updateTime != null and param.updateTime != ''">
|
||||
and tbl.update_time like concat('%',#{param.updateTime},'%')
|
||||
</if>
|
||||
<if test="param.updateUser != null and param.updateUser != ''">
|
||||
and tbl.update_user like concat('%',#{param.updateUser},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,56 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.security.pojo.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 用户历史密码记录封装类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysUserPasswordRecordRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "主键不能为空", groups = {edit.class, delete.class})
|
||||
@ChineseDescription("主键")
|
||||
private Long recordId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@NotNull(message = "用户id不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 历史密码记录
|
||||
*/
|
||||
@NotBlank(message = "历史密码记录不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("历史密码记录")
|
||||
private String historyPassword;
|
||||
|
||||
/**
|
||||
* 历史密码记录盐值
|
||||
*/
|
||||
@NotBlank(message = "历史密码记录盐值不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("历史密码记录盐值")
|
||||
private String historyPasswordSalt;
|
||||
|
||||
/**
|
||||
* 修改密码时间
|
||||
*/
|
||||
@NotNull(message = "修改密码时间不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("修改密码时间")
|
||||
private String updatePasswordTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.security.pojo.response;
|
||||
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.entity.SysUserPasswordRecord;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户历史密码记录返回值封装
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysUserPasswordRecordVo extends SysUserPasswordRecord {
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.security.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.entity.SysUserPasswordRecord;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.pojo.request.SysUserPasswordRecordRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户历史密码记录服务类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
public interface SysUserPasswordRecordService extends IService<SysUserPasswordRecord> {
|
||||
|
||||
/**
|
||||
* 新增用户历史密码记录
|
||||
*
|
||||
* @param sysUserPasswordRecordRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
void add(SysUserPasswordRecordRequest sysUserPasswordRecordRequest);
|
||||
|
||||
/**
|
||||
* 删除用户历史密码记录
|
||||
*
|
||||
* @param sysUserPasswordRecordRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
void del(SysUserPasswordRecordRequest sysUserPasswordRecordRequest);
|
||||
|
||||
/**
|
||||
* 编辑用户历史密码记录
|
||||
*
|
||||
* @param sysUserPasswordRecordRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
void edit(SysUserPasswordRecordRequest sysUserPasswordRecordRequest);
|
||||
|
||||
/**
|
||||
* 查询详情用户历史密码记录
|
||||
*
|
||||
* @param sysUserPasswordRecordRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
SysUserPasswordRecord detail(SysUserPasswordRecordRequest sysUserPasswordRecordRequest);
|
||||
|
||||
/**
|
||||
* 获取用户历史密码记录列表
|
||||
*
|
||||
* @param sysUserPasswordRecordRequest 请求参数
|
||||
* @return List<SysUserPasswordRecord> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
List<SysUserPasswordRecord> findList(SysUserPasswordRecordRequest sysUserPasswordRecordRequest);
|
||||
|
||||
/**
|
||||
* 获取用户历史密码记录分页列表
|
||||
*
|
||||
* @param sysUserPasswordRecordRequest 请求参数
|
||||
* @return PageResult<SysUserPasswordRecord> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
PageResult<SysUserPasswordRecord> findPage(SysUserPasswordRecordRequest sysUserPasswordRecordRequest);
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.security.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.entity.SysUserPasswordRecord;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.enums.SysUserPasswordRecordExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.mapper.SysUserPasswordRecordMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.pojo.request.SysUserPasswordRecordRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.security.service.SysUserPasswordRecordService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户历史密码记录业务实现层
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
@Service
|
||||
public class SysUserPasswordRecordServiceImpl extends ServiceImpl<SysUserPasswordRecordMapper, SysUserPasswordRecord> implements SysUserPasswordRecordService {
|
||||
|
||||
@Override
|
||||
public void add(SysUserPasswordRecordRequest sysUserPasswordRecordRequest) {
|
||||
SysUserPasswordRecord sysUserPasswordRecord = new SysUserPasswordRecord();
|
||||
BeanUtil.copyProperties(sysUserPasswordRecordRequest, sysUserPasswordRecord);
|
||||
this.save(sysUserPasswordRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(SysUserPasswordRecordRequest sysUserPasswordRecordRequest) {
|
||||
SysUserPasswordRecord sysUserPasswordRecord = this.querySysUserPasswordRecord(sysUserPasswordRecordRequest);
|
||||
this.removeById(sysUserPasswordRecord.getRecordId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SysUserPasswordRecordRequest sysUserPasswordRecordRequest) {
|
||||
SysUserPasswordRecord sysUserPasswordRecord = this.querySysUserPasswordRecord(sysUserPasswordRecordRequest);
|
||||
BeanUtil.copyProperties(sysUserPasswordRecordRequest, sysUserPasswordRecord);
|
||||
this.updateById(sysUserPasswordRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserPasswordRecord detail(SysUserPasswordRecordRequest sysUserPasswordRecordRequest) {
|
||||
return this.querySysUserPasswordRecord(sysUserPasswordRecordRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysUserPasswordRecord> findPage(SysUserPasswordRecordRequest sysUserPasswordRecordRequest) {
|
||||
LambdaQueryWrapper<SysUserPasswordRecord> wrapper = createWrapper(sysUserPasswordRecordRequest);
|
||||
Page<SysUserPasswordRecord> pageList = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(pageList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserPasswordRecord> findList(SysUserPasswordRecordRequest sysUserPasswordRecordRequest) {
|
||||
LambdaQueryWrapper<SysUserPasswordRecord> wrapper = this.createWrapper(sysUserPasswordRecordRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
private SysUserPasswordRecord querySysUserPasswordRecord(SysUserPasswordRecordRequest sysUserPasswordRecordRequest) {
|
||||
SysUserPasswordRecord sysUserPasswordRecord = this.getById(sysUserPasswordRecordRequest.getRecordId());
|
||||
if (ObjectUtil.isEmpty(sysUserPasswordRecord)) {
|
||||
throw new ServiceException(SysUserPasswordRecordExceptionEnum.SYS_USER_PASSWORD_RECORD_NOT_EXISTED);
|
||||
}
|
||||
return sysUserPasswordRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/10/04 23:28
|
||||
*/
|
||||
private LambdaQueryWrapper<SysUserPasswordRecord> createWrapper(SysUserPasswordRecordRequest sysUserPasswordRecordRequest) {
|
||||
LambdaQueryWrapper<SysUserPasswordRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long recordId = sysUserPasswordRecordRequest.getRecordId();
|
||||
Long userId = sysUserPasswordRecordRequest.getUserId();
|
||||
String historyPassword = sysUserPasswordRecordRequest.getHistoryPassword();
|
||||
String historyPasswordSalt = sysUserPasswordRecordRequest.getHistoryPasswordSalt();
|
||||
String updatePasswordTime = sysUserPasswordRecordRequest.getUpdatePasswordTime();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(recordId), SysUserPasswordRecord::getRecordId, recordId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(userId), SysUserPasswordRecord::getUserId, userId);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(historyPassword), SysUserPasswordRecord::getHistoryPassword, historyPassword);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(historyPasswordSalt), SysUserPasswordRecord::getHistoryPasswordSalt, historyPasswordSalt);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(updatePasswordTime), SysUserPasswordRecord::getUpdatePasswordTime, updatePasswordTime);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
CREATE TABLE `sys_user_password_record` (
|
||||
`record_id` bigint(0) NOT NULL COMMENT '主键',
|
||||
`user_id` bigint(0) NOT NULL COMMENT '用户id',
|
||||
`history_password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '历史密码记录',
|
||||
`history_password_salt` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '历史密码记录盐值',
|
||||
`update_password_time` datetime(0) NOT NULL COMMENT '修改密码时间',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`create_user` bigint(0) NULL DEFAULT NULL COMMENT '创建人',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`update_user` bigint(0) NULL DEFAULT NULL COMMENT '更新人',
|
||||
PRIMARY KEY (`record_id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户历史密码记录' ROW_FORMAT = Dynamic;
|
Loading…
Reference in New Issue