<?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.zm.order.tool.server.design.ZmStorePagesDao">

    <resultMap id="OrderMap" type="com.zm.order.tool.server.model.ZmStorePages">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column = "code" jdbcType = "VARCHAR" property = "code"/>
        <result column = "store_id" jdbcType = "INTEGER" property = "storeId"/>
        <result column = "template_id" jdbcType = "INTEGER" property = "templateId"/>
        <result column = "type" jdbcType = "VARCHAR" property = "type"/>
        <result column = "title" jdbcType = "VARCHAR" property = "title"/>
        <result column = "keyword" jdbcType = "VARCHAR" property = "keyword"/>
        <result column = "description" jdbcType = "VARCHAR" property = "description"/>
        <result column = "is_homepage" jdbcType = "INTEGER" property = "isHomepage"/>
        <result column = "config" jdbcType = "VARCHAR" property = "config"/>
        <result column = "html" jdbcType = "VARCHAR" property = "html"/>
        <result column = "created_at" jdbcType = "INTEGER" property = "createdAt"/>
        <result column = "updated_at" jdbcType = "INTEGER" property = "updatedAt"/>
        <result column = "published_at" jdbcType = "INTEGER" property = "publishedAt"/>
        <result column = "tops" jdbcType = "VARCHAR" property = "tops"/>
        <result column = "bottoms" jdbcType = "VARCHAR" property = "bottoms"/>
        <result column = "share_text" jdbcType = "VARCHAR" property = "shareText"/>
        <result column = "body_color" jdbcType = "VARCHAR" property = "bodyColor"/>
        <result column = "share_img" jdbcType = "VARCHAR" property = "shareImg"/>
        <result column = "is_show_hold_tips" jdbcType = "INTEGER" property = "isShowHoldTips"/>
        <result column = "show_hold_tips_text" jdbcType = "VARCHAR" property = "showHoldTipsText"/>
        <result column = "ext_pages" jdbcType = "VARCHAR" property = "extPages"/>
        <result column = "height" jdbcType = "VARCHAR" property = "height"/>
        <result column = "body_image" jdbcType = "VARCHAR" property = "bodyImage"/>
        <result column = "new_config" jdbcType = "VARCHAR" property = "newConfig"/>
    </resultMap>

    <sql id="tb">
        zm_store_pages
    </sql>

    <sql id="cols_all">
        id,
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
        code,
        store_id,
        template_id,
        type,
        title,
        keyword,
        description,
        is_homepage,
        config,
        html,
        created_at,
        updated_at,
        published_at,
        tops,
        bottoms,
        share_text,
        body_color,
        share_img,
        is_show_hold_tips,
        show_hold_tips_text,
        ext_pages,
        height,
        body_image,
        new_config
    </sql>

    <select id="selectList" parameterType="map" resultMap="OrderMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        where store_id = #{storeId} order by id desc
    </select>

    <update id="update" parameterType="map">
        update
        <include refid="tb"/>
        set new_config = #{newConfig}
        where id = #{id}
    </update>

</mapper>