|
|
@@ -28,6 +28,7 @@ import com.etotem.cfc.service.AttributionAnalysisService;
|
|
|
import com.etotem.cfc.service.CartService;
|
|
|
import com.etotem.cfc.service.HealthPlanService;
|
|
|
import com.etotem.cfc.service.ProductRecommendationService;
|
|
|
+import com.etotem.cfc.service.api.WechatServiceInterface;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
@@ -101,6 +102,10 @@ public class HealthPlanServiceImpl implements HealthPlanService {
|
|
|
@Resource
|
|
|
private ProductMapper productMapper;
|
|
|
|
|
|
+ /** SC-T-28:AI 方案内容安全复核(命中即拦截,发布于复核通过后) */
|
|
|
+ @Resource
|
|
|
+ private WechatServiceInterface contentSafetyService;
|
|
|
+
|
|
|
@Value("${langgraph.base-url:}")
|
|
|
private String langgraphBaseUrl;
|
|
|
|
|
|
@@ -1928,6 +1933,8 @@ public class HealthPlanServiceImpl implements HealthPlanService {
|
|
|
if (!"pending_review".equals(plan.getStatus()) && !"draft".equals(plan.getStatus())) {
|
|
|
throw new RuntimeException("方案状态不允许审核");
|
|
|
}
|
|
|
+ // SC-T-28:AI 方案内容安全复核 —— 命中即拦截,未通过前不得置为 published
|
|
|
+ assertPlanContentSafe(plan);
|
|
|
plan.setStatus("published");
|
|
|
plan.setReviewedBy(reviewedBy);
|
|
|
plan.setReviewedAt(new Date());
|
|
|
@@ -1960,6 +1967,31 @@ public class HealthPlanServiceImpl implements HealthPlanService {
|
|
|
return dto;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * SC-T-28:AI 方案内容安全复核(命中即拦截)。
|
|
|
+ *
|
|
|
+ * <p>方案正文({@code planContent})非空时须经内容安全原语 {@code checkText(String)} 复核;
|
|
|
+ * 命中敏感内容(返回 false)或内容安全依赖未配置(fail-closed)时,抛业务异常阻止发布,
|
|
|
+ * 保证状态不落库、不置为 published。</p>
|
|
|
+ */
|
|
|
+ private void assertPlanContentSafe(HealthPlan plan) {
|
|
|
+ String content = plan.getPlanContent();
|
|
|
+ if (content == null || content.trim().isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ boolean safe;
|
|
|
+ if (contentSafetyService == null) {
|
|
|
+ // fail-closed:审核链路未配置内容安全依赖时不允许发布,避免绕过复核
|
|
|
+ safe = false;
|
|
|
+ log.warn("方案{}内容安全复核依赖未配置,按不通过处理(fail-closed)", plan.getId());
|
|
|
+ } else {
|
|
|
+ safe = contentSafetyService.checkText(content);
|
|
|
+ }
|
|
|
+ if (!safe) {
|
|
|
+ throw new RuntimeException("方案内容未通过内容安全复核,请修改后重新送审");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public HealthPlan rejectPlan(Long planId, Long reviewedBy, String comment) {
|
|
|
HealthPlan plan = healthPlanMapper.selectById(planId);
|