Compare commits

..

No commits in common. "ba4dc39960db473f0f12e5e79dd10e9069895d8a" and "eefaa4191ea339ea3d5e45cad6b73783a8b5c110" have entirely different histories.

2 changed files with 13 additions and 47 deletions

View File

@ -55,8 +55,6 @@ public class OrgApplyInfoApiEntity implements Serializable {
/**民族*/ /**民族*/
private String national; private String national;
/**出生日期*/ /**出生日期*/
@JsonFormat(pattern = "yyyy年MM月dd日")
@DateTimeFormat(pattern = "yyyy年MM月dd日")
private Date birthDate; private Date birthDate;
/**住址(身份证上)*/ /**住址(身份证上)*/
private String idCardAddress; private String idCardAddress;
@ -65,12 +63,8 @@ public class OrgApplyInfoApiEntity implements Serializable {
/**签发机关*/ /**签发机关*/
private String issuingAuthority; private String issuingAuthority;
/**有效开始日期*/ /**有效开始日期*/
@JsonFormat(pattern = "yyyy.MM.dd")
@DateTimeFormat(pattern = "yyyy.MM.dd")
private Date startTime; private Date startTime;
/**有效结束日期*/ /**有效结束日期*/
@JsonFormat(pattern = "yyyy.MM.dd")
@DateTimeFormat(pattern = "yyyy.MM.dd")
private Date endTime; private Date endTime;
/**身份证正面*/ /**身份证正面*/
private String cardZmPath; private String cardZmPath;

View File

@ -1,59 +1,31 @@
package com.nu.modules.proxy; package com.nu.modules.proxy;
import org.springframework.http.HttpEntity; import org.springframework.http.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
@RestController @RestController
@RequestMapping("/api/proxy") @RequestMapping("/api/proxy")
public class ProxyApi { public class ProxyApi {
private final RestTemplate restTemplate = new RestTemplate(); // 不使用配置类直接实例化 @Autowired
private RestTemplate restTemplate;
/**
* 代理 GET 请求
* @param apiUrl 三方接口的完整 URL
* @param params 请求的查询参数
* @return 代理后的响应
*/
@GetMapping("/get") @GetMapping("/get")
public ResponseEntity<String> proxyGet( public ResponseEntity<String> proxyGet(@RequestParam String url,
@RequestParam String apiUrl, @RequestHeader(required = false) HttpHeaders headers) {
@RequestParam(required = false) String params) {
String fullUrl = apiUrl + (params != null ? "?" + params : "");
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> entity = new HttpEntity<>(headers); HttpEntity<String> entity = new HttpEntity<>(headers);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
// 发起 GET 请求 return ResponseEntity.ok(response.getBody());
ResponseEntity<String> response = restTemplate.exchange(fullUrl, HttpMethod.GET, entity, String.class);
return response; // 返回代理后的响应
} }
/**
* 代理 POST 请求
* @param apiUrl 三方接口的完整 URL
* @param body 请求体
* @return 代理后的响应
*/
@PostMapping("/post") @PostMapping("/post")
public ResponseEntity<String> proxyPost( public ResponseEntity<String> proxyPost(@RequestParam String url,
@RequestParam String apiUrl, @RequestBody(required = false) String body,
@RequestBody String body) { @RequestHeader(required = false) HttpHeaders headers) {
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> entity = new HttpEntity<>(body, headers); HttpEntity<String> entity = new HttpEntity<>(body, headers);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
// 发起 POST 请求 return ResponseEntity.ok(response.getBody());
ResponseEntity<String> response = restTemplate.exchange(apiUrl, HttpMethod.POST, entity, String.class);
return response; // 返回代理后的响应
} }
} }