<?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.TabMiniprogramSettingMapper">
    <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabMiniprogramSetting">
        <id column="miniprogram_setting_id" jdbcType="VARCHAR" property="miniprogramSettingId"/>
        <result column="wx_enterprise_id" jdbcType="VARCHAR" property="wxEnterpriseId"/>
        <result column="enterprise_id" jdbcType="VARCHAR" property="enterpriseId"/>
        <result column="miniprogram_name" jdbcType="VARCHAR" property="miniprogramName"/>
        <result column="title" jdbcType="VARCHAR" property="title"/>
        <result column="app_id" jdbcType="VARCHAR" property="appId"/>
        <result column="image_url" jdbcType="VARCHAR" property="imageUrl"/>
        <result column="media_id" jdbcType="VARCHAR" property="mediaId"/>
        <result column="media_time" jdbcType="TIMESTAMP" property="mediaTime"/>
        <result column="status_flag" jdbcType="INTEGER" property="statusFlag"/>
        <result column="miniprogram_type" jdbcType="INTEGER" property="miniprogramType"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>
    <sql id="Base_Column_List">
    miniprogram_setting_id, wx_enterprise_id, enterprise_id, miniprogram_name, title,
        app_id, image_url, media_id, media_time,miniprogram_type, status_flag, create_time, update_time
  </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_miniprogram_setting
        where miniprogram_setting_id = #{miniprogramSettingId,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    update tab_haoban_miniprogram_setting
    set status_flag=0,update_time=now()
    where miniprogram_setting_id = #{miniprogramSettingId,jdbcType=VARCHAR}
  </delete>
    <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabMiniprogramSetting">
    insert into tab_haoban_miniprogram_setting (miniprogram_setting_id, wx_enterprise_id, 
      enterprise_id, miniprogram_name, title, 
      app_id, image_url, media_id, 
      media_time, status_flag, create_time, 
      update_time)
    values (#{miniprogramSettingId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, 
      #{enterpriseId,jdbcType=VARCHAR}, #{miniprogramName,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, 
      #{appId,jdbcType=VARCHAR}, #{imageUrl,jdbcType=VARCHAR}, #{mediaId,jdbcType=VARCHAR}, 
      #{mediaTime,jdbcType=TIMESTAMP}, #{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateTime,jdbcType=TIMESTAMP})
  </insert>
    <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabMiniprogramSetting">
        insert into tab_haoban_miniprogram_setting
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="miniprogramSettingId != null">
                miniprogram_setting_id,
            </if>
            <if test="wxEnterpriseId != null">
                wx_enterprise_id,
            </if>
            <if test="enterpriseId != null">
                enterprise_id,
            </if>
            <if test="miniprogramName != null">
                miniprogram_name,
            </if>
            <if test="title != null">
                title,
            </if>
            <if test="appId != null">
                app_id,
            </if>
            <if test="imageUrl != null">
                image_url,
            </if>
            <if test="mediaId != null">
                media_id,
            </if>
            <if test="mediaTime != null">
                media_time,
            </if>
            <if test="miniprogramType != null">
                miniprogram_type,
            </if>
            <if test="statusFlag != null">
                status_flag,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="miniprogramSettingId != null">
                #{miniprogramSettingId,jdbcType=VARCHAR},
            </if>
            <if test="wxEnterpriseId != null">
                #{wxEnterpriseId,jdbcType=VARCHAR},
            </if>
            <if test="enterpriseId != null">
                #{enterpriseId,jdbcType=VARCHAR},
            </if>
            <if test="miniprogramName != null">
                #{miniprogramName,jdbcType=VARCHAR},
            </if>
            <if test="title != null">
                #{title,jdbcType=VARCHAR},
            </if>
            <if test="appId != null">
                #{appId,jdbcType=VARCHAR},
            </if>
            <if test="imageUrl != null">
                #{imageUrl,jdbcType=VARCHAR},
            </if>
            <if test="mediaId != null">
                #{mediaId,jdbcType=VARCHAR},
            </if>
            <if test="mediaTime != null">
                #{mediaTime,jdbcType=TIMESTAMP},
            </if>
            <if test="miniprogramType != null">
                #{miniprogramType,jdbcType=INTEGER},
            </if>
            <if test="statusFlag != null">
                #{statusFlag,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabMiniprogramSetting">
        update tab_haoban_miniprogram_setting
        <set>
            <if test="wxEnterpriseId != null">
                wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
            </if>
            <if test="enterpriseId != null">
                enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
            </if>
            <if test="miniprogramName != null">
                miniprogram_name = #{miniprogramName,jdbcType=VARCHAR},
            </if>
            <if test="title != null">
                title = #{title,jdbcType=VARCHAR},
            </if>
            <if test="appId != null">
                app_id = #{appId,jdbcType=VARCHAR},
            </if>
            <if test="imageUrl != null">
                image_url = #{imageUrl,jdbcType=VARCHAR},
            </if>
            <if test="mediaId != null">
                media_id = #{mediaId,jdbcType=VARCHAR},
            </if>
            <if test="mediaTime != null">
                media_time = #{mediaTime,jdbcType=TIMESTAMP},
            </if>
            <if test="statusFlag != null">
                status_flag = #{statusFlag,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where miniprogram_setting_id = #{miniprogramSettingId,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabMiniprogramSetting">
    update tab_haoban_miniprogram_setting
    set wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
      enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
      miniprogram_name = #{miniprogramName,jdbcType=VARCHAR},
      title = #{title,jdbcType=VARCHAR},
      app_id = #{appId,jdbcType=VARCHAR},
      image_url = #{imageUrl,jdbcType=VARCHAR},
      media_id = #{mediaId,jdbcType=VARCHAR},
      media_time = #{mediaTime,jdbcType=TIMESTAMP},
      status_flag = #{statusFlag,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where miniprogram_setting_id = #{miniprogramSettingId,jdbcType=VARCHAR}
  </update>

    <select id="getMiniprogramSetting" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_miniprogram_setting
        where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
        and enterprise_id=#{enterpriseId}
        and status_flag=1 and miniprogram_type = 0 order by create_time desc limit 1
    </select>

    <select id="listMiniprogramSetting" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_miniprogram_setting
        where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
        and status_flag=1
    </select>

    <select id="getMiniprogramSettingByAppId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_miniprogram_setting
        where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
        and app_id=#{appId}
        and status_flag=1
    </select>
</mapper>