ChannelMapper.xml 3.63 KB
<?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.reyun.saas.mob.user.dao.ChannelMapper">

    <!-- 查询渠道列表 -->
    <select id="findChannelList" resultType="com.reyun.saas.mob.user.domain.Channel">
        SELECT c.*,a.app_name,a.bid FROM app a LEFT JOIN channel c ON a.appkey = c.appkey
        WHERE c.appkey IN
        <foreach collection="appkeys" item="appkey" open="(" close=")" separator="," >
            #{appkey}
        </foreach>
        <if test="channelAlias != null and channelAlias != ''">
            AND c.channel_alias = #{channelAlias}
        </if>
        <if test="cid != null and cid != ''">
            AND c.cid = #{cid}
        </if>
        <if test="bid != null and bid != ''">
            AND a.bid = #{bid}
        </if>
        <if test="isCustomAlias != null">
            AND c.is_custom_alias IS ${isCustomAlias}
        </if>
        <if test="query != null and query != ''">
            AND (a.app_name LIKE CONCAT('%',#{query},'%') OR c.channel_alias LIKE CONCAT('%',#{query},'%'))
        </if>
        AND a.del_flag IS FALSE
        <if test="pageParam != null">
            ORDER BY ${pageParam.sortField} ${pageParam.sortOrder}
            LIMIT ${pageParam.page},${pageParam.size}
        </if>
    </select>

    <select id="findByAppkey" resultType="com.reyun.saas.mob.user.domain.Channel">
        select cid,channel_alias as channelAlias from channel where appkey in (${appkey})
    </select>

    <select id="findChannelListCount" resultType="java.lang.Integer">
        SELECT count(*) FROM app a LEFT JOIN channel c ON a.appkey = c.appkey
        WHERE c.appkey IN
        <foreach collection="appkeys" item="appkey" open="(" close=")" separator=",">
        #{appkey}
        </foreach>
        <if test="channelAlias != null and channelAlias != ''">
            AND c.channel_alias = #{channelAlias}
        </if>
        <if test="cid != null and cid != ''">
            AND c.cid = #{cid}
        </if>
        <if test="bid != null and bid != ''">
            AND a.bid = #{bid}
        </if>
        <if test="isCustomAlias != null">
            AND c.is_custom_alias is ${isCustomAlias}
        </if>
        <if test="query != null and query != ''">
            AND (a.app_name LIKE CONCAT('%',#{query},'%') OR c.channel_alias LIKE CONCAT('%',#{query},'%'))
        </if>
         and a.del_flag is false
    </select>

    <update id="deleteChannel" >
        UPDATE channel SET del_flag = 1,modify_user = #{modifyUser},modify_time = #{modifyDate} WHERE appkey = #{appkey}
    </update>


    <!--根据appkey查询启用的渠道-->
    <select id="findByappkeysAndIsActive" resultType="map">
        select id,cid,channel_alias channelAlias,appkey from channel where appkey in
         <foreach collection="appkeys" item="appkey" open="(" close=")" separator=",">
             #{appkey}
         </foreach>
         and del_flag is false and active is true
    </select>

    <!-- 根据appkey查询渠道动态适配启用状态 -->
    <select id="findByappkeysAndActive" resultType="com.reyun.saas.mob.user.domain.Channel">
        select * from channel where appkey in
         <foreach collection="appkeys" item="appkey" open="(" close=")" separator=",">
             #{appkey}
         </foreach>
          and del_flag is false
        <if test="active!=null">
            and active = #{active}
        </if>
    </select>

    <select id="findNormalByAppkey" resultType="java.lang.String">
        select cid from channel where appkey = #{appkey} and del_flag is false and active is true
    </select>
</mapper>