百度智能云-身份证验证(完整版-直接用)

百度云网址:

https://cloud.baidu.com

身份验证的技术文档:

百度智能云-身份证验证(完整版-直接用)_第1张图片

百度智能云-身份证验证(完整版-直接用)_第2张图片

百度智能云-身份证验证(完整版-直接用)_第3张图片

技术代码:

导入依赖:

        
            com.squareup.okhttp3
            okhttp
            3.12.13
            compile
        
		
			com.squareup.okhttp3
			okhttp
			3.12.13
			compile
		
    // JSONObject的依赖
        
            com.alibaba
            fastjson
            1.2.70
        
// io流的依赖
        
            commons-io
            commons-io
            2.4
        
//hutool

    cn.hutool
    hutool-all
    5.8.16

控制层:

    /***
     * 身份证验证上传图片接口
     */
    @PostMapping ("identityToken/{param}")
    public Result identityToken(@PathVariable("param")Integer param , MultipartFile file, HttpServletRequest request) throws IOException {
        System.out.println("图片=="+file);
        CereBuyerUser user = (CereBuyerUser) request.getAttribute("user");
        return agentUserService.identityToken(user,file,param);
    }

处理的事物层

    Result identityToken(CereBuyerUser user, MultipartFile file,Integer param) throws IOException;
package com.example.demo.service.Impl;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.example.demo.service.AgentUserService;
import com.example.demo.util.Base64Util;
import com.example.demo.util.FileUtil;
import com.example.demo.util.HttpUtils;
import okhttp3.*;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import static com.example.demo.util.IdentityCardUtil.*;

@Service
public class AgentUserServiceImpl implements AgentUserService {
    static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();

    @Value("${identity.url}")
    private String identityUrl;
    @Value("${identity.apiKey}")
    private String apiKey;
    @Value("${identity.secrtetKey}")
    private String secrtetKey;
    /**
     * 身份验证
     * @param
     * @return
     */
    @Override
    public String identityToken(MultipartFile file, String param) throws IOException {
        //获得身份验证token
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody

你可能感兴趣的:(java,java,maven,jvm,spring,cloud,mybatis,log4j)