<?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="tagCode"    column="tag_code"    />
        <result property="objType"    column="obj_type"    />
        <result property="objCode"    column="obj_code"    />
        <result property="tagName"    column="tag_name"    />
    </resultMap>

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


    <insert id="insert" parameterType="com.ruoyi.ems.domain.ObjTagRel">
        replace into adm_obj_tag_rel (tag_code, obj_type, obj_code) values (#{tagCode}, #{objType}, #{objCode})
    </insert>

    <insert id="delete" parameterType="com.ruoyi.ems.domain.ObjTagRel">
        delete from adm_obj_tag_rel where tag_code = #{tagCode} and obj_type = #{objType} and obj_code = #{objCode}
    </insert>

    <select id="selectListByType" parameterType="java.lang.Integer" resultMap="objTagRelResult">
        select
            r.tag_code, t.tag_name, r.obj_type, r.obj_code
        from adm_obj_tag_rel r
            left join dim_ems_tag t on r.tag_code = t.tag_code
        where r.obj_type = #{objType}
    </select>

    <select id="selectListByTagCode" resultMap="objTagRelResult">
        select
            r.tag_code, t.tag_name, r.obj_type, r.obj_code
        from adm_obj_tag_rel r
                 left join dim_ems_tag t on r.tag_code = t.tag_code
        where r.obj_type = #{objType} and r.tag_code = #{tagCode}
    </select>

    <select id="selectListByObjCode" resultMap="objTagRelResult">
        select
            r.tag_code, t.tag_name, r.obj_type, r.obj_code
        from adm_obj_tag_rel r
            left join dim_ems_tag t on r.tag_code = t.tag_code
        where r.obj_type = #{objType} and r.obj_code = #{objCode}
    </select>


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