ProjectFileController.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package com.hssx.cloudmodel.controller;
  2. import com.hssx.cloudmodel.entity.ProjectFile;
  3. import com.hssx.cloudmodel.entity.vo.UserVO;
  4. import com.hssx.cloudmodel.service.ProjectFileService;
  5. import com.hssx.cloudmodel.util.HttpRespMsg;
  6. import io.swagger.annotations.ApiOperation;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.beans.factory.annotation.Value;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestParam;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import org.springframework.web.bind.annotation.RestController;
  13. import org.springframework.web.multipart.MultipartFile;
  14. import javax.servlet.http.HttpServletRequest;
  15. import javax.servlet.http.HttpServletResponse;
  16. import java.io.File;
  17. import java.io.IOException;
  18. import java.util.UUID;
  19. /**
  20. * <p>
  21. * 前端控制器
  22. * </p>
  23. *
  24. * @author 吴涛涛
  25. * @since 2019-07-30
  26. */
  27. @RestController
  28. @RequestMapping("/projectfile")
  29. public class ProjectFileController {
  30. @Value("${upload.path}")
  31. private String path;
  32. @Autowired
  33. private ProjectFileService projectFileService;
  34. /**
  35. * 项目文档的上传
  36. * 参数: token 用户身份凭证,projectId 项目id ,file 文件信息
  37. *
  38. * @return
  39. */
  40. @ApiOperation("项目文档的上传")
  41. @RequestMapping("/uploadFile")
  42. @ResponseBody
  43. public HttpRespMsg uploadFile(@RequestParam(required = false) MultipartFile file,
  44. HttpServletResponse response, HttpServletRequest request, UserVO userVO) throws Exception {
  45. System.out.println("开始上传文件" + "file+" + file.getOriginalFilename());
  46. HttpRespMsg msg = new HttpRespMsg();
  47. msg = projectFileService.addFile(userVO,file,path);
  48. return msg;
  49. }
  50. /**
  51. * 项目文档的下载
  52. * 参数: token 用户身份凭证,projectId 项目id
  53. *
  54. * @return
  55. */
  56. @ApiOperation("项目文档的下载")
  57. @RequestMapping("/dowloadFile")
  58. @ResponseBody
  59. public HttpRespMsg dowloadFile(ProjectFile projectFile,String token){
  60. HttpRespMsg msg = projectFileService.dowloadFile(projectFile,token);
  61. return msg;
  62. }
  63. /**
  64. * 项目文档的列表
  65. * 参数: token 用户身份凭证,projectId 项目id
  66. *
  67. * @return
  68. */
  69. @ApiOperation("项目文档的列表")
  70. @RequestMapping("/list")
  71. @ResponseBody
  72. public HttpRespMsg list(UserVO userVO){
  73. HttpRespMsg msg = projectFileService.getFileList(userVO);
  74. return msg;
  75. }
  76. /**
  77. * 项目文档的删除
  78. * 参数: id 文档id
  79. *
  80. * @return
  81. */
  82. @ApiOperation("项目文档的删除")
  83. @RequestMapping("/delFile")
  84. @ResponseBody
  85. public HttpRespMsg delFile(ProjectFile projectFile){
  86. HttpRespMsg msg = projectFileService.delFile(projectFile);
  87. return msg;
  88. }
  89. }