|
@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.aliyuncs.AcsRequest; |
|
|
import com.aliyuncs.AcsRequest; |
|
|
import com.aliyuncs.green.model.v20180509.ImageAsyncScanRequest; |
|
|
|
|
|
import com.aliyuncs.green.model.v20180509.ImageSyncScanRequest; |
|
|
import com.aliyuncs.green.model.v20180509.ImageSyncScanRequest; |
|
|
import com.aliyuncs.green.model.v20180509.TextScanRequest; |
|
|
import com.aliyuncs.green.model.v20180509.TextScanRequest; |
|
|
import com.aliyuncs.http.FormatType; |
|
|
import com.aliyuncs.http.FormatType; |
|
@ -21,7 +20,6 @@ import com.epmet.openapi.scan.support.param.ImgScanParam; |
|
|
import com.epmet.openapi.scan.support.param.ImgTask; |
|
|
import com.epmet.openapi.scan.support.param.ImgTask; |
|
|
import com.epmet.openapi.scan.support.param.TextScanParam; |
|
|
import com.epmet.openapi.scan.support.param.TextScanParam; |
|
|
import com.epmet.openapi.scan.support.param.TextTask; |
|
|
import com.epmet.openapi.scan.support.param.TextTask; |
|
|
import com.epmet.openapi.scan.support.result.ImgAsyncScanResult; |
|
|
|
|
|
import com.epmet.openapi.scan.support.result.ScanTaskResult; |
|
|
import com.epmet.openapi.scan.support.result.ScanTaskResult; |
|
|
import com.epmet.openapi.scan.support.result.SceneDetailResult; |
|
|
import com.epmet.openapi.scan.support.result.SceneDetailResult; |
|
|
import com.epmet.openapi.scan.support.result.SyncScanResult; |
|
|
import com.epmet.openapi.scan.support.result.SyncScanResult; |
|
@ -127,46 +125,6 @@ public class ScanServiceImpl implements ScanService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Result<ImgAsyncScanResult> sendASyncImgScan(ImgScanParam imgScanParam) { |
|
|
|
|
|
ImageAsyncScanRequest imageAsyncScanRequest = new ImageAsyncScanRequest(); |
|
|
|
|
|
imageAsyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
|
|
|
|
|
|
imageAsyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
|
|
|
|
|
|
imageAsyncScanRequest.setEncoding(SysConstant.UTF8); |
|
|
|
|
|
imageAsyncScanRequest.setRegionId(regionId); |
|
|
|
|
|
|
|
|
|
|
|
//默认参数
|
|
|
|
|
|
// 鉴黄 暴恐涉政
|
|
|
|
|
|
imgScanParam.setScenes(ImgSceneEnum.getImgSceneList()); |
|
|
|
|
|
imgScanParam.setBizType(bizType); |
|
|
|
|
|
|
|
|
|
|
|
List<ImgTask> imgTasks = imgScanParam.getTasks(); |
|
|
|
|
|
if (CollectionUtils.isEmpty(imgTasks) || imgTasks.size() > SysConstant.MAX_IMG_TASKS) { |
|
|
|
|
|
return new Result<ImgAsyncScanResult>().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
imageAsyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|
|
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
|
|
log.error("sendASyncImgScan parse param exception", e); |
|
|
|
|
|
return new Result<ImgAsyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 请务必设置超时时间 |
|
|
|
|
|
*/ |
|
|
|
|
|
imageAsyncScanRequest.setConnectTimeout(3000); |
|
|
|
|
|
imageAsyncScanRequest.setReadTimeout(6000); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
ImgAsyncScanResult scanResult = null;//executeAsyncImg(imageAsyncScanRequest);
|
|
|
|
|
|
return new Result<ImgAsyncScanResult>().ok(scanResult); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
//log.error("sendASyncImgScan execute exception,param:{},fail msg:{}",JSON.toJSONString(imgScanParam), e.getMsg());
|
|
|
|
|
|
return new Result<ImgAsyncScanResult>().error(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public SyncScanResult executeSyncText(AcsRequest<?> textScanRequest) { |
|
|
public SyncScanResult executeSyncText(AcsRequest<?> textScanRequest) { |
|
|
SyncScanResult result = new SyncScanResult(); |
|
|
SyncScanResult result = new SyncScanResult(); |
|
|
try { |
|
|
try { |
|
|