<?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.gic.haoban.manage.service.dao.mapper.hm.TabHaobanHmPageMapper">
    <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.hm.TabHaobanHmPage">
        <id column="page_id" property="pageId" jdbcType="BIGINT"/>
        <result column="page_code" property="pageCode" jdbcType="CHAR"/>
        <result column="page_name" property="pageName" jdbcType="VARCHAR"/>
        <result column="enterprise_id" property="enterpriseId" jdbcType="VARCHAR"/>
        <result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="INTEGER"/>
        <result column="page_title" property="pageTitle" jdbcType="VARCHAR"/>
        <result column="merchant_name" property="merchantName" jdbcType="VARCHAR"/>
        <result column="merchant_phone_number" property="merchantPhoneNumber" jdbcType="VARCHAR"/>
        <result column="merchant_logo" property="merchantLogo" jdbcType="VARCHAR"/>
        <result column="page_background_img" property="pageBackgroundImg" jdbcType="VARCHAR"/>
        <result column="guide_comment" property="guideComment" jdbcType="VARCHAR"/>
        <result column="createor_id" property="createorId" jdbcType="VARCHAR"/>
        <result column="createor_name" property="createorName" jdbcType="VARCHAR"/>
        <result column="modifier_id" property="modifierId" jdbcType="VARCHAR"/>
        <result column="modifier_name" property="modifierName" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="page_type" property="pageType"/>
    </resultMap>
    <sql id="Base_Column_List">
        page_id
        , page_code, page_name, enterprise_id, wx_enterprise_id, status,
    page_title, merchant_name, merchant_phone_number, merchant_logo, page_background_img, 
    guide_comment, createor_id, createor_name, modifier_id, modifier_name, create_time, 
    update_time , page_type
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_hm_page
        where page_id = #{pageId,jdbcType=BIGINT}
    </select>
    <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.hm.TabHaobanHmPage">
        insert into tab_haoban_hm_page (page_id, page_code, page_name,
                                        enterprise_id, wx_enterprise_id, status,
                                        page_title, merchant_name, merchant_phone_number,
                                        merchant_logo, page_background_img, guide_comment,
                                        createor_id, createor_name, modifier_id,
                                        modifier_name, create_time, update_time , page_type)
        values (#{pageId,jdbcType=BIGINT}, #{pageCode,jdbcType=CHAR}, #{pageName,jdbcType=VARCHAR},
                #{enterpriseId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
                #{pageTitle,jdbcType=VARCHAR}, #{merchantName,jdbcType=VARCHAR},
                #{merchantPhoneNumber,jdbcType=VARCHAR},
                #{merchantLogo,jdbcType=VARCHAR}, #{pageBackgroundImg,jdbcType=VARCHAR},
                #{guideComment,jdbcType=VARCHAR},
                #{createorId,jdbcType=VARCHAR}, #{createorName,jdbcType=VARCHAR}, #{modifierId,jdbcType=VARCHAR},
                #{modifierName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} , #{pageType})
    </insert>

    <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.hm.TabHaobanHmPage">
        update tab_haoban_hm_page
        <set>
            <if test="pageCode != null">
                page_code = #{pageCode,jdbcType=CHAR},
            </if>
            <if test="pageName != null">
                page_name = #{pageName,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=INTEGER},
            </if>
            <if test="pageTitle != null">
                page_title = #{pageTitle,jdbcType=VARCHAR},
            </if>
            <if test="merchantName != null">
                merchant_name = #{merchantName,jdbcType=VARCHAR},
            </if>
            <if test="merchantPhoneNumber != null">
                merchant_phone_number = #{merchantPhoneNumber,jdbcType=VARCHAR},
            </if>
            <if test="merchantLogo != null">
                merchant_logo = #{merchantLogo,jdbcType=VARCHAR},
            </if>
            <if test="pageBackgroundImg != null">
                page_background_img = #{pageBackgroundImg,jdbcType=VARCHAR},
            </if>
            <if test="guideComment != null">
                guide_comment = #{guideComment,jdbcType=VARCHAR},
            </if>
            <if test="modifierId != null">
                modifier_id = #{modifierId,jdbcType=VARCHAR},
            </if>
            <if test="modifierName != null">
                modifier_name = #{modifierName,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where page_id = #{pageId,jdbcType=BIGINT}
    </update>
    

    <select id="queryHmPageTemplateList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_hm_page
        <where>
            <if test="pageSearchText != null and pageSearchText != ''">
                ( page_code = #{pageSearchText}
                      or page_name like concat('%', #{pageSearchText}, '%')
                      or createor_name like concat('%', #{pageSearchText}, '%') )
            </if>
            <if test="status != null">
                and `status` = #{status}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
            <if test="startTime != null">
                and create_time >= #{startTime}
            </if>
            <if test="endTime != null">
                and #{endTime} >= create_time
            </if>
            and page_type = #{pageType}
        </where>
        order by page_id desc
    </select>
</mapper>