Przeglądaj źródła

fix: 公告优化

matianxiang 3 miesięcy temu
rodzic
commit
91f9b1a130

+ 4 - 2
eitc-patient-app/src/main/java/com/eitc/patient/controller/AppNoticeManageController.java

@@ -6,6 +6,8 @@ import com.eitc.common.core.controller.BaseController;
6 6
 import com.eitc.common.core.domain.AjaxResult;
7 7
 import com.eitc.common.utils.StringUtils;
8 8
 import com.eitc.patient.domain.NoticeManage;
9
+import com.eitc.patient.enums.NoticeManageDisplayStatusEnum;
10
+import com.eitc.patient.enums.NoticeManagePublishStatusEnum;
9 11
 import com.eitc.patient.service.INoticeManageService;
10 12
 import io.swagger.annotations.Api;
11 13
 import io.swagger.annotations.ApiOperation;
@@ -38,8 +40,8 @@ public class AppNoticeManageController extends BaseController {
38 40
     public AjaxResult list(NoticeManage noticeManage) {
39 41
         LambdaQueryWrapper<NoticeManage> wrapper = Wrappers.<NoticeManage>lambdaQuery().orderByDesc(NoticeManage::getCreateDate)
40 42
                 .like(StringUtils.isNotBlank(noticeManage.getNoticeTitle()), NoticeManage::getNoticeTitle, noticeManage.getNoticeTitle())
41
-                .like(NoticeManage::getPublishStatus, 1)
42
-                .like(NoticeManage::getDisplayStatus, 2);
43
+                .like(NoticeManage::getPublishStatus, NoticeManagePublishStatusEnum.PUBLISH.getCode())
44
+                .like(NoticeManage::getDisplayStatus, NoticeManageDisplayStatusEnum.DISPLAY_PROGRESS.getCode());
43 45
         List<NoticeManage> list = noticeManageService.list(wrapper);
44 46
         return success(list);
45 47
     }

+ 34 - 0
eitc-patient-base/src/main/java/com/eitc/patient/enums/NoticeManageDisplayStatusEnum.java

@@ -0,0 +1,34 @@
1
+package com.eitc.patient.enums;
2
+
3
+/**
4
+ * NoticeManageDisplayStatusEnum
5
+ *
6
+ * @author mtx
7
+ * @date: 2024/07/31 17:22
8
+ */
9
+public enum NoticeManageDisplayStatusEnum {
10
+
11
+    // 显示状态(1未开始,2显示中,3已结束)
12
+    NOT_STARTED(1, "未开始"),
13
+    DISPLAY_PROGRESS(2, "显示中"),
14
+    IS_END(3, "已结束");
15
+
16
+    private final Integer code;
17
+    private final String info;
18
+
19
+    NoticeManageDisplayStatusEnum(Integer code, String info) {
20
+        this.code = code;
21
+        this.info = info;
22
+    }
23
+
24
+    public Integer getCode()
25
+    {
26
+        return code;
27
+    }
28
+
29
+    public String getInfo()
30
+    {
31
+        return info;
32
+    }
33
+
34
+}

+ 33 - 0
eitc-patient-base/src/main/java/com/eitc/patient/enums/NoticeManagePublishStatusEnum.java

@@ -0,0 +1,33 @@
1
+package com.eitc.patient.enums;
2
+
3
+/**
4
+ * NoticeManagePublishStatusEnum
5
+ *
6
+ * @author mtx
7
+ * @date: 2024/07/31 17:22
8
+ */
9
+public enum NoticeManagePublishStatusEnum {
10
+
11
+    // 发布状态(1发布,0未发布)
12
+    PUBLISH(1, "发布"),
13
+    NO_PUBLISH(0, "未发布");
14
+
15
+    private final Integer code;
16
+    private final String info;
17
+
18
+    NoticeManagePublishStatusEnum(Integer code, String info) {
19
+        this.code = code;
20
+        this.info = info;
21
+    }
22
+
23
+    public Integer getCode()
24
+    {
25
+        return code;
26
+    }
27
+
28
+    public String getInfo()
29
+    {
30
+        return info;
31
+    }
32
+
33
+}

+ 4 - 3
eitc-patient-base/src/main/java/com/eitc/patient/service/impl/NoticeManageServiceImpl.java

@@ -2,6 +2,7 @@ package com.eitc.patient.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 4
 import com.eitc.patient.domain.NoticeManage;
5
+import com.eitc.patient.enums.NoticeManageDisplayStatusEnum;
5 6
 import com.eitc.patient.mapper.NoticeManageMapper;
6 7
 import com.eitc.patient.service.INoticeManageService;
7 8
 import org.springframework.stereotype.Service;
@@ -41,13 +42,13 @@ public class NoticeManageServiceImpl extends ServiceImpl<NoticeManageMapper, Not
41 42
         // 比较当前时间与通知开始时间,判断通知是否已经开始
42 43
         if (now.compareTo(noticeStartTime) >= 0 && now.compareTo(noticeEndTime) <= 0) {
43 44
             // 如果当前时间在通知的开始和结束时间之间,返回状态码2,表示通知正在进行中
44
-            return 2;
45
+            return NoticeManageDisplayStatusEnum.DISPLAY_PROGRESS.getCode();
45 46
         } else if (now.compareTo(noticeStartTime) < 0) {
46 47
             // 如果当前时间早于通知开始时间,返回状态码1,表示通知尚未开始
47
-            return 1;
48
+            return NoticeManageDisplayStatusEnum.NOT_STARTED.getCode();
48 49
         } else if (now.compareTo(noticeEndTime) > 0) {
49 50
             // 如果当前时间晚于通知结束时间,返回状态码3,表示通知已经结束
50
-            return 3;
51
+            return NoticeManageDisplayStatusEnum.IS_END.getCode();
51 52
         } else {
52 53
             // 如果无法确定通知的状态,返回null
53 54
             return null;

+ 4 - 3
eitc-patient-pc/src/main/java/com/eitc/patient/controller/NoticeManageController.java

@@ -8,6 +8,7 @@ import com.eitc.common.core.domain.AjaxResult;
8 8
 import com.eitc.common.enums.BusinessType;
9 9
 import com.eitc.common.utils.StringUtils;
10 10
 import com.eitc.patient.domain.NoticeManage;
11
+import com.eitc.patient.enums.NoticeManagePublishStatusEnum;
11 12
 import com.eitc.patient.service.INoticeManageService;
12 13
 import io.swagger.annotations.Api;
13 14
 import io.swagger.annotations.ApiOperation;
@@ -84,7 +85,7 @@ public class NoticeManageController extends BaseController {
84 85
         if (Objects.isNull(noticeManage)) {
85 86
             return AjaxResult.error("公告不存在");
86 87
         }
87
-        if (Objects.equals(noticeManage.getPublishStatus(), 1)) {
88
+        if (Objects.equals(noticeManage.getPublishStatus(), NoticeManagePublishStatusEnum.PUBLISH.getCode())) {
88 89
             return AjaxResult.error("请先撤回");
89 90
         }
90 91
         noticeManage.setDisplayStatus(noticeManageService.checkDisplayStatus(noticeManage));
@@ -103,7 +104,7 @@ public class NoticeManageController extends BaseController {
103 104
             return AjaxResult.error("公告不存在");
104 105
         }
105 106
         NoticeManage notice = new NoticeManage();
106
-        notice.setPublishStatus(0);
107
+        notice.setPublishStatus(NoticeManagePublishStatusEnum.NO_PUBLISH.getCode());
107 108
         notice.setId(entry.getId());
108 109
         return toAjax(noticeManageService.updateById(notice));
109 110
     }
@@ -119,7 +120,7 @@ public class NoticeManageController extends BaseController {
119 120
         if (Objects.isNull(noticeManage)) {
120 121
             return AjaxResult.error("公告不存在");
121 122
         }
122
-        if (Objects.equals(noticeManage.getPublishStatus(), 1)) {
123
+        if (Objects.equals(noticeManage.getPublishStatus(), NoticeManagePublishStatusEnum.PUBLISH.getCode())) {
123 124
             return AjaxResult.error("请先撤回");
124 125
         }
125 126
         return toAjax(noticeManageService.removeById(id));