<?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.dsk.biz.mapper.BusinessLabelMapper">

    <resultMap type="com.dsk.biz.domain.BusinessLabel" id="BusinessLabelResult">
        <result property="id" column="id"/>
        <result property="businessId" column="business_id"/>
        <result property="label" column="label"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectBusinessLabelVo">
        select id, business_id, label, create_time, update_time
        from business_label
    </sql>

    <select id="selectBusinessLabelList" parameterType="com.dsk.biz.domain.BusinessLabel"
            resultMap="BusinessLabelResult">
        <include refid="selectBusinessLabelVo"/>
        <where>
            <if test="businessId != null ">and business_id = #{businessId}</if>
            <if test="label != null  and label != ''">and label = #{label}</if>
        </where>
    </select>

    <select id="selectBusinessLabelById" parameterType="Long" resultMap="BusinessLabelResult">
        <include refid="selectBusinessLabelVo"/>
        where id = #{id}
    </select>

    <insert id="insertBusinessLabel" parameterType="com.dsk.biz.domain.BusinessLabel"
            useGeneratedKeys="true" keyProperty="id">
        insert into business_label
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="businessId != null">business_id,</if>
            <if test="label != null">label,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="businessId != null">#{businessId},</if>
            <if test="label != null">#{label},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateBusinessLabel" parameterType="com.dsk.biz.domain.BusinessLabel">
        update business_label
        <trim prefix="SET" suffixOverrides=",">
            <if test="businessId != null">business_id = #{businessId},</if>
            <if test="label != null">label = #{label},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusinessLabelById">
        delete
        from business_label
        where id = #{labelId}
    </delete>

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