85 lines
2.5 KiB
XML
85 lines
2.5 KiB
XML
<?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.group.dao.IGroupUserDao">
|
|
|
|
<cache flushInterval="3600000"/>
|
|
|
|
<!-- 建表 -->
|
|
<update id="createTable">
|
|
CREATE TABLE IF NOT EXISTS `sys_group_user` (
|
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
`group_id` char(36) NOT NULL COMMENT '组ID',
|
|
`user_id` char(36) NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `user_id_idx` (`user_id`) USING BTREE,
|
|
KEY `group_id_idx` (`group_id`) USING BTREE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
</update>
|
|
|
|
<!-- 新增 -->
|
|
<insert id="save" parameterType="map" flushCache="true">
|
|
INSERT INTO sys_group_user(
|
|
group_id,
|
|
user_id
|
|
) VALUES(
|
|
#{groupId},
|
|
#{userId}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 删除 -->
|
|
<delete id="delete" parameterType="map" flushCache="true">
|
|
DELETE FROM
|
|
sys_group_user
|
|
WHERE
|
|
1 = 1
|
|
<if test="groupId != null and groupId != ''">
|
|
AND
|
|
group_id = #{groupId}
|
|
</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_group_user
|
|
WHERE
|
|
<if test="groupId != null and groupId != ''">
|
|
group_id = #{groupId}
|
|
</if>
|
|
<if test="groupIds != null and groupIds.size > 0">
|
|
group_id IN (
|
|
<foreach collection="groupIds" index="index" open="(" separator="," close=")">
|
|
#{groupIds[${index}]}
|
|
</foreach>
|
|
)
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 用户ID列表 -->
|
|
<select id="listGroupUserId" parameterType="map" resultType="java.lang.String" useCache="true">
|
|
SELECT
|
|
user_id
|
|
FROM
|
|
sys_group_user
|
|
WHERE
|
|
1 = 1
|
|
GROUP BY
|
|
user_id
|
|
</select>
|
|
|
|
|
|
</mapper> |