|
|
@@ -0,0 +1,141 @@
|
|
|
+<?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.linkwechat.coal.modules.qywx.system.mapper.SysDeptMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.linkwechat.common.core.domain.entity.SysDept" id="SysDeptResult">
|
|
|
+ <id property="deptId" column="dept_id" />
|
|
|
+ <result property="parentId" column="parent_id" />
|
|
|
+ <result property="ancestors" column="ancestors" />
|
|
|
+ <result property="deptName" column="dept_name" />
|
|
|
+ <result property="deptEnName" column="dept_en_name" />
|
|
|
+ <result property="orderNum" column="order_num" />
|
|
|
+ <result property="leader" column="leader" />
|
|
|
+ <result property="phone" column="phone" />
|
|
|
+ <result property="email" column="email" />
|
|
|
+ <result property="status" column="status" />
|
|
|
+ <result property="delFlag" column="del_flag" />
|
|
|
+ <result property="parentName" column="parent_name" />
|
|
|
+ <result property="createBy" column="create_by" />
|
|
|
+ <result property="createTime" column="create_time" />
|
|
|
+ <result property="updateBy" column="update_by" />
|
|
|
+ <result property="updateTime" column="update_time" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
|
|
|
+ </sql>
|
|
|
+ <sql id="selectDeptVo">
|
|
|
+ select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
|
|
|
+ from sys_dept d
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectDeptList" parameterType="com.linkwechat.common.core.domain.entity.SysDept" resultMap="SysDeptResult">
|
|
|
+ <include refid="selectDeptVo"/>
|
|
|
+ where d.del_flag = '0'
|
|
|
+ <if test="parentId != null and parentId != 0">
|
|
|
+ AND parent_id = #{parentId}
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ AND dept_name like concat('%', #{deptName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="status != null and status != ''">
|
|
|
+ AND status = #{status}
|
|
|
+ </if>
|
|
|
+ order by d.parent_id, d.order_num
|
|
|
+ </select>
|
|
|
+ <select id="select3DeptList" resultType="com.linkwechat.common.core.domain.entity.SysDept">
|
|
|
+ <include refid="selectDeptVo"/>
|
|
|
+ where d.del_flag = '0' /*and
|
|
|
+ (d.ancestors REGEXP '^[0-9]+,[0-9]+,[0-9]+,[0-9]+$'
|
|
|
+ or d.ancestors REGEXP '^[0-9]+,[0-9]+,[0-9]+$'
|
|
|
+ or d.parent_id='1' )*/
|
|
|
+ <if test="parentId != null and parentId != 0">
|
|
|
+ AND parent_id = #{parentId}
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ AND dept_name like concat('%', #{deptName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="status != null and status != ''">
|
|
|
+ AND status = #{status}
|
|
|
+ </if>
|
|
|
+ order by d.parent_id, d.order_num
|
|
|
+ </select>
|
|
|
+ <select id="selectByDeptIds" resultType="com.linkwechat.common.core.domain.entity.SysDept">
|
|
|
+ <include refid="selectDeptVo"/>
|
|
|
+ where d.del_flag = '0'
|
|
|
+ and d.dept_id in
|
|
|
+ <foreach collection="deptIds" open="(" item="item" index="index" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+ <select id="selectDeptListAllChildren" resultType="com.linkwechat.common.core.domain.entity.SysDept">
|
|
|
+ select * from (SELECT
|
|
|
+ d.dept_id, d.parent_id, d.ancestors,
|
|
|
+ case
|
|
|
+ when d.ancestors like '0,1,4%' then concat(d.dept_name,'(公司总部)')
|
|
|
+ when d.ancestors like '0,1,3007%' then concat(d.dept_name,'(个人代理)')
|
|
|
+ when d.ancestors like '0,1,3026%' then concat(d.dept_name,'(业务员)')
|
|
|
+ else d.dept_name
|
|
|
+ end as dept_name,
|
|
|
+ d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
|
|
|
+ FROM sys_dept d
|
|
|
+ where status = 0 and del_flag = '0'
|
|
|
+ and dept_id =#{deptId}
|
|
|
+ union
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from sys_dept d
|
|
|
+ where status = 0 and del_flag = '0'
|
|
|
+ and (ancestors like concat('%,',#{deptId},',%') or ancestors like concat('%,', #{deptId}))
|
|
|
+ ) aa
|
|
|
+ </select>
|
|
|
+ <select id="selectDeptListGetAllChildren" resultType="com.linkwechat.common.core.domain.entity.SysDept">
|
|
|
+ select * from (SELECT
|
|
|
+ d.dept_id, d.parent_id, d.ancestors,
|
|
|
+ case
|
|
|
+ when d.ancestors like '0,1,4%' then concat(d.dept_name,'(公司总部)')
|
|
|
+ when d.ancestors like '0,1,2973%' then concat(d.dept_name,'(离职人员)')
|
|
|
+ when d.ancestors like '0,1,3007%' then concat(d.dept_name,'(个人代理)')
|
|
|
+ when d.ancestors like '0,1,3026%' then concat(d.dept_name,'(业务员)')
|
|
|
+ when d.ancestors like '0,1,3088%' then concat(d.dept_name,'(IT)')
|
|
|
+ when d.ancestors like '0,1,3092%' then concat(d.dept_name,'(IT支持)')
|
|
|
+ when d.ancestors like '0,1,3104%' then concat(d.dept_name,'(专业代理)')
|
|
|
+ else d.dept_name
|
|
|
+ end as dept_name,
|
|
|
+ d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
|
|
|
+ FROM sys_dept d
|
|
|
+ where status = 0 and del_flag = '0'
|
|
|
+ and dept_id =#{dept}
|
|
|
+ union
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from sys_dept d
|
|
|
+ where status = 0 and del_flag = '0'
|
|
|
+ and (ancestors like concat('%,',#{dept},',%') or ancestors like concat('%,', #{dept}))
|
|
|
+ ) aa
|
|
|
+ </select>
|
|
|
+ <select id="selectByParentId" resultType="com.linkwechat.common.core.domain.entity.SysDept">
|
|
|
+ SELECT <include refid="Base_Column_List"/> from sys_dept a where a.parent_id=#{deptId}
|
|
|
+ and status = 0 and del_flag = '0'
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectParentDeptId" resultType="java.lang.String">
|
|
|
+ SELECT a.parent_id from sys_dept a
|
|
|
+ where a.dept_id in
|
|
|
+ <foreach collection="deptIds" open="(" item="item" index="index" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ and a.del_flag = '0'
|
|
|
+ </select>
|
|
|
+ <select id="selectByDeptId" resultType="java.lang.String">
|
|
|
+ select aaa.map_type from sys_dept_map aaa where aaa.dept_id = #{deptId}
|
|
|
+
|
|
|
+ </select>
|
|
|
+ <select id="selectByDeptIdGetDept" resultType="com.linkwechat.common.core.domain.entity.SysDept">
|
|
|
+ SELECT <include refid="Base_Column_List"/>
|
|
|
+ from sys_dept d
|
|
|
+ where d.dept_id =#{deptId}
|
|
|
+ </select>
|
|
|
+</mapper>
|