|
|
@@ -0,0 +1,110 @@
|
|
|
+<?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.ydtech.modules.admin.dao.SysUserLinkFrontLineDeptMapper">
|
|
|
+
|
|
|
+ <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.po.SysUserLinkFrontLineDept">
|
|
|
+ <id property="id" column="id" jdbcType="BIGINT"/>
|
|
|
+ <result property="userId" column="user_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="frontLineDeptId" column="front_line_dept_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="createUser" column="create_user" jdbcType="VARCHAR"/>
|
|
|
+ <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ id,user_id,front_line_dept_id,
|
|
|
+ create_time,create_user,update_time,
|
|
|
+ update_user
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <delete id="deleteByUserId">
|
|
|
+ delete from sys_user_link_front_line_dept
|
|
|
+ where user_id =#{userId}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <select id="queryPage" resultType="com.ydtech.modules.admin.model.dto.SysUserLinkFrontLineDeptDto">
|
|
|
+ SELECT
|
|
|
+ link.id AS id,
|
|
|
+ su.id AS userId,
|
|
|
+ su.NAME AS userName,
|
|
|
+ sd.id AS deptId,
|
|
|
+ sd.NAME AS deptName,
|
|
|
+ link.create_time AS createTime
|
|
|
+ FROM
|
|
|
+ sys_user_link_front_line_dept link
|
|
|
+ LEFT JOIN sys_user su ON link.user_id = su.id
|
|
|
+ LEFT JOIN sys_dept sd ON link.front_line_dept_id = sd.id
|
|
|
+ <where>
|
|
|
+ <if test="vo.userId != null and vo.userId != ''">
|
|
|
+ and link.user_id = #{vo.userId}
|
|
|
+ </if>
|
|
|
+ <if test="vo.userName != null and vo.userName != ''">
|
|
|
+ and su.name like CONCAT('%', #{vo.userName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="vo.orgId != null and vo.orgId != ''">
|
|
|
+ and sd.id = #{vo.orgId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ order by link.create_time desc
|
|
|
+ </select>
|
|
|
+ <select id="findDeptListByUserId" resultType="com.ydtech.modules.admin.model.SysDept">
|
|
|
+ SELECT
|
|
|
+ sd.id as id,
|
|
|
+ sd.name as name,
|
|
|
+ sd.parent_id as parentId,
|
|
|
+ sd.comlevel as comlevel,
|
|
|
+ CASE WHEN ( SELECT count( 0 ) FROM sys_user_link_front_line_dept link WHERE link.front_line_dept_id=sd.id and link.user_id = #{userId}) > 0 THEN
|
|
|
+ true ELSE false
|
|
|
+ END AS flag
|
|
|
+ FROM
|
|
|
+ sys_dept sd
|
|
|
+ WHERE
|
|
|
+ ( sd.comlevel = 3 )
|
|
|
+ OR ( sd.comlevel = 4 )
|
|
|
+ OR ( sd.comlevel > 4 AND id LIKE '%M%' )
|
|
|
+ OR ( sd.comlevel > 4 AND id LIKE '%D%' )
|
|
|
+ ORDER BY comlevel
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="findUserListByDeptPage" resultType="com.ydtech.modules.admin.model.vo.SysUserBaseVO">
|
|
|
+ SELECT
|
|
|
+ t1.id AS userId,
|
|
|
+ t1.NAME AS NAME,
|
|
|
+ t1.mobile AS mobile,
|
|
|
+ t1.`status` AS `status`,
|
|
|
+ t2.id AS deptId,
|
|
|
+ t2.`name` AS deptName,
|
|
|
+ sd2.id AS pDeptId,
|
|
|
+ sd2.`name` AS pDeptName,
|
|
|
+ CASE
|
|
|
+ WHEN ( SELECT count( 0 ) FROM sys_user_link_front_line_dept link WHERE link.user_id = t1.id) > 0 THEN
|
|
|
+ true ELSE false
|
|
|
+ END AS flag
|
|
|
+ FROM
|
|
|
+ sys_user t1
|
|
|
+ LEFT JOIN sys_dept t2 ON t1.dept_id = t2.id
|
|
|
+ LEFT JOIN sys_dept sd2 ON sd2.id = t2.parent_id
|
|
|
+ WHERE
|
|
|
+ t1.`status` = 1
|
|
|
+ AND t1.id NOT LIKE '%M%'
|
|
|
+ <if test='user !=null '>
|
|
|
+ <if test='user.name !=null and user.name!="" '>
|
|
|
+ and t1.name like CONCAT('%', #{user.name}, '%')
|
|
|
+ </if>
|
|
|
+ <if test='user.userId !=null and user.userId!="" '>
|
|
|
+ and t1.id = #{user.userId}
|
|
|
+ </if>
|
|
|
+ <if test='user.mobile !=null and user.mobile!="" '>
|
|
|
+ and t1.mobile = #{user.mobile}
|
|
|
+ </if>
|
|
|
+ <if test='user.deptId !=null and user.deptId!="" '>
|
|
|
+ and t2.id like CONCAT('', #{user.deptId}, '%')
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ order by flag desc
|
|
|
+ </select>
|
|
|
+</mapper>
|