Просмотр исходного кода

修复二级红色模板图文栏目缩略图规则

调整非繁二级网站模板-红色首页的专业建设固定区块:当栏目排版样式为图文列表时,按图文列表输出缩略图、标题和日期,不再按纯文字日期列表渲染。动态首页图文列表也不再使用默认占位图冒充缩略图,历史缺图数据会明确显示暂无缩略图。

在文章新增、修改、变动入口补充校验:发布栏目或抄送栏目属于二级红色模板且排版样式为图文列表时,必须上传缩略图,否则返回提示并阻止保存。

Validation:

- javac -encoding UTF-8 -cp "WebRoot/WEB-INF/classes:WebRoot/WEB-INF/lib/*" -d WebRoot/WEB-INF/classes src/space/apps/moudules/website/services/ArticleService.java

- git diff --cached --check

- curl http://ffkj-dept-red.localhost:4188/ 确认专业建设输出 department-major-graphic-list,已有记录使用真实缩略图;缺图历史记录显示暂无缩略图

- ./local-run/bin/status-full-local.sh
非繁 5 месяцев назад
Родитель
Сommit
cebea8064a

+ 75 - 7
WebRoot/web/upload/ffkj-template/college-red-index.jsp

@@ -66,10 +66,66 @@
 		.college-red-page .department-news-layout .department-news-list a:focus-visible::before {
 		.college-red-page .department-news-layout .department-news-list a:focus-visible::before {
 			width: 100%;
 			width: 100%;
 		}
 		}
-		.college-red-page .department-notice-panel ul b {
+		.college-red-page .department-notice-panel > ul:not(.department-major-graphic-list) b {
 			grid-row: 1 / 3;
 			grid-row: 1 / 3;
 			align-self: center;
 			align-self: center;
 		}
 		}
+		.college-red-page .department-notice-panel .department-major-graphic-list {
+			flex: 0 0 auto;
+			padding: 0 20px;
+			background: var(--hx-paper-dark);
+		}
+		.college-red-page .department-notice-panel .department-major-graphic-list a {
+			display: grid;
+			grid-template-columns: 126px minmax(0, 1fr);
+			gap: 14px;
+			align-items: center;
+			min-height: 0;
+			padding: 10px 0;
+		}
+		.college-red-page .department-notice-panel .department-major-graphic-list .department-section-thumb {
+			width: 126px;
+		}
+		.college-red-page .department-section-thumb em {
+			display: flex;
+			width: 100%;
+			height: 100%;
+			align-items: center;
+			justify-content: center;
+			color: var(--hx-muted);
+			font-size: 12px;
+			font-style: normal;
+		}
+		.college-red-page .department-notice-panel .department-major-graphic-list .department-section-copy {
+			min-width: 0;
+		}
+		.college-red-page .department-notice-panel .department-major-graphic-list .department-section-copy b {
+			display: block;
+			grid-row: auto;
+			align-self: auto;
+			color: var(--hx-ink);
+			font-family: var(--hx-nju-title);
+			font-size: 16px;
+			font-weight: 600;
+			line-height: 1.45;
+			letter-spacing: 0;
+			text-overflow: ellipsis;
+			white-space: nowrap;
+			transition: color 0.28s ease, transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
+			will-change: transform;
+		}
+		.college-red-page .department-notice-panel .department-major-graphic-list time {
+			display: block;
+			margin-top: 5px;
+			color: var(--hx-muted);
+			font-size: 13px;
+			line-height: 1.3;
+		}
+		.college-red-page .department-notice-panel .department-major-graphic-list a:hover .department-section-copy b,
+		.college-red-page .department-notice-panel .department-major-graphic-list a:focus-visible .department-section-copy b {
+			color: var(--hx-red);
+			transform: translateX(6px);
+		}
 	</style>
 	</style>
 </head>
 </head>
 <body class="${portalThemeClass}">
 <body class="${portalThemeClass}">
@@ -152,9 +208,23 @@
 
 
 					<aside class="department-notice-panel">
 					<aside class="department-notice-panel">
 						<div class="department-section-title"><h2>${empty collegeMajorNmv.navigationMap.name ? '专业建设' : collegeMajorNmv.navigationMap.name}</h2><a href="${collegeMajorNmv.navigationMap.url}">查看更多</a></div>
 						<div class="department-section-title"><h2>${empty collegeMajorNmv.navigationMap.name ? '专业建设' : collegeMajorNmv.navigationMap.name}</h2><a href="${collegeMajorNmv.navigationMap.url}">查看更多</a></div>
-						<ul>
-							<c:forEach items="${collegeMajorNmv.articleList}" var="item"><li><a href="${item.url}" target="${item.target}"><span><strong>${fn:substring(item.release_time, 8, 10)}</strong><em>${fn:substring(item.release_time, 0, 7)}</em></span><b>${item.title}</b></a></li></c:forEach>
-						</ul>
+						<c:set var="majorListStyleCode" value="${empty collegeMajorNmv.navigationMap.wnlscode ? 10000 : collegeMajorNmv.navigationMap.wnlscode}"/>
+						<c:choose>
+							<c:when test="${majorListStyleCode == 10010}">
+								<ul class="department-section-graphic-list department-major-graphic-list">
+									<c:forEach items="${collegeMajorNmv.articleList}" var="item" varStatus="vs">
+										<c:if test="${vs.count le 5}">
+											<li><a href="${item.url}" target="${item.target}"><span class="department-section-thumb"><c:choose><c:when test="${not empty item.thumbnail}"><img src="${item.thumbnail}" alt="${item.title}"></c:when><c:otherwise><em>暂无缩略图</em></c:otherwise></c:choose></span><span class="department-section-copy"><b>${item.title}</b><time>${fn:substring(item.release_time, 0, 10)}</time></span></a></li>
+										</c:if>
+									</c:forEach>
+								</ul>
+							</c:when>
+							<c:otherwise>
+								<ul>
+									<c:forEach items="${collegeMajorNmv.articleList}" var="item"><li><a href="${item.url}" target="${item.target}"><span><strong>${fn:substring(item.release_time, 8, 10)}</strong><em>${fn:substring(item.release_time, 0, 7)}</em></span><b>${item.title}</b></a></li></c:forEach>
+								</ul>
+							</c:otherwise>
+						</c:choose>
 					</aside>
 					</aside>
 
 
 				</div>
 				</div>
@@ -199,9 +269,7 @@
 												<ul class="department-section-graphic-list">
 												<ul class="department-section-graphic-list">
 													<c:forEach items="${homeSection.articleList}" var="item" varStatus="vs">
 													<c:forEach items="${homeSection.articleList}" var="item" varStatus="vs">
 														<c:if test="${vs.count le 5}">
 														<c:if test="${vs.count le 5}">
-															<c:set var="sectionImage" value="${assetBase}/official/campus-2.jpg"/>
-															<c:if test="${not empty item.thumbnail}"><c:set var="sectionImage" value="${item.thumbnail}"/></c:if>
-															<li><a href="${item.url}" target="${item.target}"><span class="department-section-thumb"><img src="${sectionImage}" alt="${item.title}"></span><span class="department-section-copy"><b>${item.title}</b><time>${fn:substring(item.release_time, 0, 10)}</time></span></a></li>
+															<li><a href="${item.url}" target="${item.target}"><span class="department-section-thumb"><c:choose><c:when test="${not empty item.thumbnail}"><img src="${item.thumbnail}" alt="${item.title}"></c:when><c:otherwise><em>暂无缩略图</em></c:otherwise></c:choose></span><span class="department-section-copy"><b>${item.title}</b><time>${fn:substring(item.release_time, 0, 10)}</time></span></a></li>
 														</c:if>
 														</c:if>
 													</c:forEach>
 													</c:forEach>
 												</ul>
 												</ul>

+ 62 - 4
src/space/apps/moudules/website/services/ArticleService.java

@@ -32,6 +32,7 @@ import space.apps.moudules.website.common.ConstVars.articleJumpTypeCode;
 import space.apps.moudules.website.common.ConstVars.articleStatusCode;
 import space.apps.moudules.website.common.ConstVars.articleStatusCode;
 import space.apps.moudules.website.template.util.WebsiteTemplateArticleUtil;
 import space.apps.moudules.website.template.util.WebsiteTemplateArticleUtil;
 import space.apps.moudules.website.template.util.WebsiteTemplateNavUtil;
 import space.apps.moudules.website.template.util.WebsiteTemplateNavUtil;
+import space.apps.moudules.website.template.util.WebsiteUtil;
 import space.apps.moudules.website.util.AppWebsiteManageUtil;
 import space.apps.moudules.website.util.AppWebsiteManageUtil;
 import space.core.apps.common.BaseTransaction;
 import space.core.apps.common.BaseTransaction;
 import space.core.apps.common.ConstVars;
 import space.core.apps.common.ConstVars;
@@ -63,6 +64,8 @@ public class ArticleService extends BaseTransaction {
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
     private static final String ARTICLE_PREVIEW_SESSION_PREFIX = "articlePreviewPath_";
     private static final String ARTICLE_PREVIEW_SESSION_PREFIX = "articlePreviewPath_";
+    private static final Long NAVIGATION_STYLE_GRAPHIC_LIST = 10010L;
+    private static final String COLLEGE_RED_TEMPLATE_ID_CODE = "ffkjcollegered1";
     private static final String ARTICLE_PUBLISHED_HISTORY_ROOT = "/web/upload/article-history/";
     private static final String ARTICLE_PUBLISHED_HISTORY_ROOT = "/web/upload/article-history/";
     private static final String PUBLISHED_CONTENT_SNAPSHOT_FIELD = "publishedContentSnapshot";
     private static final String PUBLISHED_CONTENT_SNAPSHOT_FIELD = "publishedContentSnapshot";
     private static final String PUBLISHED_EDIT_CONTENT_SNAPSHOT_FIELD = "publishedEditContentSnapshot";
     private static final String PUBLISHED_EDIT_CONTENT_SNAPSHOT_FIELD = "publishedEditContentSnapshot";
@@ -216,7 +219,10 @@ public class ArticleService extends BaseTransaction {
         if (wn == null) {
         if (wn == null) {
             return DEFAULT_FORWARD;
             return DEFAULT_FORWARD;
         }
         }
-        if (!verifyArticleCopyNavigationList(gdba, navIdList)) {
+        if (!verifyGraphicListThumbnailRequired(gdba, wn, article, "发布栏目")) {
+            return DEFAULT_FORWARD;
+        }
+        if (!verifyArticleCopyNavigationList(gdba, navIdList, article)) {
             return DEFAULT_FORWARD;
             return DEFAULT_FORWARD;
         }
         }
 
 
@@ -330,7 +336,10 @@ public class ArticleService extends BaseTransaction {
         if (wn == null) {
         if (wn == null) {
             return DEFAULT_FORWARD;
             return DEFAULT_FORWARD;
         }
         }
-        if (!verifyArticleCopyNavigationList(gdba, navIdList)) {
+        if (!verifyGraphicListThumbnailRequired(gdba, wn, article, "发布栏目")) {
+            return DEFAULT_FORWARD;
+        }
+        if (!verifyArticleCopyNavigationList(gdba, navIdList, article)) {
             return DEFAULT_FORWARD;
             return DEFAULT_FORWARD;
         }
         }
 
 
@@ -410,7 +419,8 @@ public class ArticleService extends BaseTransaction {
         return wn;
         return wn;
     }
     }
 
 
-    private boolean verifyArticleCopyNavigationList(GeneralDBAccess gdba, String navIdList) throws Exception {
+    private boolean verifyArticleCopyNavigationList(GeneralDBAccess gdba, String navIdList, Article article)
+            throws Exception {
         if (StringUtil.isNull(navIdList)) {
         if (StringUtil.isNull(navIdList)) {
             return true;
             return true;
         }
         }
@@ -426,10 +436,55 @@ public class ArticleService extends BaseTransaction {
             if (wn == null) {
             if (wn == null) {
                 return false;
                 return false;
             }
             }
+            if (!verifyGraphicListThumbnailRequired(gdba, wn, article, "抄送栏目")) {
+                return false;
+            }
         }
         }
         return true;
         return true;
     }
     }
 
 
+    private boolean verifyGraphicListThumbnailRequired(GeneralDBAccess gdba, WebsiteNavigation wn, Article article,
+            String targetName) throws Exception {
+        if (!isCollegeRedGraphicListNavigation(gdba, wn)) {
+            return true;
+        }
+
+        if (article != null && StringUtil.notNull(article.getThumbnail())) {
+            return true;
+        }
+
+        setResponsePackage(getResponseWarningMsgPackage(targetName + "为图文列表时必须上传缩略图"));
+        return false;
+    }
+
+    private boolean isCollegeRedGraphicListNavigation(GeneralDBAccess gdba, WebsiteNavigation wn) throws Exception {
+        if (wn == null || !NAVIGATION_STYLE_GRAPHIC_LIST.equals(wn.getWnlscode())) {
+            return false;
+        }
+        return isCollegeRedTemplateNavigation(gdba, wn);
+    }
+
+    private boolean isCollegeRedTemplateNavigation(GeneralDBAccess gdba, WebsiteNavigation wn) throws Exception {
+        Long wtid = wn == null ? null : wn.getWtid();
+        if (wtid == null && wn != null && wn.getWebsiteid() != null) {
+            Website website = WebsiteUtil.getWebsiteByID(gdba, wn.getWebsiteid());
+            wtid = website == null ? null : website.getWtid();
+        }
+        if (wtid == null) {
+            return false;
+        }
+        return isCollegeRedTemplateIdCode(gdba, wtid);
+    }
+
+    private boolean isCollegeRedTemplateIdCode(GeneralDBAccess gdba, Long wtid) throws Exception {
+        String sql = " select id_code from website_template where wtid = :wtid ";
+        SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
+        sqlCmd.setString("wtid", wtid);
+        Map<String, Object> templateMap = gdba.selectAsMap(sqlCmd);
+        Object idCode = templateMap == null ? null : templateMap.get("id_code");
+        return idCode != null && idCode.toString().indexOf(COLLEGE_RED_TEMPLATE_ID_CODE) >= 0;
+    }
+
     private boolean isArticleTargetNavigation(WebsiteNavigation wn) {
     private boolean isArticleTargetNavigation(WebsiteNavigation wn) {
         if (wn == null || wn.getWntcode() == null) {
         if (wn == null || wn.getWntcode() == null) {
             return false;
             return false;
@@ -537,7 +592,10 @@ public class ArticleService extends BaseTransaction {
         if (wn == null) {
         if (wn == null) {
             return TIPS_FORWARD;
             return TIPS_FORWARD;
         }
         }
-        if (!verifyArticleCopyNavigationList(gdba, navIdList)) {
+        if (!verifyGraphicListThumbnailRequired(gdba, wn, article, "发布栏目")) {
+            return TIPS_FORWARD;
+        }
+        if (!verifyArticleCopyNavigationList(gdba, navIdList, article)) {
             return TIPS_FORWARD;
             return TIPS_FORWARD;
         }
         }