<?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.bootdo.data.dao.CaInfoMapper">
  <resultMap id="BaseResultMap" type="com.bootdo.data.domain.CaInfo">
    
    <!--@Table tf_ca_info-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="uniform_social_credit_code" jdbcType="VARCHAR" property="uniformSocialCreditCode" />
    <result column="company_name" jdbcType="VARCHAR" property="companyName" />
    <result column="taxation_num" jdbcType="VARCHAR" property="taxationNum" />
    <result column="connect_address" jdbcType="VARCHAR" property="connectAddress" />
    <result column="connect_name" jdbcType="VARCHAR" property="connectName" />
    <result column="connect_phone" jdbcType="VARCHAR" property="connectPhone" />
    <result column="connect_email" jdbcType="VARCHAR" property="connectEmail" />
    <result column="effective_time_beige" jdbcType="TIMESTAMP" property="effectiveTimeBeige" />
    <result column="effective_time_end" jdbcType="TIMESTAMP" property="effectiveTimeEnd" />
    <result column="file_path" jdbcType="VARCHAR" property="filePath" />
    <result column="ca_status" jdbcType="TINYINT" property="caStatus" />
    <result column="ca_detail_id" jdbcType="INTEGER" property="caDetailId" />
    <result column="crate_time" jdbcType="TIMESTAMP" property="crateTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
  </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, uniform_social_credit_code, company_name, taxation_num, connect_address, connect_name, 
    connect_phone, connect_email, effective_time_beige, effective_time_end, file_path, 
    ca_status, ca_detail_id, crate_time, update_time, remark
  </sql>

  <select id="queryPage" resultMap="BaseResultMap">
        select
          id, uniform_social_credit_code, company_name, taxation_num, connect_address, connect_name,
            connect_phone, connect_email, effective_time_beige, effective_time_end, file_path,
            ca_status, ca_detail_id, crate_time, update_time, remark
        from  tf_ca_info
        <where>
              <if test="id != null">
                 and id = #{id,jdbcType=INTEGER}
              </if>
              <if test="uniformSocialCreditCode != null  and uniformSocialCreditCode != ''">
                and uniform_social_credit_code = #{uniformSocialCreditCode,jdbcType=VARCHAR}
              </if>
              <if test="companyName != null and companyName != ''">
                and company_name = #{companyName,jdbcType=VARCHAR}
              </if>
              <if test="taxationNum != null and taxationNum != ''">
                and taxation_num = #{taxationNum,jdbcType=VARCHAR}
              </if>
              <if test="connectAddress != null and connectAddress != ''">
                and connect_address = #{connectAddress,jdbcType=VARCHAR}
              </if>
              <if test="connectName != null and connectName != ''">
                and connect_name = #{connectName,jdbcType=VARCHAR}
              </if>
              <if test="connectPhone != null and connectPhone != ''">
                and connect_phone = #{connectPhone,jdbcType=VARCHAR}
              </if>
              <if test="connectEmail != null and connectEmail != ''">
                and connect_email = #{connectEmail,jdbcType=VARCHAR}
              </if>
              <if test="effectiveTimeBeige != null and effectiveTimeBeige != ''">
                and effective_time_beige = #{effectiveTimeBeige,jdbcType=TIMESTAMP}
              </if>
              <if test="effectiveTimeEnd != null and effectiveTimeEnd != ''">
                and effective_time_end = #{effectiveTimeEnd,jdbcType=TIMESTAMP}
              </if>
              <if test="filePath != null and filePath != ''">
                and file_path = #{filePath,jdbcType=VARCHAR}
              </if>
              <if test="caStatus != null and caStatus != ''">
                and ca_status = #{caStatus,jdbcType=TINYINT}
              </if>
              <if test="caDetailId != null and caDetailId != ''">
                and ca_detail_id = #{caDetailId,jdbcType=INTEGER}
              </if>
              <if test="crateTime != null and crateTime != ''">
                and crate_time = #{crateTime,jdbcType=TIMESTAMP}
              </if>
              <if test="updateTime != null and updateTime != ''">
                and update_time = #{updateTime,jdbcType=TIMESTAMP}
              </if>
              <if test="remark != null and remark != ''">
                and remark = #{remark,jdbcType=VARCHAR}
              </if>
        </where>
        <choose>
            <when test="sort != null and sort.trim() != ''">
                order by ${sort} ${order}
            </when>
            <otherwise>
                order by id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryPageCount" resultType="java.lang.Integer">
        select
          count(id)
        from  tf_ca_info
        <where>
              <if test="id != null">
                 and id = #{id,jdbcType=INTEGER}
              </if>
              <if test="uniformSocialCreditCode != null">
                and uniform_social_credit_code = #{uniformSocialCreditCode,jdbcType=VARCHAR}
              </if>
              <if test="companyName != null">
                and company_name = #{companyName,jdbcType=VARCHAR}
              </if>
              <if test="taxationNum != null">
                and taxation_num = #{taxationNum,jdbcType=VARCHAR}
              </if>
              <if test="connectAddress != null">
                and connect_address = #{connectAddress,jdbcType=VARCHAR}
              </if>
              <if test="connectName != null">
                and connect_name = #{connectName,jdbcType=VARCHAR}
              </if>
              <if test="connectPhone != null">
                and connect_phone = #{connectPhone,jdbcType=VARCHAR}
              </if>
              <if test="connectEmail != null">
                and connect_email = #{connectEmail,jdbcType=VARCHAR}
              </if>
              <if test="effectiveTimeBeige != null">
                and effective_time_beige = #{effectiveTimeBeige,jdbcType=TIMESTAMP}
              </if>
              <if test="effectiveTimeEnd != null">
                and effective_time_end = #{effectiveTimeEnd,jdbcType=TIMESTAMP}
              </if>
              <if test="filePath != null">
                and file_path = #{filePath,jdbcType=VARCHAR}
              </if>
              <if test="caStatus != null">
                and ca_status = #{caStatus,jdbcType=TINYINT}
              </if>
              <if test="caDetailId != null">
                and ca_detail_id = #{caDetailId,jdbcType=INTEGER}
              </if>
              <if test="crateTime != null">
                and crate_time = #{crateTime,jdbcType=TIMESTAMP}
              </if>
              <if test="updateTime != null">
                and update_time = #{updateTime,jdbcType=TIMESTAMP}
              </if>
              <if test="remark != null">
                and remark = #{remark,jdbcType=VARCHAR}
              </if>
        </where>
    </select>

  <select id="selectByExample" parameterType="com.bootdo.data.domain.CaInfoExample" resultMap="BaseResultMap">
    
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from tf_ca_info
    <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.Integer" resultMap="BaseResultMap">
    
    select 
    <include refid="Base_Column_List" />
    from tf_ca_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    
    delete from tf_ca_info
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.bootdo.data.domain.CaInfoExample">
    
    delete from tf_ca_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bootdo.data.domain.CaInfo" useGeneratedKeys="true">
    
    insert into tf_ca_info (uniform_social_credit_code, company_name, 
      taxation_num, connect_address, connect_name, 
      connect_phone, connect_email, effective_time_beige, 
      effective_time_end, file_path, ca_status, 
      ca_detail_id, crate_time, update_time, 
      remark)
    values (#{uniformSocialCreditCode,jdbcType=VARCHAR}, #{companyName,jdbcType=VARCHAR}, 
      #{taxationNum,jdbcType=VARCHAR}, #{connectAddress,jdbcType=VARCHAR}, #{connectName,jdbcType=VARCHAR}, 
      #{connectPhone,jdbcType=VARCHAR}, #{connectEmail,jdbcType=VARCHAR}, #{effectiveTimeBeige,jdbcType=TIMESTAMP}, 
      #{effectiveTimeEnd,jdbcType=TIMESTAMP}, #{filePath,jdbcType=VARCHAR}, #{caStatus,jdbcType=TINYINT}, 
      #{caDetailId,jdbcType=INTEGER}, #{crateTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, 
      #{remark,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bootdo.data.domain.CaInfo" useGeneratedKeys="true">
    
    insert into tf_ca_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="uniformSocialCreditCode != null">
        uniform_social_credit_code,
      </if>
      <if test="companyName != null">
        company_name,
      </if>
      <if test="taxationNum != null">
        taxation_num,
      </if>
      <if test="connectAddress != null">
        connect_address,
      </if>
      <if test="connectName != null">
        connect_name,
      </if>
      <if test="connectPhone != null">
        connect_phone,
      </if>
      <if test="connectEmail != null">
        connect_email,
      </if>
      <if test="effectiveTimeBeige != null">
        effective_time_beige,
      </if>
      <if test="effectiveTimeEnd != null">
        effective_time_end,
      </if>
      <if test="filePath != null">
        file_path,
      </if>
      <if test="caStatus != null">
        ca_status,
      </if>
      <if test="caDetailId != null">
        ca_detail_id,
      </if>
      <if test="crateTime != null">
        crate_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="remark != null">
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="uniformSocialCreditCode != null">
        #{uniformSocialCreditCode,jdbcType=VARCHAR},
      </if>
      <if test="companyName != null">
        #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="taxationNum != null">
        #{taxationNum,jdbcType=VARCHAR},
      </if>
      <if test="connectAddress != null">
        #{connectAddress,jdbcType=VARCHAR},
      </if>
      <if test="connectName != null">
        #{connectName,jdbcType=VARCHAR},
      </if>
      <if test="connectPhone != null">
        #{connectPhone,jdbcType=VARCHAR},
      </if>
      <if test="connectEmail != null">
        #{connectEmail,jdbcType=VARCHAR},
      </if>
      <if test="effectiveTimeBeige != null">
        #{effectiveTimeBeige,jdbcType=TIMESTAMP},
      </if>
      <if test="effectiveTimeEnd != null">
        #{effectiveTimeEnd,jdbcType=TIMESTAMP},
      </if>
      <if test="filePath != null">
        #{filePath,jdbcType=VARCHAR},
      </if>
      <if test="caStatus != null">
        #{caStatus,jdbcType=TINYINT},
      </if>
      <if test="caDetailId != null">
        #{caDetailId,jdbcType=INTEGER},
      </if>
      <if test="crateTime != null">
        #{crateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.bootdo.data.domain.CaInfoExample" resultType="java.lang.Long">
    
    select count(*) from tf_ca_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    
    update tf_ca_info
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.uniformSocialCreditCode != null">
        uniform_social_credit_code = #{record.uniformSocialCreditCode,jdbcType=VARCHAR},
      </if>
      <if test="record.companyName != null">
        company_name = #{record.companyName,jdbcType=VARCHAR},
      </if>
      <if test="record.taxationNum != null">
        taxation_num = #{record.taxationNum,jdbcType=VARCHAR},
      </if>
      <if test="record.connectAddress != null">
        connect_address = #{record.connectAddress,jdbcType=VARCHAR},
      </if>
      <if test="record.connectName != null">
        connect_name = #{record.connectName,jdbcType=VARCHAR},
      </if>
      <if test="record.connectPhone != null">
        connect_phone = #{record.connectPhone,jdbcType=VARCHAR},
      </if>
      <if test="record.connectEmail != null">
        connect_email = #{record.connectEmail,jdbcType=VARCHAR},
      </if>
      <if test="record.effectiveTimeBeige != null">
        effective_time_beige = #{record.effectiveTimeBeige,jdbcType=TIMESTAMP},
      </if>
      <if test="record.effectiveTimeEnd != null">
        effective_time_end = #{record.effectiveTimeEnd,jdbcType=TIMESTAMP},
      </if>
      <if test="record.filePath != null">
        file_path = #{record.filePath,jdbcType=VARCHAR},
      </if>
      <if test="record.caStatus != null">
        ca_status = #{record.caStatus,jdbcType=TINYINT},
      </if>
      <if test="record.caDetailId != null">
        ca_detail_id = #{record.caDetailId,jdbcType=INTEGER},
      </if>
      <if test="record.crateTime != null">
        crate_time = #{record.crateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.remark != null">
        remark = #{record.remark,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    
    update tf_ca_info
    set id = #{record.id,jdbcType=INTEGER},
      uniform_social_credit_code = #{record.uniformSocialCreditCode,jdbcType=VARCHAR},
      company_name = #{record.companyName,jdbcType=VARCHAR},
      taxation_num = #{record.taxationNum,jdbcType=VARCHAR},
      connect_address = #{record.connectAddress,jdbcType=VARCHAR},
      connect_name = #{record.connectName,jdbcType=VARCHAR},
      connect_phone = #{record.connectPhone,jdbcType=VARCHAR},
      connect_email = #{record.connectEmail,jdbcType=VARCHAR},
      effective_time_beige = #{record.effectiveTimeBeige,jdbcType=TIMESTAMP},
      effective_time_end = #{record.effectiveTimeEnd,jdbcType=TIMESTAMP},
      file_path = #{record.filePath,jdbcType=VARCHAR},
      ca_status = #{record.caStatus,jdbcType=TINYINT},
      ca_detail_id = #{record.caDetailId,jdbcType=INTEGER},
      crate_time = #{record.crateTime,jdbcType=TIMESTAMP},
      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      remark = #{record.remark,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.bootdo.data.domain.CaInfo">
    
    update tf_ca_info
    <set>
      <if test="uniformSocialCreditCode != null">
        uniform_social_credit_code = #{uniformSocialCreditCode,jdbcType=VARCHAR},
      </if>
      <if test="companyName != null">
        company_name = #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="taxationNum != null">
        taxation_num = #{taxationNum,jdbcType=VARCHAR},
      </if>
      <if test="connectAddress != null">
        connect_address = #{connectAddress,jdbcType=VARCHAR},
      </if>
      <if test="connectName != null">
        connect_name = #{connectName,jdbcType=VARCHAR},
      </if>
      <if test="connectPhone != null">
        connect_phone = #{connectPhone,jdbcType=VARCHAR},
      </if>
      <if test="connectEmail != null">
        connect_email = #{connectEmail,jdbcType=VARCHAR},
      </if>
      <if test="effectiveTimeBeige != null">
        effective_time_beige = #{effectiveTimeBeige,jdbcType=TIMESTAMP},
      </if>
      <if test="effectiveTimeEnd != null">
        effective_time_end = #{effectiveTimeEnd,jdbcType=TIMESTAMP},
      </if>
      <if test="filePath != null">
        file_path = #{filePath,jdbcType=VARCHAR},
      </if>
      <if test="caStatus != null">
        ca_status = #{caStatus,jdbcType=TINYINT},
      </if>
      <if test="caDetailId != null">
        ca_detail_id = #{caDetailId,jdbcType=INTEGER},
      </if>
      <if test="crateTime != null">
        crate_time = #{crateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.bootdo.data.domain.CaInfo">
    update tf_ca_info
    set uniform_social_credit_code = #{uniformSocialCreditCode,jdbcType=VARCHAR},
      company_name = #{companyName,jdbcType=VARCHAR},
      taxation_num = #{taxationNum,jdbcType=VARCHAR},
      connect_address = #{connectAddress,jdbcType=VARCHAR},
      connect_name = #{connectName,jdbcType=VARCHAR},
      connect_phone = #{connectPhone,jdbcType=VARCHAR},
      connect_email = #{connectEmail,jdbcType=VARCHAR},
      effective_time_beige = #{effectiveTimeBeige,jdbcType=TIMESTAMP},
      effective_time_end = #{effectiveTimeEnd,jdbcType=TIMESTAMP},
      file_path = #{filePath,jdbcType=VARCHAR},
      ca_status = #{caStatus,jdbcType=TINYINT},
      ca_detail_id = #{caDetailId,jdbcType=INTEGER},
      crate_time = #{crateTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      remark = #{remark,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="getByCompanyNameAndUniformSocialCreditCode" resultMap="BaseResultMap">
    SELECT
        <include refid="Base_Column_List" />
    FROM
        tf_ca_info
    WHERE
        company_name = #{companyName}
        AND uniform_social_credit_code = #{uniformSocialCreditCode}
        AND ca_status != 0
    ORDER BY
        crate_time desc
        LIMIT 0,1
  </select>
</mapper>