<?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.yiqi.core.mapper.ClothHangerOrderRelationMapper">

    <resultMap type="ClothHangerOrderRelation" id="ClothHangerOrderRelationResult">
        <result property="id" column="id"/>
        <result property="orderId" column="order_id"/>
        <result property="orderClothItemId" column="order_cloth_item_id"/>
        <result property="washCode" column="wash_code"/>
        <result property="clothHangerId" column="cloth_hanger_id"/>
        <result property="clothHangerCode" column="cloth_hanger_code"/>
        <result property="createById" column="create_by_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateById" column="update_by_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectClothHangerOrderRelationVo">
        select id, order_id, order_cloth_item_id, wash_code, cloth_hanger_id, cloth_hanger_code, create_by_id, create_by, create_time, update_by_id, update_by, update_time
        from cloth_hanger_order_relation
    </sql>

    <select id="selectClothHangerOrderRelationList" parameterType="ClothHangerOrderRelation" resultMap="ClothHangerOrderRelationResult">
        <include refid="selectClothHangerOrderRelationVo"/>
        <where>
            <if test="orderId != null ">
                and order_id = #{orderId}
            </if>
            <if test="orderClothItemId != null ">
                and order_cloth_item_id = #{orderClothItemId}
            </if>
            <if test="washCode != null  and washCode != ''">
                and wash_code = #{washCode}
            </if>
            <if test="clothHangerId != null ">
                and cloth_hanger_id = #{clothHangerId}
            </if>
            <if test="clothHangerCode != null  and clothHangerCode != ''">
                and cloth_hanger_code = #{clothHangerCode}
            </if>
        </where>
    </select>

    <select id="selectClothHangerOrderRelationById" parameterType="Long"
            resultMap="ClothHangerOrderRelationResult">
        <include refid="selectClothHangerOrderRelationVo"/>
        where id = #{id}
    </select>

    <insert id="insertClothHangerOrderRelation" parameterType="ClothHangerOrderRelation" useGeneratedKeys="true"
            keyProperty="id">
        insert into cloth_hanger_order_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,
            </if>
            <if test="orderClothItemId != null">order_cloth_item_id,
            </if>
            <if test="washCode != null">wash_code,
            </if>
            <if test="clothHangerId != null">cloth_hanger_id,
            </if>
            <if test="clothHangerCode != null">cloth_hanger_code,
            </if>
            <if test="createById != null">create_by_id,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateById != null">update_by_id,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},
            </if>
            <if test="orderClothItemId != null">#{orderClothItemId},
            </if>
            <if test="washCode != null">#{washCode},
            </if>
            <if test="clothHangerId != null">#{clothHangerId},
            </if>
            <if test="clothHangerCode != null">#{clothHangerCode},
            </if>
            <if test="createById != null">#{createById},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateById != null">#{updateById},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
        </trim>
    </insert>

    <update id="updateClothHangerOrderRelation" parameterType="ClothHangerOrderRelation">
        update cloth_hanger_order_relation
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id =
                #{orderId},
            </if>
            <if test="orderClothItemId != null">order_cloth_item_id =
                #{orderClothItemId},
            </if>
            <if test="washCode != null">wash_code =
                #{washCode},
            </if>
            <if test="clothHangerId != null">cloth_hanger_id =
                #{clothHangerId},
            </if>
            <if test="clothHangerCode != null">cloth_hanger_code =
                #{clothHangerCode},
            </if>
            <if test="createById != null">create_by_id =
                #{createById},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateById != null">update_by_id =
                #{updateById},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteClothHangerOrderRelationById" parameterType="Long">
        delete from cloth_hanger_order_relation where id = #{id}
    </delete>

    <delete id="deleteClothHangerOrderRelationByIds" parameterType="String">
        delete from cloth_hanger_order_relation where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>



</mapper>