测试静态资源路径
continuous-integration/drone/push Build is passing Details

于相涌/robot_optimize
YXY 1 year ago
parent e5ca378207
commit adf7c85a15

@ -2,29 +2,29 @@ package com.ruoyi.flyingbook.controller;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.utils.PdfUtils; import com.ruoyi.common.utils.PdfUtils;
import com.ruoyi.flyingbook.LarkHelper.LarkFileHelper;
import com.ruoyi.flyingbook.domain.edi.EdiResponseVo; import com.ruoyi.flyingbook.domain.edi.EdiResponseVo;
import com.ruoyi.flyingbook.domain.edi.SyncToTableRequest; import com.ruoyi.flyingbook.domain.edi.SyncToTableRequest;
import com.ruoyi.flyingbook.domain.template.CourseFeedbackTemplateDto;
import com.ruoyi.flyingbook.edi.EdiOperateService; import com.ruoyi.flyingbook.edi.EdiOperateService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
@Slf4j @Slf4j
@RestController @RestController
public class EdiController extends BaseController { public class EdiController extends BaseController {
@Autowired @Autowired
private EdiOperateService ediOperateService; private EdiOperateService ediOperateService;
@Resource @Autowired
private PdfUtils pdfUtils; private PdfUtils pdfUtils;
@Autowired
private LarkFileHelper larkFileHelper;
@Autowired
ResourceLoader resourceLoader;
/** /**
* *
@ -36,19 +36,36 @@ public class EdiController extends BaseController {
@RequestMapping("/createPdf") @RequestMapping("/createPdf")
public void exportPdfDemo(@RequestParam("param")String param) throws Exception{ public void exportPdfDemo(@RequestParam("param")String param) throws Exception{
CourseFeedbackTemplateDto resultDTO = new CourseFeedbackTemplateDto(); System.out.println(System.getProperty("user.dir"));
resultDTO.setProgram("program"); ClassPathResource classPathResource = new ClassPathResource("photo/title.png");
resultDTO.setStudentName("student"); System.out.println(classPathResource.getPath());
resultDTO.setTutor("tutor"); System.out.println(classPathResource.getURL());
resultDTO.setStartClassTime("2023-05-21 15:51:45"); Resource resource = resourceLoader.getResource("classpath:photo/title.png");
resultDTO.setEndClassTime("2023-05-22 15:51:45"); System.out.println(resource.getURL());
resultDTO.setFeedback("作业完成情况"); System.out.println(classPathResource.getURL());
resultDTO.setFeedbackScore("7 /10"); // CourseFeedbackTemplateDto resultDTO = new CourseFeedbackTemplateDto();
resultDTO.setPerformance("课堂表现"); // resultDTO.setProgram("program");
resultDTO.setPerformanceScore("9/10"); // resultDTO.setStudentName("student");
resultDTO.setContent("<p>1、课堂内容1</p><p>1、课堂内容2</p>"); // resultDTO.setTutor("tutor");
resultDTO.setWork("<p>1、课后作业1</p><p>1、课后作业2</p><p>1、课后作业3</p>"); // resultDTO.setStartClassTime("2023-05-21 15:51:45");
pdfUtils.createFile("COURSE_FEEDBACK.ftl",resultDTO); // resultDTO.setEndClassTime("2023-05-22 15:51:45");
// resultDTO.setFeedback("作业完成情况");
// resultDTO.setFeedbackScore("7 /10");
// resultDTO.setPerformance("课堂表现");
// resultDTO.setPerformanceScore("9/10");
// resultDTO.setContent("<p>1、课堂内容1</p><p>1、课堂内容2</p>");
// resultDTO.setWork("<p>1、课后作业1</p><p>1、课后作业2</p><p>1、课后作业3</p>");
// pdfUtils.createFile("COURSE_FEEDBACK.ftl",resultDTO);
// String path1 = System.getProperty("user.dir") + "/" + "test.pdf";
// File file1 = new File(path1);
// file1.delete();
// String path2 = System.getProperty("user.dir") + "/" + "test1.pdf";
// File file2 = new File(path2);
// Long length = file2.length();
// LarkFileRequest fileRequest = new LarkFileRequest("cli_a482a8572cbc9013","lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos",
// file2,file2.getName(),length.intValue(),"fldcnLt2RyUgDDD6rgC6K9gIWlM");
// larkFileHelper.uploadFile(fileRequest);
// file2.delete();
} }
} }

Loading…
Cancel
Save