<?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.com.ctop.kuaishou.modules.app.mapper.AppAdMapper">

    <!--	<resultMap id="AppAd" type="cn.com.ctop.kuaishou.modules.app.entity.AppAd" >-->
    <!--		<result column="ksid" property="ksid" jdbcType="BIGINT"/>-->
    <!--		<result column="kaid" property="kaid" jdbcType="BIGINT"/>-->
    <!--		<result column="name" property="name" jdbcType="VARCHAR"/>-->
    <!--		<result column="industry_category" property="industryCategory" jdbcType="VARCHAR"/>-->
    <!--		<result column="first_industry" property="firstIndustry" jdbcType="VARCHAR"/>-->
    <!--		<result column="second_industry" property="secondIndustry" jdbcType="VARCHAR"/>-->
    <!--		<result column="company" property="company" jdbcType="VARCHAR"/>-->
    <!--		<result column="product" property="product" jdbcType="VARCHAR"/>-->
    <!--		<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>-->
    <!--	</resultMap>-->
    <select id="queryAdFeeds" resultType="cn.com.ctop.kuaishou.modules.app.entity.AppAd" statementType="STATEMENT">
        select * from ctop_kuaishou_app_ad where user_id in (
        select ksid from ctop_kuaishou_advertiser_info where 1=1
        <if test="industry != null">
            and (industry_category ='${industry}' or first_industry = '${industry}' or second_industry = '${industry}')
        </if>
        <if test="company != null">
            and company like '%${company}%'
        </if>
        <if test="product != null">
            and product like '%${product}%'
        </if>
        )
        <if test="start != null and end != null">
            and time between '${start} 00:00:00' and '${end} 23:59:59'
        </if>
        <if test="userName != null">
            and user_name like '%${userName}%'
        </if>
        order by ${orderByColumn} ${orderByType}
        limit ${pageStart},${pageSize}
    </select>
</mapper>