refactor:用户表改为逻辑删

This commit is contained in:
sugus 2025-07-09 11:42:11 +08:00
parent 1d52e4da84
commit 5ac6e0523b
6 changed files with 22 additions and 9 deletions

View File

@ -42,7 +42,7 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
this.strictInsertFill(metaObject, "createBy", String.class, username);
this.strictInsertFill(metaObject, "updateBy", String.class, username);
// 插入时候默认赋值为正常
this.strictInsertFill(metaObject, "delFlag", String.class, DelFlagStatus.NORMAL.getValue());
this.strictInsertFill(metaObject, "delFlag", Integer.class, DelFlagStatus.NORMAL.getValue());
}
@Override

View File

@ -9,19 +9,19 @@ public enum DelFlagStatus {
/**
* 正常
*/
NORMAL("0"),
NORMAL(0),
/**
* 删除
*/
DELETED("1");
DELETED(1);
private final String value;
private final Integer value;
DelFlagStatus(String value) {
DelFlagStatus(Integer value) {
this.value = value;
}
public String getValue() {
public Integer getValue() {
return value;
}
}

View File

@ -15,6 +15,7 @@
*/
package com.aircraft.modules.system.domain;
import com.aircraft.base.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
@ -38,7 +39,7 @@ import java.util.Set;
@Getter
@Setter
@TableName("sys_user")
public class User extends SysBaseEntity implements Serializable {
public class User extends BaseEntity implements Serializable {
@NotNull(groups = Update.class)
@TableId(value="user_id", type = IdType.AUTO)

View File

@ -16,7 +16,8 @@
</delete>
<delete id="deleteByUserIds">
delete from sys_users_jobs
UPDATE sys_users_jobs
SET del_flag = 1
where user_id in
<foreach collection="userIds" item="id" open="(" separator="," close=")">
#{id}

View File

@ -54,6 +54,7 @@
<sql id="Whrer_Sql">
<where>
u.del_flag = 0
<if test="criteria.id != null">
and u.user_id = #{criteria.id}
</if>
@ -114,33 +115,39 @@
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.username = #{username}
and u.del_flag = 0
</select>
<select id="findByEmail" resultType="com.aircraft.modules.system.domain.User">
select user_id as id, username from sys_user
where email = #{email}
and del_flag = 0
</select>
<select id="findByPhone" resultType="com.aircraft.modules.system.domain.User">
select user_id as id, username from sys_user
where phone = #{phone}
and del_flag = 0
</select>
<select id="findByRoleId" resultType="com.aircraft.modules.system.domain.User">
SELECT u.user_id as id, u.username FROM sys_user u, sys_users_roles r
WHERE u.user_id = r.user_id AND r.role_id = #{roleId}
and u.del_flag = 0
group by u.user_id
</select>
<select id="findByRoleDeptId" resultType="com.aircraft.modules.system.domain.User">
SELECT u.* FROM sys_user u, sys_users_roles r, sys_roles_depts d
WHERE u.user_id = r.user_id AND r.role_id = d.role_id AND d.dept_id = #{deptId}
and u.del_flag = 0
group by u.user_id
</select>
<select id="findByMenuId" resultType="com.aircraft.modules.system.domain.User">
SELECT u.user_id as id, u.username FROM sys_user u, sys_users_roles ur, sys_roles_menus rm
WHERE u.user_id = ur.user_id AND ur.role_id = rm.role_id AND rm.menu_id = #{menuId}
and u.del_flag = 0
group by u.user_id
</select>
@ -150,6 +157,7 @@
<foreach collection="jobIds" item="jobId" open="(" separator="," close=")">
#{jobId}
</foreach>
and u.del_flag = 0
</select>
<select id="countByDepts" resultType="int">
@ -158,6 +166,7 @@
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
and u.del_flag = 0
</select>
<select id="countByRoles" resultType="int">
@ -166,6 +175,7 @@
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
and u.del_flag = 0
</select>
<update id="resetPwd">

View File

@ -16,7 +16,8 @@
</delete>
<delete id="deleteByUserIds">
delete from sys_users_roles
UPDATE sys_users_roles
SET del_flag = 0
where user_id in
<foreach collection="userIds" item="id" open="(" separator="," close=")">
#{id}