Commit abba8913 authored by 刘基明's avatar 刘基明

图片审核添加待审核类型

parent b05c24c1
......@@ -8,7 +8,8 @@ public enum FileChechStatusEnum {
INIT(0,"初始化"),
PASS(1,"审核通过"),
FAILED(2,"审核不通过");
FAILED(2,"审核不通过"),
REVIEW(3,"建议人工审核");
public static final HashSet<String> ossTypeSet = SetUtils.hashSet("jpg", "jpeg", "png", "txt");
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.enums.FileChechStatusEnum;
import com.tanpu.community.manager.FileManager;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
......@@ -42,10 +44,16 @@ public class CallBackController {
Map<String, Object> response = JsonUtil.toMap(content);
String fileKey = (String) response.get("object");
boolean freezed = (boolean) response.get("freezed");
FileChechStatusEnum type = freezed ? FileChechStatusEnum.FAILED : FileChechStatusEnum.PASS;
HashMap<String, Object> scanResult = (HashMap<String, Object>) response.get("scanResult");
String taskId = (String) scanResult.get("taskId");
String resultLog = JsonUtil.toJson(scanResult.get("results"));
fileManager.updateCheckResult(fileKey, freezed, taskId, resultLog);
List<HashMap<String, Object>> scenes = (List<HashMap<String, Object>>) scanResult.get("results");
for (HashMap<String, Object> scene : scenes) {
if (!"pass".equals(scene.get("suggestion"))) {
type=FileChechStatusEnum.REVIEW;
}
}
fileManager.updateCheckResult(fileKey, type, taskId, JsonUtil.toJson(scanResult));
return "success";
}
......
......@@ -15,6 +15,7 @@ import com.aliyuncs.profile.IClientProfile;
import com.tanpu.common.constant.ErrorCodeConstant;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.enums.FileChechStatusEnum;
import com.tanpu.community.api.enums.OssDirEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.service.OSSFileService;
......@@ -73,19 +74,13 @@ public class FileManager {
.collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl));
}
public void updateCheckResult(String fileKey, boolean check, String taskId, String resultLog) {
public void updateCheckResult(String fileKey, FileChechStatusEnum type, String taskId, String resultLog) {
FileRecordEntity fileRecordEntity = ossFileService.queryByOssKey(fileKey);
if (fileRecordEntity == null) {
throw new BizException("图片未找到:" + fileKey);
}
if (check) {
// 审核失败
fileRecordEntity.setCheckStatus(2);
} else {
// 审核通过
fileRecordEntity.setCheckStatus(1);
}
fileRecordEntity.setCheckStatus(type.getCode());
fileRecordEntity.setCheckTaskId(taskId);
fileRecordEntity.setCheckResultLog(resultLog);
ossFileService.update(fileRecordEntity);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment