<?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.usoft.fin.grpc.dal.mapper.DrawApplyOrderMapper">
  <resultMap id="BaseResultMap" type="com.usoft.fin.grpc.dal.entity.DrawApplyOrder">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="draw_code" jdbcType="VARCHAR" property="drawCode" />
    <result column="amount" jdbcType="DOUBLE" property="amount" />
    <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
    <result column="order_date" jdbcType="VARCHAR" property="orderDate" />
  </resultMap>
  <sql id="Base_Column_List">
    id, code, draw_code, amount, customer_name, order_date
  </sql>
  <sql id="Table_Base_Column_List">
    t_draw_apply_order.id, t_draw_apply_order.code, t_draw_apply_order.draw_code, t_draw_apply_order.amount, 
    t_draw_apply_order.customer_name, t_draw_apply_order.order_date
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_draw_apply_order
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_draw_apply_order
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.usoft.fin.grpc.dal.entity.DrawApplyOrder">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_draw_apply_order (code, draw_code, amount, 
      customer_name, order_date)
    values (#{code,jdbcType=VARCHAR}, #{drawCode,jdbcType=VARCHAR}, #{amount,jdbcType=DOUBLE}, 
      #{customerName,jdbcType=VARCHAR}, #{orderDate,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.usoft.fin.grpc.dal.entity.DrawApplyOrder">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_draw_apply_order
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="drawCode != null">
        draw_code,
      </if>
      <if test="amount != null">
        amount,
      </if>
      <if test="customerName != null">
        customer_name,
      </if>
      <if test="orderDate != null">
        order_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="drawCode != null">
        #{drawCode,jdbcType=VARCHAR},
      </if>
      <if test="amount != null">
        #{amount,jdbcType=DOUBLE},
      </if>
      <if test="customerName != null">
        #{customerName,jdbcType=VARCHAR},
      </if>
      <if test="orderDate != null">
        #{orderDate,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.usoft.fin.grpc.dal.entity.DrawApplyOrder">
    update t_draw_apply_order
    <set>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="drawCode != null">
        draw_code = #{drawCode,jdbcType=VARCHAR},
      </if>
      <if test="amount != null">
        amount = #{amount,jdbcType=DOUBLE},
      </if>
      <if test="customerName != null">
        customer_name = #{customerName,jdbcType=VARCHAR},
      </if>
      <if test="orderDate != null">
        order_date = #{orderDate,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.usoft.fin.grpc.dal.entity.DrawApplyOrder">
    update t_draw_apply_order
    set code = #{code,jdbcType=VARCHAR},
      draw_code = #{drawCode,jdbcType=VARCHAR},
      amount = #{amount,jdbcType=DOUBLE},
      customer_name = #{customerName,jdbcType=VARCHAR},
      order_date = #{orderDate,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>