|
@@ -1,6 +1,6 @@
|
|
|
<?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.yami.shop.platform.mapper.DeptMapper">
|
|
|
+<mapper namespace="com.yami.shop.dao.DeptMapper">
|
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.yami.shop.bean.model.Dept">
|
|
|
<id column="dept_id" property="deptId"/>
|
|
@@ -10,34 +10,70 @@
|
|
|
<result column="level" property="level"/>
|
|
|
<result column="seq" property="seq"/>
|
|
|
<result column="status" property="status"/>
|
|
|
+ <result column="is_delete" property="isDelete"/>
|
|
|
+ <result column="leader_user_id" property="leaderUserId"/>
|
|
|
+ <result column="phone" property="phone"/>
|
|
|
+ <result column="email" property="email"/>
|
|
|
<result column="create_time" property="createTime"/>
|
|
|
<result column="update_time" property="updateTime"/>
|
|
|
</resultMap>
|
|
|
|
|
|
-
|
|
|
+ <resultMap id="DeptWithLeaderMap" type="com.yami.shop.bean.model.Dept" extends="BaseResultMap">
|
|
|
+ <result column="leader_user_name" property="leaderUserName"/>
|
|
|
+ </resultMap>
|
|
|
|
|
|
<!-- 根据父级部门ID获取子部门列表 -->
|
|
|
<select id="selectByParentId" resultMap="BaseResultMap">
|
|
|
- SELECT dept_id, dept_name, description, parent_id, level, seq, status, create_time, update_time
|
|
|
+ SELECT dept_id, dept_name, description, parent_id, level, seq, status, is_delete, leader_user_id, phone, email, create_time, update_time
|
|
|
FROM tz_sys_dept
|
|
|
- WHERE parent_id = #{parentId}
|
|
|
+ WHERE parent_id = #{parentId} AND is_delete = 0
|
|
|
ORDER BY seq
|
|
|
</select>
|
|
|
|
|
|
- <!-- 获取部门树结构 -->
|
|
|
- <select id="selectDeptTree" resultMap="BaseResultMap">
|
|
|
- SELECT dept_id, dept_name, description, parent_id, level, seq, status, create_time, update_time
|
|
|
- FROM tz_sys_dept
|
|
|
- WHERE status = 1
|
|
|
- ORDER BY parent_id, seq
|
|
|
+ <!-- 获取部门树结构(包含负责人姓名) -->
|
|
|
+ <select id="selectDeptTree" resultMap="DeptWithLeaderMap">
|
|
|
+ SELECT
|
|
|
+ d.dept_id,
|
|
|
+ d.dept_name,
|
|
|
+ d.description,
|
|
|
+ d.parent_id,
|
|
|
+ d.level,
|
|
|
+ d.seq,
|
|
|
+ d.status,
|
|
|
+ d.is_delete,
|
|
|
+ d.leader_user_id,
|
|
|
+ d.phone,
|
|
|
+ d.email,
|
|
|
+ d.create_time,
|
|
|
+ d.update_time,
|
|
|
+ u.username as leader_user_name
|
|
|
+ FROM tz_sys_dept d
|
|
|
+ LEFT JOIN tz_sys_user u ON d.leader_user_id = u.user_id
|
|
|
+ WHERE d.status = 1 AND d.is_delete = 0
|
|
|
+ ORDER BY d.parent_id, d.seq
|
|
|
</select>
|
|
|
|
|
|
- <!-- 根据用户ID获取所属部门列表 -->
|
|
|
- <select id="selectDeptsByUserId" resultMap="BaseResultMap">
|
|
|
- SELECT d.dept_id, d.dept_name, d.description, d.parent_id, d.level, d.seq, d.status, d.create_time, d.update_time
|
|
|
+ <!-- 根据用户ID获取所属部门列表(包含负责人姓名) -->
|
|
|
+ <select id="selectDeptsByUserId" resultMap="DeptWithLeaderMap">
|
|
|
+ SELECT
|
|
|
+ d.dept_id,
|
|
|
+ d.dept_name,
|
|
|
+ d.description,
|
|
|
+ d.parent_id,
|
|
|
+ d.level,
|
|
|
+ d.seq,
|
|
|
+ d.status,
|
|
|
+ d.is_delete,
|
|
|
+ d.leader_user_id,
|
|
|
+ d.phone,
|
|
|
+ d.email,
|
|
|
+ d.create_time,
|
|
|
+ d.update_time,
|
|
|
+ u.username as leader_user_name
|
|
|
FROM tz_sys_dept d
|
|
|
- INNER JOIN tz_sys_dept_user du ON d.dept_id = du.dept_id
|
|
|
- WHERE du.user_id = #{userId}
|
|
|
+ INNER JOIN tz_sys_dept_user du ON d.dept_id = du.dept_id
|
|
|
+ LEFT JOIN tz_sys_user u ON d.leader_user_id = u.user_id
|
|
|
+ WHERE du.user_id = #{userId} AND d.is_delete = 0
|
|
|
ORDER BY d.parent_id, d.seq
|
|
|
</select>
|
|
|
|