Compare commits

..

4 Commits

2 changed files with 47 additions and 13 deletions

View File

@ -55,6 +55,8 @@ 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;
@ -63,8 +65,12 @@ 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,31 +1,59 @@
package com.nu.modules.proxy; package com.nu.modules.proxy;
import org.springframework.http.*; import org.springframework.http.HttpEntity;
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 {
@Autowired private final RestTemplate restTemplate = new RestTemplate(); // 不使用配置类直接实例化
private RestTemplate restTemplate;
/**
* 代理 GET 请求
* @param apiUrl 三方接口的完整 URL
* @param params 请求的查询参数
* @return 代理后的响应
*/
@GetMapping("/get") @GetMapping("/get")
public ResponseEntity<String> proxyGet(@RequestParam String url, public ResponseEntity<String> proxyGet(
@RequestHeader(required = false) HttpHeaders headers) { @RequestParam String apiUrl,
@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);
return ResponseEntity.ok(response.getBody()); // 发起 GET 请求
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(@RequestParam String url, public ResponseEntity<String> proxyPost(
@RequestBody(required = false) String body, @RequestParam String apiUrl,
@RequestHeader(required = false) HttpHeaders headers) { @RequestBody String body) {
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);
return ResponseEntity.ok(response.getBody()); // 发起 POST 请求
ResponseEntity<String> response = restTemplate.exchange(apiUrl, HttpMethod.POST, entity, String.class);
return response; // 返回代理后的响应
} }
} }