<?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.sckw.system.dao.KwsEntSpecialDao">

    <select id="findList" resultType="com.sckw.system.model.KwsEntSpecial" parameterType="java.util.Map" >
        SELECT
        id, special_id specialId, ent_id entId, remark, status, create_by createBy,
        create_time createTime, update_by updateBy, update_time updateTime
        from kws_ent_special
        where del_flag = 0
        <if test="entId != null and entId != ''">
            and ent_id = #{entId, jdbcType=BIGINT}
        </if>
        <if test="specialId != null and specialId != ''">
            and special_id = #{specialId, jdbcType=BIGINT}
        </if>
        ORDER BY create_time desc
    </select>

    <select id="findListByEntType" parameterType="java.util.Map" >
        select
        DISTINCT ke.id entId
        from kws_enterprise ke
        left join kws_ent_type ket on ket.ent_id = ke.id and ket.del_flag = 0
        left join kws_ent_special kes on kes.ent_id = ke.id and kes.del_flag = 0
        where ke.del_flag = 0
        <if test="entId != null and entId != ''">
            and ke.id = #{entId, jdbcType=BIGINT}
        </if>
        <if test="specialId != null and specialId != ''">
            and kes.special_id = #{specialId, jdbcType=BIGINT}
        </if>
        <if test="mainPlatform != null and mainPlatform != ''">
            and kes.special_id is null
        </if>
        <if test="type != null and type != ''">
            and FIND_IN_SET(ket.type, #{type})
        </if>
    </select>

</mapper>