NewsSectionParserHelper.java 18.9 KB
/*
 * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
 */

package com.wd.display.comp.parser;

import java.util.HashMap;
import java.util.Map;

import com.people.component.comp.layoutdata.channel.AdvSection;
import com.people.component.comp.layoutdata.channel.CompFollowSection;
import com.people.component.comp.layoutdata.channel.ImageSection;
import com.people.component.comp.layoutdata.channel.LineSection;
import com.people.component.comp.layoutdata.channel.OneKeyPlaySection;
import com.people.component.comp.layoutdata.channel.TitleLabelSection;
import com.people.component.comp.layoutmanager.channel.CompActivity01;
import com.people.component.comp.layoutmanager.channel.CompAdvGuanMI;
import com.people.component.comp.layoutmanager.channel.CompAdvLongImageLan;
import com.people.component.comp.layoutmanager.channel.CompAdvVideoEx;
import com.people.component.comp.layoutmanager.channel.CompAllResultPeoplesAccount;
import com.people.component.comp.layoutmanager.channel.CompAllSearchActivityCard;
import com.people.component.comp.layoutmanager.channel.CompAllSearchMessageCard;
import com.people.component.comp.layoutmanager.channel.CompAllSearchPeoplesAccount;
import com.people.component.comp.layoutmanager.channel.CompBanner01;
import com.people.component.comp.layoutmanager.channel.CompBanner02;
import com.people.component.comp.layoutmanager.channel.CompBigImage01;
import com.people.component.comp.layoutmanager.channel.CompBigImage02;
import com.people.component.comp.layoutmanager.channel.CompBigImage03;
import com.people.component.comp.layoutmanager.channel.CompDefaultView;
import com.people.component.comp.layoutmanager.channel.CompGridLayout01;
import com.people.component.comp.layoutmanager.channel.CompLabel02;
import com.people.component.comp.layoutmanager.channel.CompLine01;
import com.people.component.comp.layoutmanager.channel.CompMoreImage01;
import com.people.component.comp.layoutmanager.channel.CompMoreImage02;
import com.people.component.comp.layoutmanager.channel.CompNewsImage01;
import com.people.component.comp.layoutmanager.channel.CompNewsOnePlayer01;
import com.people.component.comp.layoutmanager.channel.CompRecommendChannelWz;
import com.people.component.comp.layoutmanager.channel.CompSearchRecommendationsTop;
import com.people.component.comp.layoutmanager.channel.CompShopSettled;
import com.people.component.comp.layoutmanager.channel.CompSingleMessageBoard;
import com.people.component.comp.layoutmanager.channel.CompSingleRow01;
import com.people.component.comp.layoutmanager.channel.CompSingleRow02;
import com.people.component.comp.layoutmanager.channel.CompSingleRow04;
import com.people.component.comp.layoutmanager.channel.CompSingleRow05;
import com.people.component.comp.layoutmanager.channel.CompSingleRow06;
import com.people.component.comp.layoutmanager.channel.CompSingleRow07;
import com.people.component.comp.layoutmanager.channel.CompSingleRow08;
import com.people.component.comp.layoutmanager.channel.CompSingleRow09;
import com.people.component.comp.layoutmanager.channel.CompSingleRowFollow;
import com.people.component.comp.layoutmanager.channel.CompSingleRowGolden;
import com.people.component.comp.layoutmanager.channel.CompSingleRowRecommendFollow;
import com.people.component.comp.layoutmanager.channel.CompSingleRowTheme;
import com.people.component.comp.layoutmanager.channel.CompSmallImage01;
import com.people.component.comp.layoutmanager.channel.CompSmallImage02;
import com.people.component.comp.layoutmanager.channel.CompSmallImage03;
import com.people.component.comp.layoutmanager.channel.CompTimeline;
import com.people.component.comp.layoutmanager.channel.CompTxt01;
import com.people.component.comp.layoutmanager.channel.HighQualityCommentsPageCard;
import com.people.component.comp.layoutmanager.channel.PoliticsLeaveWord;

/**
 * 首页模板section、layoutManager注册集合类<BR>
 * 智慧融媒中心首页楼层注册池
 *
 * @author zhangbo
 * @version [V1.0.0, 2022/3/25]
 * @since V1.0.0
 */
public class NewsSectionParserHelper {
    /**
     * section集合
     */
    public static final Map<String, Class<?>> SECTION_TYPE_MAP;

    /**
     * layoutManger集合
     */
    public static final Map<String, Class<?>> LAYOUT_MANGER_MAP;

    static {
        // 没有特殊处理,可以多个LayoutManager公用一个section,直接注册compType为key
        // 若需要单独出section,则注册compType$compStyle为key
        SECTION_TYPE_MAP = new HashMap<>();
        // ----组件----//
        // 轮播卡
        SECTION_TYPE_MAP.put("ZH_CAROUSEL_LAYOUT$Zh_Carousel_Layout-01", ImageSection.class);
        // 横划卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-01", ImageSection.class);
        // 小视频横划卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-02", ImageSection.class);
        // 直播预约卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-03", ImageSection.class);
        // 地方精选卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-04", ImageSection.class);
        // 人民号账号横滑卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-05", ImageSection.class);
        // 评论卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-06", ImageSection.class);


        //双流小视频卡(一行两卡)
        SECTION_TYPE_MAP.put("ZH_GRID_LAYOUT$Zh_Grid_Layout-02", ImageSection.class);
        //金刚卡
        SECTION_TYPE_MAP.put("ZH_GRID_LAYOUT$Zh_Grid_Layout-03", ImageSection.class);


        // 头图卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-02", ImageSection.class);
        // 正在直播大图卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-03", ImageSection.class);
        // 人民号主题卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-04", ImageSection.class);
        // 人民号入驻卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-05", ImageSection.class);
        // 本地问政
        SECTION_TYPE_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-06", ImageSection.class);
        // 热门留言
        SECTION_TYPE_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-07", ImageSection.class);
        // 留言板卡 以及 我的问政-我的留言头部
        SECTION_TYPE_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-08", ImageSection.class);
        // 兴趣询问卡
        SECTION_TYPE_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-09", ImageSection.class);


        // ----本地自定义样式----//
        // 广告组件 -- 顶部长通栏
        SECTION_TYPE_MAP.put("customStyle$Comp_Ad_01", ImageSection.class);
        // 广告组件 -- 冠名广告
        SECTION_TYPE_MAP.put("customStyle$Comp_Ad_02", AdvSection.class);
        // 广告组件 -- 视频展会广告
        SECTION_TYPE_MAP.put("customStyle$Comp_Ad_03", AdvSection.class);

        // 人民号主推荐卡
        SECTION_TYPE_MAP.put("customStyle$Rmh_Master_Recommend", CompFollowSection.class);
        //人民号关注横滑卡(本地)
        SECTION_TYPE_MAP.put("customStyle$Rmh_Follow", CompFollowSection.class);
        // 专题页面坂本名称稿件
        // SECTION_TYPE_MAP.put("customStyle$CompLabel01", TitleLabelSection.class);
        // 组件标题
        SECTION_TYPE_MAP.put("customStyle$CompLabel02", TitleLabelSection.class);
        // 组件线
        SECTION_TYPE_MAP.put("customStyle$CompLine01", LineSection.class);
        // 更多按钮
        // SECTION_TYPE_MAP.put("customStyle$CompButton01", ImageSection.class);
        // 早晚报专题 特殊稿件
        SECTION_TYPE_MAP.put("customStyle$CompNewsImageTxt01", ImageSection.class);
        // 早晚报专题 一键播放
        SECTION_TYPE_MAP.put("customStyle$CompNewsPlayerView01", OneKeyPlaySection.class);
        // 预约大图卡
        SECTION_TYPE_MAP.put("customStyle$CompBigImage01", ImageSection.class);
        //优质评论页-优质评论列表子项
        SECTION_TYPE_MAP.put("customStyle$HighQualityCommentsPageCard", ImageSection.class);
        //搜索-人民号更多-全部结果页- 人民号卡
        SECTION_TYPE_MAP.put("customStyle$CompAllResultPeoplesAccount", ImageSection.class);
        //搜索-全部tab下- 人民号卡(带头部更多)
        SECTION_TYPE_MAP.put("customStyle$CompAllSearchPeoplesAccount", ImageSection.class);
        //搜索-全部tab下-留言板卡 迭代三新增
        SECTION_TYPE_MAP.put("customStyle$CompAllSearchMessageCard", ImageSection.class);
        //搜索-推荐顶部无内容布局
        SECTION_TYPE_MAP.put("customStyle$SearchRrecommendationsTop", ImageSection.class);
        //搜索-活动列表
        SECTION_TYPE_MAP.put("customStyle$CompAllSearchActivityCard", ImageSection.class);

        //活动
        SECTION_TYPE_MAP.put("customStyle$CompActivity01", ImageSection.class);
        //暂无内容卡、缺省页
        SECTION_TYPE_MAP.put("customStyle$CompDefaultView", ImageSection.class);

        // ----稿件----//
//        // 小图卡
//        SECTION_TYPE_MAP.put("appStyle$1", ImageSection.class);
        // 大图卡
        SECTION_TYPE_MAP.put("appStyle$2", ImageSection.class);
        // 无图卡(全标题)
        SECTION_TYPE_MAP.put("appStyle$3", ImageSection.class);
        // 三图卡
        SECTION_TYPE_MAP.put("appStyle$4", ImageSection.class);
        // 头图卡
        SECTION_TYPE_MAP.put("appStyle$5", ImageSection.class);
        // 小视频卡
        SECTION_TYPE_MAP.put("appStyle$6", ImageSection.class);
//        // 作者卡
//        SECTION_TYPE_MAP.put("appStyle$7", ImageSection.class);
//        // 财经快讯卡
//        SECTION_TYPE_MAP.put("appStyle$8", ImageSection.class);
        // 时间轴卡
        SECTION_TYPE_MAP.put("appStyle$9", ImageSection.class);
        // 大专题卡
        SECTION_TYPE_MAP.put("appStyle$10", ImageSection.class);
        // 无图卡(标题缩略)
        SECTION_TYPE_MAP.put("appStyle$11", ImageSection.class);
        // 无图卡(标题缩略)-人民号
        SECTION_TYPE_MAP.put("appStyle$12", ImageSection.class);
        // 单图卡
        SECTION_TYPE_MAP.put("appStyle$13", ImageSection.class);
        // 单图卡-人民号
        SECTION_TYPE_MAP.put("appStyle$14", ImageSection.class);
        // 大图卡-人民号
        SECTION_TYPE_MAP.put("appStyle$15", ImageSection.class);
        // 三图卡-人民号
        SECTION_TYPE_MAP.put("appStyle$16", ImageSection.class);
        // 图集卡
        SECTION_TYPE_MAP.put("appStyle$17", ImageSection.class);
        // 图集卡-人民号
        //SECTION_TYPE_MAP.put("appStyle$18", ImageSection.class);
        // 动态图文卡-人民号
        SECTION_TYPE_MAP.put("appStyle$19", ImageSection.class);
        // 动态视频卡-人民号
        SECTION_TYPE_MAP.put("appStyle$20", ImageSection.class);
        // 小视频卡-人民号
        SECTION_TYPE_MAP.put("appStyle$21", ImageSection.class);

        //问政问答卡/问政问题卡  我的问政-我的留言/关注留言
        SECTION_TYPE_MAP.put("appStyle$23", ImageSection.class);
        // 推荐问政卡
        SECTION_TYPE_MAP.put("appStyle$24", ImageSection.class);

    }

    static {
        LAYOUT_MANGER_MAP = new HashMap<>();
        // ----组件----//
        // 迭代一
        // 轮播卡
        LAYOUT_MANGER_MAP.put("ZH_CAROUSEL_LAYOUT$Zh_Carousel_Layout-01", CompBanner02.class);
        // 横划卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-01", CompSingleRow01.class);
        // 小视频横划卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-02", CompSingleRow02.class);
        // 直播预约卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-03", CompSingleRow06.class);
        // 双流小视频卡 (一行两图卡)
        LAYOUT_MANGER_MAP.put("ZH_GRID_LAYOUT$Zh_Grid_Layout-02", CompSmallImage02.class);
        // 头图卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-02", CompBanner01.class);
        // 正在直播大图卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-03", CompBigImage01.class);

        // 迭代二
        // 金刚位横滑卡
        LAYOUT_MANGER_MAP.put("ZH_GRID_LAYOUT$Zh_Grid_Layout-03", CompSingleRowGolden.class);
        // 留言板卡 以及 我的问政-我的留言头部
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-08", CompSingleMessageBoard.class);
        // 本地问政卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-06", CompSingleRow09.class);
        // 人民留言卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-07", CompSingleRow04.class);

        // 迭代三
        // 地方精选卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-04", CompSingleRow07.class);
        // 人民账号横滑卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-05", CompSingleRowRecommendFollow.class);
        // 热门评论卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_ROW$Zh_Single_Row-06", CompSingleRow08.class);
        // 人民号主题卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-04", CompSingleRowTheme.class);
        // 人民号入驻卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-05", CompShopSettled.class);
        // 兴趣询问卡
        LAYOUT_MANGER_MAP.put("ZH_SINGLE_COLUMN$Zh_Single_Column-09", CompSingleRow05.class);


        // ----本地自定义样式----//

        // 广告组件 -- 顶部长通栏
        LAYOUT_MANGER_MAP.put("customStyle$Comp_Ad_01", CompAdvLongImageLan.class);
        // 广告组件 -- 冠名广告
        LAYOUT_MANGER_MAP.put("customStyle$Comp_Ad_02", CompAdvGuanMI.class);
        // 广告组件 -- 视频展会广告
        LAYOUT_MANGER_MAP.put("customStyle$Comp_Ad_03", CompAdvVideoEx.class);

        // 人民号主推荐卡(本地)
        LAYOUT_MANGER_MAP.put("customStyle$Rmh_Master_Recommend", CompGridLayout01.class);
        //人民号关注横滑卡(本地)
        LAYOUT_MANGER_MAP.put("customStyle$Rmh_Follow", CompSingleRowFollow.class);
        // 专题页面坂本名称稿件 (弃用)
        //LAYOUT_MANGER_MAP.put("customStyle$CompLabel01", CompLabel01.class);
        // 组件标题
        LAYOUT_MANGER_MAP.put("customStyle$CompLabel02", CompLabel02.class);
        // 组件线
        LAYOUT_MANGER_MAP.put("customStyle$CompLine01", CompLine01.class);
        // 更多按钮
        // LAYOUT_MANGER_MAP.put("customStyle$CompButton01", CompButton01.class);
        // 早晚报专题 特殊稿件
        LAYOUT_MANGER_MAP.put("customStyle$CompNewsImageTxt01", CompNewsImage01.class);
        // 早晚报专题 一键播放
        LAYOUT_MANGER_MAP.put("customStyle$CompNewsPlayerView01", CompNewsOnePlayer01.class);
        // 直播预约大图卡
        LAYOUT_MANGER_MAP.put("customStyle$CompBigImage01", CompBigImage02.class);
        //优质评论页-优质评论列表子项 迭代三新增
        LAYOUT_MANGER_MAP.put("customStyle$HighQualityCommentsPageCard", HighQualityCommentsPageCard.class);
        //搜索-人民号更多-全部结果页- 人民号卡
        LAYOUT_MANGER_MAP.put("customStyle$CompAllResultPeoplesAccount", CompAllResultPeoplesAccount.class);
        //搜索-全部tab下- 人民号卡(带头部更多)
        LAYOUT_MANGER_MAP.put("customStyle$CompAllSearchPeoplesAccount", CompAllSearchPeoplesAccount.class);
        //搜索-全部tab下-留言板卡 迭代三新增
        LAYOUT_MANGER_MAP.put("customStyle$CompAllSearchMessageCard", CompAllSearchMessageCard.class);
        //搜索-推荐顶部无内容布局
        LAYOUT_MANGER_MAP.put("customStyle$SearchRrecommendationsTop", CompSearchRecommendationsTop.class);
        //搜索-活动列表
        LAYOUT_MANGER_MAP.put("customStyle$CompAllSearchActivityCard", CompAllSearchActivityCard.class);
        // 活动卡
        LAYOUT_MANGER_MAP.put("customStyle$CompActivity01", CompActivity01.class);
        //暂无内容卡、缺省页
        LAYOUT_MANGER_MAP.put("customStyle$CompDefaultView", CompDefaultView.class);

        //
        // ----稿件----//
        //  1:小图卡,2:大图卡,3:无图卡(全标题),4:三图卡,5:头图卡,6:小视频卡,7:作者卡,8:财经快讯卡,9:时间轴卡,
        //  10:大专题卡,11.无图卡(标题缩略),12.无图卡(标题缩略)-人民号,13.单图卡,14.单图卡-人民号,
        //  15.大图卡-人民号,16.三图卡-人民号,17.图集卡,18.图集卡-人民号,19.动态图文卡-人民号,20.动态视频卡-人民号
        //  21.小视频卡-人民号,22.时间链,23.问政卡,24.推荐问政卡

        // 大图卡
        LAYOUT_MANGER_MAP.put("appStyle$2", CompBigImage01.class);
        // 无图卡(全标题)
        LAYOUT_MANGER_MAP.put("appStyle$3", CompTxt01.class);
        // 三图卡
        LAYOUT_MANGER_MAP.put("appStyle$4", CompMoreImage01.class);
        // 头图卡
        LAYOUT_MANGER_MAP.put("appStyle$5", CompBanner01.class);
        // 小视频卡
        LAYOUT_MANGER_MAP.put("appStyle$6", CompSmallImage03.class);
        // 时间链卡
        LAYOUT_MANGER_MAP.put("appStyle$9", CompTimeline.class);
        // 大专题卡
        LAYOUT_MANGER_MAP.put("appStyle$10", CompBigImage03.class);
        // 无图卡(标题缩略)
        LAYOUT_MANGER_MAP.put("appStyle$11", CompTxt01.class);
        // 无图卡(标题缩略)-人民号
        LAYOUT_MANGER_MAP.put("appStyle$12", CompTxt01.class);
        // 单图卡
        LAYOUT_MANGER_MAP.put("appStyle$13", CompSmallImage01.class);
        // 单图卡-人民号
        LAYOUT_MANGER_MAP.put("appStyle$14", CompSmallImage01.class);
        // 大图卡-人民号
        LAYOUT_MANGER_MAP.put("appStyle$15", CompBigImage01.class);
        // 三图卡-人民号
        LAYOUT_MANGER_MAP.put("appStyle$16", CompMoreImage01.class);
        // 图集卡
        LAYOUT_MANGER_MAP.put("appStyle$17", CompMoreImage02.class);
        // 图集卡-人民号
        // LAYOUT_MANGER_MAP.put("appStyle$18", CompMoreImage02.class);
        // 动态图文卡-人民号
        LAYOUT_MANGER_MAP.put("appStyle$19", CompMoreImage01.class);
        // 动态视频卡-人民号
        LAYOUT_MANGER_MAP.put("appStyle$20", CompBigImage01.class);
        // 小视频卡-人民号
        LAYOUT_MANGER_MAP.put("appStyle$21", CompSmallImage03.class);
        //问政问答卡/问政问题卡  我的问政-我的留言/关注留言
        LAYOUT_MANGER_MAP.put("appStyle$23", PoliticsLeaveWord.class);
        //推荐问政卡
        LAYOUT_MANGER_MAP.put("appStyle$24", CompRecommendChannelWz.class);


        // -----配置的comp end----//
    }

    private static String getCompKey(String compType, String compStyle) {
        return compType + "$" + compStyle;
    }

    private NewsSectionParserHelper() {

    }

    /**
     * 获取  ColumnCache
     *
     * @return
     */
    public static int getColumnCacheSize() {

        int compSizeTotal = LAYOUT_MANGER_MAP.size() -9;
        if(compSizeTotal > 20){
            compSizeTotal = 20;
        }
        return compSizeTotal;
    }
}