Browse Source

调整审核内容响应结果

dev_shibei_match
jianjun 5 years ago
parent
commit
b5b6dd9a2e
  1. 2
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/SysResponseEnum.java
  2. 13
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExecuteHttpException.java
  3. 10
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/controller/ScanController.java
  4. 45
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java

2
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/SysResponseEnum.java

@ -24,6 +24,8 @@ public enum SysResponseEnum {
/*审核内容 业务 01*/
SCAN_TASK_LIST_PARAM_ERROR(110010001,"任务列表不能为空"),
SCAN_PARAM_ERROR(110010002,"参数格式不正确"),
EXECUTE_ALI_RETURN_CODE_NOT_OK(110010003,"调用第三方检测服务响应异常"),
EXECUTE_ALI_DO_ACTION_EXCEPTION(110010004,"调用第三方检测服务异常"),
;
private Integer code;

13
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExeCuteHttpException.java → epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/exception/ExecuteHttpException.java

@ -8,16 +8,23 @@ import com.epmet.openapi.scan.common.enu.SysResponseEnum;
* @email liujianjun@yunzongnet.com
* @date 2020-06-05 10:31
**/
public class ExeCuteHttpException extends RuntimeException {
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... params) {
this.code = code;
this.msg = MessageUtils.getMessage(code, params);
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
}

10
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/controller/ScanController.java

@ -24,7 +24,6 @@ public class ScanController {
@Autowired
private ScanService scanService;
/**
* desc:图片同步检测接口
*
@ -34,8 +33,7 @@ public class ScanController {
@RequestMapping("imgSyncScan")
public Result<SyncScanResult> ImgSyncScan(@RequestBody ImgScanParam param) {
ValidatorUtils.validateEntity(param);
Result<SyncScanResult> scanResultResult = scanService.sendSyncImgScan(param);
return scanResultResult;
return scanService.sendSyncImgScan(param);
}
/**
@ -47,13 +45,11 @@ public class ScanController {
@RequestMapping("textSyncScan")
public Result<SyncScanResult> textSyncScan(@RequestBody TextScanParam param) {
ValidatorUtils.validateEntity(param);
Result<SyncScanResult> scanResultResult = scanService.sendTextScan(param);
return scanResultResult;
return scanService.sendTextScan(param);
}
//@RequestMapping("imgAsyncScan")
public Result<ImgAsyncScanResult> ImgAsyncScan(@RequestBody ImgScanParam param) {
Result<ImgAsyncScanResult> scanResultResult = scanService.sendASyncImgScan(param);
return scanResultResult;
return scanService.sendASyncImgScan(param);
}
}

45
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java

@ -15,7 +15,7 @@ import com.epmet.openapi.scan.common.enu.ImgSceneEnum;
import com.epmet.openapi.scan.common.enu.SuggestionEnum;
import com.epmet.openapi.scan.common.enu.SysResponseEnum;
import com.epmet.openapi.scan.common.enu.TextSceneEnum;
import com.epmet.openapi.scan.common.exception.ExeCuteHttpException;
import com.epmet.openapi.scan.common.exception.ExecuteHttpException;
import com.epmet.openapi.scan.common.util.IAcsClientUtil;
import com.epmet.openapi.scan.support.param.ImgScanParam;
import com.epmet.openapi.scan.support.param.ImgTask;
@ -49,7 +49,6 @@ public class ScanServiceImpl implements ScanService {
@Override
public Result<SyncScanResult> sendTextScan(TextScanParam textScanParam) {
//默认参数
// 鉴黄 暴恐涉政
textScanParam.setScenes(TextSceneEnum.getTextSceneList());
@ -69,7 +68,7 @@ public class ScanServiceImpl implements ScanService {
try {
textScanRequest.setHttpContent(JSON.toJSONString(textScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON);
} catch (UnsupportedEncodingException e) {
log.error("sendTextScan exception", e.getMessage());
log.error("sendTextScan parse param exception", e);
}
@ -78,18 +77,18 @@ public class ScanServiceImpl implements ScanService {
*/
textScanRequest.setConnectTimeout(3000);
textScanRequest.setReadTimeout(6000);
try {
SyncScanResult textScanResult = executeSyncText(textScanRequest);
return new Result<SyncScanResult>().ok(textScanResult);
} catch (Exception e) {
log.error("sendTextScan exception", e);
throw new ExeCuteHttpException(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg());
} catch (ExecuteHttpException e) {
log.error("sendTextScan execute Exception", e);
return new Result<SyncScanResult>().error(e.getCode(), e.getMsg());
}
}
@Override
public Result<SyncScanResult> sendSyncImgScan(ImgScanParam imgScanParam) {
ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest();
imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
imageSyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
@ -109,7 +108,7 @@ public class ScanServiceImpl implements ScanService {
try {
imageSyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON);
} catch (UnsupportedEncodingException e) {
log.error("sendSyncImgScan exception", e.getMessage());
log.error("sendSyncImgScan parse param exception", e);
return new Result<SyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg());
}
@ -122,9 +121,9 @@ public class ScanServiceImpl implements ScanService {
try {
SyncScanResult scanResult = executeSyncImg(imageSyncScanRequest);
return new Result<SyncScanResult>().ok(scanResult);
} catch (Exception e) {
log.error("sendImgScan execute Exception", e);
return new Result<SyncScanResult>().error(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg());
} catch (ExecuteHttpException e) {
log.error("sendImgScan execute exception,param:{},fail msg:{}", JSON.toJSONString(imgScanParam), e.getMsg());
return new Result<SyncScanResult>().error(e.getCode(), e.getMsg());
}
}
@ -149,7 +148,7 @@ public class ScanServiceImpl implements ScanService {
try {
imageAsyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON);
} catch (UnsupportedEncodingException e) {
log.error("sendASyncImgScan exception", e.getMessage());
log.error("sendASyncImgScan parse param exception", e);
return new Result<ImgAsyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg());
}
@ -163,7 +162,7 @@ public class ScanServiceImpl implements ScanService {
ImgAsyncScanResult scanResult = null;//executeAsyncImg(imageAsyncScanRequest);
return new Result<ImgAsyncScanResult>().ok(scanResult);
} catch (Exception e) {
log.error("sendImgScan execute 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());
}
}
@ -209,15 +208,15 @@ public class ScanServiceImpl implements ScanService {
return result;
} else {
log.warn("executeSyncText response not success. code:{}", scrResponse.getInteger(SysConstant.CODE));
throw new ExeCuteHttpException("executeSyncText detect not success. code:" + scrResponse.getInteger(SysConstant.CODE));
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getCode(), SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getMsg() + ",status:" + httpResponse.getStatus());
}
} else {
log.warn("executeSyncText response not success. status:{}", httpResponse.getStatus());
throw new ExeCuteHttpException("response not success. status:" + httpResponse.getStatus());
log.warn("executeSyncText response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse));
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getCode(), SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getMsg() + ",status:" + httpResponse.getStatus());
}
} catch (Exception e) {
log.warn("executeSyncText exception", e);
throw new ExeCuteHttpException(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg());
log.error("executeSyncText exception IAcsClientUtil do action exception", e);
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_DO_ACTION_EXCEPTION.getCode(), SysResponseEnum.EXECUTE_ALI_DO_ACTION_EXCEPTION.getMsg());
}
}
@ -260,15 +259,15 @@ public class ScanServiceImpl implements ScanService {
return result;
} else {
log.warn("executeSyncImg detect not success. code:{}", scrResponse.getInteger(SysConstant.CODE));
throw new ExeCuteHttpException("detect not success. code:" + scrResponse.getInteger(SysConstant.CODE));
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getCode(), SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getMsg() + ",status:" + httpResponse.getStatus());
}
} else {
log.warn("executeSyncImg response not success. status:{}", httpResponse.getStatus());
throw new ExeCuteHttpException("response not success. status:" + httpResponse.getStatus());
log.warn("executeSyncImg response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse));
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getCode(), SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getMsg() + ",status:" + httpResponse.getStatus());
}
} catch (Exception e) {
log.warn("executeSyncImg exception", e);
throw new ExeCuteHttpException(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg());
log.error("executeSyncImg exception IAcsClientUtil do action exception", e);
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_DO_ACTION_EXCEPTION.getCode(), SysResponseEnum.EXECUTE_ALI_DO_ACTION_EXCEPTION.getMsg());
}
}
}

Loading…
Cancel
Save