Quellcode durchsuchen

fix:优化边界处理

msdev vor 4 Monaten
Ursprung
Commit
e4be11520b

+ 47 - 18
src/main/java/net/mingsoft/cms/action/CategoryAction.java

@@ -164,28 +164,32 @@ public class CategoryAction extends BaseAction {
     @LogAnn(title = "保存分类", businessType = BusinessTypeEnum.INSERT)
     @RequiresPermissions("cms:category:save")
     public ResultData save(@ModelAttribute @Parameter(hidden = true) CategoryEntity category) {
-        //验证缩略图参数值是否合法
+        //验证banner图参数值是否合法
         if (category.getCategoryImg() == null || !category.getCategoryImg().matches("^\\[.{1,}]$")) {
             category.setCategoryImg("");
         }
+        //验证栏目小图参数值是否合法
+        if (category.getCategoryIco() == null || !category.getCategoryIco().matches("^\\[.{1,}]$")) {
+            category.setCategoryIco("");
+        }
         //验证栏目管理名称的值是否合法
         if (StringUtils.isBlank(category.getCategoryTitle())) {
             return ResultData.build().error(getResString("err.empty", this.getResString("category.title")));
         }
-        if (!StringUtil.checkLength(category.getCategoryTitle() + "", 1, 100)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("category.title"), "1", "100"));
+        if (!StringUtil.checkLength(category.getCategoryTitle() + "", 1, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.title"), "1", "200"));
         }
         //验证栏目描述的值是否合法
         if (!StringUtil.checkLength(category.getCategoryDescrip() + "", 0, 500)) {
             return ResultData.build().error(getResString("err.length", this.getResString("category.descrip"), "0", "500"));
         }
         //验证栏目关键字的值是否合法
-        if (!StringUtil.checkLength(category.getCategoryKeyword() + "", 0, 300)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("category.keyword"), "0", "300"));
+        if (!StringUtil.checkLength(category.getCategoryKeyword() + "", 0, 100)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.keyword"), "0", "100"));
         }
         //验证栏目路径的值是否合法
-        if (!StringUtil.checkLength(category.getCategoryPath() + "", 0, 500)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("category.path"), "0", "500"));
+        if (!StringUtil.checkLength(category.getCategoryPath() + "", 0, 400)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.path"), "0", "400"));
         }
         //验证栏目列表模板的值是否合法
         if (!StringUtil.checkLength(category.getCategoryListUrl() + "", 0, 50)) {
@@ -197,8 +201,8 @@ public class CategoryAction extends BaseAction {
         }
 
         //验证栏目自定义链接的值是否合法
-        if (!StringUtil.checkLength(category.getCategoryDiyUrl() + "", 0, 255)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("category.diy.url"), "0", "255"));
+        if (!StringUtil.checkLength(category.getCategoryDiyUrl() + "", 0, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.diy.url"), "0", "200"));
         }
         //验证栏目属性的值是否合法
         if (!StringUtil.checkLength(category.getCategoryFlag() + "", 0, 20)) {
@@ -227,6 +231,17 @@ public class CategoryAction extends BaseAction {
         if (!StringUtil.checkLength(category.getCategoryParentIds() + "", 1, 100)) {
             return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
         }
+        // 验证栏目副标题的值是否合法
+        if (!StringUtil.checkLength(category.getCategoryShortTitle() + "", 0, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.short.title"), "0", "200"));
+        }
+        if (StringUtils.isBlank(category.getCategoryDisplay())){
+            return ResultData.build().error(getResString("err.empty",this.getResString("category.display")));
+        }
+        if (StringUtils.isBlank(category.getCategoryIsSearch())){
+            return ResultData.build().error(getResString("err.empty",this.getResString("category.is.search")));
+        }
+
         //判断拼音是否重复
         if (StrUtil.isNotBlank(category.getCategoryPinyin())) {
             if (!category.getCategoryPinyin().matches("^[a-zA-Z0-9]*$")){
@@ -295,10 +310,14 @@ public class CategoryAction extends BaseAction {
     @LogAnn(title = "更新分类", businessType = BusinessTypeEnum.UPDATE)
     @RequiresPermissions("cms:category:update")
     public ResultData update(@ModelAttribute @Parameter(hidden = true) CategoryEntity category) {
-        //验证缩略图参数值是否合法
+        //验证banner图参数值是否合法
         if (category.getCategoryImg() == null || !category.getCategoryImg().matches("^\\[.{1,}]$")) {
             category.setCategoryImg("");
         }
+        //验证栏目小图参数值是否合法
+        if (category.getCategoryIco() == null || !category.getCategoryIco().matches("^\\[.{1,}]$")) {
+            category.setCategoryIco("");
+        }
         if (StringUtils.isEmpty(category.getId())){
             return ResultData.build().error(getResString("err.empty", this.getResString("category.id")));
         }
@@ -306,20 +325,20 @@ public class CategoryAction extends BaseAction {
         if (StringUtils.isBlank(category.getCategoryTitle())) {
             return ResultData.build().error(getResString("err.empty", this.getResString("category.title")));
         }
-        if (!StringUtil.checkLength(category.getCategoryTitle() + "", 1, 100)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("category.title"), "1", "100"));
+        if (!StringUtil.checkLength(category.getCategoryTitle() + "", 1, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.title"), "1", "200"));
         }
         //验证栏目描述的值是否合法
         if (!StringUtil.checkLength(category.getCategoryDescrip() + "", 0, 500)) {
             return ResultData.build().error(getResString("err.length", this.getResString("category.descrip"), "0", "500"));
         }
         //验证栏目关键字的值是否合法
-        if (!StringUtil.checkLength(category.getCategoryKeyword() + "", 0, 300)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("category.keyword"), "0", "300"));
+        if (!StringUtil.checkLength(category.getCategoryKeyword() + "", 0, 100)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.keyword"), "0", "100"));
         }
         //验证栏目自定义链接的值是否合法
-        if (!StringUtil.checkLength(category.getCategoryDiyUrl() + "", 0, 255)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("category.diy.url"), "0", "255"));
+        if (!StringUtil.checkLength(category.getCategoryDiyUrl() + "", 0, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.diy.url"), "0", "200"));
         }
         //验证栏目属性的值是否合法
         if (!StringUtil.checkLength(category.getCategoryFlag() + "", 0, 20)) {
@@ -330,8 +349,8 @@ public class CategoryAction extends BaseAction {
             return ResultData.build().error(getResString("err.length", this.getResString("category.list.url"), "0", "50"));
         }
         //验证栏目路径的值是否合法
-        if (!StringUtil.checkLength(category.getCategoryPath() + "", 0, 500)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("category.path"), "0", "500"));
+        if (!StringUtil.checkLength(category.getCategoryPath() + "", 0, 400)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.path"), "0", "400"));
         }
         //验证栏目类型的值是否合法
         if (!StringUtil.checkLength(category.getCategoryType() + "", 0, 1)) {
@@ -349,6 +368,16 @@ public class CategoryAction extends BaseAction {
         if (!StringUtil.checkLength(category.getCategoryParentIds() + "", 0, 100)) {
             return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
         }
+        // 验证栏目副标题的值是否合法
+        if (!StringUtil.checkLength(category.getCategoryShortTitle() + "", 0, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("category.short.title"), "0", "200"));
+        }
+        if (StringUtils.isBlank(category.getCategoryDisplay())){
+            return ResultData.build().error(getResString("err.empty",this.getResString("category.display")));
+        }
+        if (StringUtils.isBlank(category.getCategoryIsSearch())){
+            return ResultData.build().error(getResString("err.empty",this.getResString("category.is.search")));
+        }
         // 过滤非法路径
         if (FileNameUtil.containsInvalid(category.getCategoryPinyin())) {
             return ResultData.build().error(this.getResString("err.error",this.getResString("category.pinyin")));

+ 34 - 16
src/main/java/net/mingsoft/cms/action/ContentAction.java

@@ -219,20 +219,20 @@ public class ContentAction extends BaseAction {
             return ResultData.build().error(getResString("err.length", this.getResString("content.source"), "0", "200"));
         }
         //验证文章描述的值是否合法
-        if (!StringUtil.checkLength(content.getContentDescription() + "", 0, 400)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("content.description"), "0", "400"));
+        if (!StringUtil.checkLength(content.getContentDescription() + "", 0, 500)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("content.description"), "0", "500"));
         }
         //验证文章链接的值是否合法
-        if (!StringUtil.checkLength(content.getContentOutLink() + "", 0, 255)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "255"));
+        if (!StringUtil.checkLength(content.getContentOutLink() + "", 0, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200"));
         }
         //验证文章显示的值是否合法
-        if (!StringUtil.checkLength(content.getContentDisplay() + "", 0, 1)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("content.display"), "0", "1"));
+        if (StringUtils.isBlank(content.getContentDisplay())) {
+            return ResultData.build().error(getResString("err.empty", this.getResString("content.display")));
         }
         //验证文章关键字的值是否合法
-        if (!StringUtil.checkLength(content.getContentKeyword() + "", 0, 255)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("content.keyword"), "0", "255"));
+        if (!StringUtil.checkLength(content.getContentKeyword() + "", 0, 100)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("content.keyword"), "0", "100"));
         }
         //验证文章类型的值是否合法
         if (!StringUtil.checkLength(content.getContentType() + "", 0, 20)) {
@@ -242,6 +242,15 @@ public class ContentAction extends BaseAction {
         if (content.getContentDatetime()==null) {
             return ResultData.build().error(getResString("err.empty", this.getResString("content.datetime")));
         }
+
+        if (!StringUtil.checkLength(content.getContentShortTitle() + "", 0, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("content.short.title"), "0", "200"));
+        }
+        // 文章标签限制5个
+        if (StringUtils.isNotEmpty(content.getContentTags()) && content.getContentTags().split(",").length > 5){
+            return ResultData.build().error(getResString("err.length",this.getResString("content.tags"),"0","5"));
+        }
+
         contentBiz.save(content);
         return ResultData.build().success(content);
     }
@@ -325,20 +334,20 @@ public class ContentAction extends BaseAction {
             return ResultData.build().error(getResString("err.length", this.getResString("content.source"), "0", "200"));
         }
         //验证文章描述的值是否合法
-        if (!StringUtil.checkLength(content.getContentDescription() + "", 0, 400)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("content.description"), "0", "400"));
+        if (!StringUtil.checkLength(content.getContentDescription() + "", 0, 500)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("content.description"), "0", "500"));
         }
         //验证文章链接的值是否合法
-        if (!StringUtil.checkLength(content.getContentOutLink() + "", 0, 255)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "255"));
+        if (!StringUtil.checkLength(content.getContentOutLink() + "", 0, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200"));
         }
         //验证文章显示的值是否合法
-        if (!StringUtil.checkLength(content.getContentDisplay() + "", 0, 1)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("content.display"), "0", "1"));
+        if (StringUtils.isBlank(content.getContentDisplay())) {
+            return ResultData.build().error(getResString("err.empty", this.getResString("content.display")));
         }
         //验证文章关键字的值是否合法
-        if (!StringUtil.checkLength(content.getContentKeyword() + "", 0, 255)) {
-            return ResultData.build().error(getResString("err.length", this.getResString("content.keyword"), "0", "255"));
+        if (!StringUtil.checkLength(content.getContentKeyword() + "", 0, 100)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("content.keyword"), "0", "100"));
         }
         //验证文章类型的值是否合法
         if (!StringUtil.checkLength(content.getContentType() + "", 0, 20)) {
@@ -348,6 +357,15 @@ public class ContentAction extends BaseAction {
         if (content.getContentDatetime()==null) {
             return ResultData.build().error(getResString("err.empty", this.getResString("content.datetime")));
         }
+
+        if (!StringUtil.checkLength(content.getContentShortTitle() + "", 0, 200)) {
+            return ResultData.build().error(getResString("err.length", this.getResString("content.short.title"), "0", "200"));
+        }
+        // 文章标签限制5个
+        if (StringUtils.isNotEmpty(content.getContentTags()) && content.getContentTags().split(",").length > 5){
+            return ResultData.build().error(getResString("err.length",this.getResString("content.tags"),"0","5"));
+        }
+
         contentBiz.saveOrUpdate(content);
         return ResultData.build().success(content);
     }

+ 4 - 1
src/main/java/net/mingsoft/cms/action/web/ContentAction.java

@@ -92,12 +92,15 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
 			@Parameter(name = "size", description = "一页显示数量", required =false, in= ParameterIn.QUERY),
 			@Parameter(name = "orderby", description = "排序", required =false, in= ParameterIn.QUERY),
     })
-	@GetMapping(value = "/list")
+	@RequestMapping(value = "/list",method = {RequestMethod.GET,RequestMethod.POST})
 	@ResponseBody
 	public ResultData list(HttpServletResponse response, HttpServletRequest request) {
 		//会将请求参数全部转换map
 		Map map = BasicUtil.assemblyRequestMap();
 		String typeid = (String) map.get("typeid");
+		 if (StrUtil.isBlank(typeid)){
+			typeid = (String) map.get("categoryId");
+		}
 		ContentBean content = new ContentBean();
 		if (StrUtil.isNotBlank(typeid)){
 			content.setCategoryId(typeid);

+ 10 - 0
src/main/java/net/mingsoft/cms/resources/resources_en_US.properties

@@ -37,3 +37,13 @@ template.file=template file not found
 category.pinyin=pinyin
 datetime.format=datatime format
 cannot.select.child=cannot select child node
+content.short.title=Subtitle of the article
+content.title.css=Article Title Style
+content.out.link=External links to the article
+content.style=Article published to
+content.category.ids=Article Supplementary Column
+category.short.title=Column Subtitle
+category.display=Whether to display
+category.is.search=Whether to search
+
+

+ 8 - 1
src/main/java/net/mingsoft/cms/resources/resources_zh_CN.properties

@@ -37,4 +37,11 @@ template.file=\u672A\u627E\u5230\u6A21\u677F\u6587\u4EF6
 category.pinyin=\u62FC\u97F3
 datetime.format=\u65F6\u95F4\u683C\u5F0F
 cannot.select.child=\u65e0\u6cd5\u9009\u62e9\u5b50\u8282\u70b9
-
+content.short.title=\u6587\u7ae0\u526f\u6807\u9898
+content.title.css=\u6587\u7ae0\u6807\u9898\u6837\u5f0f
+content.out.link=\u6587\u7ae0\u5916\u94fe\u63a5
+content.style=\u6587\u7ae0\u53d1\u5e03\u5230
+content.category.ids=\u6587\u7ae0\u9644\u5c5e\u680f\u76ee
+category.short.title=\u680f\u76ee\u526f\u6807\u9898
+category.display=\u662F\u5426\u663E\u793A
+category.is.search=\u662f\u5426\u53ef\u88ab\u641c\u7d22