<?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="cn.reghao.tnb.content.app.vod.db.mapper.PostTagMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into vod_post_tag
            (`tag_id`,`tag_name`)
        values
        (#{tagId},#{tagName})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert ignore into vod_post_tag
            (`tag_id`,`tag_name`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.tagId},#{item.tagName})
        </foreach>
    </insert>

    <delete id="deleteByTagId">
        delete from vod_post_tag
        where tag_id=#{tagId}
    </delete>

    <select id="findAll" resultType="cn.reghao.tnb.content.app.vod.model.po.PostTag">
        select *
        from vod_post_tag
    </select>
    <select id="findByName" resultType="cn.reghao.tnb.content.app.vod.model.po.PostTag">
        select * from vod_post_tag where tag_name=#{name}
    </select>
    <select id="findByTagId" resultType="cn.reghao.tnb.content.app.vod.model.po.PostTag">
        select *
        from vod_post_tag
        where tag_id=#{tagId}
    </select>
</mapper>