2 Commits

Author SHA1 Message Date
bao
0f3c9e78a6 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/test/java/com/bao/dating/DatingApplicationTests.java
2025-12-19 01:19:22 +08:00
bao
1051a7b84f 图片审核 文本审核测试类 2025-12-19 01:18:25 +08:00
3 changed files with 13 additions and 16 deletions

View File

@@ -25,7 +25,7 @@ public class GreenImageScan {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config() com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
.setAccessKeyId(accessKeyId) .setAccessKeyId(accessKeyId)
.setAccessKeySecret(secret); .setAccessKeySecret(secret);
// 访问的域名 // 访问的域名 - 修改为北京区域
config.endpoint = "imageaudit.cn-shanghai.aliyuncs.com"; config.endpoint = "imageaudit.cn-shanghai.aliyuncs.com";
com.aliyun.imageaudit20191230.Client client = new com.aliyun.imageaudit20191230.Client(config); com.aliyun.imageaudit20191230.Client client = new com.aliyun.imageaudit20191230.Client(config);
@@ -34,21 +34,21 @@ public class GreenImageScan {
for (String img: imageList) { for (String img: imageList) {
ScanImageRequest.ScanImageRequestTask task = new ScanImageRequest.ScanImageRequestTask(); ScanImageRequest.ScanImageRequestTask task = new ScanImageRequest.ScanImageRequestTask();
task.setImageURL(img); // 修复直接使用图片URL而不是转换为字符数组 task.setDataId(UUID.randomUUID().toString()); task.setImageURL(img);
task.setDataId(UUID.randomUUID().toString());
task.setImageTimeMillisecond(1L); task.setImageTimeMillisecond(1L);
task.setInterval(1); task.setInterval(1);
task.setMaxFrames(1); task.setMaxFrames(1);
taskList.add(task); taskList.add(task);
} }
//场景 //场景
List<String> sceneList = new ArrayList<>(); List<String> sceneList = new ArrayList<>();
// 移除了不支持的"antispam"场景,使用支持的场景 // 移除了不支持的"antispam"场景,使用支持的场景
sceneList.add("porn"); // 涉黄识别 sceneList.add("porn"); // 涉黄识别
sceneList.add("terrorism"); // 暴恐识别 sceneList.add("terrorism"); // 暴恐识别
sceneList.add("ad"); // 图片广告 sceneList.add("ad"); // 图片广告
sceneList.add("live"); // 不良场景 sceneList.add("live"); // 不良场景
sceneList.add("logo"); // logo识别 sceneList.add("logo"); // logo识别
com.aliyun.imageaudit20191230.models.ScanImageRequest scanImageRequest = new com.aliyun.imageaudit20191230.models.ScanImageRequest() com.aliyun.imageaudit20191230.models.ScanImageRequest scanImageRequest = new com.aliyun.imageaudit20191230.models.ScanImageRequest()
@@ -66,9 +66,6 @@ public class GreenImageScan {
ListIterator<ScanImageResponseBody.ScanImageResponseBodyDataResultsSubResults> listIterator = subResults.listIterator(); ListIterator<ScanImageResponseBody.ScanImageResponseBodyDataResultsSubResults> listIterator = subResults.listIterator();
while (listIterator.hasNext()) { while (listIterator.hasNext()) {
ScanImageResponseBody.ScanImageResponseBodyDataResultsSubResults item = listIterator.next(); ScanImageResponseBody.ScanImageResponseBodyDataResultsSubResults item = listIterator.next();
/* System.out.println("scene = [" + item.scene + "]");
System.out.println("suggestion = [" + item.suggestion + "]");
System.out.println("label = [" + item.label + "]");*/
if (!item.suggestion.equals("pass")) { if (!item.suggestion.equals("pass")) {
resultMap.put("suggestion", item.suggestion); resultMap.put("suggestion", item.suggestion);
@@ -82,14 +79,10 @@ public class GreenImageScan {
return resultMap; return resultMap;
} else { } else {
/* *
* 表明请求整体处理失败,原因视具体的情况详细分析
*/
System.out.println("the whole image scan request failed. response:" + JSON.toJSONString(scanImageResponse)); System.out.println("the whole image scan request failed. response:" + JSON.toJSONString(scanImageResponse));
return null; return null;
} }
} catch (com.aliyun.tea.TeaException teaException) { } catch (com.aliyun.tea.TeaException teaException) {
// 获取整体报错信息 // 获取整体报错信息
System.out.println(com.aliyun.teautil.Common.toJSONString(teaException)); System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
@@ -100,9 +93,5 @@ public class GreenImageScan {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
/* Map<String, String> resultMap = new HashMap<>();
resultMap.put("suggestion", "pass");
return resultMap;*/
} }
} }

View File

@@ -6,4 +6,12 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface PostMapper { public interface PostMapper {
int insert(Post post); int insert(Post post);
int increaseLikeCount(Long postId);
int selectLikeCount(Long postId);
int decreaseLikeCount(Long postId);
int deletePostById(Integer postId);
} }

View File

@@ -111,7 +111,7 @@ public class PostServiceImpl implements PostService {
} }
Post post = new Post(); Post post = new Post();
post.setUserId(postRequestDTO.getUserId()); post.setUserId(Long.valueOf(postRequestDTO.getUserId()));
post.setContent(postRequestDTO.getContent()); post.setContent(postRequestDTO.getContent());
post.setTags(postRequestDTO.getTags()); post.setTags(postRequestDTO.getTags());
post.setMediaOssKeys(new ArrayList<>()); post.setMediaOssKeys(new ArrayList<>());