<?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.iamberry.wechat.service.mapper.CustomizedColorMapper">
    <resultMap  id="BaseResultMap" type="CustomizedColor" >
        <result    column="color_id"    property="colorId" />
        <result    column="color_name"    property="colorName" />
        <result    column="color_value"    property="colorValue" />
        <result    column="color_img"    property="colorImg" />
        <result    column="color_status"    property="colorStatus" />
        <result    column="color_create_time"    property="colorCreateTime" />
        <result    column="color_update_time"    property="colorUpdateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.color_id,
        t.color_name,
        t.color_value,
        t.color_img,
        t.color_status,
        t.color_create_time,
        t.color_update_time
    </sql>
    <select id="getCustomizedColorList" resultMap="BaseResultMap" parameterType="CustomizedColor" >
        select
        <include refid="Base_List" />
        from tb_iamberry_customized_color t
        <where>
            <if test="colorId != null ">
                AND t.color_id = #{colorId}
            </if >
            <if test="colorStatus != null ">
                AND t.color_status = #{colorStatus}
            </if >
        </where>
    </select>
    <select id="getCustomizedColorById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_customized_color t
        where t.color_id= #{colorId}
    </select>
    <insert id="save" parameterType="CustomizedColor" >
        insert into
        tb_iamberry_customized_color
        (
        color_name,
        color_value,
        color_img,
        color_status
        )
        values
        (
        #{colorName},
        #{colorValue},
        #{colorImg},
        #{colorStatus}
        )
    </insert>
    <update id="update" parameterType="CustomizedColor" >
        update
        tb_iamberry_customized_color
        <set >
            <if test="colorName != null and colorName != ''">
                color_name = #{colorName},
            </if >
            <if test="colorValue != null and colorValue != ''">
                color_value = #{colorValue},
            </if >
            <if test="colorImg != null and colorImg != ''">
                color_img = #{colorImg},
            </if >
            <if test="colorStatus != null ">
                color_status = #{colorStatus},
            </if >
        </set >
        where color_id= #{colorId}
    </update>
    <delete id="delete" parameterType="Integer" >
        delete
        tb_iamberry_customized_color
        where color_id=#{colorId}
    </delete>
</mapper>