<?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.ContractResourceMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataplatform.entity.ContractResource">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="contract_id" jdbcType="BIGINT" property="contractId" />
    <result column="publish_info_id" jdbcType="BIGINT" property="publishInfoId" />
    <result column="resource_name" jdbcType="VARCHAR" property="resourceName" />
    <result column="price" jdbcType="DECIMAL" property="price" />
    <result column="charge_method" jdbcType="VARCHAR" property="chargeMethod" />
    <result column="use_months_limit" jdbcType="BIGINT" property="useMonthsLimit" />
    <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>
  <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, contract_id, publish_info_id, resource_name, price, charge_method, use_months_limit, 
    use_times_limit, effective_date, expiried_date, created_at, created_by, deleted_at, 
    deleted_by
  </sql>
  <select id="selectByExample" parameterType="com.lightinit.hsdataplatform.entity.ContractResourceExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from contract_resource
    <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="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from contract_resource
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from contract_resource
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataplatform.entity.ContractResourceExample">
    delete from contract_resource
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataplatform.entity.ContractResource">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into contract_resource (contract_id, publish_info_id, resource_name, 
      price, charge_method, use_months_limit, 
      use_times_limit, effective_date, expiried_date, 
      created_at, created_by, deleted_at, 
      deleted_by)
    values (#{contractId,jdbcType=BIGINT}, #{publishInfoId,jdbcType=BIGINT}, #{resourceName,jdbcType=VARCHAR}, 
      #{price,jdbcType=DECIMAL}, #{chargeMethod,jdbcType=VARCHAR}, #{useMonthsLimit,jdbcType=BIGINT}, 
      #{useTimesLimit,jdbcType=BIGINT}, #{effectiveDate,jdbcType=TIMESTAMP}, #{expiriedDate,jdbcType=TIMESTAMP}, 
      #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{deletedAt,jdbcType=TIMESTAMP}, 
      #{deletedBy,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataplatform.entity.ContractResource">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into contract_resource
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="contractId != null">
        contract_id,
      </if>
      <if test="publishInfoId != null">
        publish_info_id,
      </if>
      <if test="resourceName != null">
        resource_name,
      </if>
      <if test="price != null">
        price,
      </if>
      <if test="chargeMethod != null">
        charge_method,
      </if>
      <if test="useMonthsLimit != null">
        use_months_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>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="contractId != null">
        #{contractId,jdbcType=BIGINT},
      </if>
      <if test="publishInfoId != null">
        #{publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="resourceName != null">
        #{resourceName,jdbcType=VARCHAR},
      </if>
      <if test="price != null">
        #{price,jdbcType=DECIMAL},
      </if>
      <if test="chargeMethod != null">
        #{chargeMethod,jdbcType=VARCHAR},
      </if>
      <if test="useMonthsLimit != null">
        #{useMonthsLimit,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>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataplatform.entity.ContractResourceExample" resultType="java.lang.Long">
    select count(*) from contract_resource
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update contract_resource
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.contractId != null">
        contract_id = #{record.contractId,jdbcType=BIGINT},
      </if>
      <if test="record.publishInfoId != null">
        publish_info_id = #{record.publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="record.resourceName != null">
        resource_name = #{record.resourceName,jdbcType=VARCHAR},
      </if>
      <if test="record.price != null">
        price = #{record.price,jdbcType=DECIMAL},
      </if>
      <if test="record.chargeMethod != null">
        charge_method = #{record.chargeMethod,jdbcType=VARCHAR},
      </if>
      <if test="record.useMonthsLimit != null">
        use_months_limit = #{record.useMonthsLimit,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>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update contract_resource
    set id = #{record.id,jdbcType=BIGINT},
      contract_id = #{record.contractId,jdbcType=BIGINT},
      publish_info_id = #{record.publishInfoId,jdbcType=BIGINT},
      resource_name = #{record.resourceName,jdbcType=VARCHAR},
      price = #{record.price,jdbcType=DECIMAL},
      charge_method = #{record.chargeMethod,jdbcType=VARCHAR},
      use_months_limit = #{record.useMonthsLimit,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.ContractResource">
    update contract_resource
    <set>
      <if test="contractId != null">
        contract_id = #{contractId,jdbcType=BIGINT},
      </if>
      <if test="publishInfoId != null">
        publish_info_id = #{publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="resourceName != null">
        resource_name = #{resourceName,jdbcType=VARCHAR},
      </if>
      <if test="price != null">
        price = #{price,jdbcType=DECIMAL},
      </if>
      <if test="chargeMethod != null">
        charge_method = #{chargeMethod,jdbcType=VARCHAR},
      </if>
      <if test="useMonthsLimit != null">
        use_months_limit = #{useMonthsLimit,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>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataplatform.entity.ContractResource">
    update contract_resource
    set contract_id = #{contractId,jdbcType=BIGINT},
      publish_info_id = #{publishInfoId,jdbcType=BIGINT},
      resource_name = #{resourceName,jdbcType=VARCHAR},
      price = #{price,jdbcType=DECIMAL},
      charge_method = #{chargeMethod,jdbcType=VARCHAR},
      use_months_limit = #{useMonthsLimit,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>
</mapper>