1
zhang
3 天以前 9671fa60b69a5b749bfbd989f0aa281aa284dde6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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());
        }
    }
}