<?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.device.persistent.mapper.DeviceMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.device.persistent.domain.Device">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="mac_addr" jdbcType="VARCHAR" property="macAddr" />
    <result column="serial_no" jdbcType="VARCHAR" property="serialNo" />
    <result column="cur_version" jdbcType="VARCHAR" property="curVersion" />
    <result column="manufacturer" jdbcType="VARCHAR" property="manufacturer" />
    <result column="region" jdbcType="VARCHAR" property="region" />
    <result column="department" jdbcType="VARCHAR" property="department" />
    <result column="customer" jdbcType="VARCHAR" property="customer" />
    <result column="device_type" jdbcType="VARCHAR" property="deviceType" />
    <result column="device_model" jdbcType="VARCHAR" property="deviceModel" />
    <result column="alias" jdbcType="VARCHAR" property="alias" />
    <result column="created_by" jdbcType="INTEGER" property="createdBy" />
    <result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
    <result column="last_modified_by" jdbcType="INTEGER" property="lastModifiedBy" />
    <result column="last_modified_date" jdbcType="TIMESTAMP" property="lastModifiedDate" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="signal_strength" jdbcType="VARCHAR" property="signalStrength" />
    <result column="ip_address" jdbcType="VARCHAR" property="ipAddress" />
    <result column="last_request_time" jdbcType="TIMESTAMP" property="lastRequestTime" />
    <result column="organization_id" jdbcType="INTEGER" property="organizationId" />
    <result column="store_id" jdbcType="INTEGER" property="storeId" />
  </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, mac_addr, serial_no, cur_version, manufacturer, region, department, customer, 
    device_type, device_model, alias, created_by, created_date, last_modified_by, last_modified_date, 
    status, signal_strength, ip_address, last_request_time, organization_id, store_id
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.device.persistent.domain.DeviceExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from device
    <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 device
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from device
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.device.persistent.domain.DeviceExample">
    delete from device
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.device.persistent.domain.Device" useGeneratedKeys="true">
    insert into device (mac_addr, serial_no, cur_version, 
      manufacturer, region, department, 
      customer, device_type, device_model, 
      alias, created_by, created_date, 
      last_modified_by, last_modified_date, status, 
      signal_strength, ip_address, last_request_time, 
      organization_id, store_id)
    values (#{macAddr,jdbcType=VARCHAR}, #{serialNo,jdbcType=VARCHAR}, #{curVersion,jdbcType=VARCHAR}, 
      #{manufacturer,jdbcType=VARCHAR}, #{region,jdbcType=VARCHAR}, #{department,jdbcType=VARCHAR}, 
      #{customer,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR}, #{deviceModel,jdbcType=VARCHAR}, 
      #{alias,jdbcType=VARCHAR}, #{createdBy,jdbcType=INTEGER}, #{createdDate,jdbcType=TIMESTAMP}, 
      #{lastModifiedBy,jdbcType=INTEGER}, #{lastModifiedDate,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, 
      #{signalStrength,jdbcType=VARCHAR}, #{ipAddress,jdbcType=VARCHAR}, #{lastRequestTime,jdbcType=TIMESTAMP}, 
      #{organizationId,jdbcType=INTEGER}, #{storeId,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.device.persistent.domain.Device" useGeneratedKeys="true">
    insert into device
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="macAddr != null">
        mac_addr,
      </if>
      <if test="serialNo != null">
        serial_no,
      </if>
      <if test="curVersion != null">
        cur_version,
      </if>
      <if test="manufacturer != null">
        manufacturer,
      </if>
      <if test="region != null">
        region,
      </if>
      <if test="department != null">
        department,
      </if>
      <if test="customer != null">
        customer,
      </if>
      <if test="deviceType != null">
        device_type,
      </if>
      <if test="deviceModel != null">
        device_model,
      </if>
      <if test="alias != null">
        alias,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="createdDate != null">
        created_date,
      </if>
      <if test="lastModifiedBy != null">
        last_modified_by,
      </if>
      <if test="lastModifiedDate != null">
        last_modified_date,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="signalStrength != null">
        signal_strength,
      </if>
      <if test="ipAddress != null">
        ip_address,
      </if>
      <if test="lastRequestTime != null">
        last_request_time,
      </if>
      <if test="organizationId != null">
        organization_id,
      </if>
      <if test="storeId != null">
        store_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="macAddr != null">
        #{macAddr,jdbcType=VARCHAR},
      </if>
      <if test="serialNo != null">
        #{serialNo,jdbcType=VARCHAR},
      </if>
      <if test="curVersion != null">
        #{curVersion,jdbcType=VARCHAR},
      </if>
      <if test="manufacturer != null">
        #{manufacturer,jdbcType=VARCHAR},
      </if>
      <if test="region != null">
        #{region,jdbcType=VARCHAR},
      </if>
      <if test="department != null">
        #{department,jdbcType=VARCHAR},
      </if>
      <if test="customer != null">
        #{customer,jdbcType=VARCHAR},
      </if>
      <if test="deviceType != null">
        #{deviceType,jdbcType=VARCHAR},
      </if>
      <if test="deviceModel != null">
        #{deviceModel,jdbcType=VARCHAR},
      </if>
      <if test="alias != null">
        #{alias,jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=INTEGER},
      </if>
      <if test="createdDate != null">
        #{createdDate,jdbcType=TIMESTAMP},
      </if>
      <if test="lastModifiedBy != null">
        #{lastModifiedBy,jdbcType=INTEGER},
      </if>
      <if test="lastModifiedDate != null">
        #{lastModifiedDate,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="signalStrength != null">
        #{signalStrength,jdbcType=VARCHAR},
      </if>
      <if test="ipAddress != null">
        #{ipAddress,jdbcType=VARCHAR},
      </if>
      <if test="lastRequestTime != null">
        #{lastRequestTime,jdbcType=TIMESTAMP},
      </if>
      <if test="organizationId != null">
        #{organizationId,jdbcType=INTEGER},
      </if>
      <if test="storeId != null">
        #{storeId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.device.persistent.domain.DeviceExample" resultType="java.lang.Integer">
    select count(*) from device
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update device
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.macAddr != null">
        mac_addr = #{record.macAddr,jdbcType=VARCHAR},
      </if>
      <if test="record.serialNo != null">
        serial_no = #{record.serialNo,jdbcType=VARCHAR},
      </if>
      <if test="record.curVersion != null">
        cur_version = #{record.curVersion,jdbcType=VARCHAR},
      </if>
      <if test="record.manufacturer != null">
        manufacturer = #{record.manufacturer,jdbcType=VARCHAR},
      </if>
      <if test="record.region != null">
        region = #{record.region,jdbcType=VARCHAR},
      </if>
      <if test="record.department != null">
        department = #{record.department,jdbcType=VARCHAR},
      </if>
      <if test="record.customer != null">
        customer = #{record.customer,jdbcType=VARCHAR},
      </if>
      <if test="record.deviceType != null">
        device_type = #{record.deviceType,jdbcType=VARCHAR},
      </if>
      <if test="record.deviceModel != null">
        device_model = #{record.deviceModel,jdbcType=VARCHAR},
      </if>
      <if test="record.alias != null">
        alias = #{record.alias,jdbcType=VARCHAR},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=INTEGER},
      </if>
      <if test="record.createdDate != null">
        created_date = #{record.createdDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.lastModifiedBy != null">
        last_modified_by = #{record.lastModifiedBy,jdbcType=INTEGER},
      </if>
      <if test="record.lastModifiedDate != null">
        last_modified_date = #{record.lastModifiedDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=INTEGER},
      </if>
      <if test="record.signalStrength != null">
        signal_strength = #{record.signalStrength,jdbcType=VARCHAR},
      </if>
      <if test="record.ipAddress != null">
        ip_address = #{record.ipAddress,jdbcType=VARCHAR},
      </if>
      <if test="record.lastRequestTime != null">
        last_request_time = #{record.lastRequestTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.organizationId != null">
        organization_id = #{record.organizationId,jdbcType=INTEGER},
      </if>
      <if test="record.storeId != null">
        store_id = #{record.storeId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update device
    set id = #{record.id,jdbcType=INTEGER},
      mac_addr = #{record.macAddr,jdbcType=VARCHAR},
      serial_no = #{record.serialNo,jdbcType=VARCHAR},
      cur_version = #{record.curVersion,jdbcType=VARCHAR},
      manufacturer = #{record.manufacturer,jdbcType=VARCHAR},
      region = #{record.region,jdbcType=VARCHAR},
      department = #{record.department,jdbcType=VARCHAR},
      customer = #{record.customer,jdbcType=VARCHAR},
      device_type = #{record.deviceType,jdbcType=VARCHAR},
      device_model = #{record.deviceModel,jdbcType=VARCHAR},
      alias = #{record.alias,jdbcType=VARCHAR},
      created_by = #{record.createdBy,jdbcType=INTEGER},
      created_date = #{record.createdDate,jdbcType=TIMESTAMP},
      last_modified_by = #{record.lastModifiedBy,jdbcType=INTEGER},
      last_modified_date = #{record.lastModifiedDate,jdbcType=TIMESTAMP},
      status = #{record.status,jdbcType=INTEGER},
      signal_strength = #{record.signalStrength,jdbcType=VARCHAR},
      ip_address = #{record.ipAddress,jdbcType=VARCHAR},
      last_request_time = #{record.lastRequestTime,jdbcType=TIMESTAMP},
      organization_id = #{record.organizationId,jdbcType=INTEGER},
      store_id = #{record.storeId,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.device.persistent.domain.Device">
    update device
    <set>
      <if test="macAddr != null">
        mac_addr = #{macAddr,jdbcType=VARCHAR},
      </if>
      <if test="serialNo != null">
        serial_no = #{serialNo,jdbcType=VARCHAR},
      </if>
      <if test="curVersion != null">
        cur_version = #{curVersion,jdbcType=VARCHAR},
      </if>
      <if test="manufacturer != null">
        manufacturer = #{manufacturer,jdbcType=VARCHAR},
      </if>
      <if test="region != null">
        region = #{region,jdbcType=VARCHAR},
      </if>
      <if test="department != null">
        department = #{department,jdbcType=VARCHAR},
      </if>
      <if test="customer != null">
        customer = #{customer,jdbcType=VARCHAR},
      </if>
      <if test="deviceType != null">
        device_type = #{deviceType,jdbcType=VARCHAR},
      </if>
      <if test="deviceModel != null">
        device_model = #{deviceModel,jdbcType=VARCHAR},
      </if>
      <if test="alias != null">
        alias = #{alias,jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=INTEGER},
      </if>
      <if test="createdDate != null">
        created_date = #{createdDate,jdbcType=TIMESTAMP},
      </if>
      <if test="lastModifiedBy != null">
        last_modified_by = #{lastModifiedBy,jdbcType=INTEGER},
      </if>
      <if test="lastModifiedDate != null">
        last_modified_date = #{lastModifiedDate,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="signalStrength != null">
        signal_strength = #{signalStrength,jdbcType=VARCHAR},
      </if>
      <if test="ipAddress != null">
        ip_address = #{ipAddress,jdbcType=VARCHAR},
      </if>
      <if test="lastRequestTime != null">
        last_request_time = #{lastRequestTime,jdbcType=TIMESTAMP},
      </if>
      <if test="organizationId != null">
        organization_id = #{organizationId,jdbcType=INTEGER},
      </if>
      <if test="storeId != null">
        store_id = #{storeId,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.device.persistent.domain.Device">
    update device
    set mac_addr = #{macAddr,jdbcType=VARCHAR},
      serial_no = #{serialNo,jdbcType=VARCHAR},
      cur_version = #{curVersion,jdbcType=VARCHAR},
      manufacturer = #{manufacturer,jdbcType=VARCHAR},
      region = #{region,jdbcType=VARCHAR},
      department = #{department,jdbcType=VARCHAR},
      customer = #{customer,jdbcType=VARCHAR},
      device_type = #{deviceType,jdbcType=VARCHAR},
      device_model = #{deviceModel,jdbcType=VARCHAR},
      alias = #{alias,jdbcType=VARCHAR},
      created_by = #{createdBy,jdbcType=INTEGER},
      created_date = #{createdDate,jdbcType=TIMESTAMP},
      last_modified_by = #{lastModifiedBy,jdbcType=INTEGER},
      last_modified_date = #{lastModifiedDate,jdbcType=TIMESTAMP},
      status = #{status,jdbcType=INTEGER},
      signal_strength = #{signalStrength,jdbcType=VARCHAR},
      ip_address = #{ipAddress,jdbcType=VARCHAR},
      last_request_time = #{lastRequestTime,jdbcType=TIMESTAMP},
      organization_id = #{organizationId,jdbcType=INTEGER},
      store_id = #{storeId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into device  (mac_addr, serial_no, cur_version, 
        manufacturer, region, department, 
        customer, device_type, device_model, 
        alias, created_by, created_date, 
        last_modified_by, last_modified_date, status, 
        signal_strength, ip_address, last_request_time, 
        organization_id, store_id)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.macAddr,jdbcType=VARCHAR}, #{item.serialNo,jdbcType=VARCHAR}, #{item.curVersion,jdbcType=VARCHAR}, 
        #{item.manufacturer,jdbcType=VARCHAR}, #{item.region,jdbcType=VARCHAR}, #{item.department,jdbcType=VARCHAR}, 
        #{item.customer,jdbcType=VARCHAR}, #{item.deviceType,jdbcType=VARCHAR}, #{item.deviceModel,jdbcType=VARCHAR}, 
        #{item.alias,jdbcType=VARCHAR}, #{item.createdBy,jdbcType=INTEGER}, #{item.createdDate,jdbcType=TIMESTAMP}, 
        #{item.lastModifiedBy,jdbcType=INTEGER}, #{item.lastModifiedDate,jdbcType=TIMESTAMP}, #{item.status,jdbcType=INTEGER}, 
        #{item.signalStrength,jdbcType=VARCHAR}, #{item.ipAddress,jdbcType=VARCHAR}, #{item.lastRequestTime,jdbcType=TIMESTAMP}, 
        #{item.organizationId,jdbcType=INTEGER}, #{item.storeId,jdbcType=INTEGER})
      </foreach>
    </if>
  </insert>
</mapper>