|
@@ -0,0 +1,83 @@
|
|
|
+package com.management.platform.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.management.platform.entity.Project;
|
|
|
+import com.management.platform.entity.ProjectStage;
|
|
|
+import com.management.platform.mapper.UserMapper;
|
|
|
+import com.management.platform.service.ProjectService;
|
|
|
+import com.management.platform.service.ProjectStageService;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author Seyason
|
|
|
+ * @since 2022-07-18
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/project-stage")
|
|
|
+public class ProjectStageController {
|
|
|
+ @Autowired
|
|
|
+ private ProjectStageService projectStageService;
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ private ProjectService projectService;
|
|
|
+
|
|
|
+ @RequestMapping("/list")
|
|
|
+ public HttpRespMsg list(HttpServletRequest request){
|
|
|
+ HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ List<ProjectStage> projectStageList = projectStageService.list(new QueryWrapper<ProjectStage>().eq("company_id", companyId));
|
|
|
+ httpRespMsg.data=projectStageList;
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ @RequestMapping("/addOrMod")
|
|
|
+ public HttpRespMsg addOrMod(ProjectStage projectStage, HttpServletRequest request){
|
|
|
+ HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ projectStage.setCompanyId(companyId);
|
|
|
+ if(projectStage.getId()!=null){
|
|
|
+ int cut = projectStageService.count(new QueryWrapper<ProjectStage>().eq("project_stage_name", projectStage.getProjectStageName()).eq("company_id",companyId).ne("id",projectStage.getId()));
|
|
|
+ if(cut>0){
|
|
|
+ httpRespMsg.setError("阶段名称已存在");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ projectStageService.updateById(projectStage);
|
|
|
+ }else {
|
|
|
+ int cut = projectStageService.count(new QueryWrapper<ProjectStage>().eq("project_stage_name", projectStage.getProjectStageName()).eq("company_id", companyId));
|
|
|
+ if(cut>0){
|
|
|
+ httpRespMsg.setError("阶段名称已存在");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ projectStageService.save(projectStage);
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ @RequestMapping("/delete")
|
|
|
+ public HttpRespMsg delete(Integer id){
|
|
|
+ HttpRespMsg httpRespMsg =new HttpRespMsg();
|
|
|
+ int cut = projectService.count(new QueryWrapper<Project>().eq("current_stage_id", id));
|
|
|
+ if(cut>0){
|
|
|
+ httpRespMsg.setError("该阶段已被使用");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ if(projectStageService.removeById(id)){
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ httpRespMsg.setError("参数异常");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|