|
@@ -24,6 +24,7 @@ import java.sql.Wrapper;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -40,32 +41,42 @@ public class ReviewImgRecordServiceImpl extends ServiceImpl<ReviewImgRecordMappe
|
|
|
@Resource
|
|
|
private VcrService vcrService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ThreadPoolExecutor threadPoolExecutor;
|
|
|
+
|
|
|
public ReviewImgRecord store(ReviewImgRecord reviewImgRecord) {
|
|
|
Optional<String> token = HttpContextUtil.getToken();
|
|
|
|
|
|
String uid = AESUtil.decryptStr(token.get());
|
|
|
reviewImgRecord.setUid(Long.valueOf(uid));
|
|
|
reviewImgRecord.setCreateTime(LocalDateTime.now());
|
|
|
- ResponseEntity<ImgReviewResp> resp = vcrService.reviewImg(JSON.toJSONString(ImmutableMap.of("source", reviewImgRecord.getUrl())));
|
|
|
- ImgReviewResp body = resp.getBody();
|
|
|
-
|
|
|
- if (null == body){
|
|
|
- log.error("图片审核失败 {}", resp.getStatusCode());
|
|
|
- this.save(reviewImgRecord);
|
|
|
- throw new BizException("图片审核失败,系统正在尝试重新提交,请稍后");
|
|
|
- }
|
|
|
- body.fill();
|
|
|
- reviewImgRecord.setTaskId(body.getTaskId());
|
|
|
-
|
|
|
+ reviewImgRecord.setStatus("PROVISIONING");
|
|
|
if(TextUtils.isEmpty(reviewImgRecord.getTitle())){
|
|
|
String[] extension = reviewImgRecord.getUrl().split("/");
|
|
|
reviewImgRecord.setTitle(extension[extension.length - 1]);
|
|
|
}
|
|
|
|
|
|
- reviewImgRecord.setStatus(body.getStatus());
|
|
|
- reviewImgRecord.setResult(JSON.toJSONString(body));
|
|
|
- reviewImgRecord.setReviewResult(body);
|
|
|
this.save(reviewImgRecord);
|
|
|
+
|
|
|
+ threadPoolExecutor.execute(() -> {
|
|
|
+ ResponseEntity<ImgReviewResp> resp = vcrService.reviewImg(JSON.toJSONString(ImmutableMap.of("source", reviewImgRecord.getUrl())));
|
|
|
+ ImgReviewResp body = resp.getBody();
|
|
|
+
|
|
|
+ if (null == body){
|
|
|
+ log.error("图片审核失败 {}", resp.getStatusCode());
|
|
|
+ this.save(reviewImgRecord);
|
|
|
+ throw new BizException("图片审核失败,系统正在尝试重新提交,请稍后");
|
|
|
+ }
|
|
|
+ body.fill();
|
|
|
+ reviewImgRecord.setTaskId(body.getTaskId());
|
|
|
+
|
|
|
+ reviewImgRecord.setStatus(body.getStatus());
|
|
|
+ reviewImgRecord.setResult(JSON.toJSONString(body));
|
|
|
+ reviewImgRecord.setReviewResult(body);
|
|
|
+ updateById(reviewImgRecord);
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
return reviewImgRecord;
|
|
|
}
|
|
|
|
|
@@ -96,4 +107,14 @@ public class ReviewImgRecordServiceImpl extends ServiceImpl<ReviewImgRecordMappe
|
|
|
.like(!TextUtils.isEmpty(pageReqDTO.getTitle()), ReviewImgRecord::getTitle, pageReqDTO.getTitle())
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ public void delete(Long id) {
|
|
|
+ Optional<String> token = HttpContextUtil.getToken();
|
|
|
+ String uid = AESUtil.decryptStr(token.get());
|
|
|
+ ReviewImgRecord reviewImgRecord = this.getById(id);
|
|
|
+ if (!reviewImgRecord.getUid().equals(Long.valueOf(uid))){
|
|
|
+ throw new BizException("无权删除");
|
|
|
+ }
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
}
|