鹏飞反欺诈查询历史记录
需求:根据身份证号码查询以往的查询记录。
入参:身份证号码,documentNoList
代码:
Controller
@RequestMapping(path = "/queryAntiFraudHistoryRecord", method = {RequestMethod.GET, RequestMethod.POST}) @ResponseBody public ResponseResult<List<PyQueryBean>> queryAntiFraudHistoryRecord(HttpServletRequest request, String documentNoList) { ResponseResult<List<PyQueryBean>> responseResult = new ResponseResult<>(); try { List<String> queryList = JSONArray.parseArray(documentNoList, String.class); List<PyQueryBean> resultList = pyQueryService.queryHistoryRecord(queryList); responseResult.setData(resultList); responseResult.setTimestamp(DateUtil.getTimeStamp().toString()); responseResult.setRet(SUCCESS); } catch (CreditException e) { responseResult.setErrorCode(e.getErrorCode()); responseResult.setRet(SUCCESS); responseResult.setErrorMsg(e.getMessage()); e.printStackTrace(); } catch (Exception e) { responseResult.setErrorCode(PyCreditServiceErrorEnum.SYSTEM_ERROR.getCode()); responseResult.setRet(FAILED); responseResult.setErrorMsg(PyCreditServiceErrorEnum.SYSTEM_ERROR.getMsg()); e.printStackTrace(); } return responseResult; }
Service
@Override public List<PyQueryBean> queryHistoryRecord(List<String> list) throws Exception { try { if (ListUtil.isEmpty(list)) { throw new CreditException(PyCreditServiceErrorEnum.EMPTY_PARAMETERS.getCode(), PyCreditServiceErrorEnum.EMPTY_PARAMETERS.getMsg()); } Map<String, Object> map = new HashMap<>(); map.put("list", list); map.put("queryType", QueryTypeEnum.ANTI_FRAUD_QUERY_TYPE.getCode()); return queryRecordMapper.selectByDocumentNo(map); } catch (Exception e) { logger.error("queryHistoryRecord@PyQueryServiceImpl_Exception", e); throw e; } }
sql
<!--通过身份证号码获取征信记录 按时间倒序 --> <select id="selectByDocumentNo" parameterType="java.util.Map" resultType="PyQueryBean"> SELECT NAME,DOCUMENTNO,CHANNELNAME, to_char(QUERYDATE,'yyyy-MM-dd hh24:mi:ss') AS QUERYDATE, DOCID,UMNAME,IMAGEID FROM ICS_PY_QUERYRECORD <trim prefix="WHERE" prefixOverrides="AND | OR "> <if test="list !=null"> DOCUMENTNO IN <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> AND QUERYTYPE IN (2,3) </trim> ORDER BY QUERYDATE DESC </select>