ChannelAction.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. package info.aspirecn.iov.sjjh.supplier10000044.action;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import info.aspirecn.iov.sjjh.commons.lang.ChannelTypeHandleResponseObject;
  5. import info.aspirecn.iov.sjjh.commons.lang.Constant;
  6. import info.aspirecn.iov.sjjh.supplier10000044.constant.SjjhConstant;
  7. import info.aspirecn.iov.sjjh.supplier10000044.service.ChannelService;
  8. import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
  9. import io.swagger.annotations.ApiOperation;
  10. import io.swagger.annotations.ApiParam;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.apache.tomcat.util.codec.binary.Base64;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. import org.springframework.web.context.request.RequestContextHolder;
  16. import org.springframework.web.context.request.ServletRequestAttributes;
  17. import javax.servlet.http.HttpServletRequest;
  18. /**
  19. * @description:
  20. * @author: xusonglin
  21. * @create: 2020/7/8 15:31
  22. * @version: V1.0
  23. **/
  24. @Slf4j
  25. @RestController
  26. public class ChannelAction {
  27. @Autowired
  28. ChannelService channelService;
  29. @ApiOperation(value = "身份证二要素接口", notes = "")
  30. @PostMapping(value = "/twoElementsCheck.do")
  31. public ChannelTypeHandleResponseObject twoElementsCheck(
  32. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  33. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  34. @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
  35. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  36. .getRequest();
  37. ChannelTypeHandleResponseObject ret = channelService.twoElementsCheck(request, customBody, outTime);
  38. //把接口参数、调用结果和是否收费放入访问日志中
  39. if (ret.getCode() != Constant.SUCCESS) {
  40. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  41. } else {
  42. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  43. }
  44. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  45. try {
  46. request.setAttribute(Constant.CHANNEL_LOG_QUERY,
  47. Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
  48. } catch (Exception ex) {
  49. ErrorUtils.captureException(ex);
  50. log.error("twoElementsCheck.encodeBase64String.Exception={}", ex);
  51. }
  52. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  53. return ret;
  54. }
  55. @ApiOperation(value = "人像接口", notes = "")
  56. @PostMapping(value = "/photoIdentityCheck.do")
  57. public ChannelTypeHandleResponseObject photoIdentityCheck(
  58. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  59. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  60. @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
  61. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  62. .getRequest();
  63. //调用service
  64. ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheck(request, customBody, outTime);
  65. //把接口参数、调用结果和是否收费放入访问日志中
  66. if (ret.getCode() != Constant.SUCCESS) {
  67. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  68. } else {
  69. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  70. }
  71. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  72. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  73. return ret;
  74. }
  75. @ApiOperation(value = "身份证二要素接口-返回通用版", notes = "")
  76. @PostMapping(value = "/twoElementsCheckNew.do")
  77. public ChannelTypeHandleResponseObject twoElementsCheckNew(
  78. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  79. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  80. @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
  81. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  82. .getRequest();
  83. ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_COMMON);
  84. //把接口参数、调用结果和是否收费放入访问日志中
  85. if (ret.getCode() != Constant.SUCCESS) {
  86. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  87. } else {
  88. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  89. }
  90. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  91. try {
  92. request.setAttribute(Constant.CHANNEL_LOG_QUERY,
  93. Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
  94. } catch (Exception ex) {
  95. ErrorUtils.captureException(ex);
  96. log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
  97. }
  98. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  99. return ret;
  100. }
  101. @ApiOperation(value = "身份证二要素接口-返回通用版-WZ加密版", notes = "")
  102. @PostMapping(value = "/twoElementsCheckNewWZ.do")
  103. public ChannelTypeHandleResponseObject twoElementsCheckNewWZ(
  104. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  105. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  106. @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
  107. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  108. .getRequest();
  109. ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_WEIZHONG);
  110. //把接口参数、调用结果和是否收费放入访问日志中
  111. if (ret.getCode() != Constant.SUCCESS) {
  112. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  113. } else {
  114. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  115. }
  116. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  117. try {
  118. request.setAttribute(Constant.CHANNEL_LOG_QUERY,
  119. Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
  120. } catch (Exception ex) {
  121. ErrorUtils.captureException(ex);
  122. log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
  123. }
  124. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  125. return ret;
  126. }
  127. @ApiOperation(value = "人像接口-中心通用版", notes = "")
  128. @PostMapping(value = "/photoIdentityCheckNew.do")
  129. public ChannelTypeHandleResponseObject photoIdentityCheckNew(
  130. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  131. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  132. @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
  133. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  134. .getRequest();
  135. //调用service
  136. ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_COMMON);
  137. //把接口参数、调用结果和是否收费放入访问日志中
  138. if (ret.getCode() != Constant.SUCCESS) {
  139. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  140. } else {
  141. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  142. }
  143. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  144. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  145. return ret;
  146. }
  147. @ApiOperation(value = "人像接口-中心通用版-WZ加密", notes = "")
  148. @PostMapping(value = "/photoIdentityCheckNewWZ.do")
  149. public ChannelTypeHandleResponseObject photoIdentityCheckNewWZ(
  150. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  151. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  152. @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
  153. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  154. .getRequest();
  155. //调用service
  156. ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_WEIZHONG);
  157. //把接口参数、调用结果和是否收费放入访问日志中
  158. if (ret.getCode() != Constant.SUCCESS) {
  159. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  160. } else {
  161. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  162. }
  163. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  164. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  165. return ret;
  166. }
  167. @ApiOperation(value = "身份证二要素接口-返回通用版-MD5", notes = "")
  168. @PostMapping(value = "/twoElementsCheckNewMD5.do")
  169. public ChannelTypeHandleResponseObject twoElementsCheckNewMD5(
  170. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  171. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  172. @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
  173. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  174. .getRequest();
  175. ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_MD5);
  176. //把接口参数、调用结果和是否收费放入访问日志中
  177. if (ret.getCode() != Constant.SUCCESS) {
  178. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  179. } else {
  180. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  181. }
  182. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  183. try {
  184. request.setAttribute(Constant.CHANNEL_LOG_QUERY,
  185. Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
  186. } catch (Exception ex) {
  187. ErrorUtils.captureException(ex);
  188. log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
  189. }
  190. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  191. return ret;
  192. }
  193. @ApiOperation(value = "身份证二要素接口-返回通用版-SHA256", notes = "")
  194. @PostMapping(value = "/twoElementsCheckNewSHA256.do")
  195. public ChannelTypeHandleResponseObject twoElementsCheckNewSHA256(
  196. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  197. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  198. @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
  199. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  200. .getRequest();
  201. ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_SHA256);
  202. //把接口参数、调用结果和是否收费放入访问日志中
  203. if (ret.getCode() != Constant.SUCCESS) {
  204. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  205. } else {
  206. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  207. }
  208. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  209. try {
  210. request.setAttribute(Constant.CHANNEL_LOG_QUERY,
  211. Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
  212. } catch (Exception ex) {
  213. ErrorUtils.captureException(ex);
  214. log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
  215. }
  216. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  217. return ret;
  218. }
  219. @ApiOperation(value = "人像接口-中心通用版-MD5", notes = "")
  220. @PostMapping(value = "/photoIdentityCheckNewMD5.do")
  221. public ChannelTypeHandleResponseObject photoIdentityCheckNewMD5(
  222. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  223. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  224. @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
  225. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  226. .getRequest();
  227. //调用service
  228. ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_MD5);
  229. //把接口参数、调用结果和是否收费放入访问日志中
  230. if (ret.getCode() != Constant.SUCCESS) {
  231. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  232. } else {
  233. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  234. }
  235. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  236. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  237. return ret;
  238. }
  239. @ApiOperation(value = "人像接口-中心通用版-SHA256", notes = "")
  240. @PostMapping(value = "/photoIdentityCheckNewSHA256.do")
  241. public ChannelTypeHandleResponseObject photoIdentityCheckNewSHA256(
  242. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  243. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  244. @ApiParam(value = "请求参数JSON串") @RequestBody String customBody) {
  245. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  246. .getRequest();
  247. //调用service
  248. ChannelTypeHandleResponseObject ret = channelService.photoIdentityCheckNew(request, customBody, outTime, SjjhConstant.DECODE_TYPE_SHA256);
  249. //把接口参数、调用结果和是否收费放入访问日志中
  250. if (ret.getCode() != Constant.SUCCESS) {
  251. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  252. } else {
  253. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  254. }
  255. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  256. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  257. return ret;
  258. }
  259. @ApiOperation(value = "身份证有效期", notes = "")
  260. @PostMapping(value = "/idCardValidityCheck.do")
  261. public ChannelTypeHandleResponseObject idCardValidityCheck(
  262. @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
  263. @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
  264. @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
  265. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
  266. .getRequest();
  267. ChannelTypeHandleResponseObject ret = channelService.idCardValidityCheck(request, customBody, outTime, SjjhConstant.DECODE_TYPE_WEIZHONG);
  268. //把接口参数、调用结果和是否收费放入访问日志中
  269. if (ret.getCode() != Constant.SUCCESS) {
  270. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
  271. } else {
  272. request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
  273. }
  274. request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
  275. try {
  276. request.setAttribute(Constant.CHANNEL_LOG_QUERY,
  277. Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
  278. } catch (Exception ex) {
  279. ErrorUtils.captureException(ex);
  280. log.error("twoElementsCheckNew.encodeBase64String.Exception={}", ex);
  281. }
  282. request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
  283. return ret;
  284. }
  285. }