<?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.lightinit.hsdataportal.mapper.InvoiceMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataportal.entity.Invoice">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="user_id" jdbcType="BIGINT" property="userId" />
    <result column="apply_time" jdbcType="TIMESTAMP" property="applyTime" />
    <result column="invoice_state" jdbcType="VARCHAR" property="invoiceState" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="invoice_amount" jdbcType="DECIMAL" property="invoiceAmount" />
    <result column="invoiced_by" jdbcType="BIGINT" property="invoicedBy" />
    <result column="invoiced_at" jdbcType="TIMESTAMP" property="invoicedAt" />
    <result column="org_name" jdbcType="VARCHAR" property="orgName" />
    <result column="invoice_type" jdbcType="VARCHAR" property="invoiceType" />
    <result column="invoice_number" jdbcType="VARCHAR" property="invoiceNumber" />
    <result column="invoiced_amount" jdbcType="DECIMAL" property="invoicedAmount" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="deleted_at" jdbcType="TIMESTAMP" property="deletedAt" />
    <result column="deleted_by" jdbcType="BIGINT" property="deletedBy" />
  </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, user_id, apply_time, invoice_state, order_id, invoice_amount, invoiced_by, invoiced_at, 
    org_name, invoice_type, invoice_number, invoiced_amount, created_at, created_by, 
    deleted_at, deleted_by
  </sql>
  <select id="selectByExample" parameterType="com.lightinit.hsdataportal.entity.InvoiceExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from invoice
    <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 invoice
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from invoice
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataportal.entity.InvoiceExample">
    delete from invoice
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataportal.entity.Invoice">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into invoice (user_id, apply_time, invoice_state, 
      order_id, invoice_amount, invoiced_by, 
      invoiced_at, org_name, invoice_type, 
      invoice_number, invoiced_amount, created_at, 
      created_by, deleted_at, deleted_by
      )
    values (#{userId,jdbcType=BIGINT}, #{applyTime,jdbcType=TIMESTAMP}, #{invoiceState,jdbcType=VARCHAR}, 
      #{orderId,jdbcType=BIGINT}, #{invoiceAmount,jdbcType=DECIMAL}, #{invoicedBy,jdbcType=BIGINT}, 
      #{invoicedAt,jdbcType=TIMESTAMP}, #{orgName,jdbcType=VARCHAR}, #{invoiceType,jdbcType=VARCHAR}, 
      #{invoiceNumber,jdbcType=VARCHAR}, #{invoicedAmount,jdbcType=DECIMAL}, #{createdAt,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=BIGINT}, #{deletedAt,jdbcType=TIMESTAMP}, #{deletedBy,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataportal.entity.Invoice">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into invoice
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        user_id,
      </if>
      <if test="applyTime != null">
        apply_time,
      </if>
      <if test="invoiceState != null">
        invoice_state,
      </if>
      <if test="orderId != null">
        order_id,
      </if>
      <if test="invoiceAmount != null">
        invoice_amount,
      </if>
      <if test="invoicedBy != null">
        invoiced_by,
      </if>
      <if test="invoicedAt != null">
        invoiced_at,
      </if>
      <if test="orgName != null">
        org_name,
      </if>
      <if test="invoiceType != null">
        invoice_type,
      </if>
      <if test="invoiceNumber != null">
        invoice_number,
      </if>
      <if test="invoicedAmount != null">
        invoiced_amount,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="deletedAt != null">
        deleted_at,
      </if>
      <if test="deletedBy != null">
        deleted_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        #{userId,jdbcType=BIGINT},
      </if>
      <if test="applyTime != null">
        #{applyTime,jdbcType=TIMESTAMP},
      </if>
      <if test="invoiceState != null">
        #{invoiceState,jdbcType=VARCHAR},
      </if>
      <if test="orderId != null">
        #{orderId,jdbcType=BIGINT},
      </if>
      <if test="invoiceAmount != null">
        #{invoiceAmount,jdbcType=DECIMAL},
      </if>
      <if test="invoicedBy != null">
        #{invoicedBy,jdbcType=BIGINT},
      </if>
      <if test="invoicedAt != null">
        #{invoicedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="orgName != null">
        #{orgName,jdbcType=VARCHAR},
      </if>
      <if test="invoiceType != null">
        #{invoiceType,jdbcType=VARCHAR},
      </if>
      <if test="invoiceNumber != null">
        #{invoiceNumber,jdbcType=VARCHAR},
      </if>
      <if test="invoicedAmount != null">
        #{invoicedAmount,jdbcType=DECIMAL},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        #{deletedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataportal.entity.InvoiceExample" resultType="java.lang.Long">
    select count(*) from invoice
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update invoice
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.userId != null">
        user_id = #{record.userId,jdbcType=BIGINT},
      </if>
      <if test="record.applyTime != null">
        apply_time = #{record.applyTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.invoiceState != null">
        invoice_state = #{record.invoiceState,jdbcType=VARCHAR},
      </if>
      <if test="record.orderId != null">
        order_id = #{record.orderId,jdbcType=BIGINT},
      </if>
      <if test="record.invoiceAmount != null">
        invoice_amount = #{record.invoiceAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.invoicedBy != null">
        invoiced_by = #{record.invoicedBy,jdbcType=BIGINT},
      </if>
      <if test="record.invoicedAt != null">
        invoiced_at = #{record.invoicedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.orgName != null">
        org_name = #{record.orgName,jdbcType=VARCHAR},
      </if>
      <if test="record.invoiceType != null">
        invoice_type = #{record.invoiceType,jdbcType=VARCHAR},
      </if>
      <if test="record.invoiceNumber != null">
        invoice_number = #{record.invoiceNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.invoicedAmount != null">
        invoiced_amount = #{record.invoicedAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.createdAt != null">
        created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=BIGINT},
      </if>
      <if test="record.deletedAt != null">
        deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deletedBy != null">
        deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update invoice
    set id = #{record.id,jdbcType=BIGINT},
      user_id = #{record.userId,jdbcType=BIGINT},
      apply_time = #{record.applyTime,jdbcType=TIMESTAMP},
      invoice_state = #{record.invoiceState,jdbcType=VARCHAR},
      order_id = #{record.orderId,jdbcType=BIGINT},
      invoice_amount = #{record.invoiceAmount,jdbcType=DECIMAL},
      invoiced_by = #{record.invoicedBy,jdbcType=BIGINT},
      invoiced_at = #{record.invoicedAt,jdbcType=TIMESTAMP},
      org_name = #{record.orgName,jdbcType=VARCHAR},
      invoice_type = #{record.invoiceType,jdbcType=VARCHAR},
      invoice_number = #{record.invoiceNumber,jdbcType=VARCHAR},
      invoiced_amount = #{record.invoicedAmount,jdbcType=DECIMAL},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.lightinit.hsdataportal.entity.Invoice">
    update invoice
    <set>
      <if test="userId != null">
        user_id = #{userId,jdbcType=BIGINT},
      </if>
      <if test="applyTime != null">
        apply_time = #{applyTime,jdbcType=TIMESTAMP},
      </if>
      <if test="invoiceState != null">
        invoice_state = #{invoiceState,jdbcType=VARCHAR},
      </if>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=BIGINT},
      </if>
      <if test="invoiceAmount != null">
        invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
      </if>
      <if test="invoicedBy != null">
        invoiced_by = #{invoicedBy,jdbcType=BIGINT},
      </if>
      <if test="invoicedAt != null">
        invoiced_at = #{invoicedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="orgName != null">
        org_name = #{orgName,jdbcType=VARCHAR},
      </if>
      <if test="invoiceType != null">
        invoice_type = #{invoiceType,jdbcType=VARCHAR},
      </if>
      <if test="invoiceNumber != null">
        invoice_number = #{invoiceNumber,jdbcType=VARCHAR},
      </if>
      <if test="invoicedAmount != null">
        invoiced_amount = #{invoicedAmount,jdbcType=DECIMAL},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        deleted_by = #{deletedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataportal.entity.Invoice">
    update invoice
    set user_id = #{userId,jdbcType=BIGINT},
      apply_time = #{applyTime,jdbcType=TIMESTAMP},
      invoice_state = #{invoiceState,jdbcType=VARCHAR},
      order_id = #{orderId,jdbcType=BIGINT},
      invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
      invoiced_by = #{invoicedBy,jdbcType=BIGINT},
      invoiced_at = #{invoicedAt,jdbcType=TIMESTAMP},
      org_name = #{orgName,jdbcType=VARCHAR},
      invoice_type = #{invoiceType,jdbcType=VARCHAR},
      invoice_number = #{invoiceNumber,jdbcType=VARCHAR},
      invoiced_amount = #{invoicedAmount,jdbcType=DECIMAL},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>