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

    <resultMap type="ClothSpeed" id="ClothSpeedResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="multiple" column="multiple"/>
        <result property="dayNum" column="day_num"/>
        <result property="isDefault" column="is_default"/>
        <result property="delFlag" column="del_flag"/>
        <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"/>
        <result property="remark" column="remark"/>
        <result property="status" column="status"/>
    </resultMap>

    <sql id="selectClothSpeedVo">
        select id, name, multiple, day_num, is_default, del_flag, create_by_id, create_by, create_time, update_by_id, update_by, update_time, remark, status
        from cloth_speed
    </sql>

    <select id="selectClothSpeedList" parameterType="ClothSpeed" resultMap="ClothSpeedResult">
        <include refid="selectClothSpeedVo"/>
        <where>
            del_flag='0'
            <if test="name != null  and name != ''">
                and name like concat('%', #{name}, '%')
            </if>
            <if test="isDefault != null  and isDefault != ''">
                and is_default = #{isDefault}
            </if>
        </where>
    </select>

    <select id="selectClothSpeedById" parameterType="Long"
            resultMap="ClothSpeedResult">
        <include refid="selectClothSpeedVo"/>
        where id = #{id}
    </select>

    <insert id="insertClothSpeed" parameterType="ClothSpeed" useGeneratedKeys="true"
            keyProperty="id">
        insert into cloth_speed
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,
            </if>
            <if test="multiple != null">multiple,
            </if>
            <if test="dayNum != null">day_num,
            </if>
            <if test="isDefault != null and isDefault != ''">is_default,
            </if>
            <if test="delFlag != null">del_flag,
            </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>
            <if test="remark != null">remark,
            </if>
            <if test="status != null">status,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},
            </if>
            <if test="multiple != null">#{multiple},
            </if>
            <if test="dayNum != null">#{dayNum},
            </if>
            <if test="isDefault != null and isDefault != ''">#{isDefault},
            </if>
            <if test="delFlag != null">#{delFlag},
            </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>
            <if test="remark != null">#{remark},
            </if>
            <if test="status != null">#{status},
            </if>
        </trim>
    </insert>

    <update id="updateClothSpeed" parameterType="ClothSpeed">
        update cloth_speed
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name =
                #{name},
            </if>
            <if test="multiple != null">multiple =
                #{multiple},
            </if>
            <if test="dayNum != null">day_num =
                #{dayNum},
            </if>
            <if test="isDefault != null and isDefault != ''">is_default =
                #{isDefault},
            </if>
            <if test="delFlag != null">del_flag =
                #{delFlag},
            </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>
            <if test="remark != null">remark =
                #{remark},
            </if>
            <if test="status != null">status =
                #{status},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteClothSpeedById" parameterType="Long">
            update cloth_speed set del_flag='2' where id = #{id}
        </delete>

    <delete id="deleteClothSpeedByIds" parameterType="String">
        update cloth_speed set del_flag='2' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>



</mapper>