package io.modules.item.service;

import io.modules.item.entity.SetResponse;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.http.ResponseEntity;

@Service
public class SetRequestService {

    public SetResponse sendSetRequest(String key, String value) {
        RestTemplate restTemplate = new RestTemplate();
        String url = "http://localhost:8080/set?key=" + key + "&value=" + value;

        // 发送 GET 请求并解析返回 JSON 为 SetResponse 对象
        ResponseEntity<SetResponse> response = restTemplate.getForEntity(url, SetResponse.class);

        return response.getBody();
    }
}
