|
|
@@ -0,0 +1,552 @@
|
|
|
+package space.apps.moudules.website.template.ffkjnewsred1;
|
|
|
+
|
|
|
+import apps.pojo.Article;
|
|
|
+import apps.pojo.Website;
|
|
|
+import apps.pojo.WebsiteNavigation;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import space.apps.moudules.basic.util.SortOrderUtil;
|
|
|
+import space.apps.moudules.website.template.common.WebsiteArticleManager;
|
|
|
+import space.apps.moudules.website.template.common.WebsiteCommonService;
|
|
|
+import space.apps.moudules.website.template.common.WebsiteNavManager;
|
|
|
+import space.apps.moudules.website.template.common.WebsiteTmplateConstvars.navigationType;
|
|
|
+import space.apps.moudules.website.template.common.bean.NavigationMiniView;
|
|
|
+import space.apps.moudules.website.template.util.WebsiteTemplateArticleUtil;
|
|
|
+import space.apps.moudules.website.template.util.WebsiteTemplateNavUtil;
|
|
|
+import space.core.apps.common.BaseTransaction;
|
|
|
+import space.core.db.bean.base.PageBean;
|
|
|
+import space.core.db.jdbc.GeneralDBAccess;
|
|
|
+import space.core.db.jdbc.SqlCommandImpl;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 非繁新闻资讯模板-红色服务。
|
|
|
+ */
|
|
|
+public class WebSiteArticleService extends BaseTransaction {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+ private static final String SCREEN_RED_THEME_CLASS = "screen-red-theme";
|
|
|
+ private static final String HOME_GROUP_NAV_IDCARD = "FFKJ_COLLEGE_HOME_GROUP";
|
|
|
+ private static final String NEWS_SECTION_NAV_IDCARD = "FFKJ_COLLEGE_NEWS";
|
|
|
+ private static final String NEWS_RED_CAMPUS_NAV_IDCARD = "FFKJ_NEWS_RED_CAMPUS";
|
|
|
+ private static final String NEWS_RED_FRONTLINE_NAV_IDCARD = "FFKJ_NEWS_RED_FRONTLINE";
|
|
|
+ private static final String NEWS_RED_MEDIA_NAV_IDCARD = "FFKJ_NEWS_RED_MEDIA";
|
|
|
+ private static final String NEWS_RED_CONVERGED_NAV_IDCARD = "FFKJ_NEWS_RED_CONVERGED";
|
|
|
+ private static final String NEWS_RED_NOTICE_NAV_IDCARD = "FFKJ_NEWS_RED_NOTICE";
|
|
|
+ private static final String NEWS_RED_DOWNLOAD_NAV_IDCARD = "FFKJ_NEWS_RED_DOWNLOAD";
|
|
|
+ private static final String UTILITY_LINK_NAV_IDCARD = "FFKJ_COLLEGE_SCHOOL_HOME";
|
|
|
+ private static final String FOOTER_INFO_NAV_IDCARD = "FFKJ_COLLEGE_FOOTER_INFO";
|
|
|
+ private static final String FOOTER_LINK_NAV_IDCARD = "FFKJ_COLLEGE_FOOTER_LINKS";
|
|
|
+ private static final String INITIAL_TITLE_SUFFIX = "【初始】";
|
|
|
+ private static final String DEFAULT_SCHOOL_HOME_NAME = "学校首页";
|
|
|
+ private static final String DEFAULT_SCHOOL_HOME_URL = "https://hxcs.feifan.net/";
|
|
|
+ private static final String DEFAULT_SITE_HOME_NAME = "本站首页";
|
|
|
+ private static final String DEFAULT_SITE_HOME_URL = "/";
|
|
|
+ private static final String DEFAULT_FOOTER_ADDRESS = "广东省广州市从化城鳌大道东772号";
|
|
|
+ private static final String DEFAULT_FOOTER_OFFICE_PHONE = "校办电话:020-87868999";
|
|
|
+ private static final String DEFAULT_FOOTER_ADMISSION_PHONE = "招生电话:020-87865222";
|
|
|
+ private static final String DEFAULT_FOOTER_EMPLOYMENT_PHONE = "就业办:020-87868935";
|
|
|
+ private static final String DEFAULT_FOOTER_COPYRIGHT_ENGLISH =
|
|
|
+ "Copyright © Guangzhou Huaxia Vocational College All Rights Reserved";
|
|
|
+ private static final String DEFAULT_FOOTER_BEIAN_TEXT = "粤ICP备12042111号";
|
|
|
+ private static final String DEFAULT_FOOTER_BEIAN_URL = "https://beian.miit.gov.cn/";
|
|
|
+
|
|
|
+ public String controller() throws Exception {
|
|
|
+ GeneralDBAccess gdba = getGdbaInstance();
|
|
|
+ Website website = getWebsite();
|
|
|
+ setThemeAttributes(gdba, website);
|
|
|
+ WebsiteNavigation nav = WebsiteNavManager.getNavigationByURI(gdba, website, getRequest().getRequestURI());
|
|
|
+ if (nav != null && navigationType.CATALOG.getCode().equals(nav.getWntcode())) {
|
|
|
+ setCatalogAttributes(gdba, website, nav);
|
|
|
+ return "toCatalog";
|
|
|
+ }
|
|
|
+ String forward = WebsiteCommonService.controller(gdba, website, 10, getRequest());
|
|
|
+ WebsiteCommonService.selectFfkjHeadNavigation(gdba, website, getRequest());
|
|
|
+ setCampusNewsSidebarNavList(gdba, website, nav);
|
|
|
+ return forward;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String details() throws Exception {
|
|
|
+ GeneralDBAccess gdba = getGdbaInstance();
|
|
|
+ Website website = getWebsite();
|
|
|
+ setThemeAttributes(gdba, website);
|
|
|
+ String forward = WebsiteCommonService.details(gdba, website, getRequest());
|
|
|
+ WebsiteCommonService.selectFfkjHeadNavigation(gdba, website, getRequest());
|
|
|
+ setArticleExtras(gdba, website);
|
|
|
+ WebsiteNavigation nav = (WebsiteNavigation) getRequest().getAttribute("navigation");
|
|
|
+ setCampusNewsSidebarNavList(gdba, website, nav);
|
|
|
+ return forward;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String index() throws Exception {
|
|
|
+ GeneralDBAccess gdba = getGdbaInstance();
|
|
|
+ Website website = getWebsite();
|
|
|
+
|
|
|
+ WebsiteCommonService.selectFfkjHeadNavigation(gdba, website, getRequest());
|
|
|
+ setRequestAttribute("website", website);
|
|
|
+ setThemeAttributes(gdba, website);
|
|
|
+
|
|
|
+ setNavView(gdba, website, "newsRedCampusNmv", NEWS_RED_CAMPUS_NAV_IDCARD, 6, false);
|
|
|
+ setNavView(gdba, website, "newsRedFrontlineNmv", NEWS_RED_FRONTLINE_NAV_IDCARD, 4, false);
|
|
|
+ setNavView(gdba, website, "newsRedMediaNmv", NEWS_RED_MEDIA_NAV_IDCARD, 4, false);
|
|
|
+ setNavView(gdba, website, "newsRedNoticeNmv", NEWS_RED_NOTICE_NAV_IDCARD, 4, false);
|
|
|
+ setNavView(gdba, website, "newsRedDownloadNmv", NEWS_RED_DOWNLOAD_NAV_IDCARD, 5, false);
|
|
|
+ setNavView(gdba, website, "newsRedHeroNmv", "FFKJ_NEWS_RED_HERO", 1, true);
|
|
|
+ setConvergedMediaCards(gdba, website);
|
|
|
+
|
|
|
+ return DEFAULT_FORWARD;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String search() throws Exception {
|
|
|
+ GeneralDBAccess gdba = getGdbaInstance();
|
|
|
+ Website website = getWebsite();
|
|
|
+ String forward = WebsiteCommonService.search(gdba, website, getRequest(), 10);
|
|
|
+ WebsiteCommonService.selectFfkjHeadNavigation(gdba, website, getRequest());
|
|
|
+ setThemeAttributes(gdba, website);
|
|
|
+ return forward;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setThemeAttributes(GeneralDBAccess gdba, Website website) {
|
|
|
+ setRequestAttribute("portalThemeClass", SCREEN_RED_THEME_CLASS);
|
|
|
+ setRequestAttribute("portalThemeStyle", buildPortalThemeStyle(website));
|
|
|
+ setUtilityLinks(gdba, website);
|
|
|
+ setFooterInfo(gdba, website);
|
|
|
+ setFooterLinks(gdba, website);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String buildPortalThemeStyle(Website website) {
|
|
|
+ String themeColor = getThemeColor(website);
|
|
|
+ if (themeColor.length() == 0) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ int[] rgb = parseHexColor(themeColor);
|
|
|
+ int[] darkRgb = blendColor(rgb, new int[] { 0, 0, 0 }, 0.2);
|
|
|
+ int[] brightRgb = blendColor(rgb, new int[] { 255, 255, 255 }, 0.14);
|
|
|
+ String darkColor = toHexColor(darkRgb);
|
|
|
+ String brightColor = toHexColor(brightRgb);
|
|
|
+ return "body.screen-red-theme,.screen-red-theme{--hx-red:" + themeColor + ";--hx-red-dark:"
|
|
|
+ + darkColor + ";--hx-red-bright:" + brightColor + ";--hx-red-rgb:" + toRgbText(rgb)
|
|
|
+ + ";--hx-red-dark-rgb:" + toRgbText(darkRgb) + ";--hx-red-bright-rgb:"
|
|
|
+ + toRgbText(brightRgb) + ";}";
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getThemeColor(Website website) {
|
|
|
+ if (website == null || website.getWhiteLogoFile() == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ String value = website.getWhiteLogoFile().trim();
|
|
|
+ if (!value.matches("#[0-9a-fA-F]{6}")) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return value.toLowerCase();
|
|
|
+ }
|
|
|
+
|
|
|
+ private int[] parseHexColor(String hexColor) {
|
|
|
+ return new int[] { Integer.parseInt(hexColor.substring(1, 3), 16),
|
|
|
+ Integer.parseInt(hexColor.substring(3, 5), 16),
|
|
|
+ Integer.parseInt(hexColor.substring(5, 7), 16) };
|
|
|
+ }
|
|
|
+
|
|
|
+ private int[] blendColor(int[] sourceRgb, int[] targetRgb, double ratio) {
|
|
|
+ int[] result = new int[3];
|
|
|
+ for (int index = 0; index < result.length; index++) {
|
|
|
+ result[index] = clampColor((int) Math.round(sourceRgb[index] * (1 - ratio) + targetRgb[index] * ratio));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int clampColor(int value) {
|
|
|
+ if (value < 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (value > 255) {
|
|
|
+ return 255;
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String toHexColor(int[] rgb) {
|
|
|
+ return "#" + toHexPart(rgb[0]) + toHexPart(rgb[1]) + toHexPart(rgb[2]);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String toHexPart(int value) {
|
|
|
+ String hex = Integer.toHexString(clampColor(value));
|
|
|
+ return hex.length() == 1 ? "0" + hex : hex;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String toRgbText(int[] rgb) {
|
|
|
+ return rgb[0] + ", " + rgb[1] + ", " + rgb[2];
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setUtilityLinks(GeneralDBAccess gdba, Website website) {
|
|
|
+ String schoolHomeName = DEFAULT_SCHOOL_HOME_NAME;
|
|
|
+ String schoolHomeUrl = DEFAULT_SCHOOL_HOME_URL;
|
|
|
+ String siteHomeName = DEFAULT_SITE_HOME_NAME;
|
|
|
+ String siteHomeUrl = DEFAULT_SITE_HOME_URL;
|
|
|
+
|
|
|
+ try {
|
|
|
+ setRequestAttribute("utilityLinksNmv",
|
|
|
+ WebsiteNavManager.getArticleListByNavIDCard(gdba, website, UTILITY_LINK_NAV_IDCARD, 8));
|
|
|
+ Map<String, Object> schoolHome = getUtilityLinkArticle(gdba, website, DEFAULT_SCHOOL_HOME_NAME);
|
|
|
+ schoolHomeName = firstNotBlank(schoolHome.get("title"), schoolHomeName);
|
|
|
+ schoolHomeUrl = firstNotBlank(schoolHome.get("url"), schoolHomeUrl);
|
|
|
+
|
|
|
+ Map<String, Object> siteHome = getUtilityLinkArticle(gdba, website, DEFAULT_SITE_HOME_NAME);
|
|
|
+ siteHomeName = firstNotBlank(siteHome.get("title"), siteHomeName);
|
|
|
+ siteHomeUrl = firstNotBlank(siteHome.get("url"), siteHomeUrl);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 缺少隐藏栏目或文章时保持默认入口,不影响页面打开。
|
|
|
+ setRequestAttribute("utilityLinksNmv", new NavigationMiniView());
|
|
|
+ }
|
|
|
+
|
|
|
+ setRequestAttribute("schoolHomeName", schoolHomeName);
|
|
|
+ setRequestAttribute("schoolHomeUrl", schoolHomeUrl);
|
|
|
+ setRequestAttribute("siteHomeName", siteHomeName);
|
|
|
+ setRequestAttribute("siteHomeUrl", siteHomeUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setFooterInfo(GeneralDBAccess gdba, Website website) {
|
|
|
+ String websiteName = website == null ? "" : firstNotBlank(website.getName(), "");
|
|
|
+ String footerAddress = DEFAULT_FOOTER_ADDRESS;
|
|
|
+ String footerOfficePhone = DEFAULT_FOOTER_OFFICE_PHONE;
|
|
|
+ String footerAdmissionPhone = DEFAULT_FOOTER_ADMISSION_PHONE;
|
|
|
+ String footerEmploymentPhone = DEFAULT_FOOTER_EMPLOYMENT_PHONE;
|
|
|
+ String footerOwner = "版权所有:" + websiteName;
|
|
|
+ String footerLogo = "";
|
|
|
+ String footerLogoAlt = websiteName;
|
|
|
+ String footerCopyright = DEFAULT_FOOTER_COPYRIGHT_ENGLISH;
|
|
|
+ String footerBeianText = DEFAULT_FOOTER_BEIAN_TEXT;
|
|
|
+ String footerBeianUrl = DEFAULT_FOOTER_BEIAN_URL;
|
|
|
+
|
|
|
+ try {
|
|
|
+ NavigationMiniView footerInfoNmv = WebsiteNavManager.getArticleListByNavIDCard(gdba, website,
|
|
|
+ FOOTER_INFO_NAV_IDCARD, 16);
|
|
|
+ setRequestAttribute("footerInfoNmv", footerInfoNmv);
|
|
|
+ Map<String, Map<String, Object>> footerInfoArticleMap = buildFooterInfoArticleMap(footerInfoNmv);
|
|
|
+ footerAddress = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "地址"), footerAddress);
|
|
|
+ footerOfficePhone = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "校办电话"), footerOfficePhone);
|
|
|
+ footerAdmissionPhone = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "招生电话"),
|
|
|
+ footerAdmissionPhone);
|
|
|
+ footerEmploymentPhone = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "就业办"),
|
|
|
+ footerEmploymentPhone);
|
|
|
+ footerOwner = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "版权所有"), footerOwner);
|
|
|
+ footerLogo = firstNotBlank(getFooterInfoThumbnail(footerInfoArticleMap, "底部LOGO"), footerLogo);
|
|
|
+ footerLogoAlt = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "底部LOGO"), footerLogoAlt);
|
|
|
+ footerCopyright = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "版权英文"), footerCopyright);
|
|
|
+ footerBeianText = firstNotBlank(getFooterInfoDesc(footerInfoArticleMap, "备案信息"), footerBeianText);
|
|
|
+ footerBeianUrl = firstNotBlank(getFooterInfoUrl(footerInfoArticleMap, "备案信息"), footerBeianUrl);
|
|
|
+ } catch (Exception e) {
|
|
|
+ setRequestAttribute("footerInfoNmv", new NavigationMiniView());
|
|
|
+ }
|
|
|
+
|
|
|
+ setRequestAttribute("footerAddressText", footerAddress);
|
|
|
+ setRequestAttribute("footerOfficePhoneText", footerOfficePhone);
|
|
|
+ setRequestAttribute("footerAdmissionPhoneText", footerAdmissionPhone);
|
|
|
+ setRequestAttribute("footerEmploymentPhoneText", footerEmploymentPhone);
|
|
|
+ setRequestAttribute("footerOwnerText", footerOwner);
|
|
|
+ setRequestAttribute("footerLogoUrl", footerLogo);
|
|
|
+ setRequestAttribute("footerLogoAlt", footerLogoAlt);
|
|
|
+ setRequestAttribute("footerCopyrightText", footerCopyright);
|
|
|
+ setRequestAttribute("footerBeianText", footerBeianText);
|
|
|
+ setRequestAttribute("footerBeianUrl", footerBeianUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Map<String, Object>> buildFooterInfoArticleMap(NavigationMiniView footerInfoNmv) {
|
|
|
+ Map<String, Map<String, Object>> footerInfoArticleMap = new HashMap<String, Map<String, Object>>();
|
|
|
+ if (footerInfoNmv == null || footerInfoNmv.getArticleList() == null) {
|
|
|
+ return footerInfoArticleMap;
|
|
|
+ }
|
|
|
+ for (Map<String, Object> articleMap : footerInfoNmv.getArticleList()) {
|
|
|
+ if (articleMap == null || articleMap.get("title") == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String title = normalizeFooterInfoTitle(articleMap.get("title").toString());
|
|
|
+ if (title.length() > 0 && !footerInfoArticleMap.containsKey(title)) {
|
|
|
+ footerInfoArticleMap.put(title, articleMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return footerInfoArticleMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String normalizeFooterInfoTitle(String title) {
|
|
|
+ if (title == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ String normalizedTitle = title.trim();
|
|
|
+ while (normalizedTitle.endsWith(INITIAL_TITLE_SUFFIX)) {
|
|
|
+ normalizedTitle = normalizedTitle.substring(0, normalizedTitle.length() - INITIAL_TITLE_SUFFIX.length())
|
|
|
+ .trim();
|
|
|
+ }
|
|
|
+ return normalizedTitle;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Object getFooterInfoDesc(Map<String, Map<String, Object>> footerInfoArticleMap, String title) {
|
|
|
+ return getFooterInfoField(footerInfoArticleMap, title, "desc");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Object getFooterInfoThumbnail(Map<String, Map<String, Object>> footerInfoArticleMap, String title) {
|
|
|
+ return getFooterInfoField(footerInfoArticleMap, title, "thumbnail");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Object getFooterInfoUrl(Map<String, Map<String, Object>> footerInfoArticleMap, String title) {
|
|
|
+ return getFooterInfoField(footerInfoArticleMap, title, "url");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Object getFooterInfoField(Map<String, Map<String, Object>> footerInfoArticleMap, String title, String field) {
|
|
|
+ if (footerInfoArticleMap == null || !footerInfoArticleMap.containsKey(title)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return footerInfoArticleMap.get(title).get(field);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setFooterLinks(GeneralDBAccess gdba, Website website) {
|
|
|
+ try {
|
|
|
+ setRequestAttribute("footerLinksNmv",
|
|
|
+ WebsiteNavManager.getArticleListByNavIDCard(gdba, website, FOOTER_LINK_NAV_IDCARD, 8));
|
|
|
+ } catch (Exception e) {
|
|
|
+ setRequestAttribute("footerLinksNmv", new NavigationMiniView());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> getUtilityLinkArticle(GeneralDBAccess gdba, Website website, String title)
|
|
|
+ throws Exception {
|
|
|
+ String sql = "SELECT a.title, a.url FROM article a "
|
|
|
+ + "JOIN website_navigation wn ON wn.navigationid = a.navigationid "
|
|
|
+ + "WHERE a.dcode = 61 AND a.ascode = '10010' AND a.`release` = 1 "
|
|
|
+ + "AND wn.dcode = 61 AND wn.wnccode = 10000 "
|
|
|
+ + "AND wn.websiteid = :websiteid AND wn.idcard = :idcard "
|
|
|
+ + "AND a.title = :title "
|
|
|
+ + "ORDER BY " + SortOrderUtil.articleSort("a") + " LIMIT 1";
|
|
|
+ SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
|
|
|
+ sqlCmd.setString("websiteid", website.getWebsiteid()).setString("idcard", UTILITY_LINK_NAV_IDCARD)
|
|
|
+ .setString("title", title);
|
|
|
+ Map<String, Object> article = gdba.selectAsMap(sqlCmd);
|
|
|
+ return article == null ? new java.util.HashMap<String, Object>() : article;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String firstNotBlank(Object value, String fallback) {
|
|
|
+ if (value == null) {
|
|
|
+ return fallback;
|
|
|
+ }
|
|
|
+ String text = value.toString().trim();
|
|
|
+ return text.length() == 0 ? fallback : text;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setNavView(GeneralDBAccess gdba, Website website, String attrName, String idcard, int size,
|
|
|
+ boolean thumbnailOnly) throws Exception {
|
|
|
+ try {
|
|
|
+ NavigationMiniView nmv = thumbnailOnly
|
|
|
+ ? WebsiteNavManager.getArticleThumbnailListByNavIDCard(gdba, website, idcard, size)
|
|
|
+ : WebsiteNavManager.getArticleListByNavIDCard(gdba, website, idcard, size);
|
|
|
+ setRequestAttribute(attrName, nmv);
|
|
|
+ } catch (Exception e) {
|
|
|
+ setRequestAttribute(attrName, new NavigationMiniView());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setConvergedMediaCards(GeneralDBAccess gdba, Website website) throws Exception {
|
|
|
+ List<Map<String, Object>> cards = new ArrayList<Map<String, Object>>();
|
|
|
+ Map<String, Object> parentNav = null;
|
|
|
+ try {
|
|
|
+ parentNav = WebsiteTemplateNavUtil.getNavigationByIDCardAsMap(gdba, website,
|
|
|
+ NEWS_RED_CONVERGED_NAV_IDCARD);
|
|
|
+ if (parentNav != null && parentNav.get("navigationid") != null) {
|
|
|
+ List<Map<String, Object>> children = WebsiteNavManager.getChildrenNavigation(gdba, website,
|
|
|
+ Long.valueOf(parentNav.get("navigationid").toString()));
|
|
|
+ if (children != null) {
|
|
|
+ for (Map<String, Object> childNav : children) {
|
|
|
+ if (childNav == null || childNav.get("navigationid") == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ PageBean page = new PageBean();
|
|
|
+ page.setRowCountPerPage(1);
|
|
|
+ page.setCurrentPageNo(1);
|
|
|
+ List<Map<String, Object>> articles = WebsiteTemplateArticleUtil.getArticleList(gdba,
|
|
|
+ Long.valueOf(childNav.get("navigationid").toString()), page);
|
|
|
+ if (articles == null || articles.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, Object> card = new HashMap<String, Object>();
|
|
|
+ card.put("typeName", childNav.get("name"));
|
|
|
+ card.put("article", articles.get(0));
|
|
|
+ cards.add(card);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 单类内容异常时保留其余融媒卡片。
|
|
|
+ }
|
|
|
+ setRequestAttribute("newsRedConvergedNav", parentNav);
|
|
|
+ setRequestAttribute("newsRedConvergedCards", cards);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setHomeSectionRows(GeneralDBAccess gdba, Website website) throws Exception {
|
|
|
+ List<NavigationMiniView> sectionList = new ArrayList<NavigationMiniView>();
|
|
|
+
|
|
|
+ List<Map<String, Object>> homeChildNavList = getHomeChildNavigation(gdba, website);
|
|
|
+ if (homeChildNavList != null) {
|
|
|
+ for (Map<String, Object> navMap : getHomeSectionNavigationList(homeChildNavList)) {
|
|
|
+ if (!isDynamicHomeSection(navMap)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ NavigationMiniView section = buildNavigationMiniView(gdba, navMap, 5);
|
|
|
+ sectionList.add(section);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 单个自定义栏目数据异常时跳过,避免影响首页其他栏目。
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ setRequestAttribute("collegeHomeSectionRows", groupSections(sectionList, 2));
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> getHomeSectionNavigationList(List<Map<String, Object>> homeChildNavList) {
|
|
|
+ List<Map<String, Object>> sectionNavList = new ArrayList<Map<String, Object>>();
|
|
|
+ boolean topBoundaryFound = false;
|
|
|
+
|
|
|
+ for (Map<String, Object> navMap : homeChildNavList) {
|
|
|
+ if (hasIDCard(navMap, UTILITY_LINK_NAV_IDCARD)) {
|
|
|
+ topBoundaryFound = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (hasIDCard(navMap, FOOTER_LINK_NAV_IDCARD)) {
|
|
|
+ if (topBoundaryFound) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (topBoundaryFound) {
|
|
|
+ sectionNavList.add(navMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (topBoundaryFound) {
|
|
|
+ return sectionNavList;
|
|
|
+ }
|
|
|
+ return homeChildNavList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean hasIDCard(Map<String, Object> navMap, String idcard) {
|
|
|
+ return navMap != null && navMap.get("idcard") != null && idcard.equals(navMap.get("idcard").toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> getHomeChildNavigation(GeneralDBAccess gdba, Website website) throws Exception {
|
|
|
+ Map<String, Object> homeGroupMap = WebsiteTemplateNavUtil.getNavigationByIDCardAsMap(gdba, website,
|
|
|
+ HOME_GROUP_NAV_IDCARD);
|
|
|
+ if (homeGroupMap == null || homeGroupMap.get("navigationid") == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return WebsiteTemplateNavUtil.getWebsiteALLConcealTerminalNav(gdba, website,
|
|
|
+ Long.valueOf(homeGroupMap.get("navigationid").toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setCampusNewsSidebarNavList(GeneralDBAccess gdba, Website website,
|
|
|
+ WebsiteNavigation nav) throws Exception {
|
|
|
+ if (nav == null || nav.getNavigationid() == null || nav.getIdcard() == null
|
|
|
+ || !NEWS_SECTION_NAV_IDCARD.equals(nav.getIdcard())
|
|
|
+ || nav.getWnscode() == null || !Long.valueOf(10030L).equals(nav.getWnscode())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> homeChildNavList = getHomeChildNavigation(gdba, website);
|
|
|
+ if (homeChildNavList == null || homeChildNavList.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String currentNavId = nav.getNavigationid().toString();
|
|
|
+ List<Map<String, Object>> sidebarNavList = new ArrayList<Map<String, Object>>();
|
|
|
+ boolean currentFound = false;
|
|
|
+ for (Map<String, Object> navMap : homeChildNavList) {
|
|
|
+ if (navMap == null || navMap.get("navigationid") == null || navMap.get("wnscode") == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String navId = navMap.get("navigationid").toString();
|
|
|
+ if (currentNavId.equals(navId)) {
|
|
|
+ currentFound = true;
|
|
|
+ }
|
|
|
+ if ("10000".equals(navMap.get("wnscode").toString()) || currentNavId.equals(navId)) {
|
|
|
+ sidebarNavList.add(navMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!currentFound) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ WebsiteTemplateNavUtil.clearNavOtherField(sidebarNavList);
|
|
|
+ setRequestAttribute("redSidebarNavList", sidebarNavList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isDynamicHomeSection(Map<String, Object> navMap) {
|
|
|
+ if (navMap == null || navMap.get("idcard") == null || navMap.get("wntcode") == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String idcard = navMap.get("idcard").toString();
|
|
|
+ if ("FFKJ_COLLEGE_HOME_HERO".equals(idcard) || "FFKJ_COLLEGE_NEWS".equals(idcard)
|
|
|
+ || "FFKJ_COLLEGE_NOTICE".equals(idcard) || "FFKJ_COLLEGE_MAJOR".equals(idcard)
|
|
|
+ || UTILITY_LINK_NAV_IDCARD.equals(idcard) || FOOTER_INFO_NAV_IDCARD.equals(idcard)
|
|
|
+ || FOOTER_LINK_NAV_IDCARD.equals(idcard)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return navigationType.LIST.getCode().toString().equals(navMap.get("wntcode").toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ private NavigationMiniView buildNavigationMiniView(GeneralDBAccess gdba, Map<String, Object> navMap, int size)
|
|
|
+ throws Exception {
|
|
|
+ normalizeNavigationMap(gdba, navMap);
|
|
|
+ PageBean pb = new PageBean();
|
|
|
+ pb.setRowCountPerPage(size);
|
|
|
+ List<Map<String, Object>> articleList = WebsiteTemplateArticleUtil.getArticleList(gdba,
|
|
|
+ Long.valueOf(navMap.get("navigationid").toString()), pb);
|
|
|
+ return new NavigationMiniView(navMap, articleList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void normalizeNavigationMap(GeneralDBAccess gdba, Map<String, Object> navMap) throws Exception {
|
|
|
+ if (navMap == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (navMap.get("href") == null) {
|
|
|
+ navMap.put("href", WebsiteTemplateNavUtil.getNavigationHref(gdba, navMap));
|
|
|
+ }
|
|
|
+ if (navMap.get("target") == null && navMap.get("wnjtcode") != null) {
|
|
|
+ navMap.put("target", WebsiteTemplateNavUtil.jumpTypeCodeToTargetValue(navMap.get("wnjtcode").toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<List<NavigationMiniView>> groupSections(List<NavigationMiniView> sectionList, int groupSize) {
|
|
|
+ List<List<NavigationMiniView>> rows = new ArrayList<List<NavigationMiniView>>();
|
|
|
+ if (sectionList == null || sectionList.size() == 0) {
|
|
|
+ return rows;
|
|
|
+ }
|
|
|
+ for (int index = 0; index < sectionList.size(); index += groupSize) {
|
|
|
+ List<NavigationMiniView> row = new ArrayList<NavigationMiniView>();
|
|
|
+ for (int offset = 0; offset < groupSize && index + offset < sectionList.size(); offset++) {
|
|
|
+ row.add(sectionList.get(index + offset));
|
|
|
+ }
|
|
|
+ rows.add(row);
|
|
|
+ }
|
|
|
+ return rows;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setArticleExtras(GeneralDBAccess gdba, Website website) throws Exception {
|
|
|
+ Article article = WebsiteArticleManager.getArticleByRequest(gdba, website, getRequest());
|
|
|
+ if (article != null) {
|
|
|
+ setRequestAttribute("articleThumbnail", article.getThumbnail());
|
|
|
+ setRequestAttribute("articleReadCount", article.getReadCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setCatalogAttributes(GeneralDBAccess gdba, Website website, WebsiteNavigation nav) throws Exception {
|
|
|
+ WebsiteCommonService.selectFfkjHeadNavigation(gdba, website, getRequest());
|
|
|
+ setRequestAttribute("website", website);
|
|
|
+ setRequestAttribute("navigation", nav);
|
|
|
+ List<WebsiteNavigation> crumbs = WebsiteNavManager.getNavParentList(gdba, website, nav.getNavigationid());
|
|
|
+ setRequestAttribute("crumbsNavList", crumbs);
|
|
|
+ setRequestAttribute("crumbsNavListSize", crumbs == null ? 0 : crumbs.size() - 1);
|
|
|
+ setRequestAttribute("childrenNavList", WebsiteNavManager.getChildrenNavigation(gdba, website, nav.getNavigationid()));
|
|
|
+ setRequestAttribute("navMiniViewList", WebsiteNavManager.getChildrenNavigationMiniView(gdba, website, nav.getNavigationid()));
|
|
|
+ if (nav.getParentNid() != null) {
|
|
|
+ WebsiteNavigation parNav = WebsiteNavManager.getNavigationByID(gdba, website, nav.getParentNid());
|
|
|
+ setRequestAttribute("parNavigation", parNav);
|
|
|
+ setRequestAttribute("brotherNavList", WebsiteNavManager.getChildrenNavigation(gdba, website, nav.getParentNid()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|