<?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.CustomizedPatternMapper">
    <resultMap  id="BaseResultMap" type="CustomizedPattern" >
        <result    column="pattern_id"    property="patternId" />
        <result    column="pattern_name"    property="patternName" />
        <result    column="pattern_thumbnail_img"    property="patternThumbnailImg" />
        <result    column="pattern_img"    property="patternImg" />
        <result    column="pattern_status"    property="patternStatus" />
        <result    column="pattern_create_time"    property="patternCreateTime" />
        <result    column="pattern_update_time"    property="patternUpdateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.pattern_id,
        t.pattern_name,
        t.pattern_thumbnail_img,
        t.pattern_img,
        t.pattern_status,
        t.pattern_create_time,
        t.pattern_update_time
    </sql>
    <select id="getCustomizedPatternList" resultMap="BaseResultMap" parameterType="CustomizedPattern" >
        select
        <include refid="Base_List" />
        from tb_iamberry_customized_pattern t
        <where>
            <if test="patternId != null ">
                AND t.pattern_id = #{patternId}
            </if >
            <if test="patternStatus != null ">
                AND t.pattern_status = #{patternStatus}
            </if >
        </where>
    </select>
    <select id="getCustomizedPatternById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_customized_pattern t
        where t.pattern_id= #{patternId}
    </select>
    <insert id="save" parameterType="CustomizedPattern" >
        insert into
        tb_iamberry_customized_pattern
        (
        pattern_name,
        pattern_thumbnail_img,
        pattern_img,
        pattern_status
        )
        values
        (
        #{patternName},
        #{patternThumbnailImg},
        #{patternImg},
        #{patternStatus}
        )
    </insert>
    <update id="update" parameterType="CustomizedPattern" >
        update
        tb_iamberry_customized_pattern
        <set >
            <if test="patternName != null and patternName != ''">
                pattern_name = #{patternName},
            </if >
            <if test="patternThumbnailImg != null and patternThumbnailImg != ''">
                pattern_thumbnail_img = #{patternThumbnailImg},
            </if >
            <if test="patternImg != null and patternImg != ''">
                pattern_img = #{patternImg},
            </if >
            <if test="patternStatus != null ">
                pattern_status = #{patternStatus},
            </if >
        </set >
        where pattern_id= #{patternId}
    </update>
</mapper>