|
|
@@ -94,32 +94,32 @@
|
|
|
order by d.parent_id, d.order_num
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectDeptById" resultMap="SysDeptResult">
|
|
|
+ <select id="selectDeptById" resultMap="SysDeptResult">
|
|
|
<include refid="selectDeptVo"/>
|
|
|
where dept_id = #{deptId}
|
|
|
</select>
|
|
|
|
|
|
- <select id="checkDeptExistUser" resultType="int">
|
|
|
+ <select id="checkDeptExistUser" resultType="int">
|
|
|
select count(1)
|
|
|
from sys_user
|
|
|
where dept_id = #{deptId}
|
|
|
and del_flag = '0'
|
|
|
</select>
|
|
|
|
|
|
- <select id="hasChildByDeptId" resultType="int">
|
|
|
+ <select id="hasChildByDeptId" resultType="int">
|
|
|
select count(1)
|
|
|
from sys_dept
|
|
|
where del_flag = '0'
|
|
|
and parent_id = #{deptId}
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectChildrenDeptById" resultMap="SysDeptResult">
|
|
|
+ <select id="selectChildrenDeptById" resultMap="SysDeptResult">
|
|
|
select *
|
|
|
from sys_dept
|
|
|
where find_in_set(#{deptId}, ancestors)
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectNormalChildrenDeptById" resultType="java.lang.Integer">
|
|
|
+ <select id="selectNormalChildrenDeptById" resultType="java.lang.Integer">
|
|
|
select count(*)
|
|
|
from sys_dept
|
|
|
where status = 0
|
|
|
@@ -127,20 +127,31 @@
|
|
|
and find_in_set(#{deptId}, ancestors)
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectDownDeptListById" resultMap="SysDeptResult">
|
|
|
- SELECT *
|
|
|
- FROM sys_dept WHERE STATUS = 0 AND del_flag = '0' AND parent_id = #{parentId} order by order_num asc
|
|
|
- </select>
|
|
|
+ <select id="selectDownDeptListById" resultMap="SysDeptResult">
|
|
|
+ SELECT *
|
|
|
+ FROM sys_dept
|
|
|
+ WHERE STATUS = 0
|
|
|
+ AND del_flag = '0'
|
|
|
+ AND parent_id = #{parentId}
|
|
|
+ order by order_num asc
|
|
|
+ </select>
|
|
|
|
|
|
- <select id="selectMaxNumChildrenDeptById" resultType="java.lang.Integer">
|
|
|
- SELECT CASE WHEN MAX(order_num) IS NOT NULL THEN MAX(order_num)+1 ELSE 0 END
|
|
|
- FROM sys_dept WHERE STATUS = 0 AND del_flag = '0' AND parent_id = #{parentId}
|
|
|
- </select>
|
|
|
+ <select id="selectMaxNumChildrenDeptById" resultType="java.lang.Integer">
|
|
|
+ SELECT CASE WHEN MAX(order_num) IS NOT NULL THEN MAX(order_num) + 1 ELSE 0 END
|
|
|
+ FROM sys_dept
|
|
|
+ WHERE STATUS = 0
|
|
|
+ AND del_flag = '0'
|
|
|
+ AND parent_id = #{parentId}
|
|
|
+ </select>
|
|
|
|
|
|
- <select id="selectChildrenDeptListById" resultMap="SysDeptResult">
|
|
|
- SELECT dt.* FROM sys_dept dt WHERE dt.STATUS = 0 AND dt.del_flag = '0'
|
|
|
- AND FIND_IN_SET(#{deptId}, dt.ancestors) ORDER BY dt.order_num ASC
|
|
|
- </select>
|
|
|
+ <select id="selectChildrenDeptListById" resultMap="SysDeptResult">
|
|
|
+ SELECT dt.*
|
|
|
+ FROM sys_dept dt
|
|
|
+ WHERE dt.STATUS = 0
|
|
|
+ AND dt.del_flag = '0'
|
|
|
+ AND FIND_IN_SET(#{deptId}, dt.ancestors)
|
|
|
+ ORDER BY dt.order_num ASC
|
|
|
+ </select>
|
|
|
|
|
|
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
|
|
|
<include refid="selectDeptVo"/>
|
|
|
@@ -149,7 +160,7 @@
|
|
|
<if test="delFlag != null and delFlag != ''">
|
|
|
AND del_flag = #{delFlag}
|
|
|
</if>
|
|
|
- limit 1
|
|
|
+ limit 1
|
|
|
</select>
|
|
|
|
|
|
<select id="getDeptNameUnique" resultMap="SysDeptResult">
|
|
|
@@ -184,21 +195,27 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="selectLevelByUserId" resultType="java.lang.Integer">
|
|
|
- select count(1) from sys_dept where dept_id = (select dept_id from sys_user where user_id = #{userId} and user_type = '11' limit 1) and parent_id = 0
|
|
|
+ select count(1)
|
|
|
+ from sys_dept
|
|
|
+ where dept_id = (select dept_id from sys_user where user_id = #{userId} and user_type = '11' limit 1)
|
|
|
+ and parent_id = 0
|
|
|
</select>
|
|
|
|
|
|
<select id="queryDeptSignByUserId" resultType="java.lang.String">
|
|
|
- select
|
|
|
- case when a.dept_sign is not null then a.dept_sign
|
|
|
- when (select dept_sign from sys_dept where dept_id = a.parent_id and is_lower = 1) is not null
|
|
|
- then (select dept_sign from sys_dept where dept_id = a.parent_id and is_lower = 1)
|
|
|
- else (select dept_sign from sys_dept where dept_id = replace(replace(a.ancestors, concat(',', a.parent_id), ''), '0,', '') and is_lower = 1)
|
|
|
- end
|
|
|
+ select case
|
|
|
+ when a.dept_sign is not null then a.dept_sign
|
|
|
+ when (select dept_sign from sys_dept where dept_id = a.parent_id and is_lower = 1) is not null
|
|
|
+ then (select dept_sign from sys_dept where dept_id = a.parent_id and is_lower = 1)
|
|
|
+ else (select dept_sign
|
|
|
+ from sys_dept
|
|
|
+ where dept_id = replace(replace(a.ancestors, concat(',', a.parent_id), ''), '0,', '')
|
|
|
+ and is_lower = 1)
|
|
|
+ end
|
|
|
from (
|
|
|
select dept_sign, dept_id, parent_id, ancestors
|
|
|
from sys_dept
|
|
|
where dept_id = (select dept_id from sys_user where user_id = #{userId})
|
|
|
- )a
|
|
|
+ ) a
|
|
|
</select>
|
|
|
<select id="selectDeptListByCollege" resultType="com.zd.model.entity.SysDept">
|
|
|
<include refid="selectDeptVo"/>
|
|
|
@@ -214,21 +231,63 @@
|
|
|
order by d.parent_id, d.order_num
|
|
|
</select>
|
|
|
<select id="treeDeptSubSel" resultType="com.zd.model.entity.SysDept">
|
|
|
- select d.* from (
|
|
|
- select d.dept_id,d.parent_id,
|
|
|
- ( select sd.dept_name from sys_dept sd where sd.dept_id=d.parent_id) parent_name,
|
|
|
- d.ancestors,d.dept_name,d.del_flag,1 subOrDept,d.dept_id subOrDeptId
|
|
|
- from sys_dept d
|
|
|
-
|
|
|
- union all
|
|
|
-
|
|
|
- select concat(10000,s.id) dept_id,s.build_id parent_id,
|
|
|
- (select dept_name from sys_dept sd where sd.dept_id=s.build_id) parent_name,
|
|
|
- (select dt.ancestors
|
|
|
- from sys_dept dt where dt.dept_id = s.build_id) ancestors,s.name dept_name,s.is_del del_flag,2 subOrDept,s.id subOrDeptId
|
|
|
- from lab_subject s
|
|
|
- )d
|
|
|
- where d.del_flag = '0'
|
|
|
+ select
|
|
|
+ case when d.subOrDept=1 then d.dept_id else concat(10000,d.dept_id) END dept_id,
|
|
|
+ d.parent_id,
|
|
|
+ d.parent_name,
|
|
|
+ d.ancestors,
|
|
|
+ d.dept_name,
|
|
|
+ d.del_flag,
|
|
|
+ d.subOrDept
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ d.dept_id,
|
|
|
+ d.parent_id,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ sd.dept_name
|
|
|
+ FROM
|
|
|
+ sys_dept sd
|
|
|
+ WHERE
|
|
|
+ sd.dept_id = d.parent_id
|
|
|
+ ) parent_name,
|
|
|
+ d.ancestors,
|
|
|
+ d.dept_name,
|
|
|
+ d.del_flag,
|
|
|
+ 1 subOrDept,
|
|
|
+ d.dept_id subOrDeptId
|
|
|
+ FROM
|
|
|
+ sys_dept d
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ s.dept_id dept_id,
|
|
|
+ s.build_id parent_id,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ dept_name
|
|
|
+ FROM
|
|
|
+ sys_dept sd
|
|
|
+ WHERE
|
|
|
+ sd.dept_id = s.build_id
|
|
|
+ ) parent_name,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ dt.ancestors
|
|
|
+ FROM
|
|
|
+ sys_dept dt
|
|
|
+ WHERE
|
|
|
+ dt.dept_id = s.build_id
|
|
|
+ ) ancestors,
|
|
|
+ s. NAME dept_name,
|
|
|
+ s.is_del del_flag,
|
|
|
+ 2 subOrDept,
|
|
|
+ s.id subOrDeptId
|
|
|
+ FROM
|
|
|
+ lab_subject s
|
|
|
+ ) d
|
|
|
+ WHERE
|
|
|
+ d.del_flag = '0'
|
|
|
<if test="parentId != null and parentId != 0">
|
|
|
AND d.parent_id = #{parentId}
|
|
|
</if>
|
|
|
@@ -304,14 +363,14 @@
|
|
|
</foreach>
|
|
|
</update>
|
|
|
|
|
|
- <update id="updateDeptStatusNormal" >
|
|
|
+ <update id="updateDeptStatusNormal">
|
|
|
update sys_dept set status = '0' where dept_id in
|
|
|
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
|
|
#{deptId}
|
|
|
</foreach>
|
|
|
</update>
|
|
|
|
|
|
- <delete id="deleteDeptById" >
|
|
|
+ <delete id="deleteDeptById">
|
|
|
update sys_dept
|
|
|
set del_flag = '2'
|
|
|
where dept_id = #{deptId}
|