Przeglądaj źródła

修复文章提交字段映射并发初始化问题

将 Article 静态字段映射从构造函数懒加载改为类加载时一次性初始化,避免并发请求共同写入 HashMap 导致 dcode、title 等字段映射丢失,进而触发文章 INSERT 报 Field 'dcode' doesn't have a default value。已在生产内网真实提交回归并同步外网节点。
非繁 5 dni temu
rodzic
commit
6ee6518442
1 zmienionych plików z 30 dodań i 29 usunięć
  1. 30 29
      src/apps/pojo/Article.java

+ 30 - 29
src/apps/pojo/Article.java

@@ -37,39 +37,40 @@ public class Article extends PageBean {
 	private Long guestAccessFlag;
 	private Long sortNumber;
 
+	static {
+		ARTICLE_FIELDS_MAPPING.put("articleid", new String[] { "articleid", "articleid", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("dcode", new String[] { "dcode", "dcode", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("websiteid", new String[] { "websiteid", "websiteid", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("unitid", new String[] { "unitid", "unitid", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("ascode", new String[] { "ascode", "ascode", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("navigationid", new String[] { "navigationid", "navigationid", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("title", new String[] { "title", "title", "String" });
+		ARTICLE_FIELDS_MAPPING.put("ajtcode", new String[] { "ajtcode", "ajtcode", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("desc", new String[] { "desc", "desc", "String" });
+		ARTICLE_FIELDS_MAPPING.put("source", new String[] { "source", "source", "String" });
+		ARTICLE_FIELDS_MAPPING.put("thumbnail", new String[] { "thumbnail", "thumbnail", "String" });
+		ARTICLE_FIELDS_MAPPING.put("sticktop", new String[] { "sticktop", "sticktop", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("sticktopEndTime", new String[] { "sticktop_end_time", "sticktopEndTime", "Timestamp" });
+		ARTICLE_FIELDS_MAPPING.put("sticktopSchedulesid", new String[] { "sticktop_schedulesid", "sticktopSchedulesid", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("release", new String[] { "release", "release", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("releaseTime", new String[] { "release_time", "releaseTime", "Timestamp" });
+		ARTICLE_FIELDS_MAPPING.put("releaseTaskSchedulesid", new String[] { "release_task_schedulesid", "releaseTaskSchedulesid", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("content", new String[] { "content", "content", "String" });
+		ARTICLE_FIELDS_MAPPING.put("editContent", new String[] { "edit_content", "editContent", "String" });
+		ARTICLE_FIELDS_MAPPING.put("url", new String[] { "url", "url", "String" });
+		ARTICLE_FIELDS_MAPPING.put("readCount", new String[] { "read_count", "readCount", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("createTime", new String[] { "create_time", "createTime", "Timestamp" });
+		ARTICLE_FIELDS_MAPPING.put("lastChangeTime", new String[] { "last_change_time", "lastChangeTime", "Timestamp" });
+		ARTICLE_FIELDS_MAPPING.put("createPid", new String[] { "create_pid", "createPid", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("lastChangePid", new String[] { "last_change_pid", "lastChangePid", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("guestAccessFlag", new String[] { "guest_access_flag", "guestAccessFlag", "Long" });
+		ARTICLE_FIELDS_MAPPING.put("sortNumber", new String[] { "sort_number", "sortNumber", "Long" });
+	}
+
 	public Article() {
 		this.clsInfo = " SpaceCore Compatible Version; Date: 2026/07/19;";
 		this.setObjName("Article");
 		this.setDbTableName("article");
-		if (ARTICLE_FIELDS_MAPPING.size() == 0) {
-			ARTICLE_FIELDS_MAPPING.put("articleid", new String[] { "articleid", "articleid", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("dcode", new String[] { "dcode", "dcode", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("websiteid", new String[] { "websiteid", "websiteid", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("unitid", new String[] { "unitid", "unitid", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("ascode", new String[] { "ascode", "ascode", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("navigationid", new String[] { "navigationid", "navigationid", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("title", new String[] { "title", "title", "String" });
-			ARTICLE_FIELDS_MAPPING.put("ajtcode", new String[] { "ajtcode", "ajtcode", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("desc", new String[] { "desc", "desc", "String" });
-			ARTICLE_FIELDS_MAPPING.put("source", new String[] { "source", "source", "String" });
-			ARTICLE_FIELDS_MAPPING.put("thumbnail", new String[] { "thumbnail", "thumbnail", "String" });
-			ARTICLE_FIELDS_MAPPING.put("sticktop", new String[] { "sticktop", "sticktop", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("sticktopEndTime", new String[] { "sticktop_end_time", "sticktopEndTime", "Timestamp" });
-			ARTICLE_FIELDS_MAPPING.put("sticktopSchedulesid", new String[] { "sticktop_schedulesid", "sticktopSchedulesid", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("release", new String[] { "release", "release", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("releaseTime", new String[] { "release_time", "releaseTime", "Timestamp" });
-			ARTICLE_FIELDS_MAPPING.put("releaseTaskSchedulesid", new String[] { "release_task_schedulesid", "releaseTaskSchedulesid", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("content", new String[] { "content", "content", "String" });
-			ARTICLE_FIELDS_MAPPING.put("editContent", new String[] { "edit_content", "editContent", "String" });
-			ARTICLE_FIELDS_MAPPING.put("url", new String[] { "url", "url", "String" });
-			ARTICLE_FIELDS_MAPPING.put("readCount", new String[] { "read_count", "readCount", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("createTime", new String[] { "create_time", "createTime", "Timestamp" });
-			ARTICLE_FIELDS_MAPPING.put("lastChangeTime", new String[] { "last_change_time", "lastChangeTime", "Timestamp" });
-			ARTICLE_FIELDS_MAPPING.put("createPid", new String[] { "create_pid", "createPid", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("lastChangePid", new String[] { "last_change_pid", "lastChangePid", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("guestAccessFlag", new String[] { "guest_access_flag", "guestAccessFlag", "Long" });
-			ARTICLE_FIELDS_MAPPING.put("sortNumber", new String[] { "sort_number", "sortNumber", "Long" });
-		}
 	}
 
 	public HashMap getFieldMap() {