<?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.yunzhi.marketing.xlk.mapper.VideoMapper">

    <select id="getWxVideoActiveList" resultType="com.yunzhi.marketing.xlk.entity.Video">
        SELECT
         t.*
        FROM
        xlk_video t
        LEFT JOIN ta_building a ON t.building_id = a.building_id
        LEFT JOIN td_city b ON t.city_id = b.id
        where t.org_id = #{orgId}
        and t.is_publish = 1
        <if test="name != null and name != ''">
            and (t.NAME like CONCAT('%', #{name}, '%') or a.building_name like CONCAT('%', #{name}, '%'))
        </if>
        <if test="cityId != null">
            and (t.city_id is null or t.city_id = #{cityId})
        </if>
        <if test="buildingId != null and buildingId != ''">
            and t.building_id = #{buildingId}
        </if>
    </select>
</mapper>
