<?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.neu.his.cloud.service.bms.mapper.BmsBillsRecordMapper">
  <resultMap id="BaseResultMap" type="com.neu.his.cloud.service.bms.model.BmsBillsRecord">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="type" jdbcType="INTEGER" property="type" />
    <result column="bill_no" jdbcType="VARCHAR" property="billNo" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="invoice_num" jdbcType="INTEGER" property="invoiceNum" />
    <result column="registration_id" jdbcType="BIGINT" property="registrationId" />
    <result column="record_list" jdbcType="VARCHAR" property="recordList" />
  </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, type, bill_no, create_time, status, invoice_num, registration_id, record_list
  </sql>
  <select id="selectByExample" parameterType="com.neu.his.cloud.service.bms.model.BmsBillsRecordExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from bms_bills_record
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from bms_bills_record
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from bms_bills_record
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.neu.his.cloud.service.bms.model.BmsBillsRecordExample">
    delete from bms_bills_record
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.neu.his.cloud.service.bms.model.BmsBillsRecord">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into bms_bills_record (type, bill_no, create_time, 
      status, invoice_num, registration_id, 
      record_list)
    values (#{type,jdbcType=INTEGER}, #{billNo,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{status,jdbcType=INTEGER}, #{invoiceNum,jdbcType=INTEGER}, #{registrationId,jdbcType=BIGINT}, 
      #{recordList,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.neu.his.cloud.service.bms.model.BmsBillsRecord">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into bms_bills_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="type != null">
        type,
      </if>
      <if test="billNo != null">
        bill_no,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="invoiceNum != null">
        invoice_num,
      </if>
      <if test="registrationId != null">
        registration_id,
      </if>
      <if test="recordList != null">
        record_list,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="type != null">
        #{type,jdbcType=INTEGER},
      </if>
      <if test="billNo != null">
        #{billNo,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="invoiceNum != null">
        #{invoiceNum,jdbcType=INTEGER},
      </if>
      <if test="registrationId != null">
        #{registrationId,jdbcType=BIGINT},
      </if>
      <if test="recordList != null">
        #{recordList,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neu.his.cloud.service.bms.model.BmsBillsRecordExample" resultType="java.lang.Integer">
    select count(*) from bms_bills_record
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update bms_bills_record
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.type != null">
        type = #{record.type,jdbcType=INTEGER},
      </if>
      <if test="record.billNo != null">
        bill_no = #{record.billNo,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=INTEGER},
      </if>
      <if test="record.invoiceNum != null">
        invoice_num = #{record.invoiceNum,jdbcType=INTEGER},
      </if>
      <if test="record.registrationId != null">
        registration_id = #{record.registrationId,jdbcType=BIGINT},
      </if>
      <if test="record.recordList != null">
        record_list = #{record.recordList,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update bms_bills_record
    set id = #{record.id,jdbcType=BIGINT},
      type = #{record.type,jdbcType=INTEGER},
      bill_no = #{record.billNo,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      status = #{record.status,jdbcType=INTEGER},
      invoice_num = #{record.invoiceNum,jdbcType=INTEGER},
      registration_id = #{record.registrationId,jdbcType=BIGINT},
      record_list = #{record.recordList,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neu.his.cloud.service.bms.model.BmsBillsRecord">
    update bms_bills_record
    <set>
      <if test="type != null">
        type = #{type,jdbcType=INTEGER},
      </if>
      <if test="billNo != null">
        bill_no = #{billNo,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="invoiceNum != null">
        invoice_num = #{invoiceNum,jdbcType=INTEGER},
      </if>
      <if test="registrationId != null">
        registration_id = #{registrationId,jdbcType=BIGINT},
      </if>
      <if test="recordList != null">
        record_list = #{recordList,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neu.his.cloud.service.bms.model.BmsBillsRecord">
    update bms_bills_record
    set type = #{type,jdbcType=INTEGER},
      bill_no = #{billNo,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      status = #{status,jdbcType=INTEGER},
      invoice_num = #{invoiceNum,jdbcType=INTEGER},
      registration_id = #{registrationId,jdbcType=BIGINT},
      record_list = #{recordList,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>