确认并删除了无用的代码

master
ArgonarioD 2023-01-13 23:03:59 +08:00
parent c0018c5788
commit 1cfed731e7
13 changed files with 44 additions and 277 deletions

View File

@ -24,7 +24,6 @@ public class AnnouncementController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping @GetMapping
public ResponseList<AnnouncementDTO> getAnnouncementList( public ResponseList<AnnouncementDTO> getAnnouncementList(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId @PathVariable Integer projectId
) { ) {
return ResponseList.ofSuccess(announcementService.getAnnouncementList(projectId)); return ResponseList.ofSuccess(announcementService.getAnnouncementList(projectId));
@ -33,7 +32,6 @@ public class AnnouncementController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping("/{announcementId}") @GetMapping("/{announcementId}")
public ResponseMap getAnnouncementById( public ResponseMap getAnnouncementById(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@PathVariable Long announcementId @PathVariable Long announcementId
) { ) {
@ -43,17 +41,11 @@ public class AnnouncementController {
@ProjectAuthorize("a>0 && a<=2") @ProjectAuthorize("a>0 && a<=2")
@PostMapping @PostMapping
public ResponseMap createAnnouncement( public ResponseMap createAnnouncement(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@RequestBody Announcement announcement @RequestBody Announcement announcement
) { ) {
/*Integer accessLevel = projectGroupService.getProjectAccessLevel(token, projectId);
if (accessLevel == 0 || accessLevel > 2) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}*/
announcement.setProjectId(projectId); announcement.setProjectId(projectId);
// announcement.setAnnouncementPublisherId(TokenUtils.getStaffId(token));
announcement.setAnnouncementPublisherId(staffId); announcement.setAnnouncementPublisherId(staffId);
announcement.setAnnouncementPublishTime(null); announcement.setAnnouncementPublishTime(null);
if (announcementService.save(announcement)) { if (announcementService.save(announcement)) {
@ -65,7 +57,6 @@ public class AnnouncementController {
@ProjectAuthorize("a>0 && a<=2") @ProjectAuthorize("a>0 && a<=2")
@DeleteMapping("/{announcementId}") @DeleteMapping("/{announcementId}")
public ResponseMap deleteAnnouncement( public ResponseMap deleteAnnouncement(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel, @RequestAttribute Integer globalAccessLevel,
@PathVariable Integer projectId, @PathVariable Integer projectId,

View File

@ -36,12 +36,11 @@ public class ProjectController {
@RateLimit(key = "ProjectPage", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200) @RateLimit(key = "ProjectPage", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200)
@GetMapping @GetMapping
public ResponseList<ProjectDTO> getProjectListOfStaff( public ResponseList<ProjectDTO> getProjectListOfStaff(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer globalAccessLevel, @RequestAttribute Integer globalAccessLevel,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@Valid RequestPage page, @Valid RequestPage page,
@Parameter(description = "参数列表见Project实体类时间可以用xxxxStart与xxxxEnd来确定区间" @Parameter(description = "参数列表见Project实体类时间可以用xxxxStart与xxxxEnd来确定区间", required = true)
, required = true) @RequestParam("paramMap") Map<String, Object> paramMap @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);
@ -51,7 +50,6 @@ public class ProjectController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping("/{projectId}") @GetMapping("/{projectId}")
public ResponseMap getOneProjectBasicInfo( public ResponseMap getOneProjectBasicInfo(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable("projectId") Integer projectId @PathVariable("projectId") Integer projectId
) { ) {
return ResponseMap.ofSuccess(projectService.getById(projectId)); return ResponseMap.ofSuccess(projectService.getById(projectId));
@ -60,7 +58,6 @@ public class ProjectController {
@Operation(description = "根据Token获取该员工的Project数") @Operation(description = "根据Token获取该员工的Project数")
@GetMapping("/count") @GetMapping("/count")
public ResponseMap getProjectNumOfStaff( public ResponseMap getProjectNumOfStaff(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token
@RequestAttribute Integer staffId @RequestAttribute Integer staffId
) { ) {
return ResponseMap.ofSuccess() return ResponseMap.ofSuccess()
@ -69,12 +66,7 @@ public class ProjectController {
@ProjectAuthorize("a == 1 || g == 1") @ProjectAuthorize("a == 1 || g == 1")
@PostMapping("/complete/{projectId}") @PostMapping("/complete/{projectId}")
public ResponseMap completeProject( public ResponseMap completeProject(@RequestAttribute Project targetProject) {
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Project targetProject/*,
@Parameter(description = "只需要传projectId即可{\"projectId\": 1}")
@PathVariable Integer projectId*/
) {
if (targetProject.getCompleted()) if (targetProject.getCompleted())
throw new BadRequestException(PROJECT_COMPLETED); throw new BadRequestException(PROJECT_COMPLETED);
projectService.setProjectCompleted(targetProject); projectService.setProjectCompleted(targetProject);
@ -84,7 +76,6 @@ public class ProjectController {
@ProjectAuthorize("g != 0 && g <= 2") @ProjectAuthorize("g != 0 && g <= 2")
@PostMapping @PostMapping
public ResponseMap createProject( public ResponseMap createProject(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@RequestBody Project project @RequestBody Project project
) { ) {
@ -95,7 +86,6 @@ public class ProjectController {
@ProjectAuthorize("a == 1 || g == 1") @ProjectAuthorize("a == 1 || g == 1")
@PutMapping("/{projectId}") @PutMapping("/{projectId}")
public ResponseMap updateProject( public ResponseMap updateProject(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@RequestBody Project project @RequestBody Project project
@ -110,7 +100,6 @@ public class ProjectController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping("/{projectId}/stats") @GetMapping("/{projectId}/stats")
public ResponseMap getProjectProcess( public ResponseMap getProjectProcess(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel, @RequestAttribute Integer globalAccessLevel,
@PathVariable Integer projectId @PathVariable Integer projectId

View File

@ -39,16 +39,8 @@ public class ProjectGroupController {
@GetMapping @GetMapping
public ResponseList<ProjectGroupDTO> getGroupMembers( public ResponseList<ProjectGroupDTO> getGroupMembers(
@PathVariable Integer projectId, @PathVariable Integer projectId,
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
RequestPage page RequestPage page
) { ) {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
// if (validateUtils.validate(page).isEmpty()) {
// return ResponseList.ofSuccess(projectGroupService.pageProjectMembers(page, projectId));
// }
//return ResponseList.ofSuccess(projectGroupService.listProjectMembers(projectId));
ResponseList<ProjectGroupDTO> groupMembers; ResponseList<ProjectGroupDTO> groupMembers;
if (validateUtils.validate(page).isEmpty()) { if (validateUtils.validate(page).isEmpty()) {
groupMembers = ResponseList.ofSuccess(projectGroupService.pageProjectMembers(page, projectId)); groupMembers = ResponseList.ofSuccess(projectGroupService.pageProjectMembers(page, projectId));
@ -62,13 +54,9 @@ public class ProjectGroupController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping("/{staffId}") @GetMapping("/{staffId}")
public ResponseMap getDesignatedStaffPosition( public ResponseMap getDesignatedStaffPosition(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@PathVariable Integer staffId @PathVariable Integer staffId
) { ) {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
ProjectGroup designatedStaff = projectGroupService.getOne( ProjectGroup designatedStaff = projectGroupService.getOne(
Wrappers.<ProjectGroup>lambdaQuery() Wrappers.<ProjectGroup>lambdaQuery()
.eq(ProjectGroup::getStaffId, staffId) .eq(ProjectGroup::getStaffId, staffId)
@ -83,7 +71,6 @@ public class ProjectGroupController {
@ProjectAuthorize("a == 1") @ProjectAuthorize("a == 1")
@PostMapping @PostMapping
public ResponseMap addGroupMember( public ResponseMap addGroupMember(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer accessLevel, @RequestAttribute Integer accessLevel,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@RequestBody GroupPositionVO groupPosition @RequestBody GroupPositionVO groupPosition
@ -97,7 +84,6 @@ public class ProjectGroupController {
@ProjectAuthorize("a == 1") @ProjectAuthorize("a == 1")
@DeleteMapping("/{staffId}") @DeleteMapping("/{staffId}")
public ResponseMap deleteGroupMember( public ResponseMap deleteGroupMember(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer accessLevel, @RequestAttribute Integer accessLevel,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@PathVariable Integer staffId @PathVariable Integer staffId
@ -112,7 +98,6 @@ public class ProjectGroupController {
@ProjectAuthorize("a > 0 && a <= 2") @ProjectAuthorize("a > 0 && a <= 2")
@PutMapping("/{staffId}") @PutMapping("/{staffId}")
public ResponseMap modifyDesignatedStaffPosition( public ResponseMap modifyDesignatedStaffPosition(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer accessLevel, @RequestAttribute Integer accessLevel,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@PathVariable Integer staffId, @PathVariable Integer staffId,
@ -126,7 +111,6 @@ public class ProjectGroupController {
@GetMapping("/stats") @GetMapping("/stats")
public ResponseMap getGroupPositionsStatistics( public ResponseMap getGroupPositionsStatistics(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer accessLevel, @RequestAttribute Integer accessLevel,
@PathVariable Integer projectId @PathVariable Integer projectId
) { ) {
@ -137,7 +121,6 @@ public class ProjectGroupController {
@ProjectAuthorize("a > 0 && a <= 2") @ProjectAuthorize("a > 0 && a <= 2")
@PutMapping("/{staffId}/transfer") @PutMapping("/{staffId}/transfer")
public ResponseMap transferStaffTasks( public ResponseMap transferStaffTasks(
// @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
@ -152,7 +135,6 @@ public class ProjectGroupController {
@ProjectAuthorize("a > 0 && a <= 2") @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,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@PathVariable Integer staffId, @PathVariable Integer staffId,
@PathVariable Integer targetStaffId @PathVariable Integer targetStaffId

View File

@ -49,10 +49,9 @@ public class StaffController {
@PostMapping(value = "/import") @PostMapping(value = "/import")
public ResponseMap importStaffs( public ResponseMap importStaffs(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffGlobalLevel, @RequestAttribute Integer staffGlobalLevel,
@RequestParam("fileDigest") String digest, @RequestParam("fileDigest") String digest,
@RequestParam("uploadFile") MultipartFile uploadFile @RequestParam MultipartFile uploadFile
) throws IOException { ) throws IOException {
if (null == uploadFile) { if (null == uploadFile) {
throw new BadRequestException("文件传输错误"); throw new BadRequestException("文件传输错误");
@ -68,22 +67,6 @@ public class StaffController {
return ResponseMap.ofSuccess("成功导入" + successCount + "条数据"); return ResponseMap.ofSuccess("成功导入" + successCount + "条数据");
} }
//取消功能
/*@SneakyThrows
@GetMapping("/import/template")
public void downloadTemplate(
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
HttpServletResponse response
) {
if (TokenUtils.getStaffGlobalLevel(token) > 2) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
if (FileUtils.downloadResource("static/public/账户导入模板.xlsx", response)) {
return;
}
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
}*/
@GetMapping("/import/template") @GetMapping("/import/template")
@ResponseStatus(HttpStatus.SEE_OTHER) @ResponseStatus(HttpStatus.SEE_OTHER)
public ResponseMap downloadTemplate() { public ResponseMap downloadTemplate() {

View File

@ -32,9 +32,8 @@ public class TaskController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping("/{fatherId}/subtask") @GetMapping("/{fatherId}/subtask")
public ResponseList<TaskDTO> getSubTaskList( public ResponseList<TaskDTO> getSubTaskList(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token, @PathVariable Integer projectId,
@PathVariable("projectId") Integer projectId, @PathVariable Long fatherId
@PathVariable("fatherId") Long fatherId
) { ) {
List<TaskDTO> result = taskService.listSubtasks(projectId, fatherId); List<TaskDTO> result = taskService.listSubtasks(projectId, fatherId);
return ResponseList.ofSuccess(result); return ResponseList.ofSuccess(result);
@ -44,9 +43,8 @@ public class TaskController {
@RateLimit(key = "TaskMine", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200) @RateLimit(key = "TaskMine", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
@GetMapping("/mine") @GetMapping("/mine")
public ResponseList<TaskDTO> getMyTasks( public ResponseList<TaskDTO> getMyTasks(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@PathVariable("projectId") Integer projectId @PathVariable Integer projectId
) { ) {
List<TaskDTO> result = taskService.listMyTasks(staffId, projectId); List<TaskDTO> result = taskService.listMyTasks(staffId, projectId);
return ResponseList.ofSuccess(result); return ResponseList.ofSuccess(result);
@ -55,9 +53,8 @@ public class TaskController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping("/subtask/exist") @GetMapping("/subtask/exist")
public ResponseMap existSubTask( public ResponseMap existSubTask(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token, @PathVariable Integer projectId,
@PathVariable("projectId") Integer projectId, @RequestParam Long taskId
@RequestParam("taskId") Long taskId
) { ) {
return ResponseMap.ofSuccess() return ResponseMap.ofSuccess()
.put("existSubTask", taskService.existSubTask(projectId, taskId)); .put("existSubTask", taskService.existSubTask(projectId, taskId));
@ -65,11 +62,10 @@ public class TaskController {
@PostMapping @PostMapping
public ResponseMap createTask( public ResponseMap createTask(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel, @RequestAttribute Integer globalAccessLevel,
@RequestAttribute Integer accessLevel, @RequestAttribute Integer accessLevel,
@PathVariable("projectId") Integer projectId, @PathVariable Integer projectId,
@RequestBody Task task @RequestBody Task task
) { ) {
if (!projectService.checkOpenStatus(projectId)) if (!projectService.checkOpenStatus(projectId))
@ -83,12 +79,11 @@ public class TaskController {
@RateLimit(key = "TaskModify", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200) @RateLimit(key = "TaskModify", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
@PutMapping("/{taskId}") @PutMapping("/{taskId}")
public ResponseMap modifyTask( public ResponseMap modifyTask(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel, @RequestAttribute Integer globalAccessLevel,
@RequestAttribute Integer accessLevel, @RequestAttribute Integer accessLevel,
@PathVariable("projectId") Integer projectId, @PathVariable Integer projectId,
@PathVariable("taskId") Long taskId, @PathVariable Long taskId,
@RequestBody Task task @RequestBody Task task
) { ) {
if (!projectService.checkOpenStatus(projectId)) if (!projectService.checkOpenStatus(projectId))
@ -103,11 +98,10 @@ public class TaskController {
@RateLimit(key = "TaskModify", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200) @RateLimit(key = "TaskModify", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
@DeleteMapping("/{taskId}") @DeleteMapping("/{taskId}")
public ResponseMap deleteTaskAndSubTask( public ResponseMap deleteTaskAndSubTask(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@RequestAttribute Integer globalAccessLevel, @RequestAttribute Integer globalAccessLevel,
@PathVariable("projectId") Integer projectId, @PathVariable Integer projectId,
@PathVariable("taskId") Long taskId @PathVariable Long taskId
) { ) {
if (!projectService.checkOpenStatus(projectId)) if (!projectService.checkOpenStatus(projectId))
throw new BadRequestException(IProjectService.PROJECT_UNOPENED); throw new BadRequestException(IProjectService.PROJECT_UNOPENED);
@ -123,7 +117,6 @@ public class TaskController {
@RateLimit(key = "TaskTrend", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200) @RateLimit(key = "TaskTrend", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200)
@GetMapping("/stats/trend") @GetMapping("/stats/trend")
public ResponseMap getTaskTrend( public ResponseMap getTaskTrend(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId @PathVariable Integer projectId
) { ) {
if (!projectService.checkOpenStatus(projectId)) { if (!projectService.checkOpenStatus(projectId)) {
@ -135,7 +128,6 @@ public class TaskController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping("/stats/group") @GetMapping("/stats/group")
public ResponseMap getTaskNumOfEveryone( public ResponseMap getTaskNumOfEveryone(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@PathVariable Integer projectId @PathVariable Integer projectId
) { ) {
return ResponseMap.ofSuccess("查询成功", taskService.getProjectProcessOfEveryone(projectId)); return ResponseMap.ofSuccess("查询成功", taskService.getProjectProcessOfEveryone(projectId));
@ -144,7 +136,6 @@ public class TaskController {
@ProjectAuthorize("a != 0") @ProjectAuthorize("a != 0")
@GetMapping({"/stats", "/stats/{targetStaffId}"}) @GetMapping({"/stats", "/stats/{targetStaffId}"})
public ResponseList<StaffProcessDTO> getProjectStatistics( public ResponseList<StaffProcessDTO> getProjectStatistics(
// @RequestHeader(TokenUtils.HEADER_TOKEN) String token,
@RequestAttribute Integer staffId, @RequestAttribute Integer staffId,
@PathVariable Integer projectId, @PathVariable Integer projectId,
@PathVariable(required = false) Integer targetStaffId @PathVariable(required = false) Integer targetStaffId

View File

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

View File

@ -37,8 +37,6 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
Integer getProjectAccessLevel(Integer staffId, Integer staffGlobalLevel, Integer projectId); Integer getProjectAccessLevel(Integer staffId, Integer staffGlobalLevel, Integer projectId);
Integer getProjectAccessLevelIgnoreGlobalLevel(String token, Integer projectId);
Integer getProjectAccessLevelIgnoreGlobalLevel(Integer staffId, Integer projectId); Integer getProjectAccessLevelIgnoreGlobalLevel(Integer staffId, Integer projectId);
/** /**

View File

@ -23,8 +23,6 @@ public interface ITaskService extends IService<Task> {
Boolean deleteTaskAndSubTask(Integer staffId, Integer globalAccessLevel, Long taskId) throws BadRequestException, ForbiddenException; Boolean deleteTaskAndSubTask(Integer staffId, Integer globalAccessLevel, Long taskId) throws BadRequestException, ForbiddenException;
// Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
List<StaffProcessDTO> getProjectStatistics(Integer projectId, Integer staffId) throws BadRequestException, ForbiddenException; List<StaffProcessDTO> getProjectStatistics(Integer projectId, Integer staffId) throws BadRequestException, ForbiddenException;
/** /**
@ -32,13 +30,6 @@ public interface ITaskService extends IService<Task> {
*/ */
Integer getHolderLevel(Integer staffId, Integer staffGlobalLevel, Long taskId); Integer getHolderLevel(Integer staffId, Integer staffGlobalLevel, Long taskId);
/**
* /访1
*
* @return 1:all rights 2:father holder 3:current holder 0:no right
*/
// Integer getHolderLevel(String token, Long taskId);
List<TaskDTO> listMyTasks(Integer staffId, Integer projectId) throws BadRequestException, ForbiddenException; List<TaskDTO> listMyTasks(Integer staffId, Integer projectId) throws BadRequestException, ForbiddenException;
Boolean canBeDone(Long taskId); Boolean canBeDone(Long taskId);

View File

@ -35,25 +35,6 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
return baseMapper.selectAnnouncementById(projectId, announcementId); 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 @Override
public Boolean deleteAnnouncement( public Boolean deleteAnnouncement(
Integer staffId, Integer staffId,
@ -61,13 +42,6 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
Integer projectId, Integer projectId,
Long announcementId Long announcementId
) throws ForbiddenException, BadRequestException { ) 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() Announcement rawAnnouncement = baseMapper.selectOne(Wrappers.<Announcement>lambdaQuery()
.select(Announcement::getProjectId, Announcement::getAnnouncementPublisherId) .select(Announcement::getProjectId, Announcement::getAnnouncementPublisherId)
.eq(Announcement::getAnnouncementId, announcementId) .eq(Announcement::getAnnouncementId, announcementId)

View File

@ -8,7 +8,6 @@ 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.service.IStaffService; import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
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 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.plugins.pagination.Page;
@ -43,29 +42,8 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
return baseMapper.insert(projectGroup) == 1; return baseMapper.insert(projectGroup) == 1;
} }
@Override private void buildPositions(ProjectGroup projectGroup, int accessLevel) {
public Boolean insertNewMember(int accessLevel, Integer projectId, String targetUsername, String positions) throws ForbiddenException, BadRequestException { String[] positionArray = projectGroup.getProjectStaffPosition().split(",");
if (targetUsername.equals("root")) {
throw new BadRequestException(IStaffService.STAFF_DOES_NOT_EXIST);
}
//int accessLevel = getProjectAccessLevel(token, projectId);
int targetLevel = 3;
Staff targetStaff = staffService.getOne(Wrappers.<Staff>lambdaQuery().eq(Staff::getStaffUsername, targetUsername));
if (targetStaff == null) {
throw new BadRequestException(IStaffService.STAFF_DOES_NOT_EXIST);
}
if (getProjectAccessLevelIgnoreGlobalLevel(targetStaff.getStaffId(), projectId) != 0) {
throw new BadRequestException("该成员已经在本项目中");
}
if (accessLevel == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (accessLevel > 2) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
String[] positionArray = positions.split(",");
for (String position : positionArray) { for (String position : positionArray) {
position = position.strip(); position = position.strip();
if (position.equals(POSITION_1)) { if (position.equals(POSITION_1)) {
@ -75,12 +53,30 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
if (accessLevel != 1) { if (accessLevel != 1) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE); throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
} }
targetLevel = 2; projectGroup.setProjectAccessLevel(2);
} }
} }
positions = String.join(",", positionArray); projectGroup.setProjectStaffPosition(String.join(",", positionArray));
}
return baseMapper.insert(new ProjectGroup(targetStaff.getStaffId(), projectId, positions, targetLevel)) == 1; @Override
public Boolean insertNewMember(int accessLevel, Integer projectId, String targetUsername, String positions) throws ForbiddenException, BadRequestException {
if (targetUsername.equals("root")) {
throw new BadRequestException(IStaffService.STAFF_DOES_NOT_EXIST);
}
int targetLevel = 3;
Staff targetStaff = staffService.getOne(Wrappers.<Staff>lambdaQuery().eq(Staff::getStaffUsername, targetUsername));
if (targetStaff == null) {
throw new BadRequestException(IStaffService.STAFF_DOES_NOT_EXIST);
}
if (getProjectAccessLevelIgnoreGlobalLevel(targetStaff.getStaffId(), projectId) != 0) {
throw new BadRequestException("该成员已经在本项目中");
}
ProjectGroup newProjectGroupRelation = new ProjectGroup(targetStaff.getStaffId(), projectId, positions, targetLevel);
buildPositions(newProjectGroupRelation, accessLevel);
return baseMapper.insert(newProjectGroupRelation) == 1;
} }
@Override @Override
@ -99,8 +95,6 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
@Override @Override
public Boolean updateStaffPositions(Integer accessLevel, Integer projectId, Integer targetId, String positions) throws ForbiddenException, BadRequestException { public Boolean updateStaffPositions(Integer accessLevel, Integer projectId, Integer targetId, String positions) throws ForbiddenException, BadRequestException {
//int accessLevel = getProjectAccessLevel(token, projectId);
//int originTargetLevel = getProjectAccessLevelIgnoreGlobalLevel(targetId, projectId);
ProjectGroup originProjectGroup = baseMapper.selectOne(Wrappers.<ProjectGroup>lambdaQuery() ProjectGroup originProjectGroup = baseMapper.selectOne(Wrappers.<ProjectGroup>lambdaQuery()
.select(ProjectGroup::getProjectStaffPosition, ProjectGroup::getProjectAccessLevel) .select(ProjectGroup::getProjectStaffPosition, ProjectGroup::getProjectAccessLevel)
.eq(ProjectGroup::getStaffId, targetId) .eq(ProjectGroup::getStaffId, targetId)
@ -114,34 +108,16 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
} }
int targetLevel = 3; int targetLevel = 3;
/*if (accessLevel == 0) { ProjectGroup newProjectGroupRelation = new ProjectGroup(targetId, projectId, positions, targetLevel);
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT); buildPositions(newProjectGroupRelation, accessLevel);
}
if (accessLevel > 2 || accessLevel >= originProjectGroup.getProjectAccessLevel()) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}*/
String[] positionArray = positions.split(",");
for (String position : positionArray) {
position = position.strip();
if (position.equals(POSITION_1)) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
if (position.equals(POSITION_2)) {
if (accessLevel != 1) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
targetLevel = 2;
}
}
positions = String.join(",", positionArray);
return baseMapper.update( return baseMapper.update(
null, null,
Wrappers.<ProjectGroup>lambdaUpdate() Wrappers.<ProjectGroup>lambdaUpdate()
.eq(ProjectGroup::getProjectId, projectId) .eq(ProjectGroup::getProjectId, newProjectGroupRelation.getProjectId())
.eq(ProjectGroup::getStaffId, targetId) .eq(ProjectGroup::getStaffId, newProjectGroupRelation.getStaffId())
.set(ProjectGroup::getProjectStaffPosition, positions) .set(ProjectGroup::getProjectStaffPosition, newProjectGroupRelation.getProjectStaffPosition())
.set(ProjectGroup::getProjectAccessLevel, targetLevel) .set(ProjectGroup::getProjectAccessLevel, newProjectGroupRelation.getProjectAccessLevel())
) == 1; ) == 1;
} }
@ -154,12 +130,6 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
return getProjectAccessLevelIgnoreGlobalLevel(staffId, projectId); return getProjectAccessLevelIgnoreGlobalLevel(staffId, projectId);
} }
@Override
public Integer getProjectAccessLevelIgnoreGlobalLevel(String token, Integer projectId) {
Integer staffId = TokenUtils.getStaffId(token);
return getProjectAccessLevelIgnoreGlobalLevel(staffId, projectId);
}
@Override @Override
public Integer getProjectAccessLevelIgnoreGlobalLevel(Integer staffId, Integer projectId) { public Integer getProjectAccessLevelIgnoreGlobalLevel(Integer staffId, Integer projectId) {
try { try {

View File

@ -38,23 +38,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override @Override
public ProjectProcessDTO getProjectProcess(Integer staffId, Integer globalAccessLevel, Integer projectId) throws ForbiddenException, BadRequestException { 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);
// }
return baseMapper.selectProjectProcess(projectId); return baseMapper.selectProjectProcess(projectId);
} }
@Override @Override
public Page<ProjectDTO> pageMyProjects( public Page<ProjectDTO> pageMyProjects(
// String token,
Integer staffId, Integer staffId,
RequestPage page, RequestPage page,
Map<String, Object> params Map<String, Object> params
) { ) {
// Integer staffId = TokenUtils.getStaffGlobalLevel(token) == 1 ? null : TokenUtils.getStaffId(token);
IPage<ProjectDTO> userPage = baseMapper.selectMyProject(page.getPage(), staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params)); IPage<ProjectDTO> userPage = baseMapper.selectMyProject(page.getPage(), staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params));
return (Page<ProjectDTO>) userPage; return (Page<ProjectDTO>) userPage;
} }
@ -63,12 +55,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
public Boolean setProjectCompleted( public Boolean setProjectCompleted(
Project targetProject Project targetProject
) throws BadRequestException, ForbiddenException { ) 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);*/
targetProject.setCompleted(true); targetProject.setCompleted(true);
targetProject.setProjectClosedDate(LocalDate.now()); targetProject.setProjectClosedDate(LocalDate.now());
if (baseMapper.updateById(targetProject) == 1) if (baseMapper.updateById(targetProject) == 1)
@ -78,15 +64,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override @Override
public Boolean createProject(Integer staffId, Project project) throws BadRequestException, ForbiddenException { 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);
// }
project.setProjectId(null); project.setProjectId(null);
project.setCompleted(false); project.setCompleted(false);
project.setProjectCreatedTime(null); project.setProjectCreatedTime(null);
project.setProjectCreator(staffId); project.setProjectCreator(staffId);
project.setProjectClosedDate(null); project.setProjectClosedDate(null);
if (project.getExpectedCompletion() == null) { if (project.getExpectedCompletion() == null) {
project.setExpectedCompletion((short) 100); project.setExpectedCompletion((short) 100);
} else if (project.getExpectedCompletion() < 0 || project.getExpectedCompletion() > 100 || } else if (project.getExpectedCompletion() < 0 || project.getExpectedCompletion() > 100 ||
@ -100,7 +83,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
return projectGroupService.addCreator(project.getProjectId(), staffId); return projectGroupService.addCreator(project.getProjectId(), staffId);
} }
} catch (Exception e) { } catch (Exception e) {
// log.error(e.getMessage(), e);
throw new BadRequestException(BadRequestException.OPERATE_FAILED); throw new BadRequestException(BadRequestException.OPERATE_FAILED);
} }
return false; return false;
@ -114,10 +96,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
} }
public Boolean updateProject(Integer staffId, Project project) throws BadRequestException, ForbiddenException { 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);
// }
Project rawProject = baseMapper.selectById(project.getProjectId()); Project rawProject = baseMapper.selectById(project.getProjectId());
if (Objects.equals(project, rawProject)) { if (Objects.equals(project, rawProject)) {
return true; return true;
@ -130,7 +108,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
return true; return true;
throw new BadRequestException(BadRequestException.OPERATE_FAILED); throw new BadRequestException(BadRequestException.OPERATE_FAILED);
} catch (Exception e) { } catch (Exception e) {
// log.error(e.getMessage(), e);
throw new BadRequestException(BadRequestException.OPERATE_FAILED); throw new BadRequestException(BadRequestException.OPERATE_FAILED);
} }
} }

View File

@ -146,28 +146,22 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
if (totalCount < 1) { if (totalCount < 1) {
throw new BadRequestException("读取不到条目"); throw new BadRequestException("读取不到条目");
} }
// log.debug(totalCount);
// log.debug(staffUsernameC);
if (!xlsxColumnGetter("staffPassword", 1, staffPasswordC, sheet) || if (!xlsxColumnGetter("staffPassword", 1, staffPasswordC, sheet) ||
staffPasswordC.size() != totalCount) { staffPasswordC.size() != totalCount) {
throw new BadRequestException("读取列staffPassword失败"); throw new BadRequestException("读取列staffPassword失败");
} }
// log.debug(staffPasswordC);
if (!xlsxColumnGetter("staffFullname", 2, staffFullnameC, sheet) || if (!xlsxColumnGetter("staffFullname", 2, staffFullnameC, sheet) ||
staffFullnameC.size() != totalCount) { staffFullnameC.size() != totalCount) {
throw new BadRequestException("读取列staffFullname失败"); throw new BadRequestException("读取列staffFullname失败");
} }
// log.debug(staffFullnameC);
if (!xlsxColumnGetter("staffGender", 3, staffGenderC, sheet) || if (!xlsxColumnGetter("staffGender", 3, staffGenderC, sheet) ||
staffGenderC.size() != totalCount) { staffGenderC.size() != totalCount) {
throw new BadRequestException("读取列staffGender失败"); throw new BadRequestException("读取列staffGender失败");
} }
// log.debug(staffGenderC);
if (!xlsxColumnGetter("staffGlobalLevel", 4, staffGlobalLevelC, sheet) || if (!xlsxColumnGetter("staffGlobalLevel", 4, staffGlobalLevelC, sheet) ||
staffGlobalLevelC.size() != totalCount) { staffGlobalLevelC.size() != totalCount) {
throw new BadRequestException("读取列staffGlobalLevel失败"); throw new BadRequestException("读取列staffGlobalLevel失败");
} }
// log.debug(staffGlobalLevelC);
if (staffGlobalLevelC.stream().anyMatch(level -> Integer.parseInt(level) < 2)) { if (staffGlobalLevelC.stream().anyMatch(level -> Integer.parseInt(level) < 2)) {
throw new BadRequestException("列staffGlobalLevel无效"); throw new BadRequestException("列staffGlobalLevel无效");
} }
@ -184,7 +178,6 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
staff.setStaffFullname(staffFullnameC.get(i)); staff.setStaffFullname(staffFullnameC.get(i));
staff.setStaffGender(staffGenderC.get(i)); staff.setStaffGender(staffGenderC.get(i));
staff.setStaffGlobalLevel(Integer.parseInt(staffGlobalLevelC.get(i))); staff.setStaffGlobalLevel(Integer.parseInt(staffGlobalLevelC.get(i)));
// log.debug(staff);
if (baseMapper.insert(staff) != 1) { if (baseMapper.insert(staff) != 1) {
throw new BadRequestException("第" + (i + 1) + "行数据错误"); throw new BadRequestException("第" + (i + 1) + "行数据错误");
} }

View File

@ -38,9 +38,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
@Override @Override
public List<TaskDTO> listSubtasks(Integer projectId, Long fatherId) throws ForbiddenException, BadRequestException { 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);
// }
if (fatherId == null) { if (fatherId == null) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS); throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
} }
@ -52,9 +49,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
@Override @Override
public Boolean existSubTask(Integer projectId, Long taskId) throws ForbiddenException { public Boolean existSubTask(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)); return baseMapper.exists(Wrappers.<Task>lambdaQuery().eq(Task::getTaskFatherId, taskId));
} }
@ -65,13 +59,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
Integer globalAccessLevel, Integer globalAccessLevel,
Long taskId Long taskId
) throws BadRequestException, ForbiddenException { ) 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);
// }
try { try {
List<Long> res = new ArrayList<>(); List<Long> res = new ArrayList<>();
// 添加根任务点Id获得子节点数目 // 添加根任务点Id获得子节点数目
@ -99,7 +86,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
} }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
// log.error(e.getMessage(), e);
return false; return false;
} }
} }
@ -107,9 +93,6 @@ 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, 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) {
// throw new BadRequestException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
if (level == 0) { if (level == 0) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS); throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
} }
@ -139,19 +122,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
} }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
// log.error(e.getMessage(), e);
return false; return false;
} }
} }
@Override @Override
public List<StaffProcessDTO> getProjectStatistics(Integer projectId, Integer staffId) throws ForbiddenException { 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);
// }
List<StaffProcessDTO> resList = baseMapper.selectProjectProcess(projectId, staffId); List<StaffProcessDTO> resList = baseMapper.selectProjectProcess(projectId, staffId);
addResultProjectProcess(resList, Task.TYPE_ASSIGNMENT); addResultProjectProcess(resList, Task.TYPE_ASSIGNMENT);
addResultProjectProcess(resList, Task.TYPE_DEFECT); addResultProjectProcess(resList, Task.TYPE_DEFECT);
@ -201,18 +177,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
} }
return count; return count;
} catch (Exception e) { } catch (Exception e) {
// log.error(e.getMessage(), e);
return 0; return 0;
} }
} }
// @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) { private int lowerBound(List<Task> data, long x) {
int l = 0, r = data.size() - 1; int l = 0, r = data.size() - 1;
while (l < r) { while (l < r) {
@ -238,10 +206,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
@Override @Override
public List<TaskDTO> listMyTasks(Integer staffId, Integer projectId) throws ForbiddenException { public List<TaskDTO> listMyTasks(Integer staffId, 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() List<Task> resList = baseMapper.selectList(Wrappers.<Task>lambdaQuery()
.select(Task::getTaskId, Task::getTaskFatherId, Task::getTaskHolderId) .select(Task::getTaskId, Task::getTaskFatherId, Task::getTaskHolderId)
.eq(Task::getTaskProjectId, projectId) .eq(Task::getTaskProjectId, projectId)
@ -289,7 +253,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
} }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
// log.error(e.getMessage(), e);
return false; return false;
} }
} }
@ -302,10 +265,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
Task task Task task
) throws BadRequestException, ForbiddenException { ) throws BadRequestException, ForbiddenException {
task.setTaskId(null); task.setTaskId(null);
// Integer userLevel = projectGroupService.getProjectAccessLevel(token, task.getTaskProjectId());
// if (userLevel == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
if (!task.checkInsert()) { if (!task.checkInsert()) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS); throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
} }
@ -341,7 +300,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
Integer accessLevel, Integer accessLevel,
Task task Task task
) throws BadRequestException, ForbiddenException { ) throws BadRequestException, ForbiddenException {
// Integer userLevel = projectGroupService.getProjectAccessLevel(token, task.getTaskProjectId());
Task rawTask = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, task.getTaskId())); Task rawTask = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, task.getTaskId()));
if (accessLevel == 0 || (accessLevel == 3 && getHolderLevel(staffId, globalAccessLevel, task.getTaskId()) == 0)) { if (accessLevel == 0 || (accessLevel == 3 && getHolderLevel(staffId, globalAccessLevel, task.getTaskId()) == 0)) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE); throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
@ -353,7 +311,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
if (task.getTaskStatus().equals(Task.STATUS_CLOSED)) if (task.getTaskStatus().equals(Task.STATUS_CLOSED))
typeChangeValue = 2; typeChangeValue = 2;
} }
// log.debug(!task.checkModification(rawTask));
if (!task.checkModification(rawTask) || !task.checkInsert()) { if (!task.checkModification(rawTask) || !task.checkInsert()) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS); throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
} }
@ -375,7 +332,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
throw new BadRequestException(BadRequestException.OPERATE_FAILED); throw new BadRequestException(BadRequestException.OPERATE_FAILED);
} }
} catch (Exception e) { } catch (Exception e) {
// log.error(e.getMessage(), e);
throw new BadRequestException(BadRequestException.OPERATE_FAILED); throw new BadRequestException(BadRequestException.OPERATE_FAILED);
} }
return task; return task;
@ -384,9 +340,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
// 完成任务数目概况统计 // 完成任务数目概况统计
@Override @Override
public Map<String, List<TaskTrendDTO>> getProjectTaskTrend(Integer projectId) throws ForbiddenException { public Map<String, List<TaskTrendDTO>> getProjectTaskTrend(Integer projectId) throws ForbiddenException {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
// }
// 起止日期 // 起止日期
LocalDate endDate = LocalDate.now(); LocalDate endDate = LocalDate.now();
LocalDate startDate = endDate.plusDays(-14); LocalDate startDate = endDate.plusDays(-14);
@ -482,19 +435,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
return taskTrendDTO; return taskTrendDTO;
} }
// FIXME
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class) @Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
@Override @Override
public Boolean transferStaffTasks(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 (
//// 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);
// }
Map<Long, Task> originTransferTaskMap = SimpleQuery.keyMap( Map<Long, Task> originTransferTaskMap = SimpleQuery.keyMap(
Wrappers.<Task>lambdaQuery() Wrappers.<Task>lambdaQuery()
.eq(Task::getTaskProjectId, projectId) .eq(Task::getTaskProjectId, projectId)
@ -538,19 +481,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
} }
// FIXME
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class) @Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
@Override @Override
public Boolean transferTasksToSingleStaff(Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException { public Boolean transferTasksToSingleStaff(Integer projectId, Integer transferredStaffId, Integer targetStaffId) throws ForbiddenException, BadRequestException {
// 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);
// }
Long transferredTaskCount = baseMapper.selectCount(Wrappers.<Task>lambdaQuery() Long transferredTaskCount = baseMapper.selectCount(Wrappers.<Task>lambdaQuery()
.eq(Task::getTaskHolderId, transferredStaffId) .eq(Task::getTaskHolderId, transferredStaffId)
.and(wrapper -> wrapper .and(wrapper -> wrapper
@ -574,9 +507,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
@Override @Override
public Map<String, Long> getProjectProcessOfEveryone(Integer projectId) throws ForbiddenException { public Map<String, Long> getProjectProcessOfEveryone(Integer projectId) throws ForbiddenException {
// if (projectGroupService.getProjectAccessLevel(token, projectId) == 0) {
// throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
// }
Map<String, Long> resMap = new HashMap<>(); Map<String, Long> resMap = new HashMap<>();
List<TaskNumOfEveryoneDTO> resList = baseMapper.selectProjectProcessOfEveryone(projectId); List<TaskNumOfEveryoneDTO> resList = baseMapper.selectProjectProcessOfEveryone(projectId);
for (TaskNumOfEveryoneDTO taskNumOfEveryoneDTO : resList) { for (TaskNumOfEveryoneDTO taskNumOfEveryoneDTO : resList) {