|
@@ -1,6 +1,7 @@
|
|
|
package space.apps.moudules.website.services;
|
|
package space.apps.moudules.website.services;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
|
+import java.net.URLDecoder;
|
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
@@ -13,6 +14,7 @@ import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
+import java.util.TreeSet;
|
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
@@ -227,6 +229,67 @@ public class ArticleService extends BaseTransaction {
|
|
|
setResponsePackage(getResponseWarningMsgPackage("正文中存在未上传完成或失效的图片,请重新上传"));
|
|
setResponsePackage(getResponseWarningMsgPackage("正文中存在未上传完成或失效的图片,请重新上传"));
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ String effectiveSource = StringUtil.notNull(src) && !src.startsWith("data:") ? src : originalSrc;
|
|
|
|
|
+ String localPath = extractLocalUploadPath(effectiveSource);
|
|
|
|
|
+ if (StringUtil.notNull(localPath)) {
|
|
|
|
|
+ File imageFile = new File(getWebRootPath() + localPath);
|
|
|
|
|
+ if (!imageFile.exists() || !imageFile.isFile()) {
|
|
|
|
|
+ setResponsePackage(getResponseWarningMsgPackage("正文图片文件不存在,请重新上传:" + localPath));
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String extractLocalUploadPath(String source) {
|
|
|
|
|
+ if (StringUtil.isNull(source)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ String value = source.trim();
|
|
|
|
|
+ if (!value.startsWith("/web/upload/")) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ int queryIndex = value.indexOf('?');
|
|
|
|
|
+ if (queryIndex >= 0) {
|
|
|
|
|
+ value = value.substring(0, queryIndex);
|
|
|
|
|
+ }
|
|
|
|
|
+ int fragmentIndex = value.indexOf('#');
|
|
|
|
|
+ if (fragmentIndex >= 0) {
|
|
|
|
|
+ value = value.substring(0, fragmentIndex);
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ return URLDecoder.decode(value, "UTF-8");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean verifyArticleUrlUnique(GeneralDBAccess gdba, Article article, WebsiteNavigation navigation)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ if (navigation == null || article == null || article.getAjtcode() == null
|
|
|
|
|
+ || article.getAjtcode().equals(10020L) || StringUtil.isNull(article.getUrl())) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ String sql = " select articleid, title from article"
|
|
|
|
|
+ + " where websiteid = :websiteid and dcode = 61 and url = :url";
|
|
|
|
|
+ if (article.getArticleid() != null) {
|
|
|
|
|
+ sql += " and articleid <> :articleid";
|
|
|
|
|
+ }
|
|
|
|
|
+ sql += " limit 1";
|
|
|
|
|
+ SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
|
|
|
|
|
+ sqlCmd.setString("websiteid", navigation.getWebsiteid());
|
|
|
|
|
+ sqlCmd.setString("url", article.getUrl());
|
|
|
|
|
+ if (article.getArticleid() != null) {
|
|
|
|
|
+ sqlCmd.setString("articleid", article.getArticleid());
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> duplicate = gdba.selectAsMap(sqlCmd);
|
|
|
|
|
+ if (duplicate != null) {
|
|
|
|
|
+ setResponsePackage(getResponseWarningMsgPackage("同一网站已存在相同正文地址的文章:"
|
|
|
|
|
+ + firstNotBlank(duplicate.get("title"), article.getUrl())
|
|
|
|
|
+ + ",请先处理重复文章后再保存"));
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -293,6 +356,9 @@ public class ArticleService extends BaseTransaction {
|
|
|
if (!article.getAjtcode().equals(10020L)) {
|
|
if (!article.getAjtcode().equals(10020L)) {
|
|
|
article.setUrl(WebsiteTemplateArticleUtil.getArticleURL(wn));
|
|
article.setUrl(WebsiteTemplateArticleUtil.getArticleURL(wn));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!verifyArticleUrlUnique(gdba, article, wn)) {
|
|
|
|
|
+ return DEFAULT_FORWARD;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// if (StringUtil.isNull(article.getReleaseTime())) {
|
|
// if (StringUtil.isNull(article.getReleaseTime())) {
|
|
|
// article.setReleaseTime(nowTimestamp);
|
|
// article.setReleaseTime(nowTimestamp);
|
|
@@ -439,6 +505,9 @@ public class ArticleService extends BaseTransaction {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
verifyArticleUrl(article, a2, wn);
|
|
verifyArticleUrl(article, a2, wn);
|
|
|
|
|
+ if (!verifyArticleUrlUnique(gdba, article, wn)) {
|
|
|
|
|
+ return DEFAULT_FORWARD;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
saveArticleDesc(article, content);
|
|
saveArticleDesc(article, content);
|
|
|
|
|
|
|
@@ -688,6 +757,9 @@ public class ArticleService extends BaseTransaction {
|
|
|
buildArticleChangeLogContent(a2, nowTimestamp));
|
|
buildArticleChangeLogContent(a2, nowTimestamp));
|
|
|
|
|
|
|
|
verifyArticleUrl(article, a2, wn);
|
|
verifyArticleUrl(article, a2, wn);
|
|
|
|
|
+ if (!verifyArticleUrlUnique(gdba, article, wn)) {
|
|
|
|
|
+ return DEFAULT_FORWARD;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
saveArticleContentFiles(article, content);
|
|
saveArticleContentFiles(article, content);
|
|
|
|
|
|
|
@@ -995,13 +1067,9 @@ public class ArticleService extends BaseTransaction {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private List<Map<String, Object>> getArticleFlowList(GeneralDBAccess gdba, Long articleid) throws Exception {
|
|
private List<Map<String, Object>> getArticleFlowList(GeneralDBAccess gdba, Long articleid) throws Exception {
|
|
|
- String sql = " select ap.applyid, ap.ascode, "
|
|
|
|
|
|
|
+ String applySql = " select ap.applyid, ap.ascode, "
|
|
|
+ " coalesce(asc1.name, '未知状态') as statusName, "
|
|
+ " coalesce(asc1.name, '未知状态') as statusName, "
|
|
|
+ " coalesce(initp.name, '未知') as initiatorName, "
|
|
+ " coalesce(initp.name, '未知') as initiatorName, "
|
|
|
- + " coalesce((select group_concat(distinct cp.name order by cp.name separator '、') "
|
|
|
|
|
- + " from audit cau join person cp on cp.personid = cau.personid "
|
|
|
|
|
- + " where ap.ascode = 11 and cau.applyid = ap.applyid and cau.dcode = 31 "
|
|
|
|
|
- + " and cau.audit_time is null and cau.acode in (51, 101)), '') as currentAuditors, "
|
|
|
|
|
+ " case "
|
|
+ " case "
|
|
|
+ " when lower(ap.flow_key) like '%articlechange%' then '变动审核' "
|
|
+ " when lower(ap.flow_key) like '%articlechange%' then '变动审核' "
|
|
|
+ " when lower(ap.flow_key) like '%articledisable%' then '停用审核' "
|
|
+ " when lower(ap.flow_key) like '%articledisable%' then '停用审核' "
|
|
@@ -1016,23 +1084,97 @@ public class ArticleService extends BaseTransaction {
|
|
|
+ " else 'info' "
|
|
+ " else 'info' "
|
|
|
+ " end as statusType, "
|
|
+ " end as statusType, "
|
|
|
+ " date_format(ap.create_time, '%Y-%m-%d %H:%i:%s') as createTime, "
|
|
+ " date_format(ap.create_time, '%Y-%m-%d %H:%i:%s') as createTime, "
|
|
|
- + " ifnull(date_format(ap.end_time, '%Y-%m-%d %H:%i:%s'), '') as endTime, "
|
|
|
|
|
- + " ifnull((select au.auditid from audit au "
|
|
|
|
|
- + " where au.applyid = ap.applyid and au.dcode <> 72 "
|
|
|
|
|
- + " order by case "
|
|
|
|
|
- + " when ap.ascode = 11 and au.dcode = 31 and au.audit_time is null and au.acode in (51, 101) then 0 "
|
|
|
|
|
- + " when au.audit_time is not null then 1 "
|
|
|
|
|
- + " else 2 end, "
|
|
|
|
|
- + " ifnull(au.steps, 0) desc, au.auditid desc limit 1), 0) as auditid "
|
|
|
|
|
|
|
+ + " ifnull(date_format(ap.end_time, '%Y-%m-%d %H:%i:%s'), '') as endTime "
|
|
|
+ " from apply ap "
|
|
+ " from apply ap "
|
|
|
+ " left join apply_status_code asc1 on asc1.apply_status_code = ap.ascode "
|
|
+ " left join apply_status_code asc1 on asc1.apply_status_code = ap.ascode "
|
|
|
+ " left join person initp on initp.personid = ap.personid "
|
|
+ " left join person initp on initp.personid = ap.personid "
|
|
|
+ " where ap.dcode <> 72 and ap.table_name = 'article' and ap.table_key = 'articleid' "
|
|
+ " where ap.dcode <> 72 and ap.table_name = 'article' and ap.table_key = 'articleid' "
|
|
|
+ " and ap.table_key_value = :articleid "
|
|
+ " and ap.table_key_value = :articleid "
|
|
|
+ " order by case when ap.ascode = 11 then 0 else 1 end, ap.create_time desc, ap.applyid desc ";
|
|
+ " order by case when ap.ascode = 11 then 0 else 1 end, ap.create_time desc, ap.applyid desc ";
|
|
|
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
|
|
|
|
|
- sqlCmd.setString("articleid", articleid);
|
|
|
|
|
- return gdba.selectAsMapList(sqlCmd);
|
|
|
|
|
|
|
+ SqlCommandImpl applyCmd = new SqlCommandImpl(applySql);
|
|
|
|
|
+ applyCmd.setString("articleid", articleid);
|
|
|
|
|
+ List<Map<String, Object>> applyList = gdba.selectAsMapList(applyCmd);
|
|
|
|
|
+ if (applyList == null || applyList.isEmpty()) {
|
|
|
|
|
+ return new ArrayList<Map<String, Object>>();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String auditSql = " select au.applyid, au.auditid, au.dcode, au.acode, au.audit_time, au.steps, "
|
|
|
|
|
+ + " cp.name as auditorName "
|
|
|
|
|
+ + " from audit au "
|
|
|
|
|
+ + " join apply ap on ap.applyid = au.applyid "
|
|
|
|
|
+ + " left join person cp on cp.personid = au.personid "
|
|
|
|
|
+ + " where ap.dcode <> 72 and ap.table_name = 'article' and ap.table_key = 'articleid' "
|
|
|
|
|
+ + " and ap.table_key_value = :articleid and au.dcode <> 72 "
|
|
|
|
|
+ + " order by au.applyid, au.auditid ";
|
|
|
|
|
+ SqlCommandImpl auditCmd = new SqlCommandImpl(auditSql);
|
|
|
|
|
+ auditCmd.setString("articleid", articleid);
|
|
|
|
|
+ List<Map<String, Object>> auditList = gdba.selectAsMapList(auditCmd);
|
|
|
|
|
+ Map<Long, List<Map<String, Object>>> auditsByApply = new HashMap<Long, List<Map<String, Object>>>();
|
|
|
|
|
+ if (auditList != null) {
|
|
|
|
|
+ for (Map<String, Object> audit : auditList) {
|
|
|
|
|
+ Long applyId = parseLong(audit.get("applyid"));
|
|
|
|
|
+ if (applyId == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Map<String, Object>> audits = auditsByApply.get(applyId);
|
|
|
|
|
+ if (audits == null) {
|
|
|
|
|
+ audits = new ArrayList<Map<String, Object>>();
|
|
|
|
|
+ auditsByApply.put(applyId, audits);
|
|
|
|
|
+ }
|
|
|
|
|
+ audits.add(audit);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (Map<String, Object> apply : applyList) {
|
|
|
|
|
+ Long applyId = parseLong(apply.get("applyid"));
|
|
|
|
|
+ String applyStatus = firstNotBlank(apply.get("ascode"), "");
|
|
|
|
|
+ List<Map<String, Object>> audits = auditsByApply.get(applyId);
|
|
|
|
|
+ TreeSet<String> auditorNames = new TreeSet<String>();
|
|
|
|
|
+ Long latestAuditId = 0L;
|
|
|
|
|
+ int latestPriority = Integer.MAX_VALUE;
|
|
|
|
|
+ long latestSteps = Long.MIN_VALUE;
|
|
|
|
|
+
|
|
|
|
|
+ if (audits != null) {
|
|
|
|
|
+ for (Map<String, Object> audit : audits) {
|
|
|
|
|
+ String auditDcode = firstNotBlank(audit.get("dcode"), "");
|
|
|
|
|
+ String auditAcode = firstNotBlank(audit.get("acode"), "");
|
|
|
|
|
+ boolean waitingAudit = "11".equals(applyStatus) && "31".equals(auditDcode)
|
|
|
|
|
+ && audit.get("audit_time") == null
|
|
|
|
|
+ && ("51".equals(auditAcode) || "101".equals(auditAcode));
|
|
|
|
|
+ if (waitingAudit) {
|
|
|
|
|
+ String auditorName = firstNotBlank(audit.get("auditorName"), "");
|
|
|
|
|
+ if (!auditorName.isEmpty()) {
|
|
|
|
|
+ auditorNames.add(auditorName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int priority = audit.get("audit_time") != null ? 1 : 2;
|
|
|
|
|
+ if (waitingAudit) {
|
|
|
|
|
+ priority = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ long steps = 0L;
|
|
|
|
|
+ Long stepValue = parseLong(audit.get("steps"));
|
|
|
|
|
+ if (stepValue != null) {
|
|
|
|
|
+ steps = stepValue.longValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ Long auditId = parseLong(audit.get("auditid"));
|
|
|
|
|
+ long auditIdValue = auditId == null ? 0L : auditId.longValue();
|
|
|
|
|
+ long latestAuditIdValue = latestAuditId == null ? 0L : latestAuditId.longValue();
|
|
|
|
|
+ if (priority < latestPriority
|
|
|
|
|
+ || (priority == latestPriority && steps > latestSteps)
|
|
|
|
|
+ || (priority == latestPriority && steps == latestSteps
|
|
|
|
|
+ && auditIdValue > latestAuditIdValue)) {
|
|
|
|
|
+ latestPriority = priority;
|
|
|
|
|
+ latestSteps = steps;
|
|
|
|
|
+ latestAuditId = auditId;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ apply.put("currentAuditors", String.join("、", auditorNames));
|
|
|
|
|
+ apply.put("auditid", latestAuditId == null ? 0L : latestAuditId);
|
|
|
|
|
+ }
|
|
|
|
|
+ return applyList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|