<?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.exchangeStrategy.persistent.mapper.ExchangeStrategyMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.exchangeStrategy.persistent.domain.ExchangeStrategy">
    <id column="strategy_id" jdbcType="INTEGER" property="strategyId" />
    <result column="strategy_type_id" jdbcType="INTEGER" property="strategyTypeId" />
    <result column="card_id" jdbcType="INTEGER" property="cardId" />
    <result column="params" jdbcType="VARCHAR" property="params" />
    <result column="strategy_category" jdbcType="CHAR" property="strategyCategory" />
  </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">
    strategy_id, strategy_type_id, card_id, params, strategy_category
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.exchangeStrategy.persistent.domain.ExchangeStrategyExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from exchange_strategy
    <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 exchange_strategy
    where strategy_id = #{strategyId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from exchange_strategy
    where strategy_id = #{strategyId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.exchangeStrategy.persistent.domain.ExchangeStrategyExample">
    delete from exchange_strategy
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="strategy_id" keyProperty="strategyId" parameterType="com.neusoft.smart.pos.exchangeStrategy.persistent.domain.ExchangeStrategy" useGeneratedKeys="true">
    insert into exchange_strategy (strategy_type_id, card_id, params, 
      strategy_category)
    values (#{strategyTypeId,jdbcType=INTEGER}, #{cardId,jdbcType=INTEGER}, #{params,jdbcType=VARCHAR}, 
      #{strategyCategory,jdbcType=CHAR})
  </insert>
  <insert id="insertSelective" keyColumn="strategy_id" keyProperty="strategyId" parameterType="com.neusoft.smart.pos.exchangeStrategy.persistent.domain.ExchangeStrategy" useGeneratedKeys="true">
    insert into exchange_strategy
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="strategyTypeId != null">
        strategy_type_id,
      </if>
      <if test="cardId != null">
        card_id,
      </if>
      <if test="params != null">
        params,
      </if>
      <if test="strategyCategory != null">
        strategy_category,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="strategyTypeId != null">
        #{strategyTypeId,jdbcType=INTEGER},
      </if>
      <if test="cardId != null">
        #{cardId,jdbcType=INTEGER},
      </if>
      <if test="params != null">
        #{params,jdbcType=VARCHAR},
      </if>
      <if test="strategyCategory != null">
        #{strategyCategory,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.exchangeStrategy.persistent.domain.ExchangeStrategyExample" resultType="java.lang.Integer">
    select count(*) from exchange_strategy
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update exchange_strategy
    <set>
      <if test="record.strategyId != null">
        strategy_id = #{record.strategyId,jdbcType=INTEGER},
      </if>
      <if test="record.strategyTypeId != null">
        strategy_type_id = #{record.strategyTypeId,jdbcType=INTEGER},
      </if>
      <if test="record.cardId != null">
        card_id = #{record.cardId,jdbcType=INTEGER},
      </if>
      <if test="record.params != null">
        params = #{record.params,jdbcType=VARCHAR},
      </if>
      <if test="record.strategyCategory != null">
        strategy_category = #{record.strategyCategory,jdbcType=CHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update exchange_strategy
    set strategy_id = #{record.strategyId,jdbcType=INTEGER},
      strategy_type_id = #{record.strategyTypeId,jdbcType=INTEGER},
      card_id = #{record.cardId,jdbcType=INTEGER},
      params = #{record.params,jdbcType=VARCHAR},
      strategy_category = #{record.strategyCategory,jdbcType=CHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.exchangeStrategy.persistent.domain.ExchangeStrategy">
    update exchange_strategy
    <set>
      <if test="strategyTypeId != null">
        strategy_type_id = #{strategyTypeId,jdbcType=INTEGER},
      </if>
      <if test="cardId != null">
        card_id = #{cardId,jdbcType=INTEGER},
      </if>
      <if test="params != null">
        params = #{params,jdbcType=VARCHAR},
      </if>
      <if test="strategyCategory != null">
        strategy_category = #{strategyCategory,jdbcType=CHAR},
      </if>
    </set>
    where strategy_id = #{strategyId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.exchangeStrategy.persistent.domain.ExchangeStrategy">
    update exchange_strategy
    set strategy_type_id = #{strategyTypeId,jdbcType=INTEGER},
      card_id = #{cardId,jdbcType=INTEGER},
      params = #{params,jdbcType=VARCHAR},
      strategy_category = #{strategyCategory,jdbcType=CHAR}
    where strategy_id = #{strategyId,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into exchange_strategy  (strategy_type_id, card_id, params, 
        strategy_category)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.strategyTypeId,jdbcType=INTEGER}, #{item.cardId,jdbcType=INTEGER}, #{item.params,jdbcType=VARCHAR}, 
        #{item.strategyCategory,jdbcType=CHAR})
      </foreach>
    </if>
  </insert>
</mapper>