소스 검색

fix
增加对段落超出字数限制的提醒
完善发布游记时,检测不到封面图的提醒

chenchen 4 달 전
부모
커밋
3e9bd13e57

+ 12 - 1
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/WebSiteTourismTravelNotesPublishController.java

@@ -93,6 +93,12 @@ public class WebSiteTourismTravelNotesPublishController {
 
         //将从表中的数据进行过滤,筛选出cover为1的图片为封面图,第一段落为项目简述
         List<TourismTravelNotesContentWriteDto> travelNotesContent = tourismProjectTravelNotesWriteDto.getTravelNotesContent();
+
+        //循环遍历查询内容是否超过5000长度
+        for(TourismTravelNotesContentWriteDto i:travelNotesContent){
+            if(StringUtils.isNotBlank(i.getContent()) && i.getContent().length()>5000)
+                return ResponseResult.error(ErrorCodeEnum.CONTENT_OUT_LIMIT);
+        }
         List<TourismTravelNotesContentWriteDto> coverImageList = travelNotesContent.stream().filter(item -> item.getType().equals("image") && item.getCover() != null && item.getCover() == 1).collect(Collectors.toList());
         List<TourismTravelNotesContentWriteDto> coverImageList1 = travelNotesContent.stream().filter(item -> item.getType().equals("image")).collect(Collectors.toList());
         if(CollectionUtils.isEmpty(coverImageList)){
@@ -129,7 +135,6 @@ public class WebSiteTourismTravelNotesPublishController {
         return ResponseResult.success();
     }
 
-
     /**
      * 获取数据列表
      * param type--->类型(0,草稿;1,待审核;2,审核未通过;3,审核通过
@@ -236,6 +241,12 @@ public class WebSiteTourismTravelNotesPublishController {
 
         //将从表中的数据进行过滤,筛选出cover为1的图片为封面图,第一段落为项目简述
         List<TourismTravelNotesContentWriteDto> travelNotesContent = tourismProjectTravelNotesWriteDto.getTravelNotesContent();
+
+        //循环遍历查询内容是否超过5000长度
+        for(TourismTravelNotesContentWriteDto i:travelNotesContent){
+            if(StringUtils.isNotBlank(i.getContent()) && i.getContent().length()>5000)
+                return ResponseResult.error(ErrorCodeEnum.CONTENT_OUT_LIMIT);
+        }
         List<TourismTravelNotesContentWriteDto> coverImageList = travelNotesContent.stream().filter(item -> item.getType().equals("image") && item.getCover() != null && item.getCover() == 1).collect(Collectors.toList());
         List<TourismTravelNotesContentWriteDto> coverImageList1 = travelNotesContent.stream().filter(item -> item.getType().equals("image")).collect(Collectors.toList());
         if(CollectionUtils.isEmpty(coverImageList)){

+ 3 - 1
common/common-core/src/main/java/com/tourism/common/core/constant/ErrorCodeEnum.java

@@ -77,7 +77,9 @@ public enum ErrorCodeEnum {
     PROJECT_NOT_EXIST("该项目不存在,请重新选择!"),
     DATE_PRICE_NOTEXIST("请先编辑日历价格!"),
     DATA_NOT_FOUND("数据不存在,请联系管理员!"),
-    NOT_COVER("游记内容中至少包含一张图片!");
+    NOT_COVER("游记内容中至少包含一张图片!"),
+
+    CONTENT_OUT_LIMIT("段落请勿超过5000字,请重新填写!");
     // 下面的枚举值为特定枚举值,即开发者可以根据自己的项目需求定义更多的非通用枚举值
 
     /**