Commit 23988827 by Lizh

feat: P1 Step 2.1+2.2 — 部门/岗位/用户岗位 Entity + Mapper + XML

Co-Authored-By: Claude <noreply@anthropic.com>
parent 28b55cc2
package com.jomalls.custom.dal.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 部门表 Entity
*
* @author Lizh
*/
@Data
@TableName("sys_dept")
public class SysDeptEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 部门ID
*/
@TableId(value = "dept_id", type = IdType.AUTO)
private Long deptId;
/**
* 父部门ID
*/
@TableField("parent_id")
private Long parentId;
/**
* 祖级列表
*/
@TableField("ancestors")
private String ancestors;
/**
* 部门名称
*/
@TableField("dept_name")
private String deptName;
/**
* 显示顺序
*/
@TableField("order_num")
private Integer orderNum;
/**
* 负责人
*/
@TableField("leader")
private String leader;
/**
* 联系电话
*/
@TableField("phone")
private String phone;
/**
* 邮箱
*/
@TableField("email")
private String email;
/**
* 部门状态(0正常 1停用)
*/
@TableField("status")
private String status;
/**
* 删除标志(0代表存在 2代表删除)
*/
@TableField("del_flag")
private String delFlag;
/**
* 创建者
*/
@TableField("create_by")
private String createBy;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 更新者
*/
@TableField("update_by")
private String updateBy;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private LocalDateTime updateTime;
}
package com.jomalls.custom.dal.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 岗位信息表 Entity
*
* @author Lizh
*/
@Data
@TableName("sys_post")
public class SysPostEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 岗位ID
*/
@TableId(value = "post_id", type = IdType.AUTO)
private Long postId;
/**
* 岗位编码
*/
@TableField("post_code")
private String postCode;
/**
* 岗位名称
*/
@TableField("post_name")
private String postName;
/**
* 显示顺序
*/
@TableField("post_sort")
private Integer postSort;
/**
* 状态(0正常 1停用)
*/
@TableField("status")
private String status;
/**
* 创建者
*/
@TableField("create_by")
private String createBy;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 更新者
*/
@TableField("update_by")
private String updateBy;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private LocalDateTime updateTime;
/**
* 备注
*/
@TableField("remark")
private String remark;
}
package com.jomalls.custom.dal.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 用户与岗位关联表 Entity
*
* @author Lizh
*/
@Data
@TableName("sys_user_post")
public class SysUserPostEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
@TableField("user_id")
private Long userId;
/**
* 岗位ID
*/
@TableField("post_id")
private Long postId;
}
package com.jomalls.custom.dal.mapper;
import com.jomalls.custom.dal.entity.SysDeptEntity;
import com.jomalls.custom.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 部门 Mapper
*
* @author Lizh
*/
@Mapper
public interface SysDeptMapper extends BaseMapper<SysDeptEntity> {
/**
* 查询部门列表
*
* @param dept 查询条件
* @return 部门列表
*/
List<SysDeptEntity> selectDeptList(@Param("dept") SysDeptEntity dept);
/**
* 查询部门列表(排除指定子部门)
*
* @param deptId 部门ID
* @return 部门列表
*/
List<SysDeptEntity> selectDeptListExcludeChild(@Param("deptId") Long deptId);
/**
* 查询是否有子部门
*
* @param deptId 部门ID
* @return 子部门数量
*/
int hasChildByDeptId(@Param("deptId") Long deptId);
/**
* 查询部门下是否存在用户
*
* @param deptId 部门ID
* @return 用户数量
*/
int checkDeptExistUser(@Param("deptId") Long deptId);
}
package com.jomalls.custom.dal.mapper;
import com.jomalls.custom.dal.entity.SysPostEntity;
import com.jomalls.custom.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 岗位 Mapper
*
* @author Lizh
*/
@Mapper
public interface SysPostMapper extends BaseMapper<SysPostEntity> {
}
package com.jomalls.custom.dal.mapper;
import com.jomalls.custom.dal.entity.SysUserPostEntity;
import com.jomalls.custom.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 用户-岗位关联 Mapper
*
* @author Lizh
*/
@Mapper
public interface SysUserPostMapper extends BaseMapper<SysUserPostEntity> {
}
<?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="com.jomalls.custom.dal.mapper.SysDeptMapper">
<select id="selectDeptList" resultType="com.jomalls.custom.dal.entity.SysDeptEntity">
SELECT d.*, p.dept_name AS parentName FROM sys_dept d
LEFT JOIN sys_dept p ON d.parent_id = p.dept_id
WHERE d.del_flag = '0'
<if test="dept.deptName != null and dept.deptName != ''">
AND d.dept_name LIKE CONCAT('%', #{dept.deptName}, '%')
</if>
<if test="dept.status != null and dept.status != ''">
AND d.status = #{dept.status}
</if>
ORDER BY d.parent_id, d.order_num
</select>
<select id="selectDeptListExcludeChild" resultType="com.jomalls.custom.dal.entity.SysDeptEntity">
SELECT d.* FROM sys_dept d
WHERE d.del_flag = '0'
AND d.dept_id != #{deptId}
AND d.ancestors NOT LIKE CONCAT('%', #{deptId}, '%')
ORDER BY d.parent_id, d.order_num
</select>
<select id="hasChildByDeptId" resultType="int">
SELECT COUNT(1) FROM sys_dept WHERE parent_id = #{deptId} AND del_flag = '0'
</select>
<select id="checkDeptExistUser" resultType="int">
SELECT COUNT(1) FROM sys_user WHERE dept_id = #{deptId} AND del_flag = '0'
</select>
</mapper>
<?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="com.jomalls.custom.dal.mapper.SysPostMapper">
</mapper>
<?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="com.jomalls.custom.dal.mapper.SysUserPostMapper">
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment