<?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.flossom.common.core.mapper.SiteInfoMapper">

    <resultMap type="SiteInfo" id="SiteInfoResult">
        <result property="id"    column="id"    />
        <result property="siteType"    column="site_type"    />
        <result property="siteName"    column="site_name"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="siteStartTime"    column="site_start_time"    />
        <result property="siteEndTime"    column="site_end_time"    />
        <result property="userRegisterStartTime"    column="user_register_start_time"    />
        <result property="userRegisterEndTime"    column="user_register_end_time"    />
        <result property="openType"    column="open_type"    />
        <result property="pushType"    column="push_type"    />
        <result property="pushNumber"    column="push_number"    />
        <result property="pushTimer"    column="push_timer"    />
        <result property="showWechatTag"    column="show_wechat_tag"    />
        <result property="showWechatTagId"    column="show_wechat_tag_id"    />
        <result property="showCompanyTag"    column="show_company_tag"    />
        <result property="showCompanyTagId"    column="show_company_tag_id"    />
        <result property="forbidWechatTag"    column="forbid_wechat_tag"    />
        <result property="forbidWechatTagId"    column="forbid_wechat_tag_id"    />
        <result property="forbidCompanyTag"    column="forbid_company_tag"    />
        <result property="handlerCompanyTag"    column="handler_company_tag"    />
        <result property="handlerCompanyTagId"    column="handler_company_tag_id"    />
        <result property="handlerWechatTagId"    column="handler_wechat_tag_id"    />
        <result property="handlerWechatTag"    column="handler_wechat_tag"    />
        <result property="forbidCompanyTagId"    column="forbid_company_tag_id"    />
        <result property="channelName"    column="channel_name"    />
        <result property="channelId"    column="channel_id"    />
        <result property="instrumentName"    column="instrument_name"    />
        <result property="instrumentId"    column="instrument_id"    />
        <result property="userType"    column="user_type"    />
        <result property="operate"    column="operate"    />
        <result property="signNumber"    column="sign_number"    />
        <result property="orderNumber"    column="order_number"    />
        <result property="type"    column="type"    />
        <result property="link"    column="link"    />
        <result property="linkParams"    column="link_params"    />
        <result property="redirectAppid"    column="redirect_appid"    />
        <result property="redirectUrl"    column="redirect_url"    />
        <result property="videoNo"    column="video_no"    />
        <result property="feedId"    column="feed_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSiteInfoVo">
        select id, site_type, site_name, file_url, site_start_time, site_end_time, user_register_start_time, user_register_end_time, open_type, push_type, push_number, push_timer, show_wechat_tag, show_wechat_tag_id, show_company_tag, show_company_tag_id, forbid_wechat_tag, forbid_wechat_tag_id, forbid_company_tag, handler_company_tag, handler_company_tag_id, handler_wechat_tag_id, handler_wechat_tag, forbid_company_tag_id, channel_name, channel_id, instrument_name, instrument_id, user_type, operate, sign_number, order_number, type, link, link_params, redirect_appid, redirect_url, video_no, feed_id, create_by, create_time, update_by, update_time from site_info
    </sql>

    <select id="selectSiteInfoList" parameterType="SiteInfo" resultMap="SiteInfoResult">
        <include refid="selectSiteInfoVo"/>
        <where>
            <if test="siteType != null "> and site_type = #{siteType}</if>
            <if test="siteName != null  and siteName != ''"> and site_name like concat('%', #{siteName}, '%')</if>
            <if test="fileUrl != null  and fileUrl != ''"> and file_url = #{fileUrl}</if>
            <if test="siteStartTime != null "> and site_start_time &gt;= #{siteStartTime}</if>
            <if test="siteEndTime != null "> and site_end_time &lt;= #{siteEndTime}</if>
            <if test="userRegisterStartTime != null "> and user_register_start_time = #{userRegisterStartTime}</if>
            <if test="userRegisterEndTime != null "> and user_register_end_time = #{userRegisterEndTime}</if>
            <if test="openType != null "> and open_type = #{openType}</if>
            <if test="pushType != null "> and push_type = #{pushType}</if>
            <if test="pushNumber != null "> and push_number = #{pushNumber}</if>
            <if test="pushTimer != null  and pushTimer != ''"> and push_timer = #{pushTimer}</if>
            <if test="showWechatTag != null  and showWechatTag != ''"> and show_wechat_tag = #{showWechatTag}</if>
            <if test="showWechatTagId != null  and showWechatTagId != ''"> and show_wechat_tag_id = #{showWechatTagId}</if>
            <if test="showCompanyTag != null  and showCompanyTag != ''"> and show_company_tag = #{showCompanyTag}</if>
            <if test="showCompanyTagId != null  and showCompanyTagId != ''"> and show_company_tag_id = #{showCompanyTagId}</if>
            <if test="forbidWechatTag != null  and forbidWechatTag != ''"> and forbid_wechat_tag = #{forbidWechatTag}</if>
            <if test="forbidWechatTagId != null  and forbidWechatTagId != ''"> and forbid_wechat_tag_id = #{forbidWechatTagId}</if>
            <if test="forbidCompanyTag != null  and forbidCompanyTag != ''"> and forbid_company_tag = #{forbidCompanyTag}</if>
            <if test="handlerCompanyTag != null  and handlerCompanyTag != ''"> and handler_company_tag = #{handlerCompanyTag}</if>
            <if test="handlerCompanyTagId != null  and handlerCompanyTagId != ''"> and handler_company_tag_id = #{handlerCompanyTagId}</if>
            <if test="handlerWechatTagId != null  and handlerWechatTagId != ''"> and handler_wechat_tag_id = #{handlerWechatTagId}</if>
            <if test="handlerWechatTag != null  and handlerWechatTag != ''"> and handler_wechat_tag = #{handlerWechatTag}</if>
            <if test="forbidCompanyTagId != null  and forbidCompanyTagId != ''"> and forbid_company_tag_id = #{forbidCompanyTagId}</if>
            <if test="channelName != null  and channelName != ''"> and channel_name like concat('%', #{channelName}, '%')</if>
            <if test="channelId != null  and channelId != ''"> and channel_id = #{channelId}</if>
            <if test="instrumentName != null  and instrumentName != ''"> and instrument_name like concat('%', #{instrumentName}, '%')</if>
            <if test="instrumentId != null  and instrumentId != ''"> and instrument_id = #{instrumentId}</if>
            <if test="userType != null "> and user_type = #{userType}</if>
            <if test="operate != null "> and operate = #{operate}</if>
            <if test="signNumber != null "> and sign_number = #{signNumber}</if>
            <if test="orderNumber != null "> and order_number = #{orderNumber}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="link != null  and link != ''"> and link = #{link}</if>
            <if test="linkParams != null  and linkParams != ''"> and link_params = #{linkParams}</if>
            <if test="redirectAppid != null  and redirectAppid != ''"> and redirect_appid = #{redirectAppid}</if>
            <if test="redirectUrl != null  and redirectUrl != ''"> and redirect_url = #{redirectUrl}</if>
            <if test="videoNo != null  and videoNo != ''"> and video_no = #{videoNo}</if>
            <if test="feedId != null  and feedId != ''"> and feed_id = #{feedId}</if>
        </where>
        order by order_number desc , create_time desc
    </select>

    <select id="selectSiteInfoById" parameterType="Long" resultMap="SiteInfoResult">
        <include refid="selectSiteInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertSiteInfo" parameterType="SiteInfo" useGeneratedKeys="true" keyProperty="id">
        insert into site_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="siteType != null">site_type,</if>
            <if test="siteName != null">site_name,</if>
            <if test="fileUrl != null">file_url,</if>
            <if test="siteStartTime != null">site_start_time,</if>
            <if test="siteEndTime != null">site_end_time,</if>
            <if test="userRegisterStartTime != null">user_register_start_time,</if>
            <if test="userRegisterEndTime != null">user_register_end_time,</if>
            <if test="openType != null">open_type,</if>
            <if test="pushType != null">push_type,</if>
            <if test="pushNumber != null">push_number,</if>
            <if test="pushTimer != null">push_timer,</if>
            <if test="showWechatTag != null">show_wechat_tag,</if>
            <if test="showWechatTagId != null">show_wechat_tag_id,</if>
            <if test="showCompanyTag != null">show_company_tag,</if>
            <if test="showCompanyTagId != null">show_company_tag_id,</if>
            <if test="forbidWechatTag != null">forbid_wechat_tag,</if>
            <if test="forbidWechatTagId != null">forbid_wechat_tag_id,</if>
            <if test="forbidCompanyTag != null">forbid_company_tag,</if>
            <if test="handlerCompanyTag != null">handler_company_tag,</if>
            <if test="handlerCompanyTagId != null">handler_company_tag_id,</if>
            <if test="handlerWechatTagId != null">handler_wechat_tag_id,</if>
            <if test="handlerWechatTag != null">handler_wechat_tag,</if>
            <if test="forbidCompanyTagId != null">forbid_company_tag_id,</if>
            <if test="channelName != null">channel_name,</if>
            <if test="channelId != null">channel_id,</if>
            <if test="instrumentName != null">instrument_name,</if>
            <if test="instrumentId != null">instrument_id,</if>
            <if test="userType != null">user_type,</if>
            <if test="operate != null">operate,</if>
            <if test="signNumber != null">sign_number,</if>
            <if test="orderNumber != null">order_number,</if>
            <if test="type != null">type,</if>
            <if test="link != null">link,</if>
            <if test="linkParams != null">link_params,</if>
            <if test="redirectAppid != null">redirect_appid,</if>
            <if test="redirectUrl != null">redirect_url,</if>
            <if test="videoNo != null">video_no,</if>
            <if test="feedId != null">feed_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="siteType != null">#{siteType},</if>
            <if test="siteName != null">#{siteName},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="siteStartTime != null">#{siteStartTime},</if>
            <if test="siteEndTime != null">#{siteEndTime},</if>
            <if test="userRegisterStartTime != null">#{userRegisterStartTime},</if>
            <if test="userRegisterEndTime != null">#{userRegisterEndTime},</if>
            <if test="openType != null">#{openType},</if>
            <if test="pushType != null">#{pushType},</if>
            <if test="pushNumber != null">#{pushNumber},</if>
            <if test="pushTimer != null">#{pushTimer},</if>
            <if test="showWechatTag != null">#{showWechatTag},</if>
            <if test="showWechatTagId != null">#{showWechatTagId},</if>
            <if test="showCompanyTag != null">#{showCompanyTag},</if>
            <if test="showCompanyTagId != null">#{showCompanyTagId},</if>
            <if test="forbidWechatTag != null">#{forbidWechatTag},</if>
            <if test="forbidWechatTagId != null">#{forbidWechatTagId},</if>
            <if test="forbidCompanyTag != null">#{forbidCompanyTag},</if>
            <if test="handlerCompanyTag != null">#{handlerCompanyTag},</if>
            <if test="handlerCompanyTagId != null">#{handlerCompanyTagId},</if>
            <if test="handlerWechatTagId != null">#{handlerWechatTagId},</if>
            <if test="handlerWechatTag != null">#{handlerWechatTag},</if>
            <if test="forbidCompanyTagId != null">#{forbidCompanyTagId},</if>
            <if test="channelName != null">#{channelName},</if>
            <if test="channelId != null">#{channelId},</if>
            <if test="instrumentName != null">#{instrumentName},</if>
            <if test="instrumentId != null">#{instrumentId},</if>
            <if test="userType != null">#{userType},</if>
            <if test="operate != null">#{operate},</if>
            <if test="signNumber != null">#{signNumber},</if>
            <if test="orderNumber != null">#{orderNumber},</if>
            <if test="type != null">#{type},</if>
            <if test="link != null">#{link},</if>
            <if test="linkParams != null">#{linkParams},</if>
            <if test="redirectAppid != null">#{redirectAppid},</if>
            <if test="redirectUrl != null">#{redirectUrl},</if>
            <if test="videoNo != null">#{videoNo},</if>
            <if test="feedId != null">#{feedId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateSiteInfo" parameterType="SiteInfo">
        update site_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="siteType != null">site_type = #{siteType},</if>
            <if test="siteName != null">site_name = #{siteName},</if>
            <if test="fileUrl != null">file_url = #{fileUrl},</if>
            site_start_time = #{siteStartTime},
            site_end_time = #{siteEndTime},
            user_register_start_time = #{userRegisterStartTime},
            user_register_end_time = #{userRegisterEndTime},
            <if test="openType != null">open_type = #{openType},</if>
            <if test="pushType != null">push_type = #{pushType},</if>
            <if test="pushNumber != null">push_number = #{pushNumber},</if>
            <if test="pushTimer != null">push_timer = #{pushTimer},</if>
            <if test="showWechatTag != null">show_wechat_tag = #{showWechatTag},</if>
            <if test="showWechatTagId != null">show_wechat_tag_id = #{showWechatTagId},</if>
            <if test="showCompanyTag != null">show_company_tag = #{showCompanyTag},</if>
            <if test="showCompanyTagId != null">show_company_tag_id = #{showCompanyTagId},</if>
            <if test="forbidWechatTag != null">forbid_wechat_tag = #{forbidWechatTag},</if>
            <if test="forbidWechatTagId != null">forbid_wechat_tag_id = #{forbidWechatTagId},</if>
            <if test="forbidCompanyTag != null">forbid_company_tag = #{forbidCompanyTag},</if>
            <if test="handlerCompanyTag != null">handler_company_tag = #{handlerCompanyTag},</if>
            <if test="handlerCompanyTagId != null">handler_company_tag_id = #{handlerCompanyTagId},</if>
            <if test="handlerWechatTagId != null">handler_wechat_tag_id = #{handlerWechatTagId},</if>
            <if test="handlerWechatTag != null">handler_wechat_tag = #{handlerWechatTag},</if>
            <if test="forbidCompanyTagId != null">forbid_company_tag_id = #{forbidCompanyTagId},</if>
            <if test="channelName != null">channel_name = #{channelName},</if>
            <if test="channelId != null">channel_id = #{channelId},</if>
            <if test="instrumentName != null">instrument_name = #{instrumentName},</if>
            <if test="instrumentId != null">instrument_id = #{instrumentId},</if>
            <if test="userType != null">user_type = #{userType},</if>
            <if test="operate != null">operate = #{operate},</if>
            <if test="signNumber != null">sign_number = #{signNumber},</if>
            <if test="orderNumber != null">order_number = #{orderNumber},</if>
            <if test="type != null">type = #{type},</if>
            <if test="link != null">link = #{link},</if>
            <if test="linkParams != null">link_params = #{linkParams},</if>
            <if test="redirectAppid != null">redirect_appid = #{redirectAppid},</if>
            <if test="redirectUrl != null">redirect_url = #{redirectUrl},</if>
            <if test="videoNo != null">video_no = #{videoNo},</if>
            <if test="feedId != null">feed_id = #{feedId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSiteInfoById" parameterType="Long">
        delete from site_info where id = #{id}
    </delete>

    <delete id="deleteSiteInfoByIds" parameterType="String">
        delete from site_info where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
