<?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.ningdatech.carapi.company.mapper.NdCompanySecurityProductRegulationsMapper">

    <select id="securityProductRegulationsList"
            resultType="com.ningdatech.carapi.company.entity.dto.ResSecurityProductRegulationsDTO">
        SELECT
        ncspr.file_path AS filePath,
        ncspr.file_type AS fileType,
        ncspr.create_on AS createOn,
        ncspr.regulations_name AS regulationsName,
        ncspr.competent_department AS competentDepartment
        FROM nd_company_security_product_regulations ncspr
        left join nd_company_info c on ncspr.company_id = c.id
        left join nd_region r on ncspr.region_id = r.id
        <where>
            1 = 1
            AND ncspr.file_type = #{po.fileType}
            <if test="po.startTime != null and po.startTime != ''">
                AND ncspr.create_on <![CDATA[ >= ]]> #{po.startTime}
            </if>

            <if test="po.endTime != null and po.endTime != ''">
                AND ncspr.create_on <![CDATA[ <= ]]> #{po.endTime}
            </if>

            <if test="po.regulationsName != null and po.regulationsName != ''">
                AND ncspr.regulations_name LIKE CONCAT(CONCAT('%',
                #{po.regulationsName}),'%')
            </if>

            <if test="po.competentDepartment != null and po.competentDepartment != ''">
                AND ncspr.competent_department LIKE CONCAT(CONCAT('%',
                #{po.competentDepartment}),'%')
            </if>
        </where>
        ${po.dataScopeSql}
        ORDER BY ncspr.id DESC
    </select>
</mapper>
