<?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.FileTypeMapper">
  <resultMap id="BaseResultMap" type="com.usoft.fin.grpc.dal.entity.FileType">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="product_code" jdbcType="VARCHAR" property="productCode" />
    <result column="type" jdbcType="SMALLINT" property="type" />
    <result column="required" jdbcType="SMALLINT" property="required" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="number" jdbcType="SMALLINT" property="number" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
  </resultMap>
  <sql id="Base_Column_List">
    id, code, product_code, type, required, name, number, remark
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_file_type
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_file_type
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.usoft.fin.grpc.dal.entity.FileType">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_file_type (code, product_code, type, 
      required, name, number, 
      remark)
    values (#{code,jdbcType=VARCHAR}, #{productCode,jdbcType=VARCHAR}, #{type,jdbcType=SMALLINT}, 
      #{required,jdbcType=SMALLINT}, #{name,jdbcType=VARCHAR}, #{number,jdbcType=SMALLINT}, 
      #{remark,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.usoft.fin.grpc.dal.entity.FileType">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_file_type
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="productCode != null">
        product_code,
      </if>
      <if test="type != null">
        type,
      </if>
      <if test="required != null">
        required,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="number != null">
        number,
      </if>
      <if test="remark != null">
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="productCode != null">
        #{productCode,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=SMALLINT},
      </if>
      <if test="required != null">
        #{required,jdbcType=SMALLINT},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="number != null">
        #{number,jdbcType=SMALLINT},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.usoft.fin.grpc.dal.entity.FileType">
    update t_file_type
    <set>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="productCode != null">
        product_code = #{productCode,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=SMALLINT},
      </if>
      <if test="required != null">
        required = #{required,jdbcType=SMALLINT},
      </if>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="number != null">
        number = #{number,jdbcType=SMALLINT},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.usoft.fin.grpc.dal.entity.FileType">
    update t_file_type
    set code = #{code,jdbcType=VARCHAR},
      product_code = #{productCode,jdbcType=VARCHAR},
      type = #{type,jdbcType=SMALLINT},
      required = #{required,jdbcType=SMALLINT},
      name = #{name,jdbcType=VARCHAR},
      number = #{number,jdbcType=SMALLINT},
      remark = #{remark,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectByCode" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_file_type
    where code = #{code,jdbcType=VARCHAR}
  </select>
  <sql id="Table_Base_Column_List">
    t_file_type.id, t_file_type.code, t_file_type.product_code, t_file_type.type, t_file_type.required, 
    t_file_type.name, t_file_type.number, t_file_type.remark
  </sql>
</mapper>