<?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.yd.dal.mapper.meta.MdMkCampaignMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.meta.MdMkCampaign">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="content" jdbcType="VARCHAR" property="content" />
    <result column="reward" jdbcType="DECIMAL" property="reward" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="ui_display_count" jdbcType="INTEGER" property="uiDisplayCount" />
    <result column="effective_start_date" jdbcType="DATE" property="effectiveStartDate" />
    <result column="effective_end_date" jdbcType="DATE" property="effectiveEndDate" />
    <result column="dept_id" jdbcType="BIGINT" property="deptId" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
  </resultMap>
  <sql id="Base_Column_List">
    id, `name`, code, content, reward, is_active, ui_display_count, effective_start_date, 
    effective_end_date, dept_id, created_at, created_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_md_mk_campaign
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_md_mk_campaign
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdMkCampaign" useGeneratedKeys="true">
    insert into ag_md_mk_campaign (`name`, code, content, 
      reward, is_active, ui_display_count, 
      effective_start_date, effective_end_date, dept_id, 
      created_at, created_by)
    values (#{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, 
      #{reward,jdbcType=DECIMAL}, #{isActive,jdbcType=INTEGER}, #{uiDisplayCount,jdbcType=INTEGER}, 
      #{effectiveStartDate,jdbcType=DATE}, #{effectiveEndDate,jdbcType=DATE}, #{deptId,jdbcType=BIGINT}, 
      #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdMkCampaign" useGeneratedKeys="true">
    insert into ag_md_mk_campaign
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="name != null">
        `name`,
      </if>
      <if test="code != null">
        code,
      </if>
      <if test="content != null">
        content,
      </if>
      <if test="reward != null">
        reward,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="uiDisplayCount != null">
        ui_display_count,
      </if>
      <if test="effectiveStartDate != null">
        effective_start_date,
      </if>
      <if test="effectiveEndDate != null">
        effective_end_date,
      </if>
      <if test="deptId != null">
        dept_id,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="content != null">
        #{content,jdbcType=VARCHAR},
      </if>
      <if test="reward != null">
        #{reward,jdbcType=DECIMAL},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="uiDisplayCount != null">
        #{uiDisplayCount,jdbcType=INTEGER},
      </if>
      <if test="effectiveStartDate != null">
        #{effectiveStartDate,jdbcType=DATE},
      </if>
      <if test="effectiveEndDate != null">
        #{effectiveEndDate,jdbcType=DATE},
      </if>
      <if test="deptId != null">
        #{deptId,jdbcType=BIGINT},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.meta.MdMkCampaign">
    update ag_md_mk_campaign
    <set>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="content != null">
        content = #{content,jdbcType=VARCHAR},
      </if>
      <if test="reward != null">
        reward = #{reward,jdbcType=DECIMAL},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="uiDisplayCount != null">
        ui_display_count = #{uiDisplayCount,jdbcType=INTEGER},
      </if>
      <if test="effectiveStartDate != null">
        effective_start_date = #{effectiveStartDate,jdbcType=DATE},
      </if>
      <if test="effectiveEndDate != null">
        effective_end_date = #{effectiveEndDate,jdbcType=DATE},
      </if>
      <if test="deptId != null">
        dept_id = #{deptId,jdbcType=BIGINT},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.meta.MdMkCampaign">
    update ag_md_mk_campaign
    set `name` = #{name,jdbcType=VARCHAR},
      code = #{code,jdbcType=VARCHAR},
      content = #{content,jdbcType=VARCHAR},
      reward = #{reward,jdbcType=DECIMAL},
      is_active = #{isActive,jdbcType=INTEGER},
      ui_display_count = #{uiDisplayCount,jdbcType=INTEGER},
      effective_start_date = #{effectiveStartDate,jdbcType=DATE},
      effective_end_date = #{effectiveEndDate,jdbcType=DATE},
      dept_id = #{deptId,jdbcType=BIGINT},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <select id="selectByCampaignCode" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_md_mk_campaign
    where code = #{campaignCode,jdbcType=VARCHAR}
  </select>
</mapper>