yurk il y a 3 ans
Parent
commit
418abb67c8

+ 4 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -447,5 +447,9 @@ public class ProjectController {
     public HttpRespMsg batchAddMembToGroup(String membIdArray, String groupIds) {
         return projectService.batchAddMembToGroup(membIdArray, groupIds);
     }
+    @RequestMapping("/getProjectByCustomer")
+    public HttpRespMsg getProjectByCustomer(Integer customerId,HttpServletRequest request){
+        return projectService.getProjectByCustomer(customerId,request);
+    }
 }
 

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java

@@ -125,4 +125,6 @@ public interface ProjectService extends IService<Project> {
     HttpRespMsg getProjectsGroups(String projectIdArray);
 
     HttpRespMsg batchAddMembToGroup(String membIdArray, String groupIds);
+
+    HttpRespMsg getProjectByCustomer(Integer customerId, HttpServletRequest request);
 }

+ 32 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -2781,6 +2781,38 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         return new HttpRespMsg();
     }
 
+    @Override
+    public HttpRespMsg getProjectByCustomer(Integer customerId, HttpServletRequest request) {
+        HttpRespMsg msg=new HttpRespMsg();
+        //通过公司id获取该公司所有的项目列表
+        User user = userMapper.selectById(request.getHeader("Token"));
+        Integer companyId = user.getCompanyId();
+        List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部项目");
+        //判断用户的角色,如果是管理员和负责人,查看全部的。如果是普通员工,只能是看到参与的项目
+        QueryWrapper<Project> queryWrapper = null;
+        if (functionList.size() == 0) {
+            //普通员工
+            List<Participation> pList = participationMapper.selectList(new QueryWrapper<Participation>().eq("user_id", user.getId()));
+            List<Integer> projectIds = new ArrayList<>();
+            if (pList.size() > 0) {
+                projectIds = pList.stream().map(Participation::getProjectId).collect(Collectors.toList());
+            } else {
+                projectIds.add(-1);
+            }
+            final List<Integer> ids = projectIds;
+            queryWrapper = new QueryWrapper<Project>();
+            queryWrapper.and(wrapper->wrapper.in("id", ids).or().eq("creator_id", user.getId()).or().eq("is_public", 1).eq("company_id", companyId));
+        } else {
+            queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
+        }
+        if(!StringUtils.isEmpty(customerId)){
+            queryWrapper.eq("customer_id", customerId);
+        }
+        List<Project> projectList = projectMapper.selectList(queryWrapper);
+        msg.data=projectList;
+        return msg;
+    }
+
 
     private List<Department> getSubDepts(Department dp, List<Department> list) {
         List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());;