123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package com.hssx.cloudmodel.controller;
- import com.hssx.cloudmodel.entity.ProjectFile;
- import com.hssx.cloudmodel.entity.vo.UserVO;
- import com.hssx.cloudmodel.service.ProjectFileService;
- import com.hssx.cloudmodel.util.HttpRespMsg;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.bind.annotation.RestController;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.File;
- import java.io.IOException;
- import java.util.UUID;
- /**
- * <p>
- * 前端控制器
- * </p>
- *
- * @author 吴涛涛
- * @since 2019-07-30
- */
- @RestController
- @RequestMapping("/projectfile")
- public class ProjectFileController {
- @Value("${upload.path}")
- private String path;
- @Autowired
- private ProjectFileService projectFileService;
- /**
- * 项目文档的上传
- * 参数: token 用户身份凭证,projectId 项目id ,file 文件信息
- *
- * @return
- */
- @ApiOperation("项目文档的上传")
- @RequestMapping("/uploadFile")
- @ResponseBody
- public HttpRespMsg uploadFile(@RequestParam(required = false) MultipartFile file,
- HttpServletResponse response, HttpServletRequest request, UserVO userVO) throws Exception {
- System.out.println("开始上传文件" + "file+" + file.getOriginalFilename());
- HttpRespMsg msg = new HttpRespMsg();
- msg = projectFileService.addFile(userVO,file,path);
- return msg;
- }
- /**
- * 项目文档的下载
- * 参数: token 用户身份凭证,projectId 项目id
- *
- * @return
- */
- @ApiOperation("项目文档的下载")
- @RequestMapping("/dowloadFile")
- @ResponseBody
- public HttpRespMsg dowloadFile(ProjectFile projectFile,String token){
- HttpRespMsg msg = projectFileService.dowloadFile(projectFile,token);
- return msg;
- }
- /**
- * 项目文档的列表
- * 参数: token 用户身份凭证,projectId 项目id
- *
- * @return
- */
- @ApiOperation("项目文档的列表")
- @RequestMapping("/list")
- @ResponseBody
- public HttpRespMsg list(UserVO userVO){
- HttpRespMsg msg = projectFileService.getFileList(userVO);
- return msg;
- }
- /**
- * 项目文档的删除
- * 参数: id 文档id
- *
- * @return
- */
- @ApiOperation("项目文档的删除")
- @RequestMapping("/delFile")
- @ResponseBody
- public HttpRespMsg delFile(ProjectFile projectFile){
- HttpRespMsg msg = projectFileService.delFile(projectFile);
- return msg;
- }
- }
|