package com.ruoyi.personnel.controller;
|
|
import com.ruoyi.common.core.domain.Result;
|
import com.ruoyi.personnel.service.FileGeneralService;
|
import io.swagger.annotations.Api;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@RestController
|
@Api(tags = "文件通用接口")
|
@RequestMapping("/fileGeneral")
|
public class FileGeneralController {
|
|
@Autowired
|
private FileGeneralService fileGeneralService;
|
|
/**
|
* 文件上传
|
* @param file 文件内容
|
* @param suffix 文件后最
|
* @param id 绑定表的id
|
* @param type 枚举类型
|
* @return
|
*/
|
|
@PostMapping("/fileUpload")
|
public Result fileUpload(MultipartFile file, String suffix, Integer id,Integer type) {
|
fileGeneralService.fileUpload(file, suffix, id,type);
|
return Result.success();
|
}
|
|
/**
|
* 文件数据查看
|
* @param id 绑定id
|
* @param type 枚举类型
|
* @return
|
*/
|
|
@GetMapping("/selectFile")
|
public Result selectFile(Integer id,Integer type) {
|
return Result.success(fileGeneralService.selectFile(id,type));
|
}
|
|
/**
|
* 文件删除
|
* @param id 文件id
|
* @return
|
*/
|
@GetMapping("/delFile")
|
public Result delFile(Integer id) {
|
fileGeneralService.delFile(id);
|
return Result.success();
|
}
|
|
/**
|
* 文件下载
|
* @param id 文件id
|
* @return
|
*/
|
@PostMapping("/fileDownLoad")
|
public void fileDownLoad(Integer id,HttpServletResponse response) {
|
fileGeneralService.fileDownLoad(id,response);
|
}
|
|
|
|
|
|
|
}
|