Browse Source

去掉国际化

dev
jianjun 5 years ago
parent
commit
b6996fd977
  1. 7
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExecuteHttpException.java
  2. 42
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java

7
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExecuteHttpException.java

@ -1,11 +1,9 @@
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 {
@ -15,9 +13,10 @@ public class ExecuteHttpException extends RuntimeException {
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() {

42
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<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) {
SyncScanResult result = new SyncScanResult();
try {

Loading…
Cancel
Save