Compare commits

..

No commits in common. "3b35115cb6eae948c465aca2a95b1c5e3e01b41c" and "2cf9f1af635c50017816cd5f70b8e14f759b20c2" have entirely different histories.

12 changed files with 238 additions and 271 deletions

View File

@ -2,14 +2,17 @@ package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.ProjectAuthorize;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDTO;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IAnnouncementService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -28,23 +31,37 @@ public class AnnouncementController {
private IProjectGroupService projectGroupService;
@SneakyThrows
@ProjectAuthorize("a != 0")
@GetMapping
public ResponseList<AnnouncementDTO> getAnnouncementList(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId
@PathVariable Integer projectId,
@PathVariable Integer staffId
) {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
ProjectGroup designatedStaff = projectGroupService.getOne(
Wrappers.<ProjectGroup>lambdaQuery()
.eq(ProjectGroup::getStaffId, staffId)
.eq(ProjectGroup::getProjectId, projectId));
if (designatedStaff == null) { //说明是超级管理员
designatedStaff = new ProjectGroup(staffId, projectId, IStaffService.LEVEL_1, 1);
}
return ResponseList.ofSuccess(announcementService.getAnnouncementList(projectId));
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@ProjectAuthorize("a==0")
@GetMapping("/{announcementId}")
public ResponseMap getAnnouncementById(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer accessLevel,
@PathVariable Integer projectId,
@PathVariable Long announcementId
) {
// if (accessLevel == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
return ResponseMap.ofSuccess(announcementService.getAnnouncementById(projectId, announcementId));
}
@ -88,16 +105,16 @@ public class AnnouncementController {
}*/
@SneakyThrows
@ProjectAuthorize("a>0 && a<=2")
@DeleteMapping("/{announcementId}")
public ResponseMap deleteAnnouncement(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel,
@PathVariable Integer projectId,
@PathVariable Long announcementId
@PathVariable Long announcementId,
@RequestBody Announcement announcement
) {
if (announcementService.deleteAnnouncement(projectId, staffId, globalAccessLevel, announcementId)) {
announcement.setProjectId(projectId);
announcement.setAnnouncementId(announcementId);
if (announcementService.removeById(announcement)) {
return ResponseMap.ofSuccess();
}
throw new BadRequestException(BadRequestException.OPERATE_FAILED);

View File

@ -1,11 +1,9 @@
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.ProjectAuthorize;
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.RateLimit;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
@ -21,9 +19,6 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Map;
import java.util.Objects;
import static cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService.PROJECT_COMPLETED;
/**
* @author
@ -44,72 +39,65 @@ public class ProjectController {
@GetMapping
public ResponseList<ProjectDTO> getProjectListOfStaff(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer globalAccessLevel,
@RequestAttribute Integer staffId,
@PathVariable Integer staffId,
@Valid RequestPage page,
@Parameter(description = "参数列表见Project实体类时间可以用xxxxStart与xxxxEnd来确定区间"
, required = true) @RequestParam("paramMap") Map<String, Object> paramMap
) {
if(globalAccessLevel == 1) staffId = null;
Page<ProjectDTO> result = projectService.pageMyProjects(staffId, page, paramMap);
return ResponseList.ofSuccess(result);
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@GetMapping("/{projectId}")
public ResponseMap getOneProjectBasicInfo(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer staffId,
@PathVariable("projectId") Integer projectId
) {
if (projectGroupService.getProjectAccessLevel(staffId, projectId) == 0) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
return ResponseMap.ofSuccess(projectService.getById(projectId));
}
@Operation(description = "根据Token获取该员工的Project数")
@SneakyThrows
@GetMapping("/count")
public ResponseMap getProjectNumOfStaff(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token
@RequestAttribute Integer staffId
) {
public ResponseMap getProjectNumOfStaff(@RequestHeader(TokenUtils.HEADER_TOKEN) String token) {
return ResponseMap.ofSuccess()
.put("totalNum", projectService.countMyProjects(staffId));
.put("totalNum", projectService.countMyProjects(token));
}
@SneakyThrows
@ProjectAuthorize("a == 1 || g == 1")
@PostMapping("/complete/{projectId}")
@PostMapping("/complete")
public ResponseMap completeProject(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Project targetProject,
@PathVariable Integer staffId,
@Parameter(description = "只需要传projectId即可{\"projectId\": 1}")
@PathVariable Integer projectId
@RequestBody Map<String, Object> map
) {
if (targetProject.getCompleted())
throw new BadRequestException(PROJECT_COMPLETED);
projectService.setProjectCompleted(targetProject);
Integer targetProjectId = (Integer) map.get("projectId");
projectService.setProjectCompleted(staffId, targetProjectId);
return ResponseMap.ofSuccess();
}
@SneakyThrows
@ProjectAuthorize("g != 0 && g <= 2")
@PostMapping
public ResponseMap createProject(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@RequestBody Project project
) {
@PathVariable Integer staffId,
@RequestBody Project project) {
projectService.createProject(staffId, project);
return ResponseMap.ofSuccess();
}
@SneakyThrows
@ProjectAuthorize("a == 1 || g == 1")
@PutMapping("/{projectId}")
public ResponseMap updateProject(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@PathVariable Integer projectId,
@PathVariable Integer staffId,
@RequestBody Project project
) {
project.setProjectId(projectId);
@ -120,17 +108,12 @@ public class ProjectController {
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@GetMapping("/{projectId}/stats")
public ResponseMap getProjectProcess(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel,
@PathVariable Integer projectId
@PathVariable Integer projectId,
@PathVariable Integer staffId
) {
if (Objects.equals(projectId, 0)) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
return ResponseMap.ofSuccess(projectService.getProjectProcess(staffId, globalAccessLevel, projectId));
return ResponseMap.ofSuccess(projectService.getProjectProcess(staffId, projectId));
}
}

View File

@ -1,16 +1,12 @@
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.ProjectAuthorize;
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.RateLimit;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.impl.TaskServiceImpl;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
@ -33,68 +29,54 @@ public class TaskController {
private IProjectService projectService;
@SneakyThrows
@ProjectAuthorize("a != 0")
@GetMapping("/{fatherId}/subtask")
public ResponseList<TaskDTO> getSubTaskList(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable("projectId") Integer projectId,
@PathVariable("fatherId") Long fatherId
) {
List<TaskDTO> result = taskService.listSubtasks(projectId, fatherId);
List<TaskDTO> result = taskService.listSubtasks(token, projectId, fatherId);
return ResponseList.ofSuccess(result);
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@RateLimit(key = "TaskMine", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
@GetMapping("/mine")
public ResponseList<TaskDTO> getMyTasks(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@PathVariable("projectId") Integer projectId
) {
List<TaskDTO> result = taskService.listMyTasks(staffId, projectId);
public ResponseList<TaskDTO> getMyTasks(@RequestHeader(TokenUtils.HEADER_TOKEN) String token, @PathVariable("projectId") Integer projectId) {
List<TaskDTO> result = taskService.listMyTasks(token, projectId);
return ResponseList.ofSuccess(result);
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@GetMapping("/subtask/exist")
public ResponseMap existSubTask(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable("projectId") Integer projectId,
@RequestParam("taskId") Long taskId
) {
return ResponseMap.ofSuccess()
.put("existSubTask", taskService.existSubTask(projectId, taskId));
.put("existSubTask", taskService.existSubTask(token, projectId, taskId));
}
@SneakyThrows
@PostMapping
public ResponseMap createTask(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel,
@RequestAttribute Integer accessLevel,
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable("projectId") Integer projectId,
@RequestBody Task task
) {
if (!projectService.checkOpenStatus(projectId))
throw new BadRequestException(IProjectService.PROJECT_UNOPENED);
task.setTaskProjectId(projectId);
taskService.insertTask(staffId, globalAccessLevel, accessLevel, task);
taskService.insertTask(token, task);
return ResponseMap.ofSuccess();
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@RateLimit(key = "TaskModify", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
@PutMapping("/{taskId}")
public ResponseMap modifyTask(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel,
@RequestAttribute Integer accessLevel,
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable("projectId") Integer projectId,
@PathVariable("taskId") Long taskId,
@RequestBody Task task
@ -104,7 +86,7 @@ public class TaskController {
task.setTaskProjectId(projectId);
task.setTaskId(taskId);
task.setDeleted(false);
taskService.modifyTask(staffId, globalAccessLevel, accessLevel, task);
taskService.modifyTask(token, task);
return ResponseMap.ofSuccess();
}
@ -112,59 +94,46 @@ public class TaskController {
@RateLimit(key = "TaskModify", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
@DeleteMapping("/{taskId}")
public ResponseMap deleteTaskAndSubTask(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel,
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable("projectId") Integer projectId,
@PathVariable("taskId") Long taskId
) {
if (!projectService.checkOpenStatus(projectId))
throw new BadRequestException(IProjectService.PROJECT_UNOPENED);
Integer level = taskService.getHolderLevel(staffId, globalAccessLevel, taskId);
if (level == 0 || level == 3) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
taskService.deleteTaskAndSubTask(staffId, globalAccessLevel, taskId);
taskService.deleteTaskAndSubTask(token, projectId, taskId);
return ResponseMap.ofSuccess();
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@RateLimit(key = "TaskTrend", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200)
@GetMapping("/stats/trend")
public ResponseMap getTaskTrend(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId
) {
if (!projectService.checkOpenStatus(projectId)) {
throw new BadRequestException(IProjectService.PROJECT_UNOPENED);
}
return ResponseMap.ofSuccess("查询成功", taskService.getProjectTaskTrend(projectId));
return ResponseMap.ofSuccess("查询成功", taskService.getProjectTaskTrend(token, projectId));
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@GetMapping("/stats/group")
public ResponseMap getTaskNumOfEveryone(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId
) {
return ResponseMap.ofSuccess("查询成功", taskService.getProjectProcessOfEveryone(projectId));
return ResponseMap.ofSuccess("查询成功", taskService.getProjectProcessOfEveryone(token, projectId));
}
@SneakyThrows
@ProjectAuthorize("a != 0")
@GetMapping({"/stats", "/stats/{targetStaffId}"})
@GetMapping({"/stats", "/stats/{staffId}"})
public ResponseList<StaffProcessDTO> getProjectStatistics(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId,
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId,
@PathVariable(required = false) Integer targetStaffId
@PathVariable(required = false) Integer staffId
) {
if (staffId != null && staffId.equals(targetStaffId)) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
return ResponseList.ofSuccess("查询成功", taskService.getProjectStatistics(projectId, targetStaffId));
return ResponseList.ofSuccess("查询成功", taskService.getProjectStatistics(token, projectId, staffId));
}
}

View File

@ -18,8 +18,8 @@ public interface IAnnouncementService extends IService<Announcement> {
AnnouncementDTO getAnnouncementById(Integer projectId, Long announcementId);
// Boolean updateAnnouncement(Integer projectId, Announcement announcement) throws ForbiddenException, BadRequestException;
Boolean updateAnnouncement(String token, Integer projectId, Announcement announcement) throws ForbiddenException, BadRequestException;
Boolean deleteAnnouncement(Integer projectId, Integer staffId, Integer globalAccessLevel, Long announcementId) throws ForbiddenException, BadRequestException;
Boolean deleteAnnouncement(String token, Integer projectId, Long announcementId) throws ForbiddenException, BadRequestException;
}

View File

@ -33,6 +33,7 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
/**
* @return 0AccessLevel11
*/
Integer getProjectAccessLevel(Integer staffId, Integer projectId);
Integer getProjectAccessLevel(Integer staffId, Integer staffGlobalLevel, Integer projectId);
@ -48,7 +49,7 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
* <p>
* {@link Integer#compare(int, int)}使compareProjectAccessLevel(...)>()0<token
*/
Integer compareProjectAccessLevel(Integer projectId, Integer staffId, Integer globalAccessLevel, Integer targetId);
Integer compareProjectAccessLevel(Integer projectId, String token, Integer targetId);
Page<ProjectGroupDTO> pageProjectMembers(RequestPage page, Integer projectId);

View File

@ -20,16 +20,28 @@ public interface IProjectService extends IService<Project> {
String PROJECT_UNOPENED = "该项目未开放";
String PROJECT_COMPLETED = "该项目已结项";
Long countMyProjects(Integer staffId);
Long countMyProjects(String token);
ProjectProcessDTO getProjectProcess(Integer staff, Integer globalAccessLevel, Integer projectId) throws ForbiddenException, BadRequestException;
ProjectProcessDTO getProjectProcess(Integer staffId, Integer projectId) throws ForbiddenException, BadRequestException;
Page<ProjectDTO> pageMyProjects(Integer staffId, RequestPage page, Map<String, Object> params);
Boolean setProjectCompleted(Project targetProject) throws BadRequestException, ForbiddenException;
Boolean setProjectCompleted(Integer staffId, Integer projectId) throws BadRequestException, ForbiddenException;
ProjectProcessDTO getProjectProcess(String token, Integer projectId) throws ForbiddenException, BadRequestException;
Page<ProjectDTO> pageMyProjects(
String token,
RequestPage page,
Map<String, Object> params
);
Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException, ForbiddenException;
Boolean createProject(Integer staffId, Project project) throws BadRequestException, ForbiddenException;
Boolean createProject(String token, Project project) throws BadRequestException, ForbiddenException;
Boolean checkOpenStatus(Integer projectId);
Boolean updateProject(Integer staffId, Project project) throws BadRequestException, ForbiddenException;

View File

@ -16,15 +16,15 @@ import java.util.Map;
* created at 2022/7/4 14:49
*/
public interface ITaskService extends IService<Task> {
List<TaskDTO> listSubtasks(Integer projectId, Long fatherId) throws BadRequestException, ForbiddenException;
List<TaskDTO> listSubtasks(String token, Integer projectId, Long fatherId) throws BadRequestException, ForbiddenException;
Boolean existSubTask(Integer projectId, Long taskId) throws BadRequestException, ForbiddenException;
Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException, ForbiddenException;
Boolean deleteTaskAndSubTask(Integer staffId, Integer globalAccessLevel, Long taskId) throws BadRequestException, ForbiddenException;
Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException, ForbiddenException;
// Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
List<StaffProcessDTO> getProjectStatistics(Integer projectId, Integer staffId) throws BadRequestException, ForbiddenException;
List<StaffProcessDTO> getProjectStatistics(String token, Integer projectId, Integer staffId) throws BadRequestException, ForbiddenException;
/**
* @return 1:all rights 2:father holder 3:current holder 0:no right
@ -36,21 +36,21 @@ public interface ITaskService extends IService<Task> {
*
* @return 1:all rights 2:father holder 3:current holder 0:no right
*/
// Integer getHolderLevel(String token, Long taskId);
Integer getHolderLevel(String token, Long taskId);
List<TaskDTO> listMyTasks(Integer staffId, Integer projectId) throws BadRequestException, ForbiddenException;
List<TaskDTO> listMyTasks(String token, Integer projectId) throws BadRequestException, ForbiddenException;
Boolean canBeDone(Long taskId);
Task insertTask(Integer staffId, Integer globalAccessLevel, Integer accessLevel, Task task) throws BadRequestException, ForbiddenException;
Task insertTask(String token, Task task) throws BadRequestException, ForbiddenException;
Task modifyTask(Integer staffId, Integer globalAccessLevel, Integer accessLevel, Task task) throws BadRequestException, ForbiddenException;
Task modifyTask(String token, Task task) throws BadRequestException, ForbiddenException;
Map<String, List<TaskTrendDTO>> getProjectTaskTrend(Integer projectId) throws ForbiddenException;
Map<String, List<TaskTrendDTO>> getProjectTaskTrend(String token, Integer projectId) throws ForbiddenException;
Boolean transferStaffTasks(String token, Integer projectId, Integer transferredStaffId, Map<Long, Integer> transferMap) throws ForbiddenException, BadRequestException;
Boolean transferTasksToSingleStaff(String token, Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException;
Map<String, Long> getProjectProcessOfEveryone(Integer projectId) throws ForbiddenException;
Map<String, Long> getProjectProcessOfEveryone(String token, Integer projectId) throws ForbiddenException;
}

View File

@ -35,39 +35,34 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
return baseMapper.selectAnnouncementById(projectId, announcementId);
}
// @Override
// public Boolean updateAnnouncement(Integer projectId, Announcement announcement) throws ForbiddenException, BadRequestException {
// Integer accessLevel = projectGroupService.getProjectAccessLevel(token, projectId);
// if (accessLevel == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
// if (accessLevel > 2) {
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
// Announcement rawAnnouncement = baseMapper.selectById(announcement.getAnnouncementId());
// if (projectGroupService.compareProjectAccessLevel(projectId, token, rawAnnouncement.getAnnouncementPublisherId()) <= 0) {
// if (!announcement.checkModification(rawAnnouncement)) {
// throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
// }
// return updateById(announcement);
// }
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
@Override
public Boolean updateAnnouncement(String token, Integer projectId, Announcement announcement) throws ForbiddenException, BadRequestException {
Integer accessLevel = projectGroupService.getProjectAccessLevel(token, projectId);
if (accessLevel == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (accessLevel > 2) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
Announcement rawAnnouncement = baseMapper.selectById(announcement.getAnnouncementId());
if (projectGroupService.compareProjectAccessLevel(projectId, token, rawAnnouncement.getAnnouncementPublisherId()) <= 0) {
if (!announcement.checkModification(rawAnnouncement)) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
return updateById(announcement);
}
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
@Override
public Boolean deleteAnnouncement(
Integer staffId,
Integer globalAccessLevel,
Integer projectId,
Long announcementId
) throws ForbiddenException, BadRequestException {
// Integer accessLevel = projectGroupService.getProjectAccessLevel(token, projectId);
// if (accessLevel == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
// if (accessLevel > 2) {
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
public Boolean deleteAnnouncement(String token, Integer projectId, Long announcementId) throws ForbiddenException, BadRequestException {
Integer accessLevel = projectGroupService.getProjectAccessLevel(token, projectId);
if (accessLevel == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (accessLevel > 2) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
Announcement rawAnnouncement = baseMapper.selectOne(Wrappers.<Announcement>lambdaQuery()
.select(Announcement::getProjectId, Announcement::getAnnouncementPublisherId)
.eq(Announcement::getAnnouncementId, announcementId)
@ -75,7 +70,7 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
if (!Objects.equals(projectId, rawAnnouncement.getProjectId())) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
if (projectGroupService.compareProjectAccessLevel(projectId, staffId, globalAccessLevel, rawAnnouncement.getAnnouncementPublisherId()) > 0) {
if (projectGroupService.compareProjectAccessLevel(projectId, token, rawAnnouncement.getAnnouncementPublisherId()) > 0) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
return removeById(announcementId);

View File

@ -145,6 +145,13 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
) == 1;
}
@Override
public Integer getProjectAccessLevel(String token, Integer projectId) {
Integer staffId = TokenUtils.getStaffId(token);
Integer staffGlobalLevel = TokenUtils.getStaffGlobalLevel(token);
return getProjectAccessLevel(staffId, staffGlobalLevel, projectId);
}
@Override
public Integer getProjectAccessLevel(Integer staffId, Integer staffGlobalLevel, Integer projectId) {
//对全局权限做特判
@ -177,8 +184,8 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
}
@Override
public Integer compareProjectAccessLevel(Integer projectId, Integer staffId, Integer globalAccessLevel, Integer targetId) {
return Integer.compare(getProjectAccessLevel(staffId, globalAccessLevel, projectId), getProjectAccessLevelIgnoreGlobalLevel(targetId, projectId));
public Integer compareProjectAccessLevel(Integer projectId, String token, Integer targetId) {
return Integer.compare(getProjectAccessLevel(token, projectId), getProjectAccessLevelIgnoreGlobalLevel(targetId, projectId));
}
@Override

View File

@ -33,44 +33,45 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
private IProjectGroupService projectGroupService;
@Override
public Long countMyProjects(Integer staffId) {
public Long countMyProjects(String token) {
Integer staffId = TokenUtils.getStaffId(token);
return baseMapper.selectMyProjectCount(staffId);
}
@Override
public ProjectProcessDTO getProjectProcess(Integer staffId, Integer globalAccessLevel, Integer projectId) throws ForbiddenException, BadRequestException {
// if (projectGroupService.getProjectAccessLevel(staffId, globalAccessLevel, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
// if (Objects.equals(projectId, 0)) {
// throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
// }
public ProjectProcessDTO getProjectProcess(String token, Integer projectId) throws ForbiddenException, BadRequestException {
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (Objects.equals(projectId, 0)) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
return baseMapper.selectProjectProcess(projectId);
}
@Override
public Page<ProjectDTO> pageMyProjects(
// String token,
Integer staffId,
String token,
RequestPage page,
Map<String, Object> params
) {
// Integer staffId = TokenUtils.getStaffGlobalLevel(token) == 1 ? null : TokenUtils.getStaffId(token);
Integer staffId = TokenUtils.getStaffGlobalLevel(token) == 1 ? null : TokenUtils.getStaffId(token);
IPage<ProjectDTO> userPage = baseMapper.selectMyProject(page.getPage(), staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params));
return (Page<ProjectDTO>) userPage;
}
@Override
public Boolean setProjectCompleted(
Project targetProject
) throws BadRequestException, ForbiddenException
{
// Project targetProject = baseMapper.selectById(project.getProjectId());
// if (targetProject == null)
// throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
/*if (!Objects.equals(staffId, targetProject.getProjectCreator())
&& !Objects.equals(globalAccessLevel, 1))
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);*/
public Boolean setProjectCompleted(String token, Integer projectId) throws BadRequestException, ForbiddenException {
Project project = new Project();
project.setProjectId(projectId);
Project targetProject = baseMapper.selectById(project.getProjectId());
if (targetProject == null)
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
if (!Objects.equals(TokenUtils.getStaffId(token), targetProject.getProjectCreator())
&& !Objects.equals(TokenUtils.getStaffGlobalLevel(token), 1))
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
if (targetProject.getCompleted())
throw new BadRequestException(PROJECT_COMPLETED);
targetProject.setCompleted(true);
targetProject.setProjectClosedDate(LocalDate.now());
if (baseMapper.updateById(targetProject) == 1)
@ -79,15 +80,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
}
@Override
public Boolean createProject(Integer staffId, Project project) throws BadRequestException, ForbiddenException {
// Integer staffGlobalLevel = TokenUtils.getStaffGlobalLevel(token);
// if (staffGlobalLevel == 0 || staffGlobalLevel > 2) {
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
public Boolean createProject(String token, Project project) throws BadRequestException, ForbiddenException {
Integer staffGlobalLevel = TokenUtils.getStaffGlobalLevel(token);
if (staffGlobalLevel == 0 || staffGlobalLevel > 2) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
project.setProjectId(null);
project.setCompleted(false);
project.setProjectCreatedTime(null);
project.setProjectCreator(staffId);
project.setProjectCreator(TokenUtils.getStaffId(token));
project.setProjectClosedDate(null);
if (project.getExpectedCompletion() == null) {
project.setExpectedCompletion((short) 100);
@ -99,7 +100,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
try {
if (baseMapper.insert(project) == 1) {
return projectGroupService.addCreator(project.getProjectId(), staffId);
return projectGroupService.addCreator(project.getProjectId(), TokenUtils.getStaffId(token));
}
} catch (Exception e) {
// log.error(e.getMessage(), e);
@ -115,11 +116,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
return project != null && !project.getCompleted();
}
public Boolean updateProject(Integer staffId, Project project) throws BadRequestException, ForbiddenException {
// Integer staffId = TokenUtils.getStaffId(token);
// if (!staffId.equals(project.getProjectCreator()) && TokenUtils.getStaffGlobalLevel(token) != 1) {
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
public Boolean updateProject(String token, Project project) throws BadRequestException, ForbiddenException {
Integer staffId = TokenUtils.getStaffId(token);
if (!staffId.equals(project.getProjectCreator()) && TokenUtils.getStaffGlobalLevel(token) != 1) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
Project rawProject = baseMapper.selectById(project.getProjectId());
if (Objects.equals(project, rawProject)) {
return true;

View File

@ -38,10 +38,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
private IProjectGroupService projectGroupService;
@Override
public List<TaskDTO> listSubtasks(Integer projectId, Long fatherId) throws ForbiddenException, BadRequestException {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
public List<TaskDTO> listSubtasks(String token, Integer projectId, Long fatherId) throws ForbiddenException, BadRequestException {
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (fatherId == null) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
@ -52,27 +52,23 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
}
@Override
public Boolean existSubTask(Integer projectId, Long taskId) throws ForbiddenException {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
public Boolean existSubTask(String token, Integer projectId, Long taskId) throws ForbiddenException {
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
return baseMapper.exists(Wrappers.<Task>lambdaQuery().eq(Task::getTaskFatherId, taskId));
}
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
@Override
public Boolean deleteTaskAndSubTask(
Integer staffId,
Integer globalAccessLevel,
Long taskId
) throws BadRequestException, ForbiddenException {
// Integer level = getHolderLevel(staffId, globalAccessLevel, taskId);
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
// if (level == 0 || level == 3) {
// throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
// }
public Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException, ForbiddenException {
Integer level = getHolderLevel(token, taskId);
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (level == 0 || level == 3) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
try {
List<Long> res = new ArrayList<>();
// 添加根任务点Id获得子节点数目
@ -106,11 +102,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
}
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
public Boolean closeTaskAndSubTask(Integer staffId, Integer globalAccessLevel, Integer projectId, Long taskId) throws BadRequestException {
Integer level = getHolderLevel(staffId, globalAccessLevel, taskId);
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new BadRequestException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
@Override
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
Integer level = getHolderLevel(token, taskId);
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new BadRequestException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (level == 0) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
@ -146,13 +143,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
}
@Override
public List<StaffProcessDTO> getProjectStatistics(Integer projectId, Integer staffId) throws ForbiddenException {
// if (staffId != null && !TokenUtils.getStaffId(token).equals(staffId)) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
public List<StaffProcessDTO> getProjectStatistics(String token, Integer projectId, Integer staffId) throws ForbiddenException {
if (staffId != null && !TokenUtils.getStaffId(token).equals(staffId)) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
List<StaffProcessDTO> resList = baseMapper.selectProjectProcess(projectId, staffId);
addResultProjectProcess(resList, Task.TYPE_ASSIGNMENT);
addResultProjectProcess(resList, Task.TYPE_DEFECT);
@ -207,12 +204,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
}
}
// @Override
// public Integer getHolderLevel(String token, Long taskId) {
// Integer staffId = TokenUtils.getStaffId(token);
// Integer staffGlobalLevel = TokenUtils.getStaffGlobalLevel(token);
// return getHolderLevel(staffId, staffGlobalLevel, taskId);
// }
@Override
public Integer getHolderLevel(String token, Long taskId) {
Integer staffId = TokenUtils.getStaffId(token);
Integer staffGlobalLevel = TokenUtils.getStaffGlobalLevel(token);
return getHolderLevel(staffId, staffGlobalLevel, taskId);
}
private int lowerBound(List<Task> data, long x) {
int l = 0, r = data.size() - 1;
@ -238,11 +235,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
@Override
public List<TaskDTO> listMyTasks(Integer staffId, Integer projectId) throws ForbiddenException {
// Integer staffId = TokenUtils.getStaffId(token);
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException("不可操作的项目");
// }
public List<TaskDTO> listMyTasks(String token, Integer projectId) throws ForbiddenException {
Integer staffId = TokenUtils.getStaffId(token);
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new ForbiddenException("不可操作的项目");
}
List<Task> resList = baseMapper.selectList(Wrappers.<Task>lambdaQuery()
.select(Task::getTaskId, Task::getTaskFatherId, Task::getTaskHolderId)
.eq(Task::getTaskProjectId, projectId)
@ -296,24 +293,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
}
@Override
public Task insertTask(
Integer staffId,
Integer globalAccessLevel,
Integer accessLevel,
Task task
) throws BadRequestException, ForbiddenException {
public Task insertTask(String token, Task task) throws BadRequestException, ForbiddenException {
task.setTaskId(null);
// Integer userLevel = projectGroupService.getProjectAccessLevel(token, task.getTaskProjectId());
// if (userLevel == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
Integer userLevel = projectGroupService.getProjectAccessLevel(token, task.getTaskProjectId());
if (userLevel == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (!task.checkInsert()) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}
try {
Task father = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, task.getTaskFatherId()));
if (!task.checkLegalFather(father)
|| (getHolderLevel(staffId, globalAccessLevel, task.getTaskFatherId()) == 0 && accessLevel == 3)) {
if (!task.checkLegalFather(father) || (getHolderLevel(token, task.getTaskFatherId()) == 0 && userLevel == 3)) {
throw new BadRequestException("无法指定该父级");
}
task.setTaskCreatedTime(null);
@ -336,15 +327,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
}
@Override
public Task modifyTask(
Integer staffId,
Integer globalAccessLevel,
Integer accessLevel,
Task task
) throws BadRequestException, ForbiddenException {
// Integer userLevel = projectGroupService.getProjectAccessLevel(token, task.getTaskProjectId());
public Task modifyTask(String token, Task task) throws BadRequestException, ForbiddenException {
Integer userLevel = projectGroupService.getProjectAccessLevel(token, task.getTaskProjectId());
Task rawTask = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, task.getTaskId()));
if (accessLevel == 0 || (accessLevel == 3 && getHolderLevel(staffId, globalAccessLevel, task.getTaskId()) == 0)) {
if (userLevel == 0 || (userLevel == 3 && getHolderLevel(token, task.getTaskId()) == 0)) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
int typeChangeValue = 0;
@ -367,7 +353,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
task.setTaskClosedTime(LocalDateTime.now());
}
if (typeChangeValue == 2) {
closed = closeTaskAndSubTask(staffId, globalAccessLevel, task.getTaskProjectId(), task.getTaskId());
closed = closeTaskAndSubTask(token, task.getTaskProjectId(), task.getTaskId());
}
if (Objects.equals(rawTask, task)) {
return task;
@ -384,10 +370,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
// 完成任务数目概况统计
@Override
public Map<String, List<TaskTrendDTO>> getProjectTaskTrend(Integer projectId) throws ForbiddenException {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
public Map<String, List<TaskTrendDTO>> getProjectTaskTrend(String token, Integer projectId) throws ForbiddenException {
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
// 起止日期
LocalDate endDate = LocalDate.now();
LocalDate startDate = endDate.plusDays(-14);
@ -483,18 +469,16 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
return taskTrendDTO;
}
// FIXME
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
@Override
public Boolean transferStaffTasks(String token, Integer projectId, Integer transferredStaffId, Map<Long, Integer> transferMap) throws ForbiddenException, BadRequestException {
if (
// projectGroupService.getProjectAccessLevel(token, projectId) == 0 ||
projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(transferredStaffId, projectId) == 0) {
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0
|| projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(transferredStaffId, projectId) == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
// if (projectGroupService.compareProjectAccessLevel(projectId, token, transferredStaffId) > 0) {
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
if (projectGroupService.compareProjectAccessLevel(projectId, token, transferredStaffId) > 0) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
Map<Long, Task> originTransferTaskMap = SimpleQuery.keyMap(
Wrappers.<Task>lambdaQuery()
@ -539,19 +523,17 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
}
// FIXME
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
@Override
public Boolean transferTasksToSingleStaff(String token, Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException {
if (
// projectGroupService.getProjectAccessLevel(token, projectId) == 0 ||
projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(transferredStaffId, projectId) == 0
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0
|| projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(transferredStaffId, projectId) == 0
|| projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(targetStaffId, projectId) == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
// if (projectGroupService.compareProjectAccessLevel(projectId, token, transferredStaffId) > 0) {
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
if (projectGroupService.compareProjectAccessLevel(projectId, token, transferredStaffId) > 0) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
Long transferredTaskCount = baseMapper.selectCount(Wrappers.<Task>lambdaQuery()
.eq(Task::getTaskHolderId, transferredStaffId)
.and(wrapper -> wrapper
@ -574,10 +556,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
}
@Override
public Map<String, Long> getProjectProcessOfEveryone(Integer projectId) throws ForbiddenException {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
public Map<String, Long> getProjectProcessOfEveryone(String token, Integer projectId) throws ForbiddenException {
if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
Map<String, Long> resMap = new HashMap<>();
List<TaskNumOfEveryoneDTO> resList = baseMapper.selectProjectProcessOfEveryone(projectId);
for (TaskNumOfEveryoneDTO taskNumOfEveryoneDTO : resList) {

View File

@ -87,9 +87,9 @@ public class MybatisPlusTests {
Map<String, Object> map = new HashMap<>();
map.put("completed", true);
// System.out.println(objectMapper.writeValueAsString(projectService
// .pageMyProjects("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkdXJhdGlvbiI6MTgwMDAsInN0YWZmVXNlcm5hbWUiOiJtaWtlIiwiZXhwIjoxNjU3MDkzNTU1LCJpYXQiOjE2NTcwNzU1NTUsInN0YWZmSWQiOjF9.g8l01dnHglt223469Z03i9gqZL8P13Fo7KoaA1pf310",
// page, map)));
System.out.println(objectMapper.writeValueAsString(projectService
.pageMyProjects("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkdXJhdGlvbiI6MTgwMDAsInN0YWZmVXNlcm5hbWUiOiJtaWtlIiwiZXhwIjoxNjU3MDkzNTU1LCJpYXQiOjE2NTcwNzU1NTUsInN0YWZmSWQiOjF9.g8l01dnHglt223469Z03i9gqZL8P13Fo7KoaA1pf310",
page, map)));
}
@SneakyThrows