Эх сурвалжийг харах

[fix]
修改图片审核方法

limeng 4 сар өмнө
parent
commit
a340d32fde

+ 1 - 8
common/common-huaweicloud/common-huaweicloud-moderation/src/main/java/com/tourism/common/huaweicloud/moderation/service/HuaweiCloudModerationService.java

@@ -3,7 +3,6 @@ package com.tourism.common.huaweicloud.moderation.service;
 import com.huaweicloud.sdk.core.auth.BasicCredentials;
 import com.huaweicloud.sdk.core.auth.ICredential;
 import com.huaweicloud.sdk.core.exception.ServiceResponseException;
-import com.huaweicloud.sdk.core.region.Region;
 import com.huaweicloud.sdk.moderation.v3.ModerationClient;
 import com.huaweicloud.sdk.moderation.v3.model.*;
 import com.huaweicloud.sdk.moderation.v3.region.ModerationRegion;
@@ -11,9 +10,7 @@ import com.tourism.common.huaweicloud.moderation.config.HuaweiCloudConfig;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.List;
 
 @Service
 public class HuaweiCloudModerationService {
@@ -34,10 +31,9 @@ public class HuaweiCloudModerationService {
 
         RunTextModerationRequest request = new RunTextModerationRequest();
         TextDetectionReq body = new TextDetectionReq();
-        body.withCategories(Arrays.asList("terrorism", "porn", "abuse", "ban"));
         TextDetectionDataReq databody = new TextDetectionDataReq();
-
         databody.withText(text);
+        body.withCategories(Arrays.asList("terrorism", "porn", "abuse", "ban"));
         body.withData(databody);
         body.withEventType("comment");
         request.withBody(body);
@@ -69,10 +65,7 @@ public class HuaweiCloudModerationService {
         CheckImageModerationRequest request = new CheckImageModerationRequest();
         ImageDetectionReq body = new ImageDetectionReq();
         body.withCategories(Arrays.asList("terrorism", "porn", "abuse", "ban"));
-        List<String> listbodyCategories = new ArrayList<>();
-        listbodyCategories.add("porn");
         body.withUrl(url);
-        body.withCategories(listbodyCategories);
         body.withEventType("head_image");
         request.withBody(body);
         try {