<?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.web.modules.template.mapper.BizGoodsAttrTemplateValueMapper">

    <resultMap id="BizGoodsAttrTemplateValueResult" type="com.ruoyi.web.modules.template.domain.BizGoodsAttrTemplateValue">
        <id property="valueId" column="value_id"/>
        <result property="itemId" column="item_id"/>
        <result property="valueText" column="value_text"/>
        <result property="sortNo" column="sort_no"/>
    </resultMap>

    <select id="selectByItemIds" resultMap="BizGoodsAttrTemplateValueResult">
        select value_id, item_id, value_text, sort_no
        from biz_goods_attr_template_value
        where item_id in
        <foreach collection="itemIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        order by item_id asc, sort_no asc
    </select>

    <insert id="insert">
        insert into biz_goods_attr_template_value (item_id, value_text, sort_no)
        values (#{itemId}, #{valueText}, #{sortNo})
    </insert>

    <delete id="deleteByTemplateId">
        delete v from biz_goods_attr_template_value v
        inner join biz_goods_attr_template_item i on v.item_id = i.item_id
        where i.template_id = #{templateId}
    </delete>
</mapper>
