<?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.credit.dal.mapper.PersonJsonMapper">
  <resultMap id="BaseResultMap" type="com.usoft.credit.dal.entity.PersonJson">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="personname" jdbcType="VARCHAR" property="personname" />
    <result column="documentno" jdbcType="VARCHAR" property="documentno" />
    <result column="create_date" jdbcType="DATE" property="createDate" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.usoft.credit.dal.entity.PersonJsonWithBLOBs">
    <result column="pnidentity" jdbcType="LONGVARCHAR" property="pnidentity" />
    <result column="pnshareholder" jdbcType="LONGVARCHAR" property="pnshareholder" />
  </resultMap>
  <sql id="Base_Column_List">
    id, code, personname, documentno, create_date
  </sql>
  <sql id="Blob_Column_List">
    pnidentity, pnshareholder
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from t_person_json
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="findByCreateTime" resultMap="ResultMapWithBLOBs">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from t_person_json
    where create_date = #{date} AND personname = #{personname} AND documentno = #{documentno}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_person_json
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.usoft.credit.dal.entity.PersonJsonWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_person_json (code, personname, documentno, 
      create_date, pnidentity, pnshareholder
      )
    values (#{code,jdbcType=VARCHAR}, #{personname,jdbcType=VARCHAR}, #{documentno,jdbcType=VARCHAR}, 
      #{createDate,jdbcType=DATE}, #{pnidentity,jdbcType=LONGVARCHAR}, #{pnshareholder,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.usoft.credit.dal.entity.PersonJsonWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_person_json
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="personname != null">
        personname,
      </if>
      <if test="documentno != null">
        documentno,
      </if>
      <if test="createDate != null">
        create_date,
      </if>
      <if test="pnidentity != null">
        pnidentity,
      </if>
      <if test="pnshareholder != null">
        pnshareholder,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="personname != null">
        #{personname,jdbcType=VARCHAR},
      </if>
      <if test="documentno != null">
        #{documentno,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        #{createDate,jdbcType=DATE},
      </if>
      <if test="pnidentity != null">
        #{pnidentity,jdbcType=LONGVARCHAR},
      </if>
      <if test="pnshareholder != null">
        #{pnshareholder,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.usoft.credit.dal.entity.PersonJsonWithBLOBs">
    update t_person_json
    <set>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="personname != null">
        personname = #{personname,jdbcType=VARCHAR},
      </if>
      <if test="documentno != null">
        documentno = #{documentno,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        create_date = #{createDate,jdbcType=DATE},
      </if>
      <if test="pnidentity != null">
        pnidentity = #{pnidentity,jdbcType=LONGVARCHAR},
      </if>
      <if test="pnshareholder != null">
        pnshareholder = #{pnshareholder,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.usoft.credit.dal.entity.PersonJsonWithBLOBs">
    update t_person_json
    set code = #{code,jdbcType=VARCHAR},
      personname = #{personname,jdbcType=VARCHAR},
      documentno = #{documentno,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=DATE},
      pnidentity = #{pnidentity,jdbcType=LONGVARCHAR},
      pnshareholder = #{pnshareholder,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.usoft.credit.dal.entity.PersonJson">
    update t_person_json
    set code = #{code,jdbcType=VARCHAR},
      personname = #{personname,jdbcType=VARCHAR},
      documentno = #{documentno,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=DATE}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>