ProjectTaskController.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. package com.ruoyi.web.controller.project;
  2. import com.ruoyi.common.config.RuoYiConfig;
  3. import com.ruoyi.common.core.controller.BaseController;
  4. import com.ruoyi.common.core.domain.AjaxResult;
  5. import com.ruoyi.common.core.domain.model.LoginUser;
  6. import com.ruoyi.common.core.page.TableDataInfo;
  7. import com.ruoyi.common.utils.file.FileUploadUtils;
  8. import com.ruoyi.common.utils.file.MimeTypeUtils;
  9. import com.ruoyi.project.bo.ProjectListInput;
  10. import com.ruoyi.project.bo.ProjectStaffRecordInput;
  11. import com.ruoyi.project.bo.ProjectStaffRecordOut;
  12. import com.ruoyi.project.bo.ProjectTaskListOut;
  13. import com.ruoyi.project.domain.ProjectStaff;
  14. import com.ruoyi.project.domain.ProjectStaffRecord;
  15. import com.ruoyi.project.domain.ProjectTask;
  16. import com.ruoyi.project.service.ProjectStaffRecordService;
  17. import com.ruoyi.project.service.ProjectStaffService;
  18. import com.ruoyi.project.service.ProjectTaskService;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.validation.annotation.Validated;
  21. import org.springframework.web.bind.annotation.*;
  22. import org.springframework.web.multipart.MultipartFile;
  23. import java.awt.print.Pageable;
  24. import java.util.List;
  25. /**
  26. * 项目管理
  27. */
  28. @RestController
  29. @RequestMapping("/api/project")
  30. public class ProjectTaskController extends BaseController {
  31. @Autowired
  32. private ProjectTaskService projectTaskService;
  33. @Autowired
  34. private ProjectStaffService projectStaffService;
  35. @Autowired
  36. private ProjectStaffRecordService projectStaffRecordService;
  37. /**
  38. * 新增项目任务
  39. * @param projectTask
  40. * @return
  41. */
  42. @PostMapping("/add")
  43. public AjaxResult add( @RequestBody ProjectTask projectTask){
  44. if (projectTask.getAid()== null){
  45. return error("负责人不能为空");
  46. }
  47. return projectTaskService.addProjectTask(projectTask);
  48. }
  49. /**
  50. * 新增项目成员
  51. * @param in
  52. * @return
  53. */
  54. @PostMapping("/addStaff")
  55. public AjaxResult addStaff( @RequestBody ProjectStaff in){
  56. if (in.getAid()== null){
  57. return error("项目成员不能为空");
  58. }
  59. return projectStaffService.addStaff(in);
  60. }
  61. /**
  62. * 新增成员打卡
  63. * @param in
  64. * @return
  65. */
  66. @PostMapping("/addRecord")
  67. public AjaxResult addRecord( @RequestBody ProjectStaffRecord in){
  68. return projectStaffRecordService.add(in);
  69. }
  70. /**
  71. * 修改成员打卡
  72. * @param in
  73. * @return
  74. */
  75. @PostMapping("/updateRecord")
  76. public AjaxResult updateRecord( @RequestBody ProjectStaffRecord in){
  77. return projectStaffRecordService.update(in);
  78. }
  79. /**
  80. * 审核成员打卡
  81. * @param in
  82. * @return
  83. */
  84. @PostMapping("/examineRecord")
  85. public AjaxResult examineRecord( @RequestBody ProjectStaffRecord in){
  86. if (in.getProcessStatus()!=2 && in.getProcessStatus()!=3){
  87. return AjaxResult.error("审核状态错误");
  88. }
  89. return projectStaffRecordService.examineRecord(in);
  90. }
  91. /**
  92. * 审核成员打卡
  93. * @param in
  94. * @return
  95. */
  96. @PostMapping("/listRecord")
  97. public TableDataInfo listRecord( @RequestBody ProjectStaffRecordInput in){
  98. startPage();
  99. List<ProjectStaffRecordOut> list = projectStaffRecordService.listRecord(in);
  100. return getDataTable(list);
  101. }
  102. /**
  103. * 删除项目成员
  104. * @param in
  105. * @return
  106. */
  107. @PostMapping("/deleteStaff")
  108. public AjaxResult deleteStaff( @RequestBody ProjectStaff in){
  109. if (in.getId()== null){
  110. return error("项目成员编号不能为空");
  111. }
  112. return projectStaffService.deleteStaff(in);
  113. }
  114. /**
  115. * 删除项目
  116. * @param in
  117. * @return
  118. */
  119. @PostMapping("/deleteProject")
  120. public AjaxResult deleteProject( @RequestBody ProjectTask in){
  121. if (in.getId()== null){
  122. return error("项目编号不能为空");
  123. }
  124. return projectTaskService.deleteProject(in);
  125. }
  126. /**
  127. * 项目详情
  128. * @param id
  129. * @return
  130. */
  131. @GetMapping ("/details")
  132. public AjaxResult details( Long id){
  133. if (id== null){
  134. return error("项目编号不能为空");
  135. }
  136. return projectTaskService.details(id);
  137. }
  138. /**
  139. * 项目列表
  140. * @param
  141. * @return
  142. */
  143. @GetMapping ("/list")
  144. public TableDataInfo list(ProjectListInput in){
  145. startPage();
  146. List<ProjectTaskListOut> list=projectTaskService.list(in);
  147. return getDataTable(list);
  148. }
  149. /**
  150. * 上传项目文件
  151. * @param file
  152. * @return
  153. * @throws Exception
  154. */
  155. @PostMapping("/upload")
  156. public AjaxResult upload(@RequestParam("file") MultipartFile file) throws Exception{
  157. if (!file.isEmpty()){
  158. String avatar = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
  159. AjaxResult ajax = AjaxResult.success();
  160. ajax.put("imgUrl", avatar);
  161. return ajax;
  162. }
  163. return error("上传图片异常,请联系管理员");
  164. }
  165. }