<?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.cool.store.mapper.RegionQrcodeConfigMapper">
  <resultMap id="BaseResultMap" type="com.cool.store.entity.RegionQrcodeConfigDO">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="region_id" jdbcType="BIGINT" property="regionId" />
    <result column="region_name" jdbcType="VARCHAR" property="regionName" />
    <result column="pay_pic" jdbcType="VARCHAR" property="payPic" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
    <result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
    <result column="deleted" jdbcType="BIT" property="deleted" />
  </resultMap>
  <sql id="Base_Column_List">
    id, region_id, region_name, pay_pic, create_time, update_time, create_user_id, update_user_id, 
    deleted
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from xfsg_region_qrcode_config
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from xfsg_region_qrcode_config
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insertSelective" parameterType="com.cool.store.entity.RegionQrcodeConfigDO">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into xfsg_region_qrcode_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="regionId != null">
        region_id,
      </if>
      <if test="regionName != null">
        region_name,
      </if>
      <if test="payPic != null">
        pay_pic,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="createUserId != null">
        create_user_id,
      </if>
      <if test="updateUserId != null">
        update_user_id,
      </if>
      <if test="deleted != null">
        deleted,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="regionId != null">
        #{regionId,jdbcType=BIGINT},
      </if>
      <if test="regionName != null">
        #{regionName,jdbcType=VARCHAR},
      </if>
      <if test="payPic != null">
        #{payPic,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        #{createUserId,jdbcType=VARCHAR},
      </if>
      <if test="updateUserId != null">
        #{updateUserId,jdbcType=VARCHAR},
      </if>
      <if test="deleted != null">
        #{deleted,jdbcType=BIT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.cool.store.entity.RegionQrcodeConfigDO">
    update xfsg_region_qrcode_config
    <set>
      <if test="regionId != null">
        region_id = #{regionId,jdbcType=BIGINT},
      </if>
      <if test="regionName != null">
        region_name = #{regionName,jdbcType=VARCHAR},
      </if>
      <if test="payPic != null">
        pay_pic = #{payPic,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        create_user_id = #{createUserId,jdbcType=VARCHAR},
      </if>
      <if test="updateUserId != null">
        update_user_id = #{updateUserId,jdbcType=VARCHAR},
      </if>
      <if test="deleted != null">
        deleted = #{deleted,jdbcType=BIT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <sql id="dynamicQuery">
    <trim prefix="WHERE" prefixOverrides="AND | OR">
      <if test="null != id">
         and t.id = #{id,jdbcType=BIGINT}
      </if>
      <if test="null != regionId">
         and t.region_id = #{regionId,jdbcType=BIGINT}
      </if>
      <if test="null != regionName">
         and t.region_name = #{regionName,jdbcType=VARCHAR}
      </if>
      <if test="null != payPic">
         and t.pay_pic = #{payPic,jdbcType=VARCHAR}
      </if>
      <if test="null != createTime">
         and t.create_time = #{createTime,jdbcType=TIMESTAMP}
      </if>
      <if test="null != updateTime">
         and t.update_time = #{updateTime,jdbcType=TIMESTAMP}
      </if>
      <if test="null != createUserId">
         and t.create_user_id = #{createUserId,jdbcType=VARCHAR}
      </if>
      <if test="null != updateUserId">
         and t.update_user_id = #{updateUserId,jdbcType=VARCHAR}
      </if>
      <if test="null != deleted">
         and t.deleted = #{deleted,jdbcType=BIT}
      </if>
    </trim>
  </sql>

  <select id="getByRegionId" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from xfsg_region_qrcode_config
    where region_id = #{regionId} limit 1
  </select>

</mapper>