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*/ /*审核内容 业务 01*/
SCAN_TASK_LIST_PARAM_ERROR(110010001,"任务列表不能为空"), SCAN_TASK_LIST_PARAM_ERROR(110010001,"任务列表不能为空"),
SCAN_PARAM_ERROR(110010002,"参数格式不正确"), SCAN_PARAM_ERROR(110010002,"参数格式不正确"),
EXECUTE_ALI_RETURN_CODE_NOT_OK(110010003,"调用第三方检测服务响应异常"),
EXECUTE_ALI_DO_ACTION_EXCEPTION(110010004,"调用第三方检测服务异常"),
; ;
private Integer code; 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 * @email liujianjun@yunzongnet.com
* @date 2020-06-05 10:31 * @date 2020-06-05 10:31
**/ **/
public class ExeCuteHttpException extends RuntimeException { public class ExecuteHttpException extends RuntimeException {
private int code; private int code;
private String msg; private String msg;
public ExeCuteHttpException(String msg) { public ExecuteHttpException(String msg) {
this(SysResponseEnum.EXCEPTION.getCode(), msg); this(SysResponseEnum.EXCEPTION.getCode(), msg);
} }
public ExeCuteHttpException(int code, String... params) { public ExecuteHttpException(int code, String... params) {
this.code = code; this.code = code;
this.msg = MessageUtils.getMessage(code, params); 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 @Autowired
private ScanService scanService; private ScanService scanService;
/** /**
* desc:图片同步检测接口 * desc:图片同步检测接口
* *
@ -34,8 +33,7 @@ public class ScanController {
@RequestMapping("imgSyncScan") @RequestMapping("imgSyncScan")
public Result<SyncScanResult> ImgSyncScan(@RequestBody ImgScanParam param) { public Result<SyncScanResult> ImgSyncScan(@RequestBody ImgScanParam param) {
ValidatorUtils.validateEntity(param); ValidatorUtils.validateEntity(param);
Result<SyncScanResult> scanResultResult = scanService.sendSyncImgScan(param); return scanService.sendSyncImgScan(param);
return scanResultResult;
} }
/** /**
@ -47,13 +45,11 @@ public class ScanController {
@RequestMapping("textSyncScan") @RequestMapping("textSyncScan")
public Result<SyncScanResult> textSyncScan(@RequestBody TextScanParam param) { public Result<SyncScanResult> textSyncScan(@RequestBody TextScanParam param) {
ValidatorUtils.validateEntity(param); ValidatorUtils.validateEntity(param);
Result<SyncScanResult> scanResultResult = scanService.sendTextScan(param); return scanService.sendTextScan(param);
return scanResultResult;
} }
//@RequestMapping("imgAsyncScan") //@RequestMapping("imgAsyncScan")
public Result<ImgAsyncScanResult> ImgAsyncScan(@RequestBody ImgScanParam param) { public Result<ImgAsyncScanResult> ImgAsyncScan(@RequestBody ImgScanParam param) {
Result<ImgAsyncScanResult> scanResultResult = scanService.sendASyncImgScan(param); return scanService.sendASyncImgScan(param);
return scanResultResult;
} }
} }

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

Loading…
Cancel
Save