wg-basic/service-department/src/main/resources/mybatis/mapper/department-user-mapper.xml

67 lines
2.1 KiB
XML
Raw Normal View History

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-10 23:09:02 +08:00
<mapper namespace="ink.wgink.service.department.dao.IDepartmentUserDao">
2021-01-29 15:02:37 +08:00
<cache flushInterval="3600000"/>
<!-- 新增组织用户 -->
<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
where
1 = 1
<if test="departmentId != null and departmentId != ''">
AND
department_id = #{departmentId}
</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="userId != null and userId != ''">
AND
user_id = #{userId}
</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>
</delete>
<!-- 用户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
WHERE
2021-02-05 16:52:19 +08:00
<if test="departmentId != null and departmentId != ''">
department_id = #{departmentId}
</if>
<if test="departmentIds != null and departmentIds.size > 0">
department_id IN (
<foreach collection="departmentIds" index="index" open="(" separator="," close=")">
#{departmentIds[${index}]}
</foreach>
)
</if>
2021-01-29 15:02:37 +08:00
</select>
</mapper>