彻底将鉴权部分挪移到切面处
parent
ba6f19544e
commit
f607650c73
|
@ -4,10 +4,7 @@ import cn.edu.hfut.rmdjzz.projectmanagement.annotation.ProjectAuthorize;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Announcement;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDTO;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.AnnouncementDTO;
|
||||||
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.service.IAnnouncementService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IAnnouncementService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
|
||||||
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.ResponseList;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
@ -24,8 +21,6 @@ public class AnnouncementController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAnnouncementService announcementService;
|
private IAnnouncementService announcementService;
|
||||||
@Autowired
|
|
||||||
private IProjectGroupService projectGroupService;
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@ProjectAuthorize("a != 0")
|
@ProjectAuthorize("a != 0")
|
||||||
|
|
|
@ -5,10 +5,7 @@ import cn.edu.hfut.rmdjzz.projectmanagement.annotation.RateLimit;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectDTO;
|
||||||
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.service.IProjectGroupService;
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
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.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;
|
||||||
|
@ -35,8 +32,6 @@ public class ProjectController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IProjectService projectService;
|
private IProjectService projectService;
|
||||||
@Autowired
|
|
||||||
private IProjectGroupService projectGroupService;
|
|
||||||
|
|
||||||
@Operation(summary = "根据Token获取该员工的ProjectList")
|
@Operation(summary = "根据Token获取该员工的ProjectList")
|
||||||
@RateLimit(key = "ProjectPage", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200)
|
@RateLimit(key = "ProjectPage", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200)
|
||||||
|
@ -50,7 +45,7 @@ public class ProjectController {
|
||||||
@Parameter(description = "参数列表见Project实体类,时间可以用xxxxStart与xxxxEnd来确定区间"
|
@Parameter(description = "参数列表见Project实体类,时间可以用xxxxStart与xxxxEnd来确定区间"
|
||||||
, required = true) @RequestParam("paramMap") Map<String, Object> paramMap
|
, required = true) @RequestParam("paramMap") Map<String, Object> paramMap
|
||||||
) {
|
) {
|
||||||
if(globalAccessLevel == 1) staffId = null;
|
if (globalAccessLevel == 1) staffId = null;
|
||||||
Page<ProjectDTO> result = projectService.pageMyProjects(staffId, page, paramMap);
|
Page<ProjectDTO> result = projectService.pageMyProjects(staffId, page, paramMap);
|
||||||
return ResponseList.ofSuccess(result);
|
return ResponseList.ofSuccess(result);
|
||||||
}
|
}
|
||||||
|
@ -81,9 +76,9 @@ public class ProjectController {
|
||||||
@PostMapping("/complete/{projectId}")
|
@PostMapping("/complete/{projectId}")
|
||||||
public ResponseMap completeProject(
|
public ResponseMap completeProject(
|
||||||
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
@RequestAttribute Project targetProject,
|
@RequestAttribute Project targetProject/*,
|
||||||
@Parameter(description = "只需要传projectId即可,例:{\"projectId\": 1}")
|
@Parameter(description = "只需要传projectId即可,例:{\"projectId\": 1}")
|
||||||
@PathVariable Integer projectId
|
@PathVariable Integer projectId*/
|
||||||
) {
|
) {
|
||||||
if (targetProject.getCompleted())
|
if (targetProject.getCompleted())
|
||||||
throw new BadRequestException(PROJECT_COMPLETED);
|
throw new BadRequestException(PROJECT_COMPLETED);
|
||||||
|
|
|
@ -8,7 +8,6 @@ import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
||||||
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.ValidateUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.ValidateUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
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;
|
||||||
|
@ -85,6 +84,7 @@ public class ProjectGroupController {
|
||||||
|
|
||||||
@Operation(description = "body中只传staffUsername和projectStaffPosition")
|
@Operation(description = "body中只传staffUsername和projectStaffPosition")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
@ProjectAuthorize("a == 1")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResponseMap addGroupMember(
|
public ResponseMap addGroupMember(
|
||||||
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
|
@ -99,6 +99,7 @@ public class ProjectGroupController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
@ProjectAuthorize("a == 1")
|
||||||
@DeleteMapping("/{staffId}")
|
@DeleteMapping("/{staffId}")
|
||||||
public ResponseMap deleteGroupMember(
|
public ResponseMap deleteGroupMember(
|
||||||
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
|
@ -114,6 +115,7 @@ public class ProjectGroupController {
|
||||||
|
|
||||||
@Operation(description = "body中只传projectStaffPosition")
|
@Operation(description = "body中只传projectStaffPosition")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
@ProjectAuthorize("a > 0 && a <= 2")
|
||||||
@PutMapping("/{staffId}")
|
@PutMapping("/{staffId}")
|
||||||
public ResponseMap modifyDesignatedStaffPosition(
|
public ResponseMap modifyDesignatedStaffPosition(
|
||||||
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
|
@ -140,14 +142,15 @@ public class ProjectGroupController {
|
||||||
|
|
||||||
@Operation(description = "请求体是一个key为taskId,value为staffId的map")
|
@Operation(description = "请求体是一个key为taskId,value为staffId的map")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
@ProjectAuthorize("a > 0 && a <= 2")
|
||||||
@PutMapping("/{staffId}/transfer")
|
@PutMapping("/{staffId}/transfer")
|
||||||
public ResponseMap transferStaffTasks(
|
public ResponseMap transferStaffTasks(
|
||||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
@PathVariable Integer projectId,
|
@PathVariable Integer projectId,
|
||||||
@PathVariable Integer staffId,
|
@PathVariable Integer staffId,
|
||||||
@RequestBody Map<Long, Integer> transferMap
|
@RequestBody Map<Long, Integer> transferMap
|
||||||
) {
|
) {
|
||||||
if (taskService.transferStaffTasks(token, projectId, staffId, transferMap)) {
|
if (taskService.transferStaffTasks(projectId, staffId, transferMap)) {
|
||||||
return ResponseMap.ofSuccess();
|
return ResponseMap.ofSuccess();
|
||||||
}
|
}
|
||||||
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
|
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
|
||||||
|
@ -155,14 +158,15 @@ public class ProjectGroupController {
|
||||||
|
|
||||||
@Operation(description = "将staffId的所有工作项转移至targetStaffId")
|
@Operation(description = "将staffId的所有工作项转移至targetStaffId")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
@ProjectAuthorize("a > 0 && a <= 2")
|
||||||
@PutMapping("/{staffId}/transfer/{targetStaffId}")
|
@PutMapping("/{staffId}/transfer/{targetStaffId}")
|
||||||
public ResponseMap transferTasksToSingleStaff(
|
public ResponseMap transferTasksToSingleStaff(
|
||||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
@PathVariable Integer projectId,
|
@PathVariable Integer projectId,
|
||||||
@PathVariable Integer staffId,
|
@PathVariable Integer staffId,
|
||||||
@PathVariable Integer targetStaffId
|
@PathVariable Integer targetStaffId
|
||||||
) {
|
) {
|
||||||
if (taskService.transferTasksToSingleStaff(token, projectId, staffId, targetStaffId)) {
|
if (taskService.transferTasksToSingleStaff(projectId, staffId, targetStaffId)) {
|
||||||
return ResponseMap.ofSuccess();
|
return ResponseMap.ofSuccess();
|
||||||
}
|
}
|
||||||
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
|
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
|
||||||
|
|
|
@ -10,8 +10,6 @@ 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.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
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.ResponseList;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
|
|
@ -2,7 +2,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.entity.dto;
|
package cn.edu.hfut.rmdjzz.projectmanagement.entity.dto;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
|
@ -2,7 +2,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.entity.dto;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -18,15 +17,16 @@ public class TaskTrendDTO {
|
||||||
Long taskNum;
|
Long taskNum;
|
||||||
|
|
||||||
public void changeForUnclosed(TaskTrendDTO taskTrend) {
|
public void changeForUnclosed(TaskTrendDTO taskTrend) {
|
||||||
if(Objects.equals(Task.STATUS_UNCLOSED, taskStatus)) {
|
if (Objects.equals(Task.STATUS_UNCLOSED, taskStatus)) {
|
||||||
taskNum += taskTrend.getTaskNum();
|
taskNum += taskTrend.getTaskNum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeForClosed(TaskTrendDTO taskTrend) {
|
public void changeForClosed(TaskTrendDTO taskTrend) {
|
||||||
if(Objects.equals(Task.STATUS_UNCLOSED, taskStatus)) {
|
if (Objects.equals(Task.STATUS_UNCLOSED, taskStatus)) {
|
||||||
taskNum -= taskTrend.getTaskNum();
|
taskNum -= taskTrend.getTaskNum();
|
||||||
} else {
|
} else {
|
||||||
if(Objects.equals(taskTrend.getTaskStatus(), taskStatus)) {
|
if (Objects.equals(taskTrend.getTaskStatus(), taskStatus)) {
|
||||||
taskNum += taskTrend.getTaskNum();
|
taskNum += taskTrend.getTaskNum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.interceptor;
|
package cn.edu.hfut.rmdjzz.projectmanagement.interceptor;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -7,8 +8,6 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 张韬
|
* @author 张韬
|
||||||
|
@ -18,7 +17,7 @@ import java.util.Iterator;
|
||||||
public class CorsInterceptor implements HandlerInterceptor {
|
public class CorsInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, @NotNull Object handler) {
|
||||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
response.setHeader("Access-Control-Allow-Methods", "*");
|
response.setHeader("Access-Control-Allow-Methods", "*");
|
||||||
response.setHeader("Access-Control-Allow-Headers", "Content-Type,Token");
|
response.setHeader("Access-Control-Allow-Headers", "Content-Type,Token");
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Map;
|
||||||
* @author 张韬
|
* @author 张韬
|
||||||
* created at 2022/7/4 14:49
|
* created at 2022/7/4 14:49
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
public interface ITaskService extends IService<Task> {
|
public interface ITaskService extends IService<Task> {
|
||||||
List<TaskDTO> listSubtasks(Integer projectId, Long fatherId) throws BadRequestException, ForbiddenException;
|
List<TaskDTO> listSubtasks(Integer projectId, Long fatherId) throws BadRequestException, ForbiddenException;
|
||||||
|
|
||||||
|
@ -48,9 +49,9 @@ public interface ITaskService extends IService<Task> {
|
||||||
|
|
||||||
Map<String, List<TaskTrendDTO>> getProjectTaskTrend(Integer projectId) throws ForbiddenException;
|
Map<String, List<TaskTrendDTO>> getProjectTaskTrend(Integer projectId) throws ForbiddenException;
|
||||||
|
|
||||||
Boolean transferStaffTasks(String token, Integer projectId, Integer transferredStaffId, Map<Long, Integer> transferMap) throws ForbiddenException, BadRequestException;
|
Boolean transferStaffTasks(Integer projectId, Integer transferredStaffId, Map<Long, Integer> transferMap) throws ForbiddenException, BadRequestException;
|
||||||
|
|
||||||
Boolean transferTasksToSingleStaff(String token, Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException;
|
Boolean transferTasksToSingleStaff(Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException;
|
||||||
|
|
||||||
Map<String, Long> getProjectProcessOfEveryone(Integer projectId) throws ForbiddenException;
|
Map<String, Long> getProjectProcessOfEveryone(Integer projectId) throws ForbiddenException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,12 +114,12 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
}
|
}
|
||||||
int targetLevel = 3;
|
int targetLevel = 3;
|
||||||
|
|
||||||
if (accessLevel == 0) {
|
/*if (accessLevel == 0) {
|
||||||
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
||||||
}
|
}
|
||||||
if (accessLevel > 2 || accessLevel >= originProjectGroup.getProjectAccessLevel()) {
|
if (accessLevel > 2 || accessLevel >= originProjectGroup.getProjectAccessLevel()) {
|
||||||
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||||
}
|
}*/
|
||||||
String[] positionArray = positions.split(",");
|
String[] positionArray = positions.split(",");
|
||||||
for (String position : positionArray) {
|
for (String position : positionArray) {
|
||||||
position = position.strip();
|
position = position.strip();
|
||||||
|
|
|
@ -8,7 +8,6 @@ import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.RequestPage;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
@ -63,8 +62,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||||
@Override
|
@Override
|
||||||
public Boolean setProjectCompleted(
|
public Boolean setProjectCompleted(
|
||||||
Project targetProject
|
Project targetProject
|
||||||
) throws BadRequestException, ForbiddenException
|
) throws BadRequestException, ForbiddenException {
|
||||||
{
|
|
||||||
// Project targetProject = baseMapper.selectById(project.getProjectId());
|
// Project targetProject = baseMapper.selectById(project.getProjectId());
|
||||||
// if (targetProject == null)
|
// if (targetProject == null)
|
||||||
// throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
// throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper;
|
||||||
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 com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.baomidou.mybatisplus.extension.toolkit.SimpleQuery;
|
import com.baomidou.mybatisplus.extension.toolkit.SimpleQuery;
|
||||||
|
@ -106,7 +105,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
||||||
public Boolean closeTaskAndSubTask(Integer staffId, Integer globalAccessLevel, Integer projectId, Long taskId) throws BadRequestException {
|
public Boolean closeTaskAndSubTask(Integer staffId, Integer globalAccessLevel, Long taskId) throws BadRequestException {
|
||||||
Integer level = getHolderLevel(staffId, globalAccessLevel, taskId);
|
Integer level = getHolderLevel(staffId, globalAccessLevel, taskId);
|
||||||
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
|
||||||
// throw new BadRequestException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
// throw new BadRequestException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
||||||
|
@ -367,7 +366,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
task.setTaskClosedTime(LocalDateTime.now());
|
task.setTaskClosedTime(LocalDateTime.now());
|
||||||
}
|
}
|
||||||
if (typeChangeValue == 2) {
|
if (typeChangeValue == 2) {
|
||||||
closed = closeTaskAndSubTask(staffId, globalAccessLevel, task.getTaskProjectId(), task.getTaskId());
|
closed = closeTaskAndSubTask(staffId, globalAccessLevel, task.getTaskId());
|
||||||
}
|
}
|
||||||
if (Objects.equals(rawTask, task)) {
|
if (Objects.equals(rawTask, task)) {
|
||||||
return task;
|
return task;
|
||||||
|
@ -410,8 +409,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
List<TaskTrendDTO> taskList = new ArrayList<>();
|
List<TaskTrendDTO> taskList = new ArrayList<>();
|
||||||
ListIterator<TaskTrendDTO> closedIter = closedList.listIterator();
|
ListIterator<TaskTrendDTO> closedIter = closedList.listIterator();
|
||||||
ListIterator<TaskTrendDTO> unclosedIter = unclosedList.listIterator();
|
ListIterator<TaskTrendDTO> unclosedIter = unclosedList.listIterator();
|
||||||
TaskTrendDTO closedTaskTrend = null;
|
TaskTrendDTO closedTaskTrend;
|
||||||
TaskTrendDTO unclosedTaskTrend = null;
|
TaskTrendDTO unclosedTaskTrend;
|
||||||
|
|
||||||
// 关闭与未关闭的任务的中间累加对象
|
// 关闭与未关闭的任务的中间累加对象
|
||||||
closedTaskTrend = closedIter.next();
|
closedTaskTrend = closedIter.next();
|
||||||
|
@ -453,8 +452,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
private List<TaskTrendDTO> getResultTaskStatus(Integer projectId, LocalDate startDate) {
|
private List<TaskTrendDTO> getResultTaskStatus(Integer projectId, LocalDate startDate) {
|
||||||
List<TaskTrendDTO> resList = baseMapper.selectClosedTaskTrendBeforeDate(projectId, startDate);
|
List<TaskTrendDTO> resList = baseMapper.selectClosedTaskTrendBeforeDate(projectId, startDate);
|
||||||
List<TaskTrendDTO> taskList = new ArrayList<>();
|
List<TaskTrendDTO> taskList = new ArrayList<>();
|
||||||
Boolean existClosed = false;
|
boolean existClosed = false;
|
||||||
Boolean existCompleted = false;
|
boolean existCompleted = false;
|
||||||
for (TaskTrendDTO taskTrendDTO : resList) {
|
for (TaskTrendDTO taskTrendDTO : resList) {
|
||||||
if (Objects.equals(Task.STATUS_CLOSED, taskTrendDTO.getTaskStatus())) {
|
if (Objects.equals(Task.STATUS_CLOSED, taskTrendDTO.getTaskStatus())) {
|
||||||
existClosed = true;
|
existClosed = true;
|
||||||
|
@ -486,12 +485,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
// FIXME
|
// FIXME
|
||||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public Boolean transferStaffTasks(String token, Integer projectId, Integer transferredStaffId, Map<Long, Integer> transferMap) throws ForbiddenException, BadRequestException {
|
public Boolean transferStaffTasks(Integer projectId, Integer transferredStaffId, Map<Long, Integer> transferMap) throws ForbiddenException, BadRequestException {
|
||||||
if (
|
// if (
|
||||||
// projectGroupService.getProjectAccessLevel(token, projectId) == 0 ||
|
//// projectGroupService.getProjectAccessLevel(token, projectId) == 0 ||
|
||||||
projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(transferredStaffId, projectId) == 0) {
|
// projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(transferredStaffId, projectId) == 0) {
|
||||||
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
||||||
}
|
// }
|
||||||
// if (projectGroupService.compareProjectAccessLevel(projectId, token, transferredStaffId) > 0) {
|
// if (projectGroupService.compareProjectAccessLevel(projectId, token, transferredStaffId) > 0) {
|
||||||
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||||
// }
|
// }
|
||||||
|
@ -542,13 +541,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
// FIXME
|
// FIXME
|
||||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public Boolean transferTasksToSingleStaff(String token, Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException {
|
public Boolean transferTasksToSingleStaff(Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException {
|
||||||
if (
|
// if (
|
||||||
// projectGroupService.getProjectAccessLevel(token, projectId) == 0 ||
|
//// projectGroupService.getProjectAccessLevel(token, projectId) == 0 ||
|
||||||
projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(transferredStaffId, projectId) == 0
|
// projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(transferredStaffId, projectId) == 0
|
||||||
|| projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(targetStaffId, projectId) == 0) {
|
// || projectGroupService.getProjectAccessLevelIgnoreGlobalLevel(targetStaffId, projectId) == 0) {
|
||||||
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
||||||
}
|
// }
|
||||||
// if (projectGroupService.compareProjectAccessLevel(projectId, token, transferredStaffId) > 0) {
|
// if (projectGroupService.compareProjectAccessLevel(projectId, token, transferredStaffId) > 0) {
|
||||||
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Reference in New Issue