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

View File

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