<?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.ota.persistent.mapper.ApkStrategyGroupMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.ota.persistent.domain.ApkStrategyGroup">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="is_force" jdbcType="INTEGER" property="isForce" />
    <result column="upgrade_time" jdbcType="TIMESTAMP" property="upgradeTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="organization_id" jdbcType="INTEGER" property="organizationId" />
  </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, name, is_force, upgrade_time, create_by, create_time, organization_id
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.ota.persistent.domain.ApkStrategyGroupExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from apk_strategy_group
    <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 apk_strategy_group
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from apk_strategy_group
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.ota.persistent.domain.ApkStrategyGroupExample">
    delete from apk_strategy_group
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.ota.persistent.domain.ApkStrategyGroup" useGeneratedKeys="true">
    insert into apk_strategy_group (name, is_force, upgrade_time, 
      create_by, create_time, organization_id
      )
    values (#{name,jdbcType=VARCHAR}, #{isForce,jdbcType=INTEGER}, #{upgradeTime,jdbcType=TIMESTAMP}, 
      #{createBy,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{organizationId,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.ota.persistent.domain.ApkStrategyGroup" useGeneratedKeys="true">
    insert into apk_strategy_group
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="name != null">
        name,
      </if>
      <if test="isForce != null">
        is_force,
      </if>
      <if test="upgradeTime != null">
        upgrade_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="organizationId != null">
        organization_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="isForce != null">
        #{isForce,jdbcType=INTEGER},
      </if>
      <if test="upgradeTime != null">
        #{upgradeTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="organizationId != null">
        #{organizationId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.ota.persistent.domain.ApkStrategyGroupExample" resultType="java.lang.Integer">
    select count(*) from apk_strategy_group
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update apk_strategy_group
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.name != null">
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.isForce != null">
        is_force = #{record.isForce,jdbcType=INTEGER},
      </if>
      <if test="record.upgradeTime != null">
        upgrade_time = #{record.upgradeTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createBy != null">
        create_by = #{record.createBy,jdbcType=INTEGER},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.organizationId != null">
        organization_id = #{record.organizationId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update apk_strategy_group
    set id = #{record.id,jdbcType=INTEGER},
      name = #{record.name,jdbcType=VARCHAR},
      is_force = #{record.isForce,jdbcType=INTEGER},
      upgrade_time = #{record.upgradeTime,jdbcType=TIMESTAMP},
      create_by = #{record.createBy,jdbcType=INTEGER},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      organization_id = #{record.organizationId,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.ota.persistent.domain.ApkStrategyGroup">
    update apk_strategy_group
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="isForce != null">
        is_force = #{isForce,jdbcType=INTEGER},
      </if>
      <if test="upgradeTime != null">
        upgrade_time = #{upgradeTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="organizationId != null">
        organization_id = #{organizationId,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.ota.persistent.domain.ApkStrategyGroup">
    update apk_strategy_group
    set name = #{name,jdbcType=VARCHAR},
      is_force = #{isForce,jdbcType=INTEGER},
      upgrade_time = #{upgradeTime,jdbcType=TIMESTAMP},
      create_by = #{createBy,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      organization_id = #{organizationId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into apk_strategy_group  (name, is_force, upgrade_time, 
        create_by, create_time, organization_id
        )
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.name,jdbcType=VARCHAR}, #{item.isForce,jdbcType=INTEGER}, #{item.upgradeTime,jdbcType=TIMESTAMP}, 
        #{item.createBy,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.organizationId,jdbcType=INTEGER}
        )
      </foreach>
    </if>
  </insert>
</mapper>