<?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.lightinit.hsdataplatform.mapper.PublishSettingMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataplatform.entity.PublishSetting">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="publish_info_id" jdbcType="BIGINT" property="publishInfoId" />
    <result column="charge_method" jdbcType="VARCHAR" property="chargeMethod" />
    <result column="package_name" jdbcType="VARCHAR" property="packageName" />
    <result column="package_price" jdbcType="DECIMAL" property="packagePrice" />
    <result column="package_months" jdbcType="BIGINT" property="packageMonths" />
    <result column="self_cost" jdbcType="DECIMAL" property="selfCost" />
    <result column="buy_times_limit" jdbcType="BIGINT" property="buyTimesLimit" />
    <result column="use_times_limit" jdbcType="BIGINT" property="useTimesLimit" />
    <result column="effective_date" jdbcType="TIMESTAMP" property="effectiveDate" />
    <result column="expiried_date" jdbcType="TIMESTAMP" property="expiriedDate" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="deleted_at" jdbcType="TIMESTAMP" property="deletedAt" />
    <result column="deleted_by" jdbcType="BIGINT" property="deletedBy" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.lightinit.hsdataplatform.entity.PublishSetting">
    <result column="description" jdbcType="LONGVARCHAR" property="description" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, publish_info_id, charge_method, package_name, package_price, package_months, 
    self_cost, buy_times_limit, use_times_limit, effective_date, expiried_date, created_at, 
    created_by, deleted_at, deleted_by
  </sql>
  <sql id="Blob_Column_List">
    description
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.lightinit.hsdataplatform.entity.PublishSettingExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from publish_setting
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="com.lightinit.hsdataplatform.entity.PublishSettingExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from publish_setting
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from publish_setting
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from publish_setting
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataplatform.entity.PublishSettingExample">
    delete from publish_setting
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataplatform.entity.PublishSetting">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into publish_setting (publish_info_id, charge_method, package_name, 
      package_price, package_months, self_cost, 
      buy_times_limit, use_times_limit, effective_date, 
      expiried_date, created_at, created_by, 
      deleted_at, deleted_by, description
      )
    values (#{publishInfoId,jdbcType=BIGINT}, #{chargeMethod,jdbcType=VARCHAR}, #{packageName,jdbcType=VARCHAR}, 
      #{packagePrice,jdbcType=DECIMAL}, #{packageMonths,jdbcType=BIGINT}, #{selfCost,jdbcType=DECIMAL}, 
      #{buyTimesLimit,jdbcType=BIGINT}, #{useTimesLimit,jdbcType=BIGINT}, #{effectiveDate,jdbcType=TIMESTAMP}, 
      #{expiriedDate,jdbcType=TIMESTAMP}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, 
      #{deletedAt,jdbcType=TIMESTAMP}, #{deletedBy,jdbcType=BIGINT}, #{description,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataplatform.entity.PublishSetting">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into publish_setting
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="publishInfoId != null">
        publish_info_id,
      </if>
      <if test="chargeMethod != null">
        charge_method,
      </if>
      <if test="packageName != null">
        package_name,
      </if>
      <if test="packagePrice != null">
        package_price,
      </if>
      <if test="packageMonths != null">
        package_months,
      </if>
      <if test="selfCost != null">
        self_cost,
      </if>
      <if test="buyTimesLimit != null">
        buy_times_limit,
      </if>
      <if test="useTimesLimit != null">
        use_times_limit,
      </if>
      <if test="effectiveDate != null">
        effective_date,
      </if>
      <if test="expiriedDate != null">
        expiried_date,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="deletedAt != null">
        deleted_at,
      </if>
      <if test="deletedBy != null">
        deleted_by,
      </if>
      <if test="description != null">
        description,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="publishInfoId != null">
        #{publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="chargeMethod != null">
        #{chargeMethod,jdbcType=VARCHAR},
      </if>
      <if test="packageName != null">
        #{packageName,jdbcType=VARCHAR},
      </if>
      <if test="packagePrice != null">
        #{packagePrice,jdbcType=DECIMAL},
      </if>
      <if test="packageMonths != null">
        #{packageMonths,jdbcType=BIGINT},
      </if>
      <if test="selfCost != null">
        #{selfCost,jdbcType=DECIMAL},
      </if>
      <if test="buyTimesLimit != null">
        #{buyTimesLimit,jdbcType=BIGINT},
      </if>
      <if test="useTimesLimit != null">
        #{useTimesLimit,jdbcType=BIGINT},
      </if>
      <if test="effectiveDate != null">
        #{effectiveDate,jdbcType=TIMESTAMP},
      </if>
      <if test="expiriedDate != null">
        #{expiriedDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        #{deletedBy,jdbcType=BIGINT},
      </if>
      <if test="description != null">
        #{description,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataplatform.entity.PublishSettingExample" resultType="java.lang.Long">
    select count(*) from publish_setting
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update publish_setting
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.publishInfoId != null">
        publish_info_id = #{record.publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="record.chargeMethod != null">
        charge_method = #{record.chargeMethod,jdbcType=VARCHAR},
      </if>
      <if test="record.packageName != null">
        package_name = #{record.packageName,jdbcType=VARCHAR},
      </if>
      <if test="record.packagePrice != null">
        package_price = #{record.packagePrice,jdbcType=DECIMAL},
      </if>
      <if test="record.packageMonths != null">
        package_months = #{record.packageMonths,jdbcType=BIGINT},
      </if>
      <if test="record.selfCost != null">
        self_cost = #{record.selfCost,jdbcType=DECIMAL},
      </if>
      <if test="record.buyTimesLimit != null">
        buy_times_limit = #{record.buyTimesLimit,jdbcType=BIGINT},
      </if>
      <if test="record.useTimesLimit != null">
        use_times_limit = #{record.useTimesLimit,jdbcType=BIGINT},
      </if>
      <if test="record.effectiveDate != null">
        effective_date = #{record.effectiveDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.expiriedDate != null">
        expiried_date = #{record.expiriedDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdAt != null">
        created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=BIGINT},
      </if>
      <if test="record.deletedAt != null">
        deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deletedBy != null">
        deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      </if>
      <if test="record.description != null">
        description = #{record.description,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update publish_setting
    set id = #{record.id,jdbcType=BIGINT},
      publish_info_id = #{record.publishInfoId,jdbcType=BIGINT},
      charge_method = #{record.chargeMethod,jdbcType=VARCHAR},
      package_name = #{record.packageName,jdbcType=VARCHAR},
      package_price = #{record.packagePrice,jdbcType=DECIMAL},
      package_months = #{record.packageMonths,jdbcType=BIGINT},
      self_cost = #{record.selfCost,jdbcType=DECIMAL},
      buy_times_limit = #{record.buyTimesLimit,jdbcType=BIGINT},
      use_times_limit = #{record.useTimesLimit,jdbcType=BIGINT},
      effective_date = #{record.effectiveDate,jdbcType=TIMESTAMP},
      expiried_date = #{record.expiriedDate,jdbcType=TIMESTAMP},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      description = #{record.description,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update publish_setting
    set id = #{record.id,jdbcType=BIGINT},
      publish_info_id = #{record.publishInfoId,jdbcType=BIGINT},
      charge_method = #{record.chargeMethod,jdbcType=VARCHAR},
      package_name = #{record.packageName,jdbcType=VARCHAR},
      package_price = #{record.packagePrice,jdbcType=DECIMAL},
      package_months = #{record.packageMonths,jdbcType=BIGINT},
      self_cost = #{record.selfCost,jdbcType=DECIMAL},
      buy_times_limit = #{record.buyTimesLimit,jdbcType=BIGINT},
      use_times_limit = #{record.useTimesLimit,jdbcType=BIGINT},
      effective_date = #{record.effectiveDate,jdbcType=TIMESTAMP},
      expiried_date = #{record.expiriedDate,jdbcType=TIMESTAMP},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.lightinit.hsdataplatform.entity.PublishSetting">
    update publish_setting
    <set>
      <if test="publishInfoId != null">
        publish_info_id = #{publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="chargeMethod != null">
        charge_method = #{chargeMethod,jdbcType=VARCHAR},
      </if>
      <if test="packageName != null">
        package_name = #{packageName,jdbcType=VARCHAR},
      </if>
      <if test="packagePrice != null">
        package_price = #{packagePrice,jdbcType=DECIMAL},
      </if>
      <if test="packageMonths != null">
        package_months = #{packageMonths,jdbcType=BIGINT},
      </if>
      <if test="selfCost != null">
        self_cost = #{selfCost,jdbcType=DECIMAL},
      </if>
      <if test="buyTimesLimit != null">
        buy_times_limit = #{buyTimesLimit,jdbcType=BIGINT},
      </if>
      <if test="useTimesLimit != null">
        use_times_limit = #{useTimesLimit,jdbcType=BIGINT},
      </if>
      <if test="effectiveDate != null">
        effective_date = #{effectiveDate,jdbcType=TIMESTAMP},
      </if>
      <if test="expiriedDate != null">
        expiried_date = #{expiriedDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        deleted_by = #{deletedBy,jdbcType=BIGINT},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.lightinit.hsdataplatform.entity.PublishSetting">
    update publish_setting
    set publish_info_id = #{publishInfoId,jdbcType=BIGINT},
      charge_method = #{chargeMethod,jdbcType=VARCHAR},
      package_name = #{packageName,jdbcType=VARCHAR},
      package_price = #{packagePrice,jdbcType=DECIMAL},
      package_months = #{packageMonths,jdbcType=BIGINT},
      self_cost = #{selfCost,jdbcType=DECIMAL},
      buy_times_limit = #{buyTimesLimit,jdbcType=BIGINT},
      use_times_limit = #{useTimesLimit,jdbcType=BIGINT},
      effective_date = #{effectiveDate,jdbcType=TIMESTAMP},
      expiried_date = #{expiriedDate,jdbcType=TIMESTAMP},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT},
      description = #{description,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataplatform.entity.PublishSetting">
    update publish_setting
    set publish_info_id = #{publishInfoId,jdbcType=BIGINT},
      charge_method = #{chargeMethod,jdbcType=VARCHAR},
      package_name = #{packageName,jdbcType=VARCHAR},
      package_price = #{packagePrice,jdbcType=DECIMAL},
      package_months = #{packageMonths,jdbcType=BIGINT},
      self_cost = #{selfCost,jdbcType=DECIMAL},
      buy_times_limit = #{buyTimesLimit,jdbcType=BIGINT},
      use_times_limit = #{useTimesLimit,jdbcType=BIGINT},
      effective_date = #{effectiveDate,jdbcType=TIMESTAMP},
      expiried_date = #{expiriedDate,jdbcType=TIMESTAMP},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <delete id="deleteByPublishInfoId" parameterType="java.lang.Long">
     delete from publish_setting
    where publish_info_id = #{id,jdbcType=BIGINT}
  </delete>
  <select id="selectBypublishId" parameterType="java.lang.Long" resultType="com.lightinit.hsdataplatform.model.admin.APIPublishSettingModel">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from publish_setting
    where publish_info_id = #{id,jdbcType=BIGINT} and deleted_at is null
  </select>

  <select id="selectPublishSettingByPublishInfoId" parameterType="java.lang.Long" resultType="java.lang.Long">
    SELECT id FROM publish_setting p WHERE p.publish_info_id=#{id}
  </select>
</mapper>