<?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.github.wxiaoqi.security.admin.mapper.AppUserMapper">
    <insert id="insertAppUserGroup">
        insert into app_group_member(user_id, group_id)
        VALUES
        <trim suffixOverrides=",">
            <foreach collection="groups" item="groupId">
                (#{appUserId}, #{groupId}),
            </foreach>
        </trim>

    </insert>
    <delete id="deleteAppUserGroup">
        delete from app_group_member
        where user_id = #{appUserId}
    </delete>
    <select id="selectGroupsByAppUserId" resultType="com.github.wxiaoqi.security.admin.entity.Group">
        select *
        from base_group bg
        right join app_group_member agm on bg.id = agm.group_id
        where user_id = #{id}
    </select>


</mapper>