<?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="cn.superdesk.uniorder.dao.mapper.fund.SysFundGrantMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.fund.SysFundGrant">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="fund_user_id" jdbcType="BIGINT" property="fundUserId" />
    <result column="invoice_number" jdbcType="VARCHAR" property="invoiceNumber" />
    <result column="invoice_count" jdbcType="DECIMAL" property="invoiceCount" />
    <result column="fund_count" jdbcType="DECIMAL" property="fundCount" />
    <result column="no_check_count" jdbcType="DECIMAL" property="noCheckCount" />
    <result column="no_activated_fund" jdbcType="DECIMAL" property="noActivatedFund" />
    <result column="activated_status" jdbcType="INTEGER" property="activatedStatus" />
    <result column="create_user_id" jdbcType="BIGINT" property="createUserId" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </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, fund_user_id, invoice_number, invoice_count, fund_count, no_check_count, no_activated_fund, 
    activated_status, create_user_id, create_time
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.fund.SysFundGrantExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from sys_fund_grant
    <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 sys_fund_grant
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from sys_fund_grant
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.fund.SysFundGrantExample">
    delete from sys_fund_grant
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.fund.SysFundGrant">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_fund_grant (fund_user_id, invoice_number, invoice_count, 
      fund_count, no_check_count, no_activated_fund, 
      activated_status, create_user_id, create_time
      )
    values (#{fundUserId,jdbcType=BIGINT}, #{invoiceNumber,jdbcType=VARCHAR}, #{invoiceCount,jdbcType=DECIMAL}, 
      #{fundCount,jdbcType=DECIMAL}, #{noCheckCount,jdbcType=DECIMAL}, #{noActivatedFund,jdbcType=DECIMAL}, 
      #{activatedStatus,jdbcType=INTEGER}, #{createUserId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.fund.SysFundGrant">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_fund_grant
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="fundUserId != null">
        fund_user_id,
      </if>
      <if test="invoiceNumber != null">
        invoice_number,
      </if>
      <if test="invoiceCount != null">
        invoice_count,
      </if>
      <if test="fundCount != null">
        fund_count,
      </if>
      <if test="noCheckCount != null">
        no_check_count,
      </if>
      <if test="noActivatedFund != null">
        no_activated_fund,
      </if>
      <if test="activatedStatus != null">
        activated_status,
      </if>
      <if test="createUserId != null">
        create_user_id,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="fundUserId != null">
        #{fundUserId,jdbcType=BIGINT},
      </if>
      <if test="invoiceNumber != null">
        #{invoiceNumber,jdbcType=VARCHAR},
      </if>
      <if test="invoiceCount != null">
        #{invoiceCount,jdbcType=DECIMAL},
      </if>
      <if test="fundCount != null">
        #{fundCount,jdbcType=DECIMAL},
      </if>
      <if test="noCheckCount != null">
        #{noCheckCount,jdbcType=DECIMAL},
      </if>
      <if test="noActivatedFund != null">
        #{noActivatedFund,jdbcType=DECIMAL},
      </if>
      <if test="activatedStatus != null">
        #{activatedStatus,jdbcType=INTEGER},
      </if>
      <if test="createUserId != null">
        #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.fund.SysFundGrantExample" resultType="java.lang.Long">
    select count(*) from sys_fund_grant
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update sys_fund_grant
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.fundUserId != null">
        fund_user_id = #{record.fundUserId,jdbcType=BIGINT},
      </if>
      <if test="record.invoiceNumber != null">
        invoice_number = #{record.invoiceNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.invoiceCount != null">
        invoice_count = #{record.invoiceCount,jdbcType=DECIMAL},
      </if>
      <if test="record.fundCount != null">
        fund_count = #{record.fundCount,jdbcType=DECIMAL},
      </if>
      <if test="record.noCheckCount != null">
        no_check_count = #{record.noCheckCount,jdbcType=DECIMAL},
      </if>
      <if test="record.noActivatedFund != null">
        no_activated_fund = #{record.noActivatedFund,jdbcType=DECIMAL},
      </if>
      <if test="record.activatedStatus != null">
        activated_status = #{record.activatedStatus,jdbcType=INTEGER},
      </if>
      <if test="record.createUserId != null">
        create_user_id = #{record.createUserId,jdbcType=BIGINT},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update sys_fund_grant
    set id = #{record.id,jdbcType=BIGINT},
      fund_user_id = #{record.fundUserId,jdbcType=BIGINT},
      invoice_number = #{record.invoiceNumber,jdbcType=VARCHAR},
      invoice_count = #{record.invoiceCount,jdbcType=DECIMAL},
      fund_count = #{record.fundCount,jdbcType=DECIMAL},
      no_check_count = #{record.noCheckCount,jdbcType=DECIMAL},
      no_activated_fund = #{record.noActivatedFund,jdbcType=DECIMAL},
      activated_status = #{record.activatedStatus,jdbcType=INTEGER},
      create_user_id = #{record.createUserId,jdbcType=BIGINT},
      create_time = #{record.createTime,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.fund.SysFundGrant">
    update sys_fund_grant
    <set>
      <if test="fundUserId != null">
        fund_user_id = #{fundUserId,jdbcType=BIGINT},
      </if>
      <if test="invoiceNumber != null">
        invoice_number = #{invoiceNumber,jdbcType=VARCHAR},
      </if>
      <if test="invoiceCount != null">
        invoice_count = #{invoiceCount,jdbcType=DECIMAL},
      </if>
      <if test="fundCount != null">
        fund_count = #{fundCount,jdbcType=DECIMAL},
      </if>
      <if test="noCheckCount != null">
        no_check_count = #{noCheckCount,jdbcType=DECIMAL},
      </if>
      <if test="noActivatedFund != null">
        no_activated_fund = #{noActivatedFund,jdbcType=DECIMAL},
      </if>
      <if test="activatedStatus != null">
        activated_status = #{activatedStatus,jdbcType=INTEGER},
      </if>
      <if test="createUserId != null">
        create_user_id = #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.fund.SysFundGrant">
    update sys_fund_grant
    set fund_user_id = #{fundUserId,jdbcType=BIGINT},
      invoice_number = #{invoiceNumber,jdbcType=VARCHAR},
      invoice_count = #{invoiceCount,jdbcType=DECIMAL},
      fund_count = #{fundCount,jdbcType=DECIMAL},
      no_check_count = #{noCheckCount,jdbcType=DECIMAL},
      no_activated_fund = #{noActivatedFund,jdbcType=DECIMAL},
      activated_status = #{activatedStatus,jdbcType=INTEGER},
      create_user_id = #{createUserId,jdbcType=BIGINT},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>