package com.izouma.wenlvju.web;


import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import com.github.kevinsawicki.http.HttpRequest;
import com.izouma.wenlvju.ApplicationTests;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
import java.io.InputStream;

public class RateControllerTest extends ApplicationTests {
    @Autowired
    private RateController rateController;

    @Test
    public void test() {
        System.out.println(rateController.get1(162L));
    }

    @Test
    public void test1() {
//        rateController.saveReviewTime(162L, "2021-10-01 00:00:00");
//        System.out.println(Convert.toLocalDateTime("2021-10-01 00:00:00"));
        System.out.println(DateUtil.now());
    }


    @Test
    public void test3() {
        String uri = "http://192.168.50.238:8080/word2pdf";
        // String uri = "http://frp.drewslab.cn:2223/word2pdf";
        // java输出文件
//        String export = rateController.export(410L);
//        InputStream is = new ByteArrayInputStream(export.getBytes());
//        本地文件
//        File file = new File("/Users/qiufangchao/Desktop/20210422.doc");
//        System.out.println(file.exists());


//        HttpURLConnection conn;
//        InputStream is = null;
//        try {
//            URL url = new URL("https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/application/2021-04-22-09-31-18HXEusrCL.docx");
//            conn = (HttpURLConnection)url.openConnection();
//            conn.setRequestMethod("GET");
//            conn.setConnectTimeout(20 * 1000);
//            final ByteArrayOutputStream output = new ByteArrayOutputStream();
//            IOUtils.copy(conn.getInputStream(),output);
//            is =  new ByteArrayInputStream(output.toByteArray());
//            is = conn.getInputStream();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        InputStream is = HttpRequest.get("https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/application/2021-04-22-09-31-18HXEusrCL.docx")
                .stream();

        HttpRequest.post("http://192.168.50.238:8080/word2pdf")
                .accept("*/*")
                .part("file", "审核材料.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", is)
                .receive(new File("/Users/qiufangchao/Desktop/审核材料1.pdf"));
    }
}