package com.zy.acs.hex.controller;
|
|
import com.zy.acs.framework.common.R;
|
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.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.client.RestTemplate;
|
|
@RestController
|
@RequestMapping(value = "/proxy")
|
public class ProxyController {
|
|
private final RestTemplate restTemplate = new RestTemplate();
|
|
@GetMapping(value = "/decode")
|
public R decode(@RequestParam String hexData) {
|
try {
|
String url = "http://127.0.0.1:9060/utils/decode/" + hexData;
|
HttpHeaders headers = new HttpHeaders();
|
headers.set("Content-Type", "application/json");
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
ResponseEntity<Object> response = restTemplate.exchange(url, HttpMethod.GET, entity, Object.class);
|
return R.ok(response.getBody());
|
} catch (Exception e) {
|
return R.error("解析失败: " + e.getMessage());
|
}
|
}
|
}
|