|
@@ -1,13 +1,11 @@
|
|
|
package com.jpsoft.campus.modules.mobile.controller;
|
|
|
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.google.gson.Gson;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import com.jpsoft.campus.modules.base.entity.*;
|
|
|
import com.jpsoft.campus.modules.base.service.*;
|
|
|
import com.jpsoft.campus.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.campus.modules.common.utils.JwtUtil;
|
|
|
-import com.jpsoft.campus.modules.common.utils.StringUtils;
|
|
|
import com.jpsoft.campus.modules.sys.service.SysLogService;
|
|
|
import com.wfl.uias.dto.JITObject;
|
|
|
import com.wfl.uias.http.HttpClientExecutor;
|
|
@@ -15,12 +13,7 @@ import com.wfl.uias.servlet.JITResponseHandler;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
-import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
-import org.apache.http.client.methods.HttpPost;
|
|
|
-import org.apache.http.entity.StringEntity;
|
|
|
-import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
-import org.apache.http.impl.client.HttpClients;
|
|
|
-import org.apache.http.util.EntityUtils;
|
|
|
+
|
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|
|
import org.joda.time.DateTime;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -28,17 +21,10 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.net.ssl.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStreamReader;
|
|
|
-import java.io.OutputStream;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.net.URL;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
+
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@@ -110,24 +96,57 @@ public class UiasApiController {
|
|
|
System.out.println("map:" + map);
|
|
|
System.out.println("用户详细信息json:" + str);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ final String fullUri2 = "https://oauth.hubei.gov.cn:8443/uias/unity/user_info";
|
|
|
+ HttpClientExecutor executor2 = new HttpClientExecutor(fullUri2);
|
|
|
+ executor2.addRequestParam("access_token", token);
|
|
|
+
|
|
|
+ JITResponseHandler responseHandler2 = new JITResponseHandler();
|
|
|
+ executor2.execute(responseHandler2, "get", filePath, decrypto);
|
|
|
+ JITObject jitObject2= responseHandler2.getObj();
|
|
|
+
|
|
|
+ String str2 = jitObject2.getOriginalText();
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject(str2);
|
|
|
+
|
|
|
+ String userId = jsonObject.get("userId").toString();
|
|
|
+
|
|
|
+ System.out.println("用户详细信息json2:" + str2);
|
|
|
+
|
|
|
if(map != null) {
|
|
|
String idCard = (String)map.get("id_card");
|
|
|
- personInfo = personInfoService.findByIdCard(idCard);
|
|
|
-
|
|
|
- if(personInfo == null){
|
|
|
- personInfo = new PersonInfo();
|
|
|
- personInfo.setId(UUID.randomUUID().toString());
|
|
|
- personInfo.setName((String)map.get("name"));
|
|
|
- personInfo.setIdCard((String)map.get("id_card"));
|
|
|
- personInfo.setPhone((String)map.get("mobile_phone"));
|
|
|
- personInfo.setUiasId(token);
|
|
|
|
|
|
- personInfo.setDelFlag(false);
|
|
|
- personInfo.setCreateTime(new Date());
|
|
|
-
|
|
|
- personInfoService.insert(personInfo);
|
|
|
+ personInfo = personInfoService.findByUserId(userId);
|
|
|
+ if(personInfo == null) {
|
|
|
+ personInfo = personInfoService.findByIdCard(idCard);
|
|
|
+ if (personInfo == null) {
|
|
|
+ personInfo = new PersonInfo();
|
|
|
+ personInfo.setId(UUID.randomUUID().toString());
|
|
|
+ personInfo.setName((String) map.get("name"));
|
|
|
+ personInfo.setIdCard((String) map.get("id_card"));
|
|
|
+ personInfo.setPhone((String) map.get("mobile_phone"));
|
|
|
+ personInfo.setUiasId(token);
|
|
|
+ personInfo.setUserId(userId);
|
|
|
+ personInfo.setOtherInfo(str);
|
|
|
+ personInfo.setUserInfo(str2);
|
|
|
+
|
|
|
+ personInfo.setDelFlag(false);
|
|
|
+ personInfo.setCreateTime(new Date());
|
|
|
+
|
|
|
+ personInfoService.insert(personInfo);
|
|
|
+ } else {
|
|
|
+ personInfo.setUiasId(token);
|
|
|
+ personInfo.setUserId(userId);
|
|
|
+ personInfo.setOtherInfo(str);
|
|
|
+ personInfo.setUserInfo(str2);
|
|
|
+ personInfoService.update(personInfo);
|
|
|
+ }
|
|
|
}else{
|
|
|
personInfo.setUiasId(token);
|
|
|
+ personInfo.setUserId(userId);
|
|
|
+ personInfo.setOtherInfo(str);
|
|
|
+ personInfo.setUserInfo(str2);
|
|
|
personInfoService.update(personInfo);
|
|
|
}
|
|
|
}else{
|
|
@@ -137,6 +156,9 @@ public class UiasApiController {
|
|
|
// personInfo.setIdCard((String)map.get("id_card"));
|
|
|
// personInfo.setPhone((String)map.get("mobile_phone"));
|
|
|
personInfo.setUiasId(token);
|
|
|
+ personInfo.setUserId(userId);
|
|
|
+ personInfo.setOtherInfo(str);
|
|
|
+ personInfo.setUserInfo(str2);
|
|
|
|
|
|
personInfo.setDelFlag(false);
|
|
|
personInfo.setCreateTime(new Date());
|
|
@@ -178,6 +200,7 @@ public class UiasApiController {
|
|
|
String filePath = path;
|
|
|
//使用授权码换取token
|
|
|
final String fullUri = "https://oauth.hubei.gov.cn:8443/uias/unity/other_info";
|
|
|
+
|
|
|
HttpClientExecutor executor = new HttpClientExecutor(fullUri);
|
|
|
executor.addRequestParam("access_token", uiasId);
|
|
|
|
|
@@ -186,13 +209,32 @@ public class UiasApiController {
|
|
|
JITResponseHandler responseHandler = new JITResponseHandler();
|
|
|
executor.execute(responseHandler, "get", filePath, decrypto);
|
|
|
JITObject jitObject = responseHandler.getObj();
|
|
|
+
|
|
|
String str = jitObject.getText();
|
|
|
|
|
|
+
|
|
|
org.codehaus.jackson.map.ObjectMapper objectMapper = new ObjectMapper();
|
|
|
map = objectMapper.readValue(str, Map.class);
|
|
|
System.out.println("map:" + map);
|
|
|
System.out.println("用户详细信息json:" + str);
|
|
|
|
|
|
+
|
|
|
+ final String fullUri2 = "https://oauth.hubei.gov.cn:8443/uias/unity/user_info";
|
|
|
+ HttpClientExecutor executor2 = new HttpClientExecutor(fullUri2);
|
|
|
+ executor2.addRequestParam("access_token", uiasId);
|
|
|
+
|
|
|
+ JITResponseHandler responseHandler2 = new JITResponseHandler();
|
|
|
+ executor2.execute(responseHandler2, "get", filePath, decrypto);
|
|
|
+ JITObject jitObject2= responseHandler2.getObj();
|
|
|
+
|
|
|
+ String str2 = jitObject2.getOriginalText();
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject(str2);
|
|
|
+ String userId = jsonObject.get("userId").toString();
|
|
|
+
|
|
|
+ System.out.println("用户详细信息json2:" + str2);
|
|
|
+ System.out.println("用户详细信息json2:" + userId);
|
|
|
+
|
|
|
messageResult.setData(map);
|
|
|
messageResult.setResult(true);
|
|
|
} catch (Exception ex) {
|