jinlin
2024-08-02 826cd5b51d5106cfea07e397eda184fb15ec7a30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.zt.life.export.controller;
 
import com.zt.life.export.dto.WordFile;
import com.zt.life.export.service.DownloadService;
import com.zt.life.export.service.WordFileService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.io.*;
 
@RestController
@RequestMapping("/export")
public class ExportController {
 
    @Autowired
    WordFileService wordFileService;
 
    @Value("${zt.oss.local-path}")
    private String path;
 
    @GetMapping("module")
    @ApiOperation("模板导出")
    public void ExportWord(HttpServletResponse response, @RequestParam String resourcePath,@RequestParam String fileName) throws IOException {
//        File directory = new File(resourcePath);
//        String modulePath = directory.getCanonicalPath();
        path += "template/" + fileName;
        //String filepath = this.getClass().getResource(fileName).getPath();
        DownloadService.download(response, path, fileName);
    }
}