Skip to content

Commit 6a5d46e

Browse files
author
markjrzhang
committed
Merge branch 'mark-dev' into 'master' (merge request !38)
add tool to process ImageAuditingResponse
2 parents b07189d + bafafa1 commit 6a5d46e

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/main/java/com/qcloud/cos/demo/ci/AuditingResultUtil.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.qcloud.cos.model.ciModel.auditing.AudtingCommonInfo;
99
import com.qcloud.cos.model.ciModel.auditing.DetectType;
1010
import com.qcloud.cos.model.ciModel.auditing.IllegalInfo;
11+
import com.qcloud.cos.model.ciModel.auditing.ImageAuditingResponse;
1112
import com.qcloud.cos.model.ciModel.auditing.PoliticsInfo;
1213
import com.qcloud.cos.model.ciModel.auditing.PornInfo;
1314
import com.qcloud.cos.model.ciModel.auditing.SectionInfo;
@@ -32,6 +33,18 @@ public static AuditingResult getAuditingResult(AuditingJobsDetail jobsDetail) {
3233
return result;
3334
}
3435

36+
public static List<AuditingInfo> getImageInfoList(ImageAuditingResponse response) {
37+
AuditingJobsDetail jobsDetail = new AuditingJobsDetail();
38+
List<SectionInfo> sectionList = jobsDetail.getSectionList();
39+
SectionInfo sectionInfo = new SectionInfo();
40+
sectionInfo.setPoliticsInfo(response.getPoliticsInfo());
41+
sectionInfo.setPornInfo(response.getPornInfo());
42+
sectionInfo.setAdsInfo(response.getAdsInfo());
43+
sectionInfo.setTerroristInfo(response.getTerroristInfo());
44+
sectionList.add(sectionInfo);
45+
return getAuditingInfoList(jobsDetail);
46+
}
47+
3548
public static List<AuditingInfo> getAuditingInfoList(AuditingJobsDetail jobsDetail) {
3649
List<AuditingInfo> list = new ArrayList<>();
3750
List<SnapshotInfo> snapshotList = jobsDetail.getSnapshotList();

src/main/java/com/qcloud/cos/demo/ci/ImageAuditingDemo.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.qcloud.cos.demo.ci;
22

33
import com.qcloud.cos.COSClient;
4+
import com.qcloud.cos.model.ciModel.auditing.AuditingInfo;
45
import com.qcloud.cos.model.ciModel.auditing.ImageAuditingRequest;
56
import com.qcloud.cos.model.ciModel.auditing.ImageAuditingResponse;
67

8+
import java.util.List;
9+
710
/**
811
* 内容审核 图片审核接口相关demo 详情见https://cloud.tencent.com/document/product/460/37318
912
*/
@@ -28,11 +31,12 @@ public static void imageAuditing(COSClient client) {
2831
//2.1设置请求bucket
2932
request.setBucketName("demo-123456789");
3033
//2.2设置审核类型
31-
request.setDetectType("porn");
34+
request.setDetectType("porn,terrorist,politics,ads");
3235
//2.3设置bucket中的图片位置
3336
request.setObjectKey("1.png");
3437
//3.调用接口,获取任务响应对象
3538
ImageAuditingResponse response = client.imageAuditing(request);
36-
System.out.println(response);
39+
//4调用工具类,获取各审核类型详情集合 (也可自行根据业务解析)
40+
List<AuditingInfo> imageInfoList = AuditingResultUtil.getImageInfoList(response);
3741
}
3842
}

src/main/java/com/qcloud/cos/model/ciModel/auditing/AuditingInfo.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.qcloud.cos.model.ciModel.auditing;
22

3+
import java.util.Arrays;
4+
35
/**
46
* 审核结果信息
57
*/
@@ -86,4 +88,17 @@ public String getCount() {
8688
public void setCount(String count) {
8789
this.count = count;
8890
}
91+
92+
@Override
93+
public String toString() {
94+
final StringBuilder sb = new StringBuilder("AuditingInfo{");
95+
sb.append("type=").append(type);
96+
sb.append(", typeName='").append(typeName).append('\'');
97+
sb.append(", keyWords=").append(Arrays.toString(keyWords));
98+
sb.append(", hitFlag='").append(hitFlag).append('\'');
99+
sb.append(", score='").append(score).append('\'');
100+
sb.append(", count='").append(count).append('\'');
101+
sb.append('}');
102+
return sb.toString();
103+
}
89104
}

0 commit comments

Comments
 (0)