<?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.TfInfoEnterpriseDao">

    <resultMap id="BaseResultMap" type="com.bootdo.data.entity.TfInfoEnterprise">
        <!--@Table tf_info_enterprise-->
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="uniformSocialCreditCode" column="uniform_social_credit_code" jdbcType="VARCHAR"/>
        <result property="companyName" column="company_name" jdbcType="VARCHAR"/>
        <result property="password" column="password" jdbcType="VARCHAR"/>
        <result property="contacts" column="contacts" jdbcType="VARCHAR"/>
        <result property="industry" column="industry" jdbcType="VARCHAR"/>
        <result property="mobile" column="mobile" jdbcType="VARCHAR"/>
        <result property="address" column="address" jdbcType="VARCHAR"/>
        <result property="email" column="email" jdbcType="VARCHAR"/>
        <result property="state" column="state" jdbcType="OTHER"/>
        <result property="province" column="province" jdbcType="VARCHAR"/>
        <result property="city" column="city" jdbcType="VARCHAR"/>
        <result property="district" column="district" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="serviceType" column="service_type" jdbcType="VARCHAR"/>
        <result property="asOfDate" column="as_of_date" jdbcType="TIMESTAMP"/>
        <result property="businessLicence" column="business_licence" jdbcType="VARCHAR"/>
        <result property="creditChina" column="credit_china" jdbcType="VARCHAR"/>
        <result property="taxRegistrationNumber" column="tax_registration_number" jdbcType="VARCHAR"/>
        <result property="registrationNumber" column="registration_number" jdbcType="VARCHAR"/>
        <result property="organizationCode" column="organization_code" jdbcType="VARCHAR"/>
        <result property="settlingBank" column="settling_bank" jdbcType="VARCHAR"/>
        <result property="effectTime" column="effect_time" jdbcType="VARCHAR"/>
        <result property="expirationTime" column="expiration_time" jdbcType="VARCHAR"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="BaseResultMap">
        select
          id, uniform_social_credit_code, company_name, password, contacts, industry, mobile, address, email, state, province, city, district, create_time, update_time, service_type, as_of_date, business_licence, credit_china, tax_registration_number, registration_number, organization_code, settling_bank, effect_time, expiration_time
        from tf_info_enterprise
        where id = #{id}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="BaseResultMap">
        select
          id, uniform_social_credit_code, company_name, password, contacts, industry, mobile, address, email, state, province, city, district, create_time, update_time, service_type, as_of_date, business_licence, credit_china, tax_registration_number, registration_number, organization_code, settling_bank, effect_time, expiration_time
        from tf_info_enterprise
        limit #{offset}, #{limit}
    </select>

    <!--通过实体作为筛选条件查询-->
    <select id="queryAll" resultMap="BaseResultMap">
        select
          id, uniform_social_credit_code, company_name, password, contacts, industry, mobile, address, email, state, province, city, district, create_time, update_time, service_type, as_of_date, business_licence, credit_china, tax_registration_number, registration_number, organization_code, settling_bank, effect_time, expiration_time
        from tf_info_enterprise
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="uniformSocialCreditCode != null and uniformSocialCreditCode != ''">
                and uniform_social_credit_code = #{uniformSocialCreditCode}
            </if>
            <if test="companyName != null and companyName != ''">
                and company_name = #{companyName}
            </if>
            <if test="password != null and password != ''">
                and password = #{password}
            </if>
            <if test="contacts != null and contacts != ''">
                and contacts = #{contacts}
            </if>
            <if test="industry != null and industry != ''">
                and industry = #{industry}
            </if>
            <if test="mobile != null and mobile != ''">
                and mobile = #{mobile}
            </if>
            <if test="address != null and address != ''">
                and address = #{address}
            </if>
            <if test="email != null and email != ''">
                and email = #{email}
            </if>
            <if test="state != null">
                and state = #{state}
            </if>
            <if test="province != null and province != ''">
                and province = #{province}
            </if>
            <if test="city != null and city != ''">
                and city = #{city}
            </if>
            <if test="district != null and district != ''">
                and district = #{district}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
            <if test="serviceType != null and serviceType != ''">
                and service_type = #{serviceType}
            </if>
            <if test="asOfDate != null">
                and as_of_date = #{asOfDate}
            </if>
            <if test="businessLicence != null and businessLicence != ''">
                and business_licence = #{businessLicence}
            </if>
            <if test="creditChina != null and creditChina != ''">
                and credit_china = #{creditChina}
            </if>
            <if test="taxRegistrationNumber != null and taxRegistrationNumber != ''">
                and tax_registration_number = #{taxRegistrationNumber}
            </if>
            <if test="registrationNumber != null and registrationNumber != ''">
                and registration_number = #{registrationNumber}
            </if>
            <if test="organizationCode != null and organizationCode != ''">
                and organization_code = #{organizationCode}
            </if>
            <if test="settlingBank != null and settlingBank != ''">
                and settling_bank = #{settlingBank}
            </if>
            <if test="effectTime != null and effectTime != ''">
                and effect_time = #{effectTime}
            </if>
            <if test="expirationTime != null and expirationTime != ''">
                and expiration_time = #{expirationTime}
            </if>
        </where>
    </select>

    <select id="queryPage" resultMap="BaseResultMap">
        select
          id, uniform_social_credit_code, company_name, password, contacts, industry, mobile, address, email, state, province, city, district, create_time, update_time, service_type, as_of_date, business_licence, credit_china, tax_registration_number, registration_number, organization_code, settling_bank, effect_time, expiration_time
        from tf_info_enterprise
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="uniformSocialCreditCode != null and uniformSocialCreditCode != ''">
                and uniform_social_credit_code = #{uniformSocialCreditCode}
            </if>
            <if test="companyName != null and companyName != ''">
                and company_name = #{companyName}
            </if>
            <if test="password != null and password != ''">
                and password = #{password}
            </if>
            <if test="contacts != null and contacts != ''">
                and contacts = #{contacts}
            </if>
            <if test="industry != null and industry != ''">
                and industry = #{industry}
            </if>
            <if test="mobile != null and mobile != ''">
                and mobile = #{mobile}
            </if>
            <if test="address != null and address != ''">
                and address = #{address}
            </if>
            <if test="email != null and email != ''">
                and email = #{email}
            </if>
            <if test="state != null">
                and state = #{state}
            </if>
            <if test="province != null and province != ''">
                and province = #{province}
            </if>
            <if test="city != null and city != ''">
                and city = #{city}
            </if>
            <if test="district != null and district != ''">
                and district = #{district}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
            <if test="serviceType != null and serviceType != ''">
                and service_type = #{serviceType}
            </if>
            <if test="asOfDate != null">
                and as_of_date = #{asOfDate}
            </if>
            <if test="businessLicence != null and businessLicence != ''">
                and business_licence = #{businessLicence}
            </if>
            <if test="creditChina != null and creditChina != ''">
                and credit_china = #{creditChina}
            </if>
            <if test="taxRegistrationNumber != null and taxRegistrationNumber != ''">
                and tax_registration_number = #{taxRegistrationNumber}
            </if>
            <if test="registrationNumber != null and registrationNumber != ''">
                and registration_number = #{registrationNumber}
            </if>
            <if test="organizationCode != null and organizationCode != ''">
                and organization_code = #{organizationCode}
            </if>
            <if test="settlingBank != null and settlingBank != ''">
                and settling_bank = #{settlingBank}
            </if>
            <if test="effectTime != null and effectTime != ''">
                and effect_time = #{effectTime}
            </if>
            <if test="expirationTime != null and expirationTime != ''">
                and expiration_time = #{expirationTime}
            </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_info_enterprise
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="uniformSocialCreditCode != null and uniformSocialCreditCode != ''">
                and uniform_social_credit_code = #{uniformSocialCreditCode}
            </if>
            <if test="companyName != null and companyName != ''">
                and company_name = #{companyName}
            </if>
            <if test="password != null and password != ''">
                and password = #{password}
            </if>
            <if test="contacts != null and contacts != ''">
                and contacts = #{contacts}
            </if>
            <if test="industry != null and industry != ''">
                and industry = #{industry}
            </if>
            <if test="mobile != null and mobile != ''">
                and mobile = #{mobile}
            </if>
            <if test="address != null and address != ''">
                and address = #{address}
            </if>
            <if test="email != null and email != ''">
                and email = #{email}
            </if>
            <if test="state != null">
                and state = #{state}
            </if>
            <if test="province != null and province != ''">
                and province = #{province}
            </if>
            <if test="city != null and city != ''">
                and city = #{city}
            </if>
            <if test="district != null and district != ''">
                and district = #{district}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
            <if test="serviceType != null and serviceType != ''">
                and service_type = #{serviceType}
            </if>
            <if test="asOfDate != null">
                and as_of_date = #{asOfDate}
            </if>
            <if test="businessLicence != null and businessLicence != ''">
                and business_licence = #{businessLicence}
            </if>
            <if test="creditChina != null and creditChina != ''">
                and credit_china = #{creditChina}
            </if>
            <if test="taxRegistrationNumber != null and taxRegistrationNumber != ''">
                and tax_registration_number = #{taxRegistrationNumber}
            </if>
            <if test="registrationNumber != null and registrationNumber != ''">
                and registration_number = #{registrationNumber}
            </if>
            <if test="organizationCode != null and organizationCode != ''">
                and organization_code = #{organizationCode}
            </if>
            <if test="settlingBank != null and settlingBank != ''">
                and settling_bank = #{settlingBank}
            </if>
            <if test="effectTime != null and effectTime != ''">
                and effect_time = #{effectTime}
            </if>
            <if test="expirationTime != null and expirationTime != ''">
                and expiration_time = #{expirationTime}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
        insert into tf_info_enterprise(uniform_social_credit_code, company_name, password, contacts, industry, mobile, address, email, state, province, city, district, create_time, update_time, service_type, as_of_date, business_licence, credit_china, tax_registration_number, registration_number, organization_code, settling_bank, effect_time, expiration_time)
        values (#{uniformSocialCreditCode}, #{companyName}, #{password}, #{contacts}, #{industry}, #{mobile}, #{address}, #{email}, #{state}, #{province}, #{city}, #{district}, #{createTime}, #{updateTime}, #{serviceType}, #{asOfDate}, #{businessLicence}, #{creditChina}, #{taxRegistrationNumber}, #{registrationNumber}, #{organizationCode}, #{settlingBank}, #{effectTime}, #{expirationTime})
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update tf_info_enterprise
        <set>
            <if test="uniformSocialCreditCode != null and uniformSocialCreditCode != ''">
                uniform_social_credit_code = #{uniformSocialCreditCode},
            </if>
            <if test="companyName != null and companyName != ''">
                company_name = #{companyName},
            </if>
            <if test="password != null and password != ''">
                password = #{password},
            </if>
            <if test="contacts != null and contacts != ''">
                contacts = #{contacts},
            </if>
            <if test="industry != null and industry != ''">
                industry = #{industry},
            </if>
            <if test="mobile != null and mobile != ''">
                mobile = #{mobile},
            </if>
            <if test="address != null and address != ''">
                address = #{address},
            </if>
            <if test="email != null and email != ''">
                email = #{email},
            </if>
            <if test="state != null">
                state = #{state},
            </if>
            <if test="province != null and province != ''">
                province = #{province},
            </if>
            <if test="city != null and city != ''">
                city = #{city},
            </if>
            <if test="district != null and district != ''">
                district = #{district},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime},
            </if>
            <if test="serviceType != null and serviceType != ''">
                service_type = #{serviceType},
            </if>
            <if test="asOfDate != null">
                as_of_date = #{asOfDate},
            </if>
            <if test="businessLicence != null and businessLicence != ''">
                business_licence = #{businessLicence},
            </if>
            <if test="creditChina != null and creditChina != ''">
                credit_china = #{creditChina},
            </if>
            <if test="taxRegistrationNumber != null and taxRegistrationNumber != ''">
                tax_registration_number = #{taxRegistrationNumber},
            </if>
            <if test="registrationNumber != null and registrationNumber != ''">
                registration_number = #{registrationNumber},
            </if>
            <if test="organizationCode != null and organizationCode != ''">
                organization_code = #{organizationCode},
            </if>
            <if test="settlingBank != null and settlingBank != ''">
                settling_bank = #{settlingBank},
            </if>
            <if test="effectTime != null and effectTime != ''">
                effect_time = #{effectTime},
            </if>
            <if test="expirationTime != null and expirationTime != ''">
                expiration_time = #{expirationTime},
            </if>
        </set>
        where id = #{id}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from tf_info_enterprise where id = #{id}
    </delete>

    <select id="loginQuery" resultMap="BaseResultMap">
        select
          id, uniform_social_credit_code, company_name, password, contacts, industry, mobile, address, email, state, province, city, district, create_time, update_time, service_type, as_of_date, business_licence, credit_china, tax_registration_number, registration_number, organization_code, settling_bank, effect_time, expiration_time
        from tf_info_enterprise
        <where>
            <if test="uniformSocialCreditCode != null and uniformSocialCreditCode != ''">
                and uniform_social_credit_code = #{uniformSocialCreditCode}
            </if>
            <if test="companyName != null and companyName != ''">
                and company_name = #{companyName}
            </if>
            <if test="password != null and password != ''">
                and password = #{password}
            </if>
            and state = 1
        </where>
    </select>

</mapper>