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