改变架构!
This commit is contained in:
parent
74e038dd56
commit
78c7a0d9a9
@ -1,4 +1,13 @@
|
||||
|
||||
/**
|
||||
* @Author: Kane Wang <wangkane@qq.com>
|
||||
* @Date: 2023-05-26 18:40:36
|
||||
* @LastEditors: Kane Wang
|
||||
* @LastModified: 2025-05-07 22:02:07
|
||||
* @FilePath: src/main/java/com/cpic/xim/utils/config/EncryptionParameters.java
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) 2025 by Kane All rights reserved
|
||||
*/
|
||||
package com.cpic.xim.utils.config;
|
||||
|
||||
public class EncryptionParameters
|
||||
|
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @Author: Kane Wang <wangkane@qq.com>
|
||||
* @Date: 2024-04-29 11:09:50
|
||||
* @LastEditors: Kane Wang
|
||||
* @LastModified: 2025-05-07 22:04:08
|
||||
* @FilePath: src/main/java/com/cpic/xim/utils/http/HttpUtils.java
|
||||
* @Description: 用于http的相关工具方法
|
||||
*
|
||||
* Copyright (c) 2025 by Kane All rights reserved
|
||||
*/
|
||||
package com.cpic.xim.utils.http;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
public class HttpUtils
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
* @param bodyMap
|
||||
* @return
|
||||
*/
|
||||
public static String sendPost( String url, Map<String, String> bodyMap )
|
||||
{
|
||||
HttpPost post = new HttpPost( url );
|
||||
|
||||
try
|
||||
{
|
||||
// 创建参数集合
|
||||
List<BasicNameValuePair> list = new ArrayList<>();
|
||||
// 添加参数
|
||||
if ( bodyMap != null )
|
||||
{
|
||||
for ( String str : bodyMap.keySet() )
|
||||
{
|
||||
list.add( new BasicNameValuePair( str, bodyMap.get( str ) ) );
|
||||
}
|
||||
}
|
||||
// 把参数放入请求对象,post发送的参数list,指定格式
|
||||
post.setEntity( new UrlEncodedFormEntity( list, "UTF-8" ) );
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
// 启动执行请求,并获得返回值
|
||||
CloseableHttpResponse response = client.execute( post );
|
||||
// 得到返回的entity对象
|
||||
HttpEntity entity = response.getEntity();
|
||||
// 把实体对象转换为string
|
||||
return EntityUtils.toString( entity, "UTF-8" );
|
||||
}
|
||||
catch ( Exception e1 )
|
||||
{
|
||||
e1.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
* @Author: Kane Wang <wangkane@qq.com>
|
||||
* @Date: 2023-05-26 18:40:36
|
||||
* @LastEditors: Kane Wang
|
||||
* @LastModified: 2025-05-07 19:06:53
|
||||
* @LastModified: 2025-05-07 22:06:09
|
||||
* @FilePath: src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java
|
||||
* @Description:
|
||||
*
|
||||
@ -28,6 +28,7 @@ import org.apache.http.util.EntityUtils;
|
||||
import com.cpic.xim.utils.security.encode.EncryptionUtils;
|
||||
import com.cpic.xim.utils.security.decode.DecryptionUtils;
|
||||
import com.cpic.xim.utils.security.sign.SignUtils;
|
||||
import com.cpic.xim.utils.http.HttpUtils;
|
||||
import com.cpic.xim.utils.config.EncryptionParameters;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
@ -69,7 +70,7 @@ public class NewCitizenUitls
|
||||
params.put( "key", key );
|
||||
params.put( "sign", sign );
|
||||
|
||||
String resultJSON = sendPost( identifyURL, params );
|
||||
String resultJSON = HttpUtils.sendPost( identifyURL, params );
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
IdentifyResult identifyResult = null;
|
||||
ResponseResult response = null;
|
||||
@ -88,38 +89,38 @@ public class NewCitizenUitls
|
||||
return identifyResult;
|
||||
}
|
||||
|
||||
public static String sendPost( String url, Map<String, String> bodyMap )
|
||||
{
|
||||
HttpPost post = new HttpPost( url );
|
||||
// public static String sendPost( String url, Map<String, String> bodyMap )
|
||||
// {
|
||||
// HttpPost post = new HttpPost( url );
|
||||
|
||||
try
|
||||
{
|
||||
// 创建参数集合
|
||||
List<BasicNameValuePair> list = new ArrayList<>();
|
||||
// 添加参数
|
||||
if ( bodyMap != null )
|
||||
{
|
||||
for ( String str : bodyMap.keySet() )
|
||||
{
|
||||
list.add( new BasicNameValuePair( str, bodyMap.get( str ) ) );
|
||||
}
|
||||
}
|
||||
// 把参数放入请求对象,post发送的参数list,指定格式
|
||||
post.setEntity( new UrlEncodedFormEntity( list, "UTF-8" ) );
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
// 启动执行请求,并获得返回值
|
||||
CloseableHttpResponse response = client.execute( post );
|
||||
// 得到返回的entity对象
|
||||
HttpEntity entity = response.getEntity();
|
||||
// 把实体对象转换为string
|
||||
return EntityUtils.toString( entity, "UTF-8" );
|
||||
}
|
||||
catch ( Exception e1 )
|
||||
{
|
||||
e1.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
// try
|
||||
// {
|
||||
// // 创建参数集合
|
||||
// List<BasicNameValuePair> list = new ArrayList<>();
|
||||
// // 添加参数
|
||||
// if ( bodyMap != null )
|
||||
// {
|
||||
// for ( String str : bodyMap.keySet() )
|
||||
// {
|
||||
// list.add( new BasicNameValuePair( str, bodyMap.get( str ) ) );
|
||||
// }
|
||||
// }
|
||||
// // 把参数放入请求对象,post发送的参数list,指定格式
|
||||
// post.setEntity( new UrlEncodedFormEntity( list, "UTF-8" ) );
|
||||
// CloseableHttpClient client = HttpClients.createDefault();
|
||||
// // 启动执行请求,并获得返回值
|
||||
// CloseableHttpResponse response = client.execute( post );
|
||||
// // 得到返回的entity对象
|
||||
// HttpEntity entity = response.getEntity();
|
||||
// // 把实体对象转换为string
|
||||
// return EntityUtils.toString( entity, "UTF-8" );
|
||||
// }
|
||||
// catch ( Exception e1 )
|
||||
// {
|
||||
// e1.printStackTrace();
|
||||
// return "";
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-05-25 20:26:06
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /NewCitizenQueryResult/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResult.java
|
||||
/**
|
||||
* @Author: Kane Wang <wangkane@qq.com>
|
||||
* @Date: 2024-04-29 11:09:50
|
||||
* @LastEditors: Kane Wang
|
||||
* @LastModified: 2025-05-07 22:01:21
|
||||
* @FilePath: src/main/java/com/cpic/xim/web/controllers/newcitizen/IdentifyNewCitizenResponse.java
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
* Copyright (c) 2025 by Kane All rights reserved
|
||||
*/
|
||||
package com.cpic.xim.web.controllers.newcitizen;
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
/**
|
||||
* @Author: Kane
|
||||
* @Date: 2023-05-25 12:09:27
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java
|
||||
* @Author: Kane Wang <wangkane@qq.com>
|
||||
* @Date: 2024-04-29 11:09:50
|
||||
* @LastEditors: Kane Wang
|
||||
* @LastModified: 2025-05-07 22:00:48
|
||||
* @FilePath: src/main/java/com/cpic/xim/web/controllers/newcitizen/QueryResultController.java
|
||||
* @Description:
|
||||
* @
|
||||
* @Copyright (c) ${2023} by Kane, All Rights Reserved.
|
||||
*
|
||||
* Copyright (c) 2025 by Kane All rights reserved
|
||||
*/
|
||||
|
||||
package com.cpic.xim.web.controllers.newcitizen;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
@ -1,4 +1,13 @@
|
||||
|
||||
/**
|
||||
* @Author: Kane Wang <wangkane@qq.com>
|
||||
* @Date: 2024-04-29 11:09:50
|
||||
* @LastEditors: Kane Wang
|
||||
* @LastModified: 2025-05-07 22:00:35
|
||||
* @FilePath: src/main/java/com/cpic/xim/web/controllers/newcitizen/QueryResultRequest.java
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) 2025 by Kane All rights reserved
|
||||
*/
|
||||
package com.cpic.xim.web.controllers.newcitizen;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-05-25 11:02:53
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /NewCitizenQueryResult/src/main/java/com/cpic/xim/web/filters/CrosFilter.java
|
||||
/**
|
||||
* @Author: Kane Wang <wangkane@qq.com>
|
||||
* @Date: 2023-05-26 18:40:36
|
||||
* @LastEditors: Kane Wang
|
||||
* @LastModified: 2025-05-07 22:00:26
|
||||
* @FilePath: src/main/java/com/cpic/xim/web/filters/CrosFilter.java
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
* Copyright (c) 2025 by Kane All rights reserved
|
||||
*/
|
||||
|
||||
package com.cpic.xim.web.filters;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -24,17 +24,18 @@ public class CrosFilter implements Filter
|
||||
{
|
||||
@Override
|
||||
public void doFilter( ServletRequest req, ServletResponse resp, FilterChain chain )
|
||||
throws ServletException, IOException
|
||||
throws ServletException,
|
||||
IOException
|
||||
{
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
HttpServletResponse response = (HttpServletResponse) resp;
|
||||
HttpServletRequest request = ( HttpServletRequest ) req;
|
||||
HttpServletResponse response = ( HttpServletResponse ) resp;
|
||||
String method = request.getMethod();
|
||||
String originHeader = request.getHeader( "Origin" );
|
||||
|
||||
System.out.println( "收到" + method + "请求,来自" + originHeader);
|
||||
System.out.println( "收到" + method + "请求,来自" + originHeader );
|
||||
|
||||
// 如果是Options请求
|
||||
if ( method.equals(HttpMethod.OPTIONS.toString()) )
|
||||
if ( method.equals( HttpMethod.OPTIONS.toString() ) )
|
||||
{
|
||||
originHeader = "*";
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app
|
||||
version="4.0"
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:javaee="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">
|
||||
|
||||
<display-name>Archetype Created Web Application</display-name>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user