4
hao
2025-04-16 c5fb1fbcbb2bf4d511773d348f9ef625855c61fc
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.web.ftp.controller;
 
import com.app.base.data.ApiResponseResult;
import com.web.ftp.service.FileCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
 
import javax.servlet.http.HttpServletResponse;
 
@Api(description = "附件管理")
@CrossOrigin
@ControllerAdvice
@RestController
@RequestMapping(value = "/kl_file")
public class SopFileController {
 
    @Autowired
    private FileCheckService fileCheckService;
 
    @ApiOperation(value="PDF在线预览", notes="PDF在线预览")
    @RequestMapping(value = "/viewPdf", method = RequestMethod.GET)
    @ResponseBody
    public ApiResponseResult viewPdf(@RequestParam(value = "url") String url,
                                     @RequestParam(value = "account") String account,
                                     @RequestParam(value = "password") String password,
                                     @RequestParam(value = "path") String path,
                                     @RequestParam(value = "fileName") String fileName,
                                     @RequestParam(value = "root") String root) {
        try {
            return fileCheckService.onlineViewPdf(url, 21,account,password,path,fileName,root,getResponse());
        } catch (Exception e) {
            System.out.println(e.toString());
            return ApiResponseResult.failure("PDF在线预览失败!");
        }
    }
 
    /**
     * 获取response
     * @return
     */
    protected HttpServletResponse getResponse() {
        return getServletRequestAttributes().getResponse();
    }
    /**
     * 获取servlet属性
     * @return
     */
    protected final ServletRequestAttributes getServletRequestAttributes() {
        return (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    }
 
}