2021-01-29 15:02:37 +08:00
|
|
|
<?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">
|
2021-02-14 22:09:36 +08:00
|
|
|
<mapper namespace="ink.wgink.service.department.dao.IDepartmentUserDao">
|
2021-01-29 15:02:37 +08:00
|
|
|
|
|
|
|
<cache flushInterval="3600000"/>
|
|
|
|
|
2021-02-14 22:09:36 +08:00
|
|
|
<!-- 建表 -->
|
|
|
|
<update id="createTable">
|
|
|
|
CREATE TABLE IF NOT EXISTS `sys_department_user` (
|
|
|
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`department_id` char(36) NOT NULL,
|
|
|
|
`user_id` char(36) NOT NULL,
|
|
|
|
`user_sort` varchar(255) DEFAULT 'ZZZ-000',
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `user_id_idx` (`user_id`) USING BTREE,
|
|
|
|
KEY `department_id_idx` (`department_id`) USING BTREE
|
2021-02-16 12:35:13 +08:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
2021-02-14 22:09:36 +08:00
|
|
|
</update>
|
|
|
|
|
2021-01-29 15:02:37 +08:00
|
|
|
<!-- 新增组织用户 -->
|
|
|
|
<insert id="save" parameterType="map" flushCache="true">
|
|
|
|
INSERT INTO sys_department_user(
|
|
|
|
department_id,
|
|
|
|
user_id
|
|
|
|
) VALUES(
|
|
|
|
#{departmentId},
|
|
|
|
#{userId}
|
|
|
|
)
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 删除组织用户 -->
|
|
|
|
<delete id="delete" parameterType="map" flushCache="true">
|
|
|
|
DELETE FROM
|
|
|
|
sys_department_user
|
2021-06-10 17:01:16 +08:00
|
|
|
<where>
|
|
|
|
<if test="departmentId != null and departmentId != ''">
|
2021-01-29 15:02:37 +08:00
|
|
|
AND
|
|
|
|
department_id = #{departmentId}
|
2021-06-10 17:01:16 +08:00
|
|
|
</if>
|
|
|
|
<if test="departmentIds != null and departmentIds.size > 0">
|
2021-01-29 15:02:37 +08:00
|
|
|
AND
|
|
|
|
department_id IN
|
2021-06-10 17:01:16 +08:00
|
|
|
<foreach collection="departmentIds" index="index" open="(" separator="," close=")">
|
2021-01-29 15:02:37 +08:00
|
|
|
#{departmentIds[${index}]}
|
2021-06-10 17:01:16 +08:00
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
<if test="userId != null and userId != ''">
|
2021-01-29 15:02:37 +08:00
|
|
|
AND
|
|
|
|
user_id = #{userId}
|
2021-06-10 17:01:16 +08:00
|
|
|
</if>
|
|
|
|
<if test="userIds != null and userIds.size > 0">
|
2021-01-29 15:02:37 +08:00
|
|
|
AND
|
|
|
|
user_id IN
|
2021-06-10 17:01:16 +08:00
|
|
|
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
2021-01-29 15:02:37 +08:00
|
|
|
#{userIds[${index}]}
|
2021-06-10 17:01:16 +08:00
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
</where>
|
2021-01-29 15:02:37 +08:00
|
|
|
</delete>
|
|
|
|
|
2021-06-10 17:01:16 +08:00
|
|
|
<!-- 更新组织用户排序 -->
|
|
|
|
<update id="updateSort" parameterType="map" flushCache="true">
|
|
|
|
UPDATE
|
|
|
|
sys_department_user
|
|
|
|
SET
|
|
|
|
user_sort = #{userSort}
|
|
|
|
WHERE
|
|
|
|
department_id = #{departmentId}
|
|
|
|
AND
|
|
|
|
user_sort = #{userSort}
|
|
|
|
</update>
|
|
|
|
|
2021-01-29 15:02:37 +08:00
|
|
|
<!-- 用户ID列表 -->
|
2021-02-05 16:52:19 +08:00
|
|
|
<select id="listUserId" parameterType="map" resultType="java.lang.String">
|
2021-01-29 15:02:37 +08:00
|
|
|
SELECT
|
|
|
|
user_id
|
|
|
|
FROM
|
|
|
|
sys_department_user
|
2021-06-10 17:01:16 +08:00
|
|
|
<where>
|
|
|
|
<if test="departmentId != null and departmentId != ''">
|
2021-02-05 16:52:19 +08:00
|
|
|
department_id = #{departmentId}
|
2021-06-10 17:01:16 +08:00
|
|
|
</if>
|
|
|
|
<if test="departmentIds != null and departmentIds.size > 0">
|
|
|
|
AND
|
|
|
|
department_id IN (
|
|
|
|
<foreach collection="departmentIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{departmentIds[${index}]}
|
|
|
|
</foreach>
|
|
|
|
)
|
|
|
|
</if>
|
|
|
|
<if test="userIds != null and userIds.size > 0">
|
|
|
|
AND
|
|
|
|
user_id IN (
|
|
|
|
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{userIds[${index}]}
|
|
|
|
</foreach>
|
|
|
|
)
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
ORDER BY
|
|
|
|
user_sort
|
2021-01-29 15:02:37 +08:00
|
|
|
</select>
|
|
|
|
|
2021-02-14 22:09:36 +08:00
|
|
|
<!-- 用户ID列表 -->
|
|
|
|
<select id="listGroupUserId" parameterType="map" resultType="java.lang.String">
|
|
|
|
SELECT
|
|
|
|
user_id
|
|
|
|
FROM
|
|
|
|
sys_department_user
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
GROUP BY
|
|
|
|
user_id
|
|
|
|
</select>
|
|
|
|
|
2021-02-25 23:23:47 +08:00
|
|
|
<!-- 部门ID列表 -->
|
|
|
|
<select id="listDepartmentId" parameterType="map" resultType="java.lang.String">
|
|
|
|
SELECT
|
|
|
|
department_id
|
|
|
|
FROM
|
|
|
|
sys_department_user
|
|
|
|
WHERE
|
|
|
|
<if test="userId != null and userId != ''">
|
|
|
|
user_id = #{userId}
|
|
|
|
</if>
|
|
|
|
<if test="userIds != null and userIds.size > 0">
|
|
|
|
user_id IN (
|
|
|
|
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{userIds[${index}]}
|
|
|
|
</foreach>
|
|
|
|
)
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
2021-01-29 15:02:37 +08:00
|
|
|
</mapper>
|