<?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.neusoft.smart.pos.member.persistent.mapper.MemberLevelPolicyMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.member.persistent.domain.MemberLevelPolicy">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="level_number" jdbcType="INTEGER" property="levelNumber" />
    <result column="level_name" jdbcType="VARCHAR" property="levelName" />
    <result column="version" jdbcType="INTEGER" property="version" />
    <result column="org_id" jdbcType="INTEGER" property="orgId" />
    <result column="store_id" jdbcType="INTEGER" property="storeId" />
    <result column="duration_time" jdbcType="TIMESTAMP" property="durationTime" />
    <result column="level_condition" jdbcType="VARCHAR" property="levelCondition" />
    <result column="bonus_calculator" jdbcType="VARCHAR" property="bonusCalculator" />
    <result column="member_image" jdbcType="VARCHAR" property="memberImage" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
  </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, level_number, level_name, version, org_id, store_id, duration_time, level_condition, 
    bonus_calculator, member_image, is_active, created_time, created_by, updated_time, 
    updated_by
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberLevelPolicyExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from member_level_policy
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="offset != null and limit != null">
      limit ${offset}, ${limit}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from member_level_policy
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from member_level_policy
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberLevelPolicyExample">
    delete from member_level_policy
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberLevelPolicy" useGeneratedKeys="true">
    insert into member_level_policy (level_number, level_name, version, 
      org_id, store_id, duration_time, 
      level_condition, bonus_calculator, member_image, 
      is_active, created_time, created_by, 
      updated_time, updated_by)
    values (#{levelNumber,jdbcType=INTEGER}, #{levelName,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, 
      #{orgId,jdbcType=INTEGER}, #{storeId,jdbcType=INTEGER}, #{durationTime,jdbcType=TIMESTAMP}, 
      #{levelCondition,jdbcType=VARCHAR}, #{bonusCalculator,jdbcType=VARCHAR}, #{memberImage,jdbcType=VARCHAR}, 
      #{isActive,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}, 
      #{updatedTime,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberLevelPolicy" useGeneratedKeys="true">
    insert into member_level_policy
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="levelNumber != null">
        level_number,
      </if>
      <if test="levelName != null">
        level_name,
      </if>
      <if test="version != null">
        version,
      </if>
      <if test="orgId != null">
        org_id,
      </if>
      <if test="storeId != null">
        store_id,
      </if>
      <if test="durationTime != null">
        duration_time,
      </if>
      <if test="levelCondition != null">
        level_condition,
      </if>
      <if test="bonusCalculator != null">
        bonus_calculator,
      </if>
      <if test="memberImage != null">
        member_image,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="levelNumber != null">
        #{levelNumber,jdbcType=INTEGER},
      </if>
      <if test="levelName != null">
        #{levelName,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        #{version,jdbcType=INTEGER},
      </if>
      <if test="orgId != null">
        #{orgId,jdbcType=INTEGER},
      </if>
      <if test="storeId != null">
        #{storeId,jdbcType=INTEGER},
      </if>
      <if test="durationTime != null">
        #{durationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="levelCondition != null">
        #{levelCondition,jdbcType=VARCHAR},
      </if>
      <if test="bonusCalculator != null">
        #{bonusCalculator,jdbcType=VARCHAR},
      </if>
      <if test="memberImage != null">
        #{memberImage,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
        #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        #{updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberLevelPolicyExample" resultType="java.lang.Integer">
    select count(*) from member_level_policy
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update member_level_policy
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.levelNumber != null">
        level_number = #{record.levelNumber,jdbcType=INTEGER},
      </if>
      <if test="record.levelName != null">
        level_name = #{record.levelName,jdbcType=VARCHAR},
      </if>
      <if test="record.version != null">
        version = #{record.version,jdbcType=INTEGER},
      </if>
      <if test="record.orgId != null">
        org_id = #{record.orgId,jdbcType=INTEGER},
      </if>
      <if test="record.storeId != null">
        store_id = #{record.storeId,jdbcType=INTEGER},
      </if>
      <if test="record.durationTime != null">
        duration_time = #{record.durationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.levelCondition != null">
        level_condition = #{record.levelCondition,jdbcType=VARCHAR},
      </if>
      <if test="record.bonusCalculator != null">
        bonus_calculator = #{record.bonusCalculator,jdbcType=VARCHAR},
      </if>
      <if test="record.memberImage != null">
        member_image = #{record.memberImage,jdbcType=VARCHAR},
      </if>
      <if test="record.isActive != null">
        is_active = #{record.isActive,jdbcType=INTEGER},
      </if>
      <if test="record.createdTime != null">
        created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updatedTime != null">
        updated_time = #{record.updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updatedBy != null">
        updated_by = #{record.updatedBy,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update member_level_policy
    set id = #{record.id,jdbcType=INTEGER},
      level_number = #{record.levelNumber,jdbcType=INTEGER},
      level_name = #{record.levelName,jdbcType=VARCHAR},
      version = #{record.version,jdbcType=INTEGER},
      org_id = #{record.orgId,jdbcType=INTEGER},
      store_id = #{record.storeId,jdbcType=INTEGER},
      duration_time = #{record.durationTime,jdbcType=TIMESTAMP},
      level_condition = #{record.levelCondition,jdbcType=VARCHAR},
      bonus_calculator = #{record.bonusCalculator,jdbcType=VARCHAR},
      member_image = #{record.memberImage,jdbcType=VARCHAR},
      is_active = #{record.isActive,jdbcType=INTEGER},
      created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=VARCHAR},
      updated_time = #{record.updatedTime,jdbcType=TIMESTAMP},
      updated_by = #{record.updatedBy,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberLevelPolicy">
    update member_level_policy
    <set>
      <if test="levelNumber != null">
        level_number = #{levelNumber,jdbcType=INTEGER},
      </if>
      <if test="levelName != null">
        level_name = #{levelName,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        version = #{version,jdbcType=INTEGER},
      </if>
      <if test="orgId != null">
        org_id = #{orgId,jdbcType=INTEGER},
      </if>
      <if test="storeId != null">
        store_id = #{storeId,jdbcType=INTEGER},
      </if>
      <if test="durationTime != null">
        duration_time = #{durationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="levelCondition != null">
        level_condition = #{levelCondition,jdbcType=VARCHAR},
      </if>
      <if test="bonusCalculator != null">
        bonus_calculator = #{bonusCalculator,jdbcType=VARCHAR},
      </if>
      <if test="memberImage != null">
        member_image = #{memberImage,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        updated_time = #{updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberLevelPolicy">
    update member_level_policy
    set level_number = #{levelNumber,jdbcType=INTEGER},
      level_name = #{levelName,jdbcType=VARCHAR},
      version = #{version,jdbcType=INTEGER},
      org_id = #{orgId,jdbcType=INTEGER},
      store_id = #{storeId,jdbcType=INTEGER},
      duration_time = #{durationTime,jdbcType=TIMESTAMP},
      level_condition = #{levelCondition,jdbcType=VARCHAR},
      bonus_calculator = #{bonusCalculator,jdbcType=VARCHAR},
      member_image = #{memberImage,jdbcType=VARCHAR},
      is_active = #{isActive,jdbcType=INTEGER},
      created_time = #{createdTime,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=VARCHAR},
      updated_time = #{updatedTime,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into member_level_policy  (level_number, level_name, version, 
        org_id, store_id, duration_time, 
        level_condition, bonus_calculator, member_image, 
        is_active, created_time, created_by, 
        updated_time, updated_by)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.levelNumber,jdbcType=INTEGER}, #{item.levelName,jdbcType=VARCHAR}, #{item.version,jdbcType=INTEGER}, 
        #{item.orgId,jdbcType=INTEGER}, #{item.storeId,jdbcType=INTEGER}, #{item.durationTime,jdbcType=TIMESTAMP}, 
        #{item.levelCondition,jdbcType=VARCHAR}, #{item.bonusCalculator,jdbcType=VARCHAR}, #{item.memberImage,jdbcType=VARCHAR}, 
        #{item.isActive,jdbcType=INTEGER}, #{item.createdTime,jdbcType=TIMESTAMP}, #{item.createdBy,jdbcType=VARCHAR}, 
        #{item.updatedTime,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=VARCHAR})
      </foreach>
    </if>
  </insert>
</mapper>