|
|
@ -27,12 +27,59 @@ import java.util.stream.Collectors; |
|
|
|
**/ |
|
|
|
@Slf4j |
|
|
|
public class ScanContentUtils { |
|
|
|
|
|
|
|
// 内容审核是否可用。烟台是政务网,无法使用互联网,所以该功能不可用
|
|
|
|
public static final Boolean USABLE = true; |
|
|
|
|
|
|
|
/** |
|
|
|
* 模拟sync成功的结果(可以用来模拟,也可以适用于无法使用互联网的环境) |
|
|
|
* @author wxz |
|
|
|
* @date 2022/12/13 15:37 |
|
|
|
* |
|
|
|
* * @return Result<SyncScanResult> |
|
|
|
*/ |
|
|
|
public static Result<SyncScanResult> mockSyncSuccessResult() { |
|
|
|
Result<SyncScanResult> tempRst = new Result<>(); |
|
|
|
SyncScanResult syncScanResult = new SyncScanResult(); |
|
|
|
syncScanResult.setAllPass(true); |
|
|
|
tempRst.setData(syncScanResult); |
|
|
|
return tempRst; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 模拟async成功的结果(可以用来模拟,也可以适用于无法使用互联网的环境) |
|
|
|
* @author wxz |
|
|
|
* @date 2022/12/13 15:46 |
|
|
|
* |
|
|
|
* * @return Result<AsyncScanResult> |
|
|
|
*/ |
|
|
|
public static Result<AsyncScanResult> mockAsyncSuccessResult() { |
|
|
|
Result<AsyncScanResult> tempRst = new Result<>(); |
|
|
|
AsyncScanResult asyncScanResult = new AsyncScanResult(); |
|
|
|
asyncScanResult.setAllSuccess(true); |
|
|
|
tempRst.setData(asyncScanResult); |
|
|
|
return tempRst; |
|
|
|
} |
|
|
|
|
|
|
|
public static Result<VideoAsyncScanResultDTO> mockVideoAsyncSuccessResult() { |
|
|
|
Result<VideoAsyncScanResultDTO> tempRst = new Result<>(); |
|
|
|
VideoAsyncScanResultDTO asyncScanResult = new VideoAsyncScanResultDTO(); |
|
|
|
asyncScanResult.setIsAllPass(true); |
|
|
|
tempRst.setData(asyncScanResult); |
|
|
|
return tempRst; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:图片同步扫描 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Result<SyncScanResult> imgSyncScan(String url, ImgScanParamDTO param) { |
|
|
|
|
|
|
|
if (!USABLE) { |
|
|
|
return mockSyncSuccessResult(); |
|
|
|
} |
|
|
|
|
|
|
|
//start 测试环境停机了,先这样改试试
|
|
|
|
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
|
|
|
if(EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())||EnvEnum.DEV.getCode().equals(currentEnv.getCode())){ |
|
|
@ -68,6 +115,11 @@ public class ScanContentUtils { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Result<SyncScanResult> textSyncScan(String url, TextScanParamDTO param) { |
|
|
|
|
|
|
|
if (!USABLE) { |
|
|
|
return mockSyncSuccessResult(); |
|
|
|
} |
|
|
|
|
|
|
|
//start 测试环境停机了,先这样改试试
|
|
|
|
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
|
|
|
if(EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())||EnvEnum.DEV.getCode().equals(currentEnv.getCode())){ |
|
|
@ -104,6 +156,11 @@ public class ScanContentUtils { |
|
|
|
* @return 返回检测对象对应的任务id |
|
|
|
*/ |
|
|
|
public static Result<AsyncScanResult> voiceAsyncScan(String url, VoiceScanParamDTO param){ |
|
|
|
|
|
|
|
if (!USABLE) { |
|
|
|
return mockAsyncSuccessResult(); |
|
|
|
} |
|
|
|
|
|
|
|
log.debug("voiceAsyncScan param:{}", JSON.toJSONString(param)); |
|
|
|
if (StringUtils.isBlank(url) || param == null) { |
|
|
|
throw new RenException("参数错误"); |
|
|
@ -164,6 +221,11 @@ public class ScanContentUtils { |
|
|
|
* @description 异步检测-提交检测任务 |
|
|
|
**/ |
|
|
|
public static Result<AsyncScanResult> videoAsyncScan(String url, VideoScanParamDTO param){ |
|
|
|
|
|
|
|
if (!USABLE) { |
|
|
|
return mockAsyncSuccessResult(); |
|
|
|
} |
|
|
|
|
|
|
|
log.debug("videoAsyncScan param:{}", JSON.toJSONString(param)); |
|
|
|
if (StringUtils.isBlank(url) || param == null) { |
|
|
|
throw new RenException("参数错误"); |
|
|
@ -194,6 +256,11 @@ public class ScanContentUtils { |
|
|
|
* @description 查询视频检测结果 |
|
|
|
**/ |
|
|
|
public static Result<VideoAsyncScanResultDTO> videoResults(String url, List<String> taskIds) { |
|
|
|
|
|
|
|
if (!USABLE) { |
|
|
|
return mockVideoAsyncSuccessResult(); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(url) || CollectionUtils.isEmpty(taskIds)) { |
|
|
|
throw new RenException("参数错误"); |
|
|
|
} |
|
|
|