<?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.ximai.mes.md.mapper.MdSizeGroupItemMapper">

    <resultMap type="MdSizeGroupItem" id="MdSizeGroupItemResult">
        <result property="sizeGroupItemId"    column="size_group_item_id"    />
        <result property="sizeGroupId"    column="size_group_id"    />
        <result property="sizeIndex"    column="size_index"    />
        <result property="sizeName"    column="size_name"    />
        <result property="sizeDisplayName"    column="size_display_name"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectMdSizeGroupItemVo">
        select size_group_item_id, size_group_id, size_index, size_name, size_display_name, remark, create_by, create_time, update_by, update_time from md_size_group_item
    </sql>

    <select id="selectMdSizeGroupItemList" parameterType="MdSizeGroupItem" resultMap="MdSizeGroupItemResult">
        <include refid="selectMdSizeGroupItemVo"/>
        <where>
            <if test="sizeGroupId != null "> and size_group_id = #{sizeGroupId}</if>
            <if test="sizeIndex != null "> and size_index = #{sizeIndex}</if>
            <if test="sizeName != null  and sizeName != ''"> and size_name like concat('%', #{sizeName}, '%')</if>
            <if test="sizeDisplayName != null  and sizeDisplayName != ''"> and size_display_name like concat('%', #{sizeDisplayName}, '%')</if>
        </where>
    </select>

    <select id="selectMdSizeGroupItemBySizeGroupItemId" parameterType="Long" resultMap="MdSizeGroupItemResult">
        <include refid="selectMdSizeGroupItemVo"/>
        where size_group_item_id = #{sizeGroupItemId}
    </select>

    <insert id="insertMdSizeGroupItem" parameterType="MdSizeGroupItem">
        insert into md_size_group_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sizeGroupItemId != null">size_group_item_id,</if>
            <if test="sizeGroupId != null">size_group_id,</if>
            <if test="sizeIndex != null">size_index,</if>
            <if test="sizeName != null">size_name,</if>
            <if test="sizeDisplayName != null">size_display_name,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            create_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sizeGroupItemId != null">#{sizeGroupItemId},</if>
            <if test="sizeGroupId != null">#{sizeGroupId},</if>
            <if test="sizeIndex != null">#{sizeIndex},</if>
            <if test="sizeName != null">#{sizeName},</if>
            <if test="sizeDisplayName != null">#{sizeDisplayName},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            sysdate()
         </trim>
    </insert>

    <update id="updateMdSizeGroupItem" parameterType="MdSizeGroupItem">
        update md_size_group_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="sizeGroupId != null">size_group_id = #{sizeGroupId},</if>
            <if test="sizeIndex != null">size_index = #{sizeIndex},</if>
            <if test="sizeName != null">size_name = #{sizeName},</if>
            <if test="sizeDisplayName != null">size_display_name = #{sizeDisplayName},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            update_time = sysdate()
        </trim>
        where size_group_item_id = #{sizeGroupItemId}
    </update>

    <delete id="deleteMdSizeGroupItemBySizeGroupItemId" parameterType="Long">
        delete from md_size_group_item where size_group_item_id = #{sizeGroupItemId}
    </delete>

    <delete id="deleteMdSizeGroupItemBySizeGroupItemIds" parameterType="String">
        delete from md_size_group_item where size_group_item_id in
        <foreach item="sizeGroupItemId" collection="array" open="(" separator="," close=")">
            #{sizeGroupItemId}
        </foreach>
    </delete>
</mapper>
