package com.ningdatech.carapi.irs.service.impl;

import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import com.ningdatech.carapi.irs.service.FilePreviewService;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * @author CMM
 * @since 2023/03/07 15:36
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class FilePreviewServiceImpl implements FilePreviewService {

    @Override
    public String filePreview(String ext,String remoteUrl,String markText,String upt) {
        return null;
    }


    public static void main(String[] args) {
        RestTemplate restTemplate = new RestTemplate();
        Map<String,Object> map = new HashMap<>();
        map.put("ext","png");
        map.put("remoteUrl","http://pic37.nipic.com/20140113/9900276_184927469000_2.png");
        map.put("markText","false");
        map.put("upt",null);
        ResponseEntity<String> responseEntity = null;
        //发送post请求
        RequestEntity<Map<String,Object>> requestEntity = RequestEntity
                .post("")
                .header("Accept", MediaType.APPLICATION_JSON.toString())
                .contentType(MediaType.APPLICATION_JSON)
                .accept(MediaType.APPLICATION_JSON)
                .body(map);

        try {
            responseEntity=  restTemplate.exchange(requestEntity,String.class);
        } catch (Exception e) {
            log.error("[RestTemplateTest-test] http request error", e);
        }

        System.out.println(responseEntity.toString());
    }
}
