<?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.ruoyi.ems.mapper.ObjTagRelMapper">
    
    <resultMap type="com.ruoyi.ems.domain.ObjTagRel" id="objTagRelResult">
        <result property="tagType"    column="tag_type"    />
        <result property="tagCode"    column="tag_code"    />
        <result property="objCode"    column="obj_code"    />
    </resultMap>

    <sql id="selectAdmObjTagRelVo">
        select tag_type, tag_code, obj_code from adm_obj_tag_rel
    </sql>

    <select id="selectListByType" parameterType="java.lang.Integer" resultMap="objTagRelResult">
        <include refid="selectAdmObjTagRelVo"/>
        where tag_type = #{tagType}
    </select>

    <select id="selectListByTagCode" resultMap="objTagRelResult">
        <include refid="selectAdmObjTagRelVo"/>
        where tag_type = #{tagType} and tag_code = #{tagCode}
    </select>

    <select id="selectListByObjCode" resultMap="objTagRelResult">
        <include refid="selectAdmObjTagRelVo"/>
        where tag_type = #{tagType} and obj_code = #{objCode}
    </select>

    <insert id="insertBatch" parameterType="java.util.List">
        insert into adm_obj_tag_rel (tag_type, tag_code, obj_code)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.tagType}, #{item.tagCode}, #{item.objCode})
        </foreach>
    </insert>

    <delete id="deleteByTagCode" >
        delete from adm_obj_tag_rel where tag_code = #{tagCode}
    </delete>


    <delete id="deleteByObjCode">
        delete from adm_obj_tag_rel where tag_type = #{tagType} and obj_code = #{objCode}
    </delete>
</mapper>