Selaa lähdekoodia

fix(backend): 活动提交审核业务异常转400提示并支持退回草稿

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
E2E Test Bot 3 viikkoa sitten
vanhempi
sitoutus
c08e467458

+ 12 - 10
cfc-backend/src/main/java/com/etotem/cfc/service/ActivityAdminService.java

@@ -110,10 +110,10 @@ public class ActivityAdminService {
     public void submitForReview(Long id) {
         Activity activity = activityMapper.selectById(id);
         if (activity == null) {
-            throw new RuntimeException("活动不存在");
+            throw new IllegalStateException("活动不存在");
         }
         if (!"draft".equals(activity.getStatus())) {
-            throw new RuntimeException("仅草稿状态可提交审核");
+            throw new IllegalStateException("仅草稿状态可提交审核");
         }
         activity.setStatus("pending");
         activity.setAuditStatus("pending");
@@ -124,13 +124,13 @@ public class ActivityAdminService {
     public void auditActivity(Long id, String action, String auditReason, Long adminId) {
         Activity activity = activityMapper.selectById(id);
         if (activity == null) {
-            throw new RuntimeException("活动不存在");
+            throw new IllegalStateException("活动不存在");
         }
         if (!"pending".equals(activity.getStatus())) {
-            throw new RuntimeException("仅待审核状态可审核");
+            throw new IllegalStateException("仅待审核状态可审核");
         }
         if (!"approved".equals(action) && !"rejected".equals(action)) {
-            throw new RuntimeException("审核操作无效");
+            throw new IllegalStateException("审核操作无效");
         }
         if ("approved".equals(action)) {
             activity.setStatus("published");
@@ -149,10 +149,10 @@ public class ActivityAdminService {
     public void withdraw(Long id) {
         Activity activity = activityMapper.selectById(id);
         if (activity == null) {
-            throw new RuntimeException("活动不存在");
+            throw new IllegalStateException("活动不存在");
         }
         if (!"published".equals(activity.getStatus())) {
-            throw new RuntimeException("仅发布中的活动可撤回");
+            throw new IllegalStateException("仅发布中的活动可撤回");
         }
         activity.setStatus("withdrawn");
         activityMapper.updateById(activity);
@@ -162,10 +162,12 @@ public class ActivityAdminService {
     public void reDraft(Long id) {
         Activity activity = activityMapper.selectById(id);
         if (activity == null) {
-            throw new RuntimeException("活动不存在");
+            throw new IllegalStateException("活动不存在");
         }
-        if (!"rejected".equals(activity.getStatus())) {
-            throw new RuntimeException("仅已驳回的活动可重新编辑");
+        // 已驳回/已撤回/已发布的活动均可退回草稿重新编辑
+        String status = activity.getStatus();
+        if (!"rejected".equals(status) && !"withdrawn".equals(status) && !"published".equals(status)) {
+            throw new IllegalStateException("当前状态不可退回草稿");
         }
         activity.setStatus("draft");
         activity.setAuditStatus(null);