kongdeqiang
2024-04-22 7bc78d8f70a4d11e46f8bd640228804a3dd0dc68
src/main/java/com/boying/controller/FileInfo2Controller.java
@@ -3,6 +3,8 @@
import com.boying.entity.FileInfo;
import com.boying.service.FileInfoService;
import io.lettuce.core.dynamic.annotation.Param;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -14,6 +16,7 @@
@RestController
@RequestMapping("ffzf/fileInfo")
@RequiredArgsConstructor
@Tag(description = "ffzf/fileInfo" , name = "文件上传接口" )
public class FileInfo2Controller {
    private final FileInfoService fileInfoService;
@@ -23,12 +26,14 @@
     * @Param downloadPath 文件路径
     */
    @GetMapping("/download/downloadZip")
    @Operation(summary = "下载zip" , description = "下载zip" )
    public void downloadZip(@Param("downloadPath") String downloadPath, HttpServletRequest request, HttpServletResponse response) {
        //下载图片
        String down = fileInfoService.downloadPathFile(downloadPath, request, response);
    }
    @PostMapping("/download/downloadZips")
    @Operation(summary = "下载多个zip" , description = "下载多个zip" )
    public void downloadZips(String fileIds, HttpServletRequest request, HttpServletResponse response) {
        List<FileInfo> fileInfoList = new ArrayList<>();
        if(fileIds.contains(",")){
@@ -46,17 +51,20 @@
        fileInfoService.downForZip(fileInfoList, request, response);
    }
    @PostMapping("/download/downloadPng")
    @Operation(summary = "下载图片" , description = "下载图片" )
    public void downloadPng(String fileId, HttpServletRequest request, HttpServletResponse response) {
        FileInfo byId = fileInfoService.getById(Integer.parseInt(fileId));
        fileInfoService.downloadPng(byId,request,response);
    }
    @GetMapping("/showImg")
    @Operation(summary = "根据路径预览图片" , description = "根据路径预览图片" )
    public void showImg( String path,HttpServletResponse response) {
        fileInfoService.getFile(path,response);
    }
    @GetMapping("/showImgById/{fileId}")
    @Operation(summary = "根据文件id预览图片" , description = "根据文件id预览图片" )
    public void showImgById(@PathVariable Long fileId,HttpServletResponse response) {
        fileInfoService.getFileById(fileId,response);
    }