<?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.zcloud.basic.info.persistence.mapper.CorpInfoMapper">

    <select id="corpUserMiddlePage" resultType="com.zcloud.basic.info.persistence.dataobject.CorpInfoDO">
        SELECT c.*
        FROM corp_info c
        LEFT JOIN corp_form f ON c.id = f.info_id
        WHERE
        c.delete_enum='false'
        <if test="params.type != null">
            AND c.type IN
            <foreach collection="params.type" item="type" open="(" close=")" separator=",">
                #{type}
            </foreach>
        </if>
        <if test="params.selectFrom != null and params.selectFrom.trim() != ''">
            AND f.item_code = #{params.selectFrom}
        </if>
        <if test="params.likeCorpName != null and params.likeCorpName.trim() != ''">
            AND c.corp_name like concat('%',#{params.likeCorpName},'%')
        </if>
        <if test="params.eqProvince != null and params.eqProvince.trim() != ''">
            AND c.province = #{params.eqProvince}
        </if>
        <if test="params.eqCity != null and params.eqCity.trim() != ''">
            AND c.city = #{params.eqCity}
        </if>
        <if test="params.eqCountry != null and params.eqCountry.trim() != ''">
            AND c.country = #{params.eqCountry}
        </if>
        <if test="params.eqStreet != null and params.eqStreet.trim() != ''">
            AND c.street = #{params.eqStreet}
        </if>
        <if test="params.eqVillage != null and params.eqVillage.trim() != ''">
            AND c.village = #{params.eqVillage}
        </if>
        group by c.id
        ORDER BY
        c.corp_order ASC,
        c.create_time DESC
    </select>

    <select id="selectUserPage" resultType="com.zcloud.basic.info.persistence.dataobject.CorpInfoDO">
        SELECT *
        FROM corp_info
            ${ew.customSqlSegment}
    </select>
</mapper>

