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));
|
}
|
|
|
|
|
|
|
|
|
}
|