From ede811fa02bf7e37e804e23c3d4a86cff723fced Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Wed, 7 May 2025 15:18:07 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=85=E5=90=8D?= =?UTF-8?q?=E4=BB=8ENewCitizen=E5=8F=98=E4=B8=BAnewcitizen=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.vscode/fileheader.template.js | 87 +++++++++++++++++++ .../NewCitizen/IdentifyNewCitizenRequest.java | 27 +++--- .../IdentifyNewCitizenResponse.java | 2 +- .../NewCitizen/QueryResultController.java | 48 +++++----- .../NewCitizen/QueryResultRequest.java | 2 +- 5 files changed, 128 insertions(+), 38 deletions(-) create mode 100644 code/backend/NewCitizenIdentify/.vscode/fileheader.template.js diff --git a/code/backend/NewCitizenIdentify/.vscode/fileheader.template.js b/code/backend/NewCitizenIdentify/.vscode/fileheader.template.js new file mode 100644 index 0000000..3eb8772 --- /dev/null +++ b/code/backend/NewCitizenIdentify/.vscode/fileheader.template.js @@ -0,0 +1,87 @@ +/* + * @Author: Kane + * @Date: 2025-03-16 00:35:09 + * @LastEditors: Kane + * @FilePath: /cpicxim-huixiabao/.vscode/fileheader.template.js + * @Description: + * + * Copyright (c) ${2023} by Kane, All Rights Reserved. + */ +/** + * This file is generated by VSCode extension: Fileheader Pro + */ + +/** + * These comments can help you write your own template with type hint + * @typedef {Object} FileheaderVariable Fileheader variables + * @property {string} birthtime file birth time. will get it from VCS or fallback to filesystem when it is not available + * @property {string} mtime file modification time. will get it from VCS or fallback to filesystem when it is not available + * @property {string} authorName if the file is tracked by VCS, it will get the author name from VCS. else it will get it from current user name + * @property {string} authorEmail if the file is tracked by VCS, it will get the author email from VCS. else it will get it from current user email + * @property {string} userName else it will get it from current user name + * @property {string} userEmail user email is from VSCode config, and fallback to VCS config + * @property {string} companyName + * @property {string} projectName name of current project + * @property {string} filePath the file path, relative to project root with POSIX path separator + * @property {string} dirPath the directory path, relative to project root with POSIX path separator + * @property {string} fileName filename with extension + */ + + /** + * @typedef {string | number | null | undefined | Template | boolean} TemplateInterpolation NOTE: boolean or falsy value will render empty string + * + * @typedef {{ strings: TemplateStringsArray; interpolations: TemplateInterpolation[]; }} Template + * @typedef {(strings: TemplateStringsArray, ...values: any[]) => string} ITemplateFunction + * + */ + +/** + * Please confirm your provider extends from globalThis.FileheaderLanguageProvider + */ +class CustomLanguageProvider extends globalThis.FileheaderLanguageProvider { + /** + * @type {string[]} + */ + languages = [ + "java", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + ]; + + /** + * @type {string=} the language block comment start string. + * this is for future feature: support detect old custom template when custom template changes + */ + blockCommentStart = "/**"; + + /** + * @type {string=} + */ + blockCommentEnd = "*/"; + + /** + * get your template when document language matched + * @param {ITemplateFunction} tpl template function, it is a tagged function, support nested interpolation + * @param {FileheaderVariable} variables template variables + * @returns {Template} + */ + getTemplate(tpl, variables) { + // prettier-ignore + return tpl +`/** + * @Author: ${variables.authorName} <${variables.authorEmail}> + * @Date: ${variables.birthtime} + * @LastEditors: ${variables.userName} + * @LastModified: ${variables.mtime} + * @FilePath: ${variables.filePath} + * @Description: + * + * Copyright (c) ${2025} by Kane All rights reserved + */`; + } +} + +// export your provider classes +module.exports = [CustomLanguageProvider]; diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenRequest.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenRequest.java index d64144c..4dc3bd1 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenRequest.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenRequest.java @@ -1,21 +1,24 @@ -/* - * @Author: Kane - * @Date: 2023-05-25 15:17:49 - * @LastEditors: Kane - * @FilePath: /NewCitizenQueryResult/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenRequest.java - * @Description: +/** + * @Author: Kane Wang + * @Date: 2023-05-26 18:40:36 + * @LastEditors: Kane Wang + * @LastModified: 2025-05-07 14:59:15 + * @FilePath: src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenRequest.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; +package com.cpic.xim.web.controllers.newcitizen; import com.fasterxml.jackson.annotation.JsonProperty; public class IdentifyNewCitizenRequest { - public IdentifyNewCitizenRequest() {} + public IdentifyNewCitizenRequest() + { + } - public String getIdCardNo() + public String getIdCardNo() { return idCardNo; } @@ -35,9 +38,9 @@ public class IdentifyNewCitizenRequest this.name = name; } - @JsonProperty("idcard_no") + @JsonProperty( "idcard_no" ) private String idCardNo; - @JsonProperty("name") + @JsonProperty( "name" ) private String name; } \ No newline at end of file diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResponse.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResponse.java index 603724b..b54618e 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResponse.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResponse.java @@ -7,7 +7,7 @@ * * Copyright (c) ${2022} by Kane, All Rights Reserved. */ -package com.cpic.xim.web.controllers.NewCitizen; +package com.cpic.xim.web.controllers.newcitizen; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java index 7135235..dbfdda2 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java @@ -1,14 +1,14 @@ -/* +/** * @Author: Kane * @Date: 2023-05-25 12:09:27 - * @LastEditors: Kane - * @FilePath: /NewCitizenQueryResult/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java - * @Description: - * - * Copyright (c) ${2022} by Kane, All Rights Reserved. +* @LastEditors: Kane +* @FilePath: /NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java + * @Description: + * @ + * @Copyright (c) ${2023} by Kane, All Rights Reserved. */ -package com.cpic.xim.web.controllers.NewCitizen; +package com.cpic.xim.web.controllers.newcitizen; import jakarta.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; @@ -23,37 +23,37 @@ import com.cpic.xim.utils.newcitizen.*; @Controller public class QueryResultController { - @RequestMapping("/save_score.do") - public void saveQueryResult(HttpServletResponse response, @RequestBody QueryResultRequest result ) + @RequestMapping( "/save_score.do" ) + public void saveQueryResult( HttpServletResponse response, @RequestBody QueryResultRequest result ) { - response.setStatus(HttpServletResponse.SC_OK); + response.setStatus( HttpServletResponse.SC_OK ); } - @RequestMapping("/identify.do") + @RequestMapping( "/identify.do" ) @ResponseBody - public IdentifyNewCitizenResponse identifyNewCitizen(@RequestBody IdentifyNewCitizenRequest request ) + public IdentifyNewCitizenResponse identifyNewCitizen( @RequestBody IdentifyNewCitizenRequest request ) { - String idCardNo = request.getIdCardNo(); - String name = request.getName(); - IdentifyResult result = null; + String idCardNo = request.getIdCardNo(); + String name = request.getName(); + IdentifyResult result = null; IdentifyNewCitizenResponse response = new IdentifyNewCitizenResponse(); - + try { - result = NewCitizenUitls.identifyNewCitizen(idCardNo, name); + result = NewCitizenUitls.identifyNewCitizen( idCardNo, name ); - response.setSuccess(true); - response.setMessage("调用成功"); - response.setCitizenType(result.getCitizenType()); - response.setScore(result.getScore()); - response.setExpireDate(result.getExpireDate()); + response.setSuccess( true ); + response.setMessage( "调用成功" ); + response.setCitizenType( result.getCitizenType() ); + response.setScore( result.getScore() ); + response.setExpireDate( result.getExpireDate() ); } catch ( Exception error ) { System.out.println( error.getMessage() ); - response.setSuccess(false); - response.setMessage(error.getMessage()); + response.setSuccess( false ); + response.setMessage( error.getMessage() ); } return response; diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultRequest.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultRequest.java index f764cbe..691ce72 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultRequest.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultRequest.java @@ -1,5 +1,5 @@ -package com.cpic.xim.web.controllers.NewCitizen; +package com.cpic.xim.web.controllers.newcitizen; import com.fasterxml.jackson.annotation.JsonProperty; From 56fb6b6b10a497bd7ccf1b845a91a57219e7b009 Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Wed, 7 May 2025 19:01:51 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xim/utils/newcitizen/NewCitizenUitls.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java index 7641ff2..3881e98 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java @@ -1,15 +1,12 @@ -/* - * @Author: Kane +/** + * @Author: Kane Wang + * @Date: 2023-05-26 18:40:36 + * @LastEditors: Kane Wang + * @LastModified: 2025-05-07 16:50:56 + * @FilePath: src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java + * @Description: * - * @Date: 2023-05-25 15:26:09 - * - * @LastEditors: Kane - * - * @FilePath: /NewCitizenQueryResult/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java - * - * @Description: 新市民认证相关的工具方法 - * - * Copyright (c) ${2022} by Kane, All Rights Reserved. + * Copyright (c) 2025 by Kane All rights reserved */ package com.cpic.xim.utils.newcitizen; From 74e038dd56d79c5a64e8fd9cc6d5b6a3db237fa6 Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Wed, 7 May 2025 19:07:24 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java index 3881e98..f1a8152 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java @@ -2,7 +2,7 @@ * @Author: Kane Wang * @Date: 2023-05-26 18:40:36 * @LastEditors: Kane Wang - * @LastModified: 2025-05-07 16:50:56 + * @LastModified: 2025-05-07 19:06:53 * @FilePath: src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java * @Description: * From 78c7a0d9a9f2583844f05a86a70672ee4af627bf Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Thu, 8 May 2025 00:56:14 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=94=B9=E5=8F=98=E6=9E=B6=E6=9E=84?= =?UTF-8?q?=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/config/EncryptionParameters.java | 11 ++- .../com/cpic/xim/utils/http/HttpUtils.java | 65 ++++++++++++++++++ .../xim/utils/newcitizen/NewCitizenUitls.java | 67 ++++++++++--------- .../IdentifyNewCitizenResponse.java | 15 +++-- .../NewCitizen/QueryResultController.java | 14 ++-- .../NewCitizen/QueryResultRequest.java | 11 ++- .../com/cpic/xim/web/filters/CrosFilter.java | 39 +++++------ .../src/main/webapp/WEB-INF/web.xml | 10 ++- 8 files changed, 161 insertions(+), 71 deletions(-) create mode 100644 code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/http/HttpUtils.java diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/config/EncryptionParameters.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/config/EncryptionParameters.java index 22dbd3b..8502eac 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/config/EncryptionParameters.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/config/EncryptionParameters.java @@ -1,4 +1,13 @@ - +/** + * @Author: Kane Wang + * @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 diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/http/HttpUtils.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/http/HttpUtils.java new file mode 100644 index 0000000..062b2d0 --- /dev/null +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/http/HttpUtils.java @@ -0,0 +1,65 @@ +/** + * @Author: Kane Wang + * @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 bodyMap ) + { + HttpPost post = new HttpPost( url ); + + try + { + // 创建参数集合 + List 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 ""; + } + } +} \ No newline at end of file diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java index f1a8152..9334279 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java @@ -2,7 +2,7 @@ * @Author: Kane Wang * @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 bodyMap ) - { - HttpPost post = new HttpPost( url ); + // public static String sendPost( String url, Map bodyMap ) + // { + // HttpPost post = new HttpPost( url ); - try - { - // 创建参数集合 - List 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 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 ""; + // } + // } } diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResponse.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResponse.java index b54618e..1e311ef 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResponse.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/IdentifyNewCitizenResponse.java @@ -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 - * @Description: +/** + * @Author: Kane Wang + * @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; diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java index dbfdda2..66f1fe4 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultController.java @@ -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 + * @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; diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultRequest.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultRequest.java index 691ce72..1c21fde 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultRequest.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/controllers/NewCitizen/QueryResultRequest.java @@ -1,4 +1,13 @@ - +/** + * @Author: Kane Wang + * @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; diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/filters/CrosFilter.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/filters/CrosFilter.java index 593e014..5b3eed9 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/filters/CrosFilter.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/web/filters/CrosFilter.java @@ -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 - * @Description: +/** + * @Author: Kane Wang + * @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,26 +24,27 @@ 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; - String method = request.getMethod(); - String originHeader = request.getHeader( "Origin" ); - - System.out.println( "收到" + method + "请求,来自" + originHeader); - + HttpServletRequest request = ( HttpServletRequest ) req; + HttpServletResponse response = ( HttpServletResponse ) resp; + String method = request.getMethod(); + String originHeader = request.getHeader( "Origin" ); + + System.out.println( "收到" + method + "请求,来自" + originHeader ); + // 如果是Options请求 - if ( method.equals(HttpMethod.OPTIONS.toString()) ) + if ( method.equals( HttpMethod.OPTIONS.toString() ) ) { originHeader = "*"; } - + response.setHeader( "Access-Control-Allow-Origin", originHeader ); response.setHeader( "Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT" ); response.setHeader( "Access-Control-Max-Age", "0" ); response.setHeader( "Access-Control-Allow-Headers", - "Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token" ); + "Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token" ); response.setHeader( "Access-Control-Allow-Credentials", "true" ); response.setHeader( "XDomainRequestAllowed", "1" ); response.setHeader( "XDomainRequestAllowed", "1" ); diff --git a/code/backend/NewCitizenIdentify/src/main/webapp/WEB-INF/web.xml b/code/backend/NewCitizenIdentify/src/main/webapp/WEB-INF/web.xml index 11e2001..c06119f 100644 --- a/code/backend/NewCitizenIdentify/src/main/webapp/WEB-INF/web.xml +++ b/code/backend/NewCitizenIdentify/src/main/webapp/WEB-INF/web.xml @@ -1,7 +1,11 @@ - + + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"> Archetype Created Web Application From bbe1ee44c173b97f8d29f6c4199022d576cf502c Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Thu, 8 May 2025 18:56:46 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=B8=85=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xim/utils/newcitizen/NewCitizenUitls.java | 58 ++----------------- 1 file changed, 6 insertions(+), 52 deletions(-) diff --git a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java index 9334279..e2c3e27 100644 --- a/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java +++ b/code/backend/NewCitizenIdentify/src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java @@ -2,7 +2,7 @@ * @Author: Kane Wang * @Date: 2023-05-26 18:40:36 * @LastEditors: Kane Wang - * @LastModified: 2025-05-07 22:06:09 + * @LastModified: 2025-05-08 18:55:36 * @FilePath: src/main/java/com/cpic/xim/utils/newcitizen/NewCitizenUitls.java * @Description: * @@ -10,28 +10,15 @@ */ package com.cpic.xim.utils.newcitizen; -import java.util.ArrayList; import java.util.HashMap; -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; -// import com.cdp.product.security.decode.CdpDecryptUtil; -// import com.cdp.product.security.encode.EncryptionUtils; -// import com.cdp.product.security.sign.CdpSignUtil; -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.cpic.xim.utils.http.HttpUtils; +import com.cpic.xim.utils.security.decode.DecryptionUtils; +import com.cpic.xim.utils.security.encode.EncryptionUtils; +import com.cpic.xim.utils.security.sign.SignUtils; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.ObjectMapper; public class NewCitizenUitls @@ -88,39 +75,6 @@ public class NewCitizenUitls return identifyResult; } - - // public static String sendPost( String url, Map bodyMap ) - // { - // HttpPost post = new HttpPost( url ); - - // try - // { - // // 创建参数集合 - // List 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 ""; - // } - // } }