<?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.ycl.mapper.depart.UmsDepartMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ycl.entity.depart.UmsDepart">
|
<id column="id" property="id"/>
|
<result column="depart_name" property="departName"/>
|
<result column="depart_des" property="departDes"/>
|
<result column="depart_type" property="departType"/>
|
<result column="parent_id" property="parentId"/>
|
<result column="status" property="status"/>
|
<result column="create_time" property="createTime"/>
|
<result column="update_time" property="updateTime"/>
|
<result column="is_deleted" property="isDeleted"/>
|
</resultMap>
|
<resultMap type="com.ycl.entity.depart.UmsDepart" id="UserDepartResultMap" extends="BaseResultMap">
|
<collection property="userInfoDTOS" javaType="ArrayList" ofType="com.ycl.dto.user.DepartUserDTO">
|
<id column="user_id" property="userId"/>
|
<result column="username" property="username"/>
|
</collection>
|
</resultMap>
|
|
<resultMap id="DepartVOMap" type="com.ycl.vo.depart.UmsDepartVO" extends="BaseResultMap">
|
<result column="depart_type_name" property="departTypeName" jdbcType="VARCHAR"></result>
|
<result column="p_depart_name" property="parentDepartName" jdbcType="VARCHAR"></result>
|
<collection property="userInfoDTOS" javaType="ArrayList" ofType="com.ycl.dto.user.DepartUserDTO">
|
<id column="user_id" property="userId"/>
|
<result column="username" property="username"/>
|
<result column="is_leader" property="leader" jdbcType="BOOLEAN"></result>
|
</collection>
|
</resultMap>
|
|
<select id="selectDepartList" resultMap="UserDepartResultMap">
|
SELECT ud.*,
|
ua.id user_id,
|
ua.username
|
FROM ums_depart ud
|
LEFT JOIN ums_depart_manager udm ON ud.id = udm.depart_id
|
LEFT JOIN ums_admin ua ON udm.user_id = ua.id
|
where ud.is_deleted = 0 and ud.status=1
|
</select>
|
<select id="selectPageByName" resultMap="DepartVOMap">
|
SELECT t_0.*,
|
ua.id user_id,
|
ua.username,
|
dd.`name` as depart_type_name,udm.is_leader,pd.depart_name as p_depart_name
|
FROM (
|
SELECT ud.*
|
FROM ums_depart ud
|
WHERE is_deleted = 0
|
<if test="departName!=null and departName!=''">
|
and ud.depart_name like CONCAT('%',#{departName},'%')
|
</if>
|
ORDER BY ud.parent_id,ud.id desc
|
LIMIT #{offset}, #{size}
|
) t_0
|
LEFT JOIN ums_depart_manager udm ON t_0.id = udm.depart_id
|
LEFT JOIN ums_admin ua ON udm.user_id = ua.id
|
left join ums_data_dictionary as dd on t_0.depart_type = dd.id
|
left join ums_depart as pd on t_0.parent_id = pd.id
|
</select>
|
|
<select id="selectSurplusUser" resultType="com.ycl.entity.user.UmsAdmin">
|
SELECT
|
t.id,
|
t3.username
|
FROM
|
( SELECT t1.id FROM ums_admin t1 UNION ALL SELECT t2.user_id FROM ums_depart_manager t2 ) t
|
LEFT JOIN ums_admin t3 on t3.id =t.id
|
GROUP BY
|
id
|
HAVING
|
count( * )= 1
|
</select>
|
|
<select id="selectSurplusUserAndExistUser" resultType="com.ycl.entity.user.UmsAdmin" parameterType="java.lang.Long">
|
SELECT
|
t4.id,
|
t4.username
|
FROM
|
ums_depart_manager t3
|
LEFT JOIN ums_admin t4 ON t3.user_id = t4.id
|
WHERE
|
t3.depart_id = #{id} UNION ALL
|
SELECT
|
t.id,
|
t3.username
|
FROM
|
( SELECT t1.id FROM ums_admin t1 UNION ALL SELECT t2.user_id FROM ums_depart_manager t2 ) t
|
LEFT JOIN ums_admin t3 ON t3.id = t.id
|
GROUP BY
|
id
|
HAVING
|
count( * )= 1
|
</select>
|
<select id="getDepartType" resultType="java.lang.String">
|
select name from ums_data_dictionary where id = #{id}
|
</select>
|
</mapper>
|