|
@@ -2781,6 +2781,38 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
return new HttpRespMsg();
|
|
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) {
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());;
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());;
|