<?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.fs.store.mapper.FsStoreCanvasMapper">
    
    <resultMap type="FsStoreCanvas" id="FsStoreCanvasResult">
        <result property="canvasId"    column="canvas_id"    />
        <result property="terminal"    column="terminal"    />
        <result property="json"    column="json"    />
        <result property="type"    column="type"    />
        <result property="name"    column="name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectFsStoreCanvasVo">
        select canvas_id, terminal, json, type, name, create_time, update_time, is_del from fs_store_canvas
    </sql>

    <select id="selectFsStoreCanvasList" parameterType="FsStoreCanvas" resultMap="FsStoreCanvasResult">
        <include refid="selectFsStoreCanvasVo"/>
        <where>  
            <if test="terminal != null "> and terminal = #{terminal}</if>
            <if test="json != null  and json != ''"> and json = #{json}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectFsStoreCanvasById" parameterType="Long" resultMap="FsStoreCanvasResult">
        <include refid="selectFsStoreCanvasVo"/>
        where canvas_id = #{canvasId}
    </select>
        
    <insert id="insertFsStoreCanvas" parameterType="FsStoreCanvas" useGeneratedKeys="true" keyProperty="canvasId">
        insert into fs_store_canvas
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="terminal != null">terminal,</if>
            <if test="json != null">json,</if>
            <if test="type != null">type,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="terminal != null">#{terminal},</if>
            <if test="json != null">#{json},</if>
            <if test="type != null">#{type},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateFsStoreCanvas" parameterType="FsStoreCanvas">
        update fs_store_canvas
        <trim prefix="SET" suffixOverrides=",">
            <if test="terminal != null">terminal = #{terminal},</if>
            <if test="json != null">json = #{json},</if>
            <if test="type != null">type = #{type},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where canvas_id = #{canvasId}
    </update>

    <delete id="deleteFsStoreCanvasById" parameterType="Long">
        delete from fs_store_canvas where canvas_id = #{canvasId}
    </delete>

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