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

    <resultMap id="BizGoodsAttrTemplateItemResult" type="com.ruoyi.web.modules.template.domain.BizGoodsAttrTemplateItem">
        <id property="itemId" column="item_id"/>
        <result property="templateId" column="template_id"/>
        <result property="itemType" column="item_type"/>
        <result property="itemName" column="item_name"/>
        <result property="sortNo" column="sort_no"/>
    </resultMap>

    <select id="selectByTemplateId" resultMap="BizGoodsAttrTemplateItemResult">
        select item_id, template_id, item_type, item_name, sort_no
        from biz_goods_attr_template_item
        where template_id = #{templateId}
        order by item_type asc, sort_no asc
    </select>

    <select id="selectByTemplateIds" resultMap="BizGoodsAttrTemplateItemResult">
        select item_id, template_id, item_type, item_name, sort_no
        from biz_goods_attr_template_item
        where template_id in
        <foreach collection="templateIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        order by template_id asc, item_type asc, sort_no asc
    </select>

    <insert id="insert" useGeneratedKeys="true" keyProperty="itemId">
        insert into biz_goods_attr_template_item (template_id, item_type, item_name, sort_no)
        values (#{templateId}, #{itemType}, #{itemName}, #{sortNo})
    </insert>

    <delete id="deleteByTemplateId">
        delete from biz_goods_attr_template_item where template_id = #{templateId}
    </delete>
</mapper>
