package cd.casic.server;

import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
import cd.casic.ci.process.process.service.report.ReportService;
import cn.hutool.core.codec.Base64;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;

@SpringBootTest(classes = {OpsServerApplication.class})
@ActiveProfiles("local")
public class FileDownLoadTest {
//    "D:\博彦科技-项目相关\ops-pro\ops-server\src\main\resources"
    @Resource
    private ReportService reportService;
    @Test
    public void test01() throws Exception {
        BaseIdReq baseIdReq = new BaseIdReq();
        ArrayList<Integer> ids = new ArrayList<>(3);
        ids.add(28);
        baseIdReq.setReportIds(ids);
        ResponseEntity<String> response = reportService.downLoadReport(baseIdReq);
        byte[] bytes = Base64.decode(response.getBody());
        File file = new File("D:/博彦科技-项目相关/ops-pro/ops-server/src/main/resources/test.xlsx");
        FileOutputStream fos = new FileOutputStream(file);
        fos.write(bytes);
    }
}
