分页查询项目成员id,用户名,全名,职位,权限等级
parent
ad9544111c
commit
0db64e3fad
|
@ -1,20 +1,24 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDto;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.vo.GroupPositionVo;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.vo.GroupPositionVo;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,8 +37,15 @@ public class ProjectGroupController {
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseList<Integer> getGroupNumber(@PathVariable Integer projectId, @RequestHeader("Token") String token) {
|
public ResponseList<ProjectGroupDto> getGroupNumber(
|
||||||
List<Integer> res = projectGroupService.findAllProjectNumber(token, projectId);
|
@PathVariable Integer projectId,
|
||||||
|
@RequestHeader("Token") String token,
|
||||||
|
@Valid RequestPage page
|
||||||
|
) {
|
||||||
|
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
|
throw new ForbiddenException("无该项目访问权限");
|
||||||
|
}
|
||||||
|
Page<ProjectGroupDto> res = projectGroupService.getOnePageProjectNumber(page, projectId);
|
||||||
return ResponseList.ofSuccess("查询成功", res);
|
return ResponseList.ofSuccess("查询成功", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class ProjectGroupDto {
|
public class ProjectGroupDto {
|
||||||
Integer staffId;
|
Integer staffId;
|
||||||
|
String staffUsername;
|
||||||
String staffFullname;
|
String staffFullname;
|
||||||
Integer projectId;
|
|
||||||
String projectStaffPosition;
|
String projectStaffPosition;
|
||||||
Integer projectAccessLevel;
|
Integer projectAccessLevel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,25 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDto;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 张韬
|
* @author 张韬
|
||||||
* created at 2022/6/30 21:34
|
* created at 2022/6/30 21:34
|
||||||
*/
|
*/
|
||||||
public interface ProjectGroupMapper extends BaseMapper<ProjectGroup> {
|
public interface ProjectGroupMapper extends BaseMapper<ProjectGroup> {
|
||||||
|
@Select("""
|
||||||
|
SELECT staff.staff_id, staff_username, staff_fullname, project_staff_position, project_access_level
|
||||||
|
FROM project_group inner join staff
|
||||||
|
ON project_group.staff_id = staff.staff_id AND project_group.project_id = #{projectId}
|
||||||
|
""")
|
||||||
|
Page<ProjectGroupDto> findNumber(IPage<ProjectDto> pg, @Param("projectId") Integer projectId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDto;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -28,7 +31,7 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
|
||||||
|
|
||||||
Integer compareProjectAccessLevel(Integer projectId, Integer staffId1, Integer staffId2);
|
Integer compareProjectAccessLevel(Integer projectId, Integer staffId1, Integer staffId2);
|
||||||
|
|
||||||
List<Integer> findAllProjectNumber(String token, Integer projectId) throws BadRequestException;
|
Page<ProjectGroupDto> getOnePageProjectNumber(RequestPage page, Integer projectId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计小组中各岗位数量
|
* 统计小组中各岗位数量
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDto;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDto;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectGroupMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectGroupMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -117,19 +122,9 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> findAllProjectNumber(String token, Integer projectId) throws BadRequestException {
|
public Page<ProjectGroupDto> getOnePageProjectNumber(RequestPage page, Integer projectId){
|
||||||
List<Integer> res = new ArrayList<>();
|
IPage<ProjectGroupDto> numberPage = baseMapper.findNumber(page.getPage(), projectId);
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
return (Page<ProjectGroupDto>) numberPage;
|
||||||
List<ProjectGroup> targetProject = baseMapper.selectList(Wrappers.<ProjectGroup>lambdaQuery().eq(ProjectGroup::getProjectId, projectId));
|
|
||||||
|
|
||||||
if (targetProject.size() == 0)
|
|
||||||
throw new BadRequestException("项目不存在");
|
|
||||||
for (ProjectGroup projectGroup : targetProject) {
|
|
||||||
res.add(projectGroup.getStaffId());
|
|
||||||
}
|
|
||||||
if (!res.contains(staffId))
|
|
||||||
throw new BadRequestException("用户请求非法");
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue