2021-02-16 18:21:24 +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">
|
|
|
|
<mapper namespace="ink.wgink.service.position.dao.IPositionUserDao">
|
|
|
|
|
|
|
|
<cache flushInterval="3600000"/>
|
|
|
|
|
|
|
|
<!-- 建表 -->
|
|
|
|
<update id="createTable">
|
|
|
|
CREATE TABLE IF NOT EXISTS `sys_position_user` (
|
|
|
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`position_id` char(36) NOT NULL,
|
|
|
|
`user_id` char(36) NOT NULL,
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `user_id_idx` (`user_id`) USING BTREE,
|
|
|
|
KEY `position_id_idx` (`position_id`) USING BTREE
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 新增 -->
|
|
|
|
<insert id="save" parameterType="map" flushCache="true">
|
|
|
|
INSERT INTO sys_position_user(
|
|
|
|
position_id,
|
|
|
|
user_id
|
|
|
|
) VALUES(
|
|
|
|
#{positionId},
|
|
|
|
#{userId}
|
|
|
|
)
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 删除 -->
|
|
|
|
<delete id="delete" parameterType="map" flushCache="true">
|
|
|
|
DELETE FROM
|
|
|
|
sys_position_user
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
<if test="positionId != null and positionId != ''">
|
|
|
|
AND
|
|
|
|
position_id = #{positionId}
|
|
|
|
</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列表 -->
|
|
|
|
<select id="listUserId" parameterType="map" resultType="java.lang.String" useCache="true">
|
|
|
|
SELECT
|
|
|
|
user_id
|
|
|
|
FROM
|
|
|
|
sys_position_user
|
2022-04-07 23:30:25 +08:00
|
|
|
<where>
|
2021-02-16 18:21:24 +08:00
|
|
|
<if test="positionId != null and positionId != ''">
|
|
|
|
position_id = #{positionId}
|
|
|
|
</if>
|
|
|
|
<if test="positionIds != null and positionIds.size > 0">
|
2022-04-07 23:30:25 +08:00
|
|
|
AND
|
2021-02-16 18:21:24 +08:00
|
|
|
position_id IN (
|
|
|
|
<foreach collection="positionIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{positionIds[${index}]}
|
|
|
|
</foreach>
|
|
|
|
)
|
|
|
|
</if>
|
2022-04-07 23:30:25 +08:00
|
|
|
<if test="userIds != null and userIds.size > 0">
|
|
|
|
AND
|
|
|
|
user_id IN
|
|
|
|
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{userIds[${index}]}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
2021-02-16 18:21:24 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 用户ID列表 -->
|
|
|
|
<select id="listGroupUserId" parameterType="map" resultType="java.lang.String" useCache="true">
|
|
|
|
SELECT
|
|
|
|
user_id
|
|
|
|
FROM
|
|
|
|
sys_position_user
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
GROUP BY
|
|
|
|
user_id
|
|
|
|
</select>
|
|
|
|
|
2021-02-25 23:23:47 +08:00
|
|
|
<!-- 职位ID列表 -->
|
|
|
|
<select id="listPositionId" parameterType="map" resultType="java.lang.String">
|
|
|
|
SELECT
|
|
|
|
position_id
|
|
|
|
FROM
|
|
|
|
sys_position_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-02-16 18:21:24 +08:00
|
|
|
|
|
|
|
</mapper>
|