1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > java身份证实名认证-身份证二要素实名认证-身份证实名校验-身份证一致性实名认证

java身份证实名认证-身份证二要素实名认证-身份证实名校验-身份证一致性实名认证

时间:2020-03-23 06:08:13

相关推荐

java身份证实名认证-身份证二要素实名认证-身份证实名校验-身份证一致性实名认证

aliyun身份证实名认证-身份证二要素实名认证-身份证实名校验-身份证一致性实名认证

官网地址(需付费使用):

/products/57000002/cmapi026109.html?spm=5176.730005.result.5.426336f2dyiAnF&innerSource=search#sku=yuncode900004

public int insertUser(User user) {String idCardIdentityCardVerification = EonUtils.isIdCardIdentityCardVerification(user.getIdcard());if (!idCardIdentityCardVerification.equals("200")) throw new RuntimeException(idCardIdentityCardVerification);String url = "/eid/check";//产品codeString appCode = "d589d30785b64629b18b664ad637d711";Map<String, String> params = new HashMap<>();params.put("idcard", user.getIdcard());params.put("name", user.getName());try {String result = postForm(appCode, url, params);HashMap map = JSON.parseObject(result, HashMap.class);HashMap resultmap = JSON.parseObject(map.get("result").toString(), HashMap.class);Integer sex = resultmap.get("sex").equals("男") ? 0 : 1;user.setSex(sex);String code = map.get("code").toString();String message = map.get("message") != null && !"".equals("成功") ? map.get("message").toString() : "检验姓名和身份证失败";if (!code.equals("0")) throw new RuntimeException(message);/*HashMap map2 = JSON.parseObject(resultmap.get("result").toString(), HashMap.class);*///DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");String description = resultmap.get("description").toString();/*(1) 现役军人、武警官兵、特殊部门人员及特殊级别官员;(2) 退役不到2年的军人和士兵(根据军衔、兵种不同,时间会有所不同,一般为2年);(3) 户口迁出,且没有在新的迁入地迁入;(4) 户口迁入新迁入地,当地公安系统未将迁移信息上报到公安部(上报时间地域不同而有所差异);(5) 更改姓名,当地公安系统未将更改信息上报到公安部(上报时间因地域不同而有所差异);(6) 移民;(7) 未更换二代身份证;(8) 死亡。(9) 身份证号确实不存在*/if (!description.equals("一致")) throw new RuntimeException("上传身份证信息与权威库不一致,请重新上传");// HashMap resultty = JSON.parseObject(map.get("result").toString(), HashMap.class);} catch (IOException e) {e.printStackTrace();log.error("校验身份证接口出现问题:"+e.getMessage());throw new RuntimeException("网络异常请稍后重试");}user.setCreateTime(DateUtils.getNowDate());user.setPoints(10);return userMapper.insertUser(user);}

工具类

public static String postForm(String appCode, String url, Map<String, String> params) throws IOException {OkHttpClient client = new OkHttpClient.Builder().build();FormBody.Builder formbuilder = new FormBody.Builder();Iterator<String> it = params.keySet().iterator();while (it.hasNext()) {String key = it.next();formbuilder.add(key, params.get(key));}FormBody body = formbuilder.build();Request request = new Request.Builder().url(url).addHeader("Authorization", "APPCODE " + appCode).post(body).build();Response response = client.newCall(request).execute();String result = response.body().string();return result;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。