<?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.MyResourceTagMapper">

    <resultMap id="BaseResultMap" type="com.zhentao.entity.MyResourceTag">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="resourceId" column="resource_id" jdbcType="INTEGER"/>
        <result property="tagId" column="tag_id" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <!-- 根据资源ID删除所有标签关联 -->
    <delete id="deleteByResourceId" parameterType="java.lang.Integer">
        DELETE FROM my_resource_tag
        WHERE resource_id = #{resourceId}
    </delete>

    <!-- 根据资源ID查询所有标签ID -->
    <select id="selectTagIdsByResourceId" parameterType="java.lang.Integer" resultType="java.lang.Integer">
        SELECT tag_id
        FROM my_resource_tag
        WHERE resource_id = #{resourceId}
        ORDER BY create_time ASC
    </select>

</mapper>

