<?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.iocoder.yudao.module.jx.mapper.DriveSchoolCredentialsMapper">

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolCredentials" id="DriveSchoolCredentialsResult">
        <result property="id"    column="id"    />
        <result property="schoolName"    column="school_name"    />
        <result property="businessLicenseNumber"    column="business_license_number"    />
        <result property="legalRepresentative"    column="legal_representative"    />
        <result property="legalIdNumber"    column="legal_id_number"    />
        <result property="bankAccountName"    column="bank_account_name"    />
        <result property="bankAccountNumber"    column="bank_account_number"    />
        <result property="bankName"    column="bank_name"    />
        <result property="bankBranch"    column="bank_branch"    />
        <result property="licenseIssueDate"    column="license_issue_date"    />
        <result property="licenseExpiryDate"    column="license_expiry_date"    />
        <result property="registrationCertificateNumber"    column="registration_certificate_number"    />
        <result property="registrationCertificateIssueDate"    column="registration_certificate_issue_date"    />
        <result property="registrationCertificateExpiryDate"    column="registration_certificate_expiry_date"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
        <result property="filingCover"    column="filing_cover"    />
        <result property="businessLicenseCover"    column="business_icense_cover"    />
        <result property="deptId"    column="dept_id"    />
    </resultMap>

    <sql id="selectDriveSchoolCredentialsVo">
        select id, school_name, business_license_number, legal_representative, legal_id_number, bank_account_name, bank_account_number, bank_name, bank_branch, license_issue_date, license_expiry_date, registration_certificate_number, registration_certificate_issue_date, registration_certificate_expiry_date, create_time, creator, update_time, updater, filing_cover, business_icense_cover, dept_id from drive_school_credentials
    </sql>

    <select id="selectDriveSchoolCredentialsList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCredentials" resultMap="DriveSchoolCredentialsResult">
        <include refid="selectDriveSchoolCredentialsVo"/>
        <where>
            deleted = 0
            <if test="entity.schoolName != null  and entity.schoolName != ''"> and school_name like concat('%', #{entity.schoolName}, '%')</if>
            <if test="entity.businessLicenseNumber != null  and entity.businessLicenseNumber != ''"> and business_license_number = #{entity.businessLicenseNumber}</if>
            <if test="entity.legalRepresentative != null  and entity.legalRepresentative != ''"> and legal_representative like concat('%', #{entity.legalRepresentative}, '%')</if>
            <if test="entity.legalIdNumber != null  and entity.legalIdNumber != ''"> and legal_id_number = #{entity.legalIdNumber}</if>
            <if test="entity.bankAccountName != null  and entity.bankAccountName != ''"> and bank_account_name like concat('%', #{entity.bankAccountName}, '%')</if>
            <if test="entity.bankAccountNumber != null  and entity.bankAccountNumber != ''"> and bank_account_number = #{entity.bankAccountNumber}</if>
            <if test="entity.bankName != null  and entity.bankName != ''"> and bank_name like concat('%', #{entity.bankName}, '%')</if>
            <if test="entity.bankBranch != null  and entity.bankBranch != ''"> and bank_branch like concat('%', #{entity.bankBranch}, '%')</if>
            <if test="entity.licenseIssueDate != null "> and license_issue_date = #{entity.licenseIssueDate}</if>
            <if test="entity.licenseExpiryDate != null "> and license_expiry_date = #{entity.licenseExpiryDate}</if>
            <if test="entity.registrationCertificateNumber != null  and entity.registrationCertificateNumber != ''"> and registration_certificate_number like concat('%', #{entity.registrationCertificateNumber}, '%')</if>
            <if test="entity.registrationCertificateIssueDate != null "> and registration_certificate_issue_date = #{entity.registrationCertificateIssueDate}</if>
            <if test="entity.registrationCertificateExpiryDate != null "> and registration_certificate_expiry_date = #{entity.registrationCertificateExpiryDate}</if>
        </where>
    </select>

    <select id="selectDriveSchoolCredentialsById" parameterType="Long" resultMap="DriveSchoolCredentialsResult">
        <include refid="selectDriveSchoolCredentialsVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolCredentials" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCredentials" useGeneratedKeys="true" keyProperty="id">
        insert into drive_school_credentials
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="schoolName != null and schoolName != ''">school_name,</if>
            <if test="businessLicenseNumber != null and businessLicenseNumber != ''">business_license_number,</if>
            <if test="legalRepresentative != null and legalRepresentative != ''">legal_representative,</if>
            <if test="legalIdNumber != null and legalIdNumber != ''">legal_id_number,</if>
            <if test="bankAccountName != null and bankAccountName != ''">bank_account_name,</if>
            <if test="bankAccountNumber != null and bankAccountNumber != ''">bank_account_number,</if>
            <if test="bankName != null and bankName != ''">bank_name,</if>
            <if test="bankBranch != null and bankBranch != ''">bank_branch,</if>
            <if test="licenseIssueDate != null">license_issue_date,</if>
            <if test="licenseExpiryDate != null">license_expiry_date,</if>
            <if test="registrationCertificateNumber != null">registration_certificate_number,</if>
            <if test="registrationCertificateIssueDate != null">registration_certificate_issue_date,</if>
            <if test="registrationCertificateExpiryDate != null">registration_certificate_expiry_date,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updater != null">updater,</if>
            <if test="filingCover != null">filing_cover,</if>
            <if test="businessLicenseCover != null">business_icense_cover,</if>
            <if test="deptId != null">dept_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="schoolName != null and schoolName != ''">#{schoolName},</if>
            <if test="businessLicenseNumber != null and businessLicenseNumber != ''">#{businessLicenseNumber},</if>
            <if test="legalRepresentative != null and legalRepresentative != ''">#{legalRepresentative},</if>
            <if test="legalIdNumber != null and legalIdNumber != ''">#{legalIdNumber},</if>
            <if test="bankAccountName != null and bankAccountName != ''">#{bankAccountName},</if>
            <if test="bankAccountNumber != null and bankAccountNumber != ''">#{bankAccountNumber},</if>
            <if test="bankName != null and bankName != ''">#{bankName},</if>
            <if test="bankBranch != null and bankBranch != ''">#{bankBranch},</if>
            <if test="licenseIssueDate != null">#{licenseIssueDate},</if>
            <if test="licenseExpiryDate != null">#{licenseExpiryDate},</if>
            <if test="registrationCertificateNumber != null">#{registrationCertificateNumber},</if>
            <if test="registrationCertificateIssueDate != null">#{registrationCertificateIssueDate},</if>
            <if test="registrationCertificateExpiryDate != null">#{registrationCertificateExpiryDate},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updater != null">#{updater},</if>
            <if test="filingCover != null">#{filingCover},</if>
            <if test="businessLicenseCover != null">#{businessLicenseCover},</if>
            <if test="deptId != null">#{deptId},</if>
         </trim>
    </insert>

    <update id="updateDriveSchoolCredentials" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCredentials">
        update drive_school_credentials
        <trim prefix="SET" suffixOverrides=",">
            <if test="schoolName != null and schoolName != ''">school_name = #{schoolName},</if>
            <if test="businessLicenseNumber != null and businessLicenseNumber != ''">business_license_number = #{businessLicenseNumber},</if>
            <if test="legalRepresentative != null and legalRepresentative != ''">legal_representative = #{legalRepresentative},</if>
            <if test="legalIdNumber != null and legalIdNumber != ''">legal_id_number = #{legalIdNumber},</if>
            <if test="bankAccountName != null and bankAccountName != ''">bank_account_name = #{bankAccountName},</if>
            <if test="bankAccountNumber != null and bankAccountNumber != ''">bank_account_number = #{bankAccountNumber},</if>
            <if test="bankName != null and bankName != ''">bank_name = #{bankName},</if>
            <if test="bankBranch != null and bankBranch != ''">bank_branch = #{bankBranch},</if>
            <if test="licenseIssueDate != null">license_issue_date = #{licenseIssueDate},</if>
            <if test="licenseExpiryDate != null">license_expiry_date = #{licenseExpiryDate},</if>
            <if test="registrationCertificateNumber != null">registration_certificate_number = #{registrationCertificateNumber},</if>
            <if test="registrationCertificateIssueDate != null">registration_certificate_issue_date = #{registrationCertificateIssueDate},</if>
            <if test="registrationCertificateExpiryDate != null">registration_certificate_expiry_date = #{registrationCertificateExpiryDate},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updater != null">updater = #{updater},</if>
            <if test="filingCover != null">filing_cover = #{filingCover},</if>
            <if test="businessLicenseCover != null">business_icense_cover = #{businessLicenseCover},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriveSchoolCredentialsById" parameterType="Long">
        delete from drive_school_credentials where id = #{id}
    </delete>

    <delete id="deleteDriveSchoolCredentialsByIds" parameterType="String">
        delete from drive_school_credentials where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
