<?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.slodon.b2b2c.dao.write.promotion.SignActivityWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.promotion.pojo.SignActivity">
    <id column="sign_activity_id" property="signActivityId" />
    <result column="start_time" property="startTime" />
    <result column="end_time" property="endTime" />
    <result column="integral_per_sign" property="integralPerSign" />
    <result column="is_remind" property="isRemind" />
    <result column="continue_num" property="continueNum" />
    <result column="bonus_rules" property="bonusRules" />
    <result column="bonus_integral" property="bonusIntegral" />
    <result column="bonus_voucher" property="bonusVoucher" />
    <result column="state" property="state" />
    <result column="template_json" property="templateJson" />
    <result column="create_admin_id" property="createAdminId" />
    <result column="create_admin_name" property="createAdminName" />
    <result column="create_time" property="createTime" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="startTime != null">
        `start_time`,
      </if>
      <if test="endTime != null">
        `end_time`,
      </if>
      <if test="integralPerSign != null">
        `integral_per_sign`,
      </if>
      <if test="isRemind != null">
        `is_remind`,
      </if>
      <if test="continueNum != null">
        `continue_num`,
      </if>
      <if test="bonusRules != null">
        `bonus_rules`,
      </if>
      <if test="bonusIntegral != null">
        `bonus_integral`,
      </if>
      <if test="bonusVoucher != null">
        `bonus_voucher`,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="templateJson != null">
        `template_json`,
      </if>
      <if test="createAdminId != null">
        `create_admin_id`,
      </if>
      <if test="createAdminName != null">
        `create_admin_name`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `sign_activity_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.signActivityIdNotEquals != null">
          AND `sign_activity_id` != #{example.signActivityIdNotEquals}
        </if>
        <if test="example.signActivityIdIn != null">
          AND `sign_activity_id` in (${example.signActivityIdIn})
        </if>
        <if test="example.startTimeAfter != null">
          AND `start_time` <![CDATA[ >= ]]> #{example.startTimeAfter}
        </if>
        <if test="example.startTimeBefore != null">
          AND `start_time` <![CDATA[ <= ]]> #{example.startTimeBefore}
        </if>
        <if test="example.endTimeAfter != null">
          AND `end_time` <![CDATA[ >= ]]> #{example.endTimeAfter}
        </if>
        <if test="example.endTimeBefore != null">
          AND `end_time` <![CDATA[ <= ]]> #{example.endTimeBefore}
        </if>
        <if test="example.integralPerSign != null">
          AND `integral_per_sign` = #{example.integralPerSign}
        </if>
        <if test="example.isRemind != null">
          AND `is_remind` = #{example.isRemind}
        </if>
        <if test="example.continueNum != null">
          AND `continue_num` = #{example.continueNum}
        </if>
        <if test="example.bonusRules != null">
          AND `bonus_rules` = #{example.bonusRules}
        </if>
        <if test="example.bonusIntegral != null">
          AND `bonus_integral` = #{example.bonusIntegral}
        </if>
        <if test="example.bonusVoucher != null">
          AND `bonus_voucher` = #{example.bonusVoucher}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.templateJson != null">
          AND `template_json` = #{example.templateJson}
        </if>
        <if test="example.createAdminId != null">
          AND `create_admin_id` = #{example.createAdminId}
        </if>
        <if test="example.createAdminName != null">
          AND `create_admin_name` = #{example.createAdminName}
        </if>
        <if test="example.createAdminNameLike != null">
          AND `create_admin_name` like concat('%',#{example.createAdminNameLike},'%')
        </if>
        <if test="example.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `sign_activity_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.promotion.example.SignActivityExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `promotion_sign_activity`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_sign_activity`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_sign_activity`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_sign_activity`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `promotion_sign_activity`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `promotion_sign_activity`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `promotion_sign_activity`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `promotion_sign_activity`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="sign_activity_id" keyProperty="signActivityId" parameterType="com.slodon.b2b2c.promotion.pojo.SignActivity" useGeneratedKeys="true">
    INSERT INTO `promotion_sign_activity`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="startTime != null">
        #{startTime},
      </if>
      <if test="endTime != null">
        #{endTime},
      </if>
      <if test="integralPerSign != null">
        #{integralPerSign},
      </if>
      <if test="isRemind != null">
        #{isRemind},
      </if>
      <if test="continueNum != null">
        #{continueNum},
      </if>
      <if test="bonusRules != null">
        #{bonusRules},
      </if>
      <if test="bonusIntegral != null">
        #{bonusIntegral},
      </if>
      <if test="bonusVoucher != null">
        #{bonusVoucher},
      </if>
      <if test="state != null">
        #{state},
      </if>
      <if test="templateJson != null">
        #{templateJson},
      </if>
      <if test="createAdminId != null">
        #{createAdminId},
      </if>
      <if test="createAdminName != null">
        #{createAdminName},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `promotion_sign_activity`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.startTime != null">
        `start_time` = #{record.startTime},
      </if>
      <if test="record.endTime != null">
        `end_time` = #{record.endTime},
      </if>
      <if test="record.integralPerSign != null">
        `integral_per_sign` = #{record.integralPerSign},
      </if>
      <if test="record.isRemind != null">
        `is_remind` = #{record.isRemind},
      </if>
      <if test="record.continueNum != null">
        `continue_num` = #{record.continueNum},
      </if>
      <if test="record.bonusRules != null">
        `bonus_rules` = #{record.bonusRules},
      </if>
      <if test="record.bonusIntegral != null">
        `bonus_integral` = #{record.bonusIntegral},
      </if>
      <if test="record.bonusVoucher != null">
        `bonus_voucher` = #{record.bonusVoucher},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
      <if test="record.templateJson != null">
        `template_json` = #{record.templateJson},
      </if>
      <if test="record.createAdminId != null">
        `create_admin_id` = #{record.createAdminId},
      </if>
      <if test="record.createAdminName != null">
        `create_admin_name` = #{record.createAdminName},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `promotion_sign_activity`
    <trim prefix="SET" suffixOverrides=",">
      <if test="startTime != null">
        `start_time` = #{startTime},
      </if>
      <if test="endTime != null">
        `end_time` = #{endTime},
      </if>
      <if test="integralPerSign != null">
        `integral_per_sign` = #{integralPerSign},
      </if>
      <if test="isRemind != null">
        `is_remind` = #{isRemind},
      </if>
      <if test="continueNum != null">
        `continue_num` = #{continueNum},
      </if>
      <if test="bonusRules != null">
        `bonus_rules` = #{bonusRules},
      </if>
      <if test="bonusIntegral != null">
        `bonus_integral` = #{bonusIntegral},
      </if>
      <if test="bonusVoucher != null">
        `bonus_voucher` = #{bonusVoucher},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
      <if test="templateJson != null">
        `template_json` = #{templateJson},
      </if>
      <if test="createAdminId != null">
        `create_admin_id` = #{createAdminId},
      </if>
      <if test="createAdminName != null">
        `create_admin_name` = #{createAdminName},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
    </trim>
    WHERE `sign_activity_id` = #{signActivityId}
  </update>
</mapper>