<?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.PrinterTaskInfoMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.printer.persistent.domain.PrinterTaskInfo">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="org_id" jdbcType="INTEGER" property="orgId" />
    <result column="shop_id" jdbcType="INTEGER" property="shopId" />
    <result column="printer_id" jdbcType="INTEGER" property="printerId" />
    <result column="printer_type" jdbcType="VARCHAR" property="printerType" />
    <result column="order_number" jdbcType="VARCHAR" property="orderNumber" />
    <result column="order_type" jdbcType="VARCHAR" property="orderType" />
    <result column="printer_json" jdbcType="VARCHAR" property="printerJson" />
    <result column="task_status" jdbcType="VARCHAR" property="taskStatus" />
    <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, printer_id, printer_type, order_number, order_type, printer_json, 
    task_status, version, created_at, created_by, updated_by, updated_at
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterTaskInfoExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from printer_task_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 printer_task_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from printer_task_info
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterTaskInfoExample">
    delete from printer_task_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.PrinterTaskInfo" useGeneratedKeys="true">
    insert into printer_task_info (org_id, shop_id, printer_id, 
      printer_type, order_number, order_type, 
      printer_json, task_status, version, 
      created_at, created_by, updated_by, 
      updated_at)
    values (#{orgId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{printerId,jdbcType=INTEGER}, 
      #{printerType,jdbcType=VARCHAR}, #{orderNumber,jdbcType=VARCHAR}, #{orderType,jdbcType=VARCHAR}, 
      #{printerJson,jdbcType=VARCHAR}, #{taskStatus,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.PrinterTaskInfo" useGeneratedKeys="true">
    insert into printer_task_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        org_id,
      </if>
      <if test="shopId != null">
        shop_id,
      </if>
      <if test="printerId != null">
        printer_id,
      </if>
      <if test="printerType != null">
        printer_type,
      </if>
      <if test="orderNumber != null">
        order_number,
      </if>
      <if test="orderType != null">
        order_type,
      </if>
      <if test="printerJson != null">
        printer_json,
      </if>
      <if test="taskStatus != null">
        task_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="printerId != null">
        #{printerId,jdbcType=INTEGER},
      </if>
      <if test="printerType != null">
        #{printerType,jdbcType=VARCHAR},
      </if>
      <if test="orderNumber != null">
        #{orderNumber,jdbcType=VARCHAR},
      </if>
      <if test="orderType != null">
        #{orderType,jdbcType=VARCHAR},
      </if>
      <if test="printerJson != null">
        #{printerJson,jdbcType=VARCHAR},
      </if>
      <if test="taskStatus != null">
        #{taskStatus,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.PrinterTaskInfoExample" resultType="java.lang.Integer">
    select count(*) from printer_task_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update printer_task_info
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </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.printerId != null">
        printer_id = #{record.printerId,jdbcType=INTEGER},
      </if>
      <if test="record.printerType != null">
        printer_type = #{record.printerType,jdbcType=VARCHAR},
      </if>
      <if test="record.orderNumber != null">
        order_number = #{record.orderNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.orderType != null">
        order_type = #{record.orderType,jdbcType=VARCHAR},
      </if>
      <if test="record.printerJson != null">
        printer_json = #{record.printerJson,jdbcType=VARCHAR},
      </if>
      <if test="record.taskStatus != null">
        task_status = #{record.taskStatus,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_task_info
    set id = #{record.id,jdbcType=INTEGER},
      org_id = #{record.orgId,jdbcType=INTEGER},
      shop_id = #{record.shopId,jdbcType=INTEGER},
      printer_id = #{record.printerId,jdbcType=INTEGER},
      printer_type = #{record.printerType,jdbcType=VARCHAR},
      order_number = #{record.orderNumber,jdbcType=VARCHAR},
      order_type = #{record.orderType,jdbcType=VARCHAR},
      printer_json = #{record.printerJson,jdbcType=VARCHAR},
      task_status = #{record.taskStatus,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.PrinterTaskInfo">
    update printer_task_info
    <set>
      <if test="orgId != null">
        org_id = #{orgId,jdbcType=INTEGER},
      </if>
      <if test="shopId != null">
        shop_id = #{shopId,jdbcType=INTEGER},
      </if>
      <if test="printerId != null">
        printer_id = #{printerId,jdbcType=INTEGER},
      </if>
      <if test="printerType != null">
        printer_type = #{printerType,jdbcType=VARCHAR},
      </if>
      <if test="orderNumber != null">
        order_number = #{orderNumber,jdbcType=VARCHAR},
      </if>
      <if test="orderType != null">
        order_type = #{orderType,jdbcType=VARCHAR},
      </if>
      <if test="printerJson != null">
        printer_json = #{printerJson,jdbcType=VARCHAR},
      </if>
      <if test="taskStatus != null">
        task_status = #{taskStatus,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=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.printer.persistent.domain.PrinterTaskInfo">
    update printer_task_info
    set org_id = #{orgId,jdbcType=INTEGER},
      shop_id = #{shopId,jdbcType=INTEGER},
      printer_id = #{printerId,jdbcType=INTEGER},
      printer_type = #{printerType,jdbcType=VARCHAR},
      order_number = #{orderNumber,jdbcType=VARCHAR},
      order_type = #{orderType,jdbcType=VARCHAR},
      printer_json = #{printerJson,jdbcType=VARCHAR},
      task_status = #{taskStatus,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=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into printer_task_info  (org_id, shop_id, printer_id, 
        printer_type, order_number, order_type, 
        printer_json, task_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.printerId,jdbcType=INTEGER}, 
        #{item.printerType,jdbcType=VARCHAR}, #{item.orderNumber,jdbcType=VARCHAR}, #{item.orderType,jdbcType=VARCHAR}, 
        #{item.printerJson,jdbcType=VARCHAR}, #{item.taskStatus,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>