<?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.zhentao.mapper.AdminUserRoleMapper">

    <resultMap id="BaseResultMap" type="com.zhentao.entity.AdminUserRole">
            <id property="id" column="id" />
            <result property="userId" column="user_id" />
            <result property="roleId" column="role_id" />
            <result property="createTime" column="create_time" />
    </resultMap>

    <sql id="Base_Column_List">
        id,user_id,role_id,create_time
    </sql>
    
    <!-- 根据用户ID查询角色ID列表 -->
    <select id="selectRoleIdsByUserId" resultType="java.lang.Integer">
        SELECT role_id
        FROM admin_user_role
        WHERE user_id = #{userId}
    </select>
    
    <!-- 根据用户ID删除所有角色关联 -->
    <delete id="deleteByUserId">
        DELETE FROM admin_user_role
        WHERE user_id = #{userId}
    </delete>
</mapper>
