123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- package info.aspirecn.iov.sjjh.supplier10000044.action;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import info.aspirecn.iov.sjjh.commons.lang.ChannelTypeHandleResponseObject;
- import info.aspirecn.iov.sjjh.commons.lang.Constant;
- import info.aspirecn.iov.sjjh.supplier10000044.constant.SjjhConstant;
- import info.aspirecn.iov.sjjh.supplier10000044.service.ChannelService;
- import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.tomcat.util.codec.binary.Base64;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.context.request.RequestContextHolder;
- import org.springframework.web.context.request.ServletRequestAttributes;
- import javax.servlet.http.HttpServletRequest;
- /**
- * @description:
- * @author: xusonglin
- * @create: 2020/7/8 15:31
- * @version: V1.0
- **/
- @Slf4j
- @RestController
- public class ChannelAction {
- @Autowired
- ChannelService channelService;
- @ApiOperation(value = "身份证二要素接口", notes = "")
- @PostMapping(value = "/twoElementsCheck.do")
- public ChannelTypeHandleResponseObject twoElementsCheck(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- ChannelTypeHandleResponseObject ret = channelService.twoElementsCheck(request, customBody, outTime);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- try {
- request.setAttribute(Constant.CHANNEL_LOG_QUERY,
- Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
- } catch (Exception ex) {
- ErrorUtils.captureException(ex);
- log.error("twoElementsCheck.encodeBase64String.Exception={}", ex);
- }
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "人像接口", notes = "")
- @PostMapping(value = "/photoIdentityCheck.do")
- public ChannelTypeHandleResponseObject photoIdentityCheck(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- //调用service
- ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheck(request, customBody, outTime);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "身份证二要素接口-返回通用版", notes = "")
- @PostMapping(value = "/twoElementsCheckNew.do")
- public ChannelTypeHandleResponseObject twoElementsCheckNew(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_COMMON);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- try {
- request.setAttribute(Constant.CHANNEL_LOG_QUERY,
- Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
- } catch (Exception ex) {
- ErrorUtils.captureException(ex);
- log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
- }
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "身份证二要素接口-返回通用版-WZ加密版", notes = "")
- @PostMapping(value = "/twoElementsCheckNewWZ.do")
- public ChannelTypeHandleResponseObject twoElementsCheckNewWZ(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_WEIZHONG);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- try {
- request.setAttribute(Constant.CHANNEL_LOG_QUERY,
- Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
- } catch (Exception ex) {
- ErrorUtils.captureException(ex);
- log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
- }
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "人像接口-中心通用版", notes = "")
- @PostMapping(value = "/photoIdentityCheckNew.do")
- public ChannelTypeHandleResponseObject photoIdentityCheckNew(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- //调用service
- ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_COMMON);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "人像接口-中心通用版-WZ加密", notes = "")
- @PostMapping(value = "/photoIdentityCheckNewWZ.do")
- public ChannelTypeHandleResponseObject photoIdentityCheckNewWZ(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- //调用service
- ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_WEIZHONG);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "身份证二要素接口-返回通用版-MD5", notes = "")
- @PostMapping(value = "/twoElementsCheckNewMD5.do")
- public ChannelTypeHandleResponseObject twoElementsCheckNewMD5(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_MD5);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- try {
- request.setAttribute(Constant.CHANNEL_LOG_QUERY,
- Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
- } catch (Exception ex) {
- ErrorUtils.captureException(ex);
- log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
- }
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "身份证二要素接口-返回通用版-SHA256", notes = "")
- @PostMapping(value = "/twoElementsCheckNewSHA256.do")
- public ChannelTypeHandleResponseObject twoElementsCheckNewSHA256(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_SHA256);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- try {
- request.setAttribute(Constant.CHANNEL_LOG_QUERY,
- Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
- } catch (Exception ex) {
- ErrorUtils.captureException(ex);
- log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
- }
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "人像接口-中心通用版-MD5", notes = "")
- @PostMapping(value = "/photoIdentityCheckNewMD5.do")
- public ChannelTypeHandleResponseObject photoIdentityCheckNewMD5(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- //调用service
- ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_MD5);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "人像接口-中心通用版-SHA256", notes = "")
- @PostMapping(value = "/photoIdentityCheckNewSHA256.do")
- public ChannelTypeHandleResponseObject photoIdentityCheckNewSHA256(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- //调用service
- ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_SHA256);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- @ApiOperation(value = "身份证有效期", notes = "")
- @PostMapping(value = "/idCardValidityCheck.do")
- public ChannelTypeHandleResponseObject idCardValidityCheck(
- @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
- @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
- @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
- .getRequest();
- ChannelTypeHandleResponseObject ret = channelService.idCardValidityCheck(request, customBody, outTime, SjjhConstant.DECODE_TYPE_WEIZHONG);
- //把接口参数、调用结果和是否收费放入访问日志中
- if (ret.getCode() != Constant.SUCCESS) {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
- } else {
- request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
- }
- request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
- try {
- request.setAttribute(Constant.CHANNEL_LOG_QUERY,
- Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
- } catch (Exception ex) {
- ErrorUtils.captureException(ex);
- log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
- }
- request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
- return ret;
- }
- }
|