<?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.zkqy.system.mapper.MobilePageDataMapper">
    
    <resultMap type="com.zkqy.system.entity.MobilePageData" id="MobilePageDataResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="templateJson"    column="templateJson"    />
        <result property="component"    column="component"    />
    </resultMap>

    <sql id="selectMobilePageDataVo">
        select id, name, templateJson, component from mobile_page_data
    </sql>

    <select id="selectMobilePageDataList" parameterType="com.zkqy.system.entity.MobilePageData" resultMap="MobilePageDataResult">
        <include refid="selectMobilePageDataVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="templateJson != null  and templateJson != ''"> and templateJson = #{templateJson}</if>
            <if test="component != null  and component != ''"> and component = #{component}</if>
        </where>
    </select>
    
    <select id="selectMobilePageDataById" parameterType="Long" resultMap="MobilePageDataResult">
        <include refid="selectMobilePageDataVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMobilePageData" parameterType="com.zkqy.system.entity.MobilePageData" useGeneratedKeys="true" keyProperty="id">
        insert into mobile_page_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="templateJson != null">templateJson,</if>
            <if test="component != null">component,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="templateJson != null">#{templateJson},</if>
            <if test="component != null">#{component},</if>
         </trim>
    </insert>

    <update id="updateMobilePageData" parameterType="com.zkqy.system.entity.MobilePageData">
        update mobile_page_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="templateJson != null">templateJson = #{templateJson},</if>
            <if test="component != null">component = #{component},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMobilePageDataById" parameterType="Long">
        delete from mobile_page_data where id = #{id}
    </delete>

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