Преглед изворни кода

fix:酒吧演出提交后区分审核状态

panzhilin пре 3 месеци
родитељ
комит
f485cc9f4f

+ 15 - 4
alien-store/src/main/java/shop/alien/store/controller/BarPerformanceController.java

@@ -66,12 +66,23 @@ public class BarPerformanceController {
      */
     @ApiOperation("新增或更新酒吧演出")
     @PostMapping("/saveOrUpdate")
-    public R<Integer> addOrUpdateBarPerformance(@RequestBody BarPerformance barPerformance) {
+    public R<BarPerformance> addOrUpdateBarPerformance(@RequestBody BarPerformance barPerformance) {
         log.info("BarPerformanceController.addOrUpdateBarPerformance?barPerformance={}", barPerformance);
         try {
-            int result = barPerformanceService.addOrUpdateBarPerformance(barPerformance);
-            if (result > 0) {
-                return R.success("操作成功");
+            BarPerformance result = barPerformanceService.addOrUpdateBarPerformance(barPerformance);
+            if (result != null) {
+                // 根据审核状态返回不同的提示信息
+                if (result.getReviewStatus() != null && result.getReviewStatus() == 2) {
+                    // 审核拒绝:数据已保存,但审核未通过
+                    return R.success("数据保存成功,但内容审核未通过:" + 
+                            (result.getRejectReason() != null ? result.getRejectReason() : "内容包含违规信息"));
+                } else if (result.getReviewStatus() != null && result.getReviewStatus() == 1) {
+                    // 审核通过
+                    return R.success("操作成功");
+                } else {
+                    // 其他状态
+                    return R.success("操作成功");
+                }
             } else {
                 return R.fail("操作失败");
             }

+ 3 - 2
alien-store/src/main/java/shop/alien/store/service/BarPerformanceService.java

@@ -25,11 +25,12 @@ public interface BarPerformanceService {
 
     /**
      * 新增或更新酒吧演出
+     * 审核不通过时也会保存数据,但会标记为审核拒绝状态
      *
      * @param barPerformance 演出信息
-     * @return 操作结果
+     * @return 保存后的演出对象(包含ID和审核状态)
      */
-    int addOrUpdateBarPerformance(BarPerformance barPerformance);
+    BarPerformance addOrUpdateBarPerformance(BarPerformance barPerformance);
 
     /**
      * 获取酒吧演出详情

+ 28 - 12
alien-store/src/main/java/shop/alien/store/service/impl/BarPerformanceServiceImpl.java

@@ -53,7 +53,7 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
     }
 
     @Override
-    public int addOrUpdateBarPerformance(BarPerformance barPerformance) {
+    public BarPerformance addOrUpdateBarPerformance(BarPerformance barPerformance) {
         // 1. 演出名称验证:必填且限20字
         if (StringUtils.isEmpty(barPerformance.getPerformanceName())) {
             throw new IllegalArgumentException("演出名称不能为空");
@@ -215,22 +215,23 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
             }
         }
         // 调用AI内容审核接口,文本和图片分开审核
-        // 如果检测到违规内容会抛出异常
+        // 审核失败时保存数据但标记为审核拒绝状态
         AiContentModerationUtil.AuditResult auditResult = aiContentModerationUtil.auditContent(moderationText, imageUrls);
         if (auditResult == null || !auditResult.isPassed()) {
-            // AI审核失败,设置审核状态为2(审核拒绝)并记录拒绝原因
+            // AI审核失败,设置审核状态为2(审核拒绝)并记录拒绝原因,但仍然保存数据
             String failureReason = (auditResult != null && StringUtils.isNotEmpty(auditResult.getFailureReason()))
                     ? auditResult.getFailureReason()
                     : "内容包含违规信息";
             barPerformance.setReviewStatus(2); // 审核拒绝
             barPerformance.setRejectReason(failureReason);
-            log.warn("酒吧演出内容审核失败:{}", failureReason);
-            throw new IllegalArgumentException("内容审核未通过:" + failureReason);
+            log.warn("酒吧演出内容审核失败:{},将保存数据并标记为审核拒绝状态", failureReason);
+            // 不抛出异常,继续保存数据,但reviewStatus已设置为2(审核拒绝)
+        } else {
+            // AI审核通过,设置审核状态为1(审核通过),清除拒绝原因
+            barPerformance.setReviewStatus(1); // 审核通过
+            barPerformance.setRejectReason(null); // 清除拒绝原因
+            log.info("酒吧演出内容审核通过");
         }
-        // AI审核通过,设置审核状态为1(审核通过),清除拒绝原因
-        barPerformance.setReviewStatus(1); // 审核通过
-        barPerformance.setRejectReason(null); // 清除拒绝原因
-        log.info("酒吧演出内容审核通过");
 
         Integer id = barPerformance.getId();
 
@@ -266,7 +267,12 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
             if (barPerformance.getPerformanceWeek() == null) {
                 barPerformance.setPerformanceWeek("");
             }
-            return barPerformanceMapper.insert(barPerformance);
+            int result = barPerformanceMapper.insert(barPerformance);
+            if (result > 0) {
+                // 返回保存后的对象,包含自动生成的ID和审核状态
+                return barPerformance;
+            }
+            return null;
         } else {
             // 更新操作:先查询记录是否存在
             BarPerformance existing = barPerformanceMapper.selectById(id);
@@ -299,10 +305,20 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
                 if (barPerformance.getPerformanceWeek() == null) {
                     barPerformance.setPerformanceWeek("");
                 }
-                return barPerformanceMapper.insert(barPerformance);
+                int result = barPerformanceMapper.insert(barPerformance);
+                if (result > 0) {
+                    // 返回保存后的对象,包含自动生成的ID和审核状态
+                    return barPerformance;
+                }
+                return null;
             } else {
                 // 记录存在,执行更新
-                return barPerformanceMapper.updateById(barPerformance);
+                int result = barPerformanceMapper.updateById(barPerformance);
+                if (result > 0) {
+                    // 返回更新后的对象(重新查询以获取完整信息)
+                    return barPerformanceMapper.selectById(id);
+                }
+                return null;
             }
         }
     }