From b6996fd977ccf51baff62a0680f9ce69c1e50f61 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 14 Jul 2020 22:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/ExecuteHttpException.java | 9 ++-- .../scan/service/impl/ScanServiceImpl.java | 42 ------------------- 2 files changed, 4 insertions(+), 47 deletions(-) diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExecuteHttpException.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExecuteHttpException.java index 1eb4f8d0e3..a5694da79c 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExecuteHttpException.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExecuteHttpException.java @@ -1,23 +1,22 @@ package com.epmet.openapi.scan.common.exception; -import com.epmet.commons.tools.utils.MessageUtils; import com.epmet.openapi.scan.common.enu.SysResponseEnum; /** * @author jianjun liu - * @email liujianjun@yunzongnet.com * @date 2020-06-05 10:31 **/ public class ExecuteHttpException extends RuntimeException { private int code; private String msg; - public ExecuteHttpException(String msg) { + public ExecuteHttpException(String msg) { this(SysResponseEnum.EXCEPTION.getCode(), msg); } - public ExecuteHttpException(int code, String... params) { + + public ExecuteHttpException(int code, String msg) { this.code = code; - this.msg = MessageUtils.getMessage(code, params); + this.msg = msg; } public int getCode() { diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java index 1a88b5b86f..95185ae703 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.aliyuncs.AcsRequest; -import com.aliyuncs.green.model.v20180509.ImageAsyncScanRequest; import com.aliyuncs.green.model.v20180509.ImageSyncScanRequest; import com.aliyuncs.green.model.v20180509.TextScanRequest; 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.TextScanParam; 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.SceneDetailResult; import com.epmet.openapi.scan.support.result.SyncScanResult; @@ -127,46 +125,6 @@ public class ScanServiceImpl implements ScanService { } } - @Override - public Result 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 imgTasks = imgScanParam.getTasks(); - if (CollectionUtils.isEmpty(imgTasks) || imgTasks.size() > SysConstant.MAX_IMG_TASKS) { - return new Result().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().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().ok(scanResult); - } catch (Exception e) { - //log.error("sendASyncImgScan execute exception,param:{},fail msg:{}",JSON.toJSONString(imgScanParam), e.getMsg()); - return new Result().error(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg()); - } - } - public SyncScanResult executeSyncText(AcsRequest textScanRequest) { SyncScanResult result = new SyncScanResult(); try {