package com.elephant.framework.galaxy.aroad.module.common.getInterfaceData;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
@Component
public class HttpClient {
    @Value("${jlzf.url}")
    private String jlzf_url;

    public String client(String token) {
        RestTemplate template = new RestTemplate();
        String url = jlzf_url+"/updateAccessTokenSysInterfaceEnterprise.action?refreshtoken="+token;
        ResponseEntity<String> response = template.getForEntity(url, String.class);
        return response.getBody();
    }

    public  String callOtherInterface(String propUrl, String token, String createData) {
        RestTemplate rest =new RestTemplate();
        String json = "{\"createDate\":\""+createData+"\"}";
        String url = jlzf_url+propUrl+"?access_token="+token+"&key="+json;
        ResponseEntity<String> res= rest.getForEntity(url,String.class,json);
        return  res.getBody();
    }
}
