lxp
2025-03-12 11af23e0c7976eed1211ba2ca0beae3a12e19310
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.ruoyi.common.controller;
 
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.service.AttachmentTableService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
 
@RestController
@RequestMapping("/file/attachmentType")
@AllArgsConstructor
public class AttachmentTypeController {
 
    private AttachmentTableService attachmentTableService;
 
    /**
     * 上传文件
     * @param file 文件
     * @param type 枚举类型
     * @param id 业务id
     * @return
     */
    @PostMapping("/upload")
    public Result upload(@RequestParam("file")MultipartFile file,@RequestParam("type")Integer type,@RequestParam("id")Integer id) {
        attachmentTableService.upload(file,type,id);
        return Result.success();
    }
 
    /**
     * 下载文件
     * @param id 业务id
     * @param type 枚举类型
     * @param code 文件名称
     * @param suffix 文件后缀 可能是word 或者 pdf
     * @return
     */
    @GetMapping("/downLoad")
    public void downLoad(Integer id, Integer type , String code,String suffix, HttpServletResponse response)   {
        attachmentTableService.downLoad(id, type,code, suffix,response);
    }
 
    /**
     * 获取文件的MIME
     * @param id
     * @param type
     * @return
     */
    @GetMapping("/getMIME")
    public Result getMIME(Integer id, Integer type,String suffix) {
        return Result.success(attachmentTableService.getAttachmentList(id, type,suffix));
    }
 
 
    /**
     * 获取文件URL
     * @param id
     * @param type
     * @param suffix 文件后缀  可能是word 和 pdf
     */
    @GetMapping("/getURL")
    public Result getURL(Integer id, Integer type  , String suffix) {
        return Result.success(attachmentTableService.getURL(id, type , suffix));
    }
 
 
 
 
 
 
 
 
}