<?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.starry.admin.modules.system.mapper.SysUserRoleMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.starry.admin.modules.system.module.entity.SysUserRoleEntity">
        <id column="user_role_id" property="userRoleId"/>
        <result column="role_id" property="roleId"/>
        <result column="user_id" property="userId"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="updated_time" property="updatedTime"/>
        <result column="updated_by" property="updatedBy"/>
        <result column="created_time" property="createdTime"/>
        <result column="created_by" property="createdBy"/>
        <result column="deleted" property="deleted"/>
        <result column="version" property="version"/>
    </resultMap>

    <delete id="deleteUserRoleByTenantId">
        delete from sys_user_role where tenant_id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteUserRoleInfo">
        delete from sys_user_role where user_id=#{userId} and role_id=#{roleId}
    </delete>

    <delete id="deleteUserRoleInfos">
        delete from sys_user_role where role_id=#{roleId} and user_id in
        <foreach collection="userIds" item="userId" open="(" separator="," close=")">
            #{userId}
        </foreach>
    </delete>
</mapper>
