<?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.printer.persistent.mapper.PrinterInfoMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.printer.persistent.domain.PrinterInfo">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="org_id" jdbcType="INTEGER" property="orgId" />
    <result column="shop_id" jdbcType="INTEGER" property="shopId" />
    <result column="parent_id" jdbcType="BIGINT" property="parentId" />
    <result column="printer_sn" jdbcType="VARCHAR" property="printerSn" />
    <result column="printer_name" jdbcType="VARCHAR" property="printerName" />
    <result column="printer_ip" jdbcType="VARCHAR" property="printerIp" />
    <result column="printer_port" jdbcType="VARCHAR" property="printerPort" />
    <result column="printer_type" jdbcType="VARCHAR" property="printerType" />
    <result column="device_type" jdbcType="VARCHAR" property="deviceType" />
    <result column="printer_status" jdbcType="VARCHAR" property="printerStatus" />
    <result column="version" jdbcType="INTEGER" property="version" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
  </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, org_id, shop_id, parent_id, printer_sn, printer_name, printer_ip, printer_port, 
    printer_type, device_type, printer_status, version, created_at, created_by, updated_by, 
    updated_at
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterInfoExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from printer_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.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from printer_info
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from printer_info
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterInfoExample">
    delete from printer_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterInfo" useGeneratedKeys="true">
    insert into printer_info (org_id, shop_id, parent_id, 
      printer_sn, printer_name, printer_ip, 
      printer_port, printer_type, device_type, 
      printer_status, version, created_at, 
      created_by, updated_by, updated_at
      )
    values (#{orgId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{parentId,jdbcType=BIGINT}, 
      #{printerSn,jdbcType=VARCHAR}, #{printerName,jdbcType=VARCHAR}, #{printerIp,jdbcType=VARCHAR}, 
      #{printerPort,jdbcType=VARCHAR}, #{printerType,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR}, 
      #{printerStatus,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=VARCHAR}, #{updatedBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterInfo" useGeneratedKeys="true">
    insert into printer_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        org_id,
      </if>
      <if test="shopId != null">
        shop_id,
      </if>
      <if test="parentId != null">
        parent_id,
      </if>
      <if test="printerSn != null">
        printer_sn,
      </if>
      <if test="printerName != null">
        printer_name,
      </if>
      <if test="printerIp != null">
        printer_ip,
      </if>
      <if test="printerPort != null">
        printer_port,
      </if>
      <if test="printerType != null">
        printer_type,
      </if>
      <if test="deviceType != null">
        device_type,
      </if>
      <if test="printerStatus != null">
        printer_status,
      </if>
      <if test="version != null">
        version,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        #{orgId,jdbcType=INTEGER},
      </if>
      <if test="shopId != null">
        #{shopId,jdbcType=INTEGER},
      </if>
      <if test="parentId != null">
        #{parentId,jdbcType=BIGINT},
      </if>
      <if test="printerSn != null">
        #{printerSn,jdbcType=VARCHAR},
      </if>
      <if test="printerName != null">
        #{printerName,jdbcType=VARCHAR},
      </if>
      <if test="printerIp != null">
        #{printerIp,jdbcType=VARCHAR},
      </if>
      <if test="printerPort != null">
        #{printerPort,jdbcType=VARCHAR},
      </if>
      <if test="printerType != null">
        #{printerType,jdbcType=VARCHAR},
      </if>
      <if test="deviceType != null">
        #{deviceType,jdbcType=VARCHAR},
      </if>
      <if test="printerStatus != null">
        #{printerStatus,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        #{version,jdbcType=INTEGER},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterInfoExample" resultType="java.lang.Integer">
    select count(*) from printer_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update printer_info
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.orgId != null">
        org_id = #{record.orgId,jdbcType=INTEGER},
      </if>
      <if test="record.shopId != null">
        shop_id = #{record.shopId,jdbcType=INTEGER},
      </if>
      <if test="record.parentId != null">
        parent_id = #{record.parentId,jdbcType=BIGINT},
      </if>
      <if test="record.printerSn != null">
        printer_sn = #{record.printerSn,jdbcType=VARCHAR},
      </if>
      <if test="record.printerName != null">
        printer_name = #{record.printerName,jdbcType=VARCHAR},
      </if>
      <if test="record.printerIp != null">
        printer_ip = #{record.printerIp,jdbcType=VARCHAR},
      </if>
      <if test="record.printerPort != null">
        printer_port = #{record.printerPort,jdbcType=VARCHAR},
      </if>
      <if test="record.printerType != null">
        printer_type = #{record.printerType,jdbcType=VARCHAR},
      </if>
      <if test="record.deviceType != null">
        device_type = #{record.deviceType,jdbcType=VARCHAR},
      </if>
      <if test="record.printerStatus != null">
        printer_status = #{record.printerStatus,jdbcType=VARCHAR},
      </if>
      <if test="record.version != null">
        version = #{record.version,jdbcType=INTEGER},
      </if>
      <if test="record.createdAt != null">
        created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updatedBy != null">
        updated_by = #{record.updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updatedAt != null">
        updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update printer_info
    set id = #{record.id,jdbcType=BIGINT},
      org_id = #{record.orgId,jdbcType=INTEGER},
      shop_id = #{record.shopId,jdbcType=INTEGER},
      parent_id = #{record.parentId,jdbcType=BIGINT},
      printer_sn = #{record.printerSn,jdbcType=VARCHAR},
      printer_name = #{record.printerName,jdbcType=VARCHAR},
      printer_ip = #{record.printerIp,jdbcType=VARCHAR},
      printer_port = #{record.printerPort,jdbcType=VARCHAR},
      printer_type = #{record.printerType,jdbcType=VARCHAR},
      device_type = #{record.deviceType,jdbcType=VARCHAR},
      printer_status = #{record.printerStatus,jdbcType=VARCHAR},
      version = #{record.version,jdbcType=INTEGER},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=VARCHAR},
      updated_by = #{record.updatedBy,jdbcType=VARCHAR},
      updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterInfo">
    update printer_info
    <set>
      <if test="orgId != null">
        org_id = #{orgId,jdbcType=INTEGER},
      </if>
      <if test="shopId != null">
        shop_id = #{shopId,jdbcType=INTEGER},
      </if>
      <if test="parentId != null">
        parent_id = #{parentId,jdbcType=BIGINT},
      </if>
      <if test="printerSn != null">
        printer_sn = #{printerSn,jdbcType=VARCHAR},
      </if>
      <if test="printerName != null">
        printer_name = #{printerName,jdbcType=VARCHAR},
      </if>
      <if test="printerIp != null">
        printer_ip = #{printerIp,jdbcType=VARCHAR},
      </if>
      <if test="printerPort != null">
        printer_port = #{printerPort,jdbcType=VARCHAR},
      </if>
      <if test="printerType != null">
        printer_type = #{printerType,jdbcType=VARCHAR},
      </if>
      <if test="deviceType != null">
        device_type = #{deviceType,jdbcType=VARCHAR},
      </if>
      <if test="printerStatus != null">
        printer_status = #{printerStatus,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        version = #{version,jdbcType=INTEGER},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterInfo">
    update printer_info
    set org_id = #{orgId,jdbcType=INTEGER},
      shop_id = #{shopId,jdbcType=INTEGER},
      parent_id = #{parentId,jdbcType=BIGINT},
      printer_sn = #{printerSn,jdbcType=VARCHAR},
      printer_name = #{printerName,jdbcType=VARCHAR},
      printer_ip = #{printerIp,jdbcType=VARCHAR},
      printer_port = #{printerPort,jdbcType=VARCHAR},
      printer_type = #{printerType,jdbcType=VARCHAR},
      device_type = #{deviceType,jdbcType=VARCHAR},
      printer_status = #{printerStatus,jdbcType=VARCHAR},
      version = #{version,jdbcType=INTEGER},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=VARCHAR},
      updated_by = #{updatedBy,jdbcType=VARCHAR},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into printer_info  (org_id, shop_id, parent_id, 
        printer_sn, printer_name, printer_ip, 
        printer_port, printer_type, device_type, 
        printer_status, version, created_at, 
        created_by, updated_by, updated_at
        )
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.orgId,jdbcType=INTEGER}, #{item.shopId,jdbcType=INTEGER}, #{item.parentId,jdbcType=BIGINT}, 
        #{item.printerSn,jdbcType=VARCHAR}, #{item.printerName,jdbcType=VARCHAR}, #{item.printerIp,jdbcType=VARCHAR}, 
        #{item.printerPort,jdbcType=VARCHAR}, #{item.printerType,jdbcType=VARCHAR}, #{item.deviceType,jdbcType=VARCHAR}, 
        #{item.printerStatus,jdbcType=VARCHAR}, #{item.version,jdbcType=INTEGER}, #{item.createdAt,jdbcType=TIMESTAMP}, 
        #{item.createdBy,jdbcType=VARCHAR}, #{item.updatedBy,jdbcType=VARCHAR}, #{item.updatedAt,jdbcType=TIMESTAMP}
        )
      </foreach>
    </if>
  </insert>
</mapper>