修复了离队时不检查工作项完成情况的问题,列出mytask时没有holderFullname的问题,修改职位时受前后空格影响的问题和不更新权限的问题,格式化了代码
parent
9bc59be2a0
commit
76966938a1
|
@ -2,7 +2,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
|||
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.ProjectGroupDTO;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.vo.GroupPositionVO;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.ForbiddenException;
|
||||
|
@ -20,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author 史鹏辉
|
||||
|
@ -94,13 +92,7 @@ public class ProjectGroupController {
|
|||
@PathVariable Integer projectId,
|
||||
@PathVariable Integer staffId
|
||||
) {
|
||||
if (projectGroupService.compareProjectAccessLevel(projectId, token, staffId) >= 0) {
|
||||
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||
}
|
||||
if (projectGroupService.remove(Wrappers.<ProjectGroup>lambdaQuery()
|
||||
.eq(ProjectGroup::getProjectId, projectId)
|
||||
.eq(ProjectGroup::getStaffId, staffId))
|
||||
) {
|
||||
if (projectGroupService.removeMember(token, projectId, staffId)) {
|
||||
return ResponseMap.ofSuccess();
|
||||
}
|
||||
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
|
||||
|
|
|
@ -3,7 +3,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
|||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||
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.IProjectService;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.ITaskService;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||
|
@ -40,8 +39,8 @@ public class TaskController {
|
|||
|
||||
@SneakyThrows
|
||||
@GetMapping("/mine")
|
||||
public ResponseList<Task> getMyTasks(@RequestHeader(TokenUtils.HEADER_TOKEN) String token, @PathVariable("projectId") Integer projectId) {
|
||||
List<Task> result = taskService.listMyTasks(token, 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);
|
||||
}
|
||||
|
||||
|
@ -117,7 +116,7 @@ public class TaskController {
|
|||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||
@PathVariable Integer projectId
|
||||
) {
|
||||
if(!projectService.checkOpenStatus(projectId)) {
|
||||
if (!projectService.checkOpenStatus(projectId)) {
|
||||
throw new BadRequestException(IProjectService.PROJECT_UNOPENED);
|
||||
}
|
||||
return ResponseMap.ofSuccess("查询成功", taskService.getProjectProcessOfEveryone(token, projectId));
|
||||
|
@ -131,7 +130,7 @@ public class TaskController {
|
|||
@PathVariable Integer projectId,
|
||||
@PathVariable(required = false) Integer staffId
|
||||
) {
|
||||
if(!projectService.checkOpenStatus(projectId)) {
|
||||
if (!projectService.checkOpenStatus(projectId)) {
|
||||
throw new BadRequestException(IProjectService.PROJECT_UNOPENED);
|
||||
}
|
||||
return ResponseList.ofSuccess("查询成功", taskService.getProjectStatistics(token, projectId, staffId));
|
||||
|
|
|
@ -29,4 +29,14 @@ public interface ProjectGroupMapper extends BaseMapper<ProjectGroup> {
|
|||
ON project_group.staff_id = staff.staff_id AND project_group.project_id = #{projectId}
|
||||
""")
|
||||
List<ProjectGroupDTO> selectMembersByList(@Param("projectId") Integer projectId);
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(task_id)
|
||||
FROM task
|
||||
WHERE task_project_id = #{projectId}
|
||||
AND task_holder_id = #{staffId}
|
||||
AND is_deleted = 0
|
||||
AND (task_status = '待进行' OR task_status = '进行中');
|
||||
""")
|
||||
Long selectUnfinishedTaskCountByStaffId(@Param("projectId") Integer projectId, @Param("staffId") Integer staffId);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@ import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
|
|||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskNumOfEveryoneDTO;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskTrendDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
@ -16,6 +18,8 @@ import java.util.List;
|
|||
* created at 2022/7/4 14:52
|
||||
*/
|
||||
public interface TaskMapper extends BaseMapper<Task> {
|
||||
List<TaskDTO> selectTaskList(@Param(Constants.WRAPPER) Wrapper<Task> wrapper);
|
||||
|
||||
List<TaskDTO> selectSubTaskList(@Param("projectId") Integer projectId, @Param("fatherId") Long fatherId);
|
||||
|
||||
List<StaffProcessDTO> selectProjectProcess(@Param("projectId") Integer projectId, @Param("staffId") Integer staffId);
|
||||
|
|
|
@ -26,6 +26,8 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
|
|||
|
||||
Boolean insertNewMember(String token, Integer projectId, String staffUsername, String positions) throws ForbiddenException, BadRequestException;
|
||||
|
||||
Boolean removeMember(String token, Integer projectId, Integer targetId) throws ForbiddenException, BadRequestException;
|
||||
|
||||
Boolean updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ public interface ITaskService extends IService<Task> {
|
|||
*/
|
||||
Integer getHolderLevel(String token, Long taskId);
|
||||
|
||||
List<Task> listMyTasks(String token, Integer projectId) throws BadRequestException;
|
||||
List<TaskDTO> listMyTasks(String token, Integer projectId) throws BadRequestException;
|
||||
|
||||
Boolean canBeDone(Long taskId);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
|
|||
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||
}
|
||||
Announcement rawAnnouncement = baseMapper.selectById(announcement.getAnnouncementId());
|
||||
if (projectGroupService.compareProjectAccessLevel(projectId, token, rawAnnouncement.getAnnouncementPublisherId()) >= 0) {
|
||||
if (projectGroupService.compareProjectAccessLevel(projectId, token, rawAnnouncement.getAnnouncementPublisherId()) <= 0) {
|
||||
if (!announcement.checkModification(rawAnnouncement)) {
|
||||
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
|||
}
|
||||
String[] positionArray = positions.split(",");
|
||||
for (String position : positionArray) {
|
||||
position = position.strip();
|
||||
if (position.equals(POSITION_1)) {
|
||||
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||
}
|
||||
|
@ -70,10 +71,25 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
|||
targetLevel = 2;
|
||||
}
|
||||
}
|
||||
positions = String.join(",", positionArray);
|
||||
|
||||
return baseMapper.insert(new ProjectGroup(targetStaff.getStaffId(), projectId, positions, targetLevel)) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean removeMember(String token, Integer projectId, Integer targetId) throws ForbiddenException, BadRequestException {
|
||||
if (compareProjectAccessLevel(projectId, token, targetId) >= 0) {
|
||||
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||
}
|
||||
Long taskUnfinishedCount = baseMapper.selectUnfinishedTaskCountByStaffId(projectId, targetId);
|
||||
if (taskUnfinishedCount != 0) {
|
||||
throw new BadRequestException("该成员仍有未完成或未被关闭的工作项");
|
||||
}
|
||||
return baseMapper.delete(Wrappers.<ProjectGroup>lambdaQuery()
|
||||
.eq(ProjectGroup::getProjectId, projectId)
|
||||
.eq(ProjectGroup::getStaffId, targetId)) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException {
|
||||
int accessLevel = getProjectAccessLevel(token, projectId);
|
||||
|
@ -87,13 +103,18 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
|||
}
|
||||
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) && accessLevel != 1) {
|
||||
if (position.equals(POSITION_2)) {
|
||||
if (accessLevel != 1) {
|
||||
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||
}
|
||||
targetLevel = 2;
|
||||
}
|
||||
}
|
||||
positions = String.join(",", positionArray);
|
||||
|
||||
return baseMapper.update(
|
||||
null,
|
||||
|
@ -101,6 +122,7 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
|||
.eq(ProjectGroup::getProjectId, projectId)
|
||||
.eq(ProjectGroup::getStaffId, targetId)
|
||||
.set(ProjectGroup::getProjectStaffPosition, positions)
|
||||
.set(ProjectGroup::getProjectAccessLevel, targetLevel)
|
||||
) == 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -220,13 +220,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
|
||||
|
||||
@Override
|
||||
public List<Task> listMyTasks(String token, Integer projectId) throws BadRequestException {
|
||||
public List<TaskDTO> listMyTasks(String token, Integer projectId) {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
List<Task> resList = baseMapper.selectList(Wrappers.<Task>lambdaQuery().select(Task::getTaskId, Task::getTaskFatherId, Task::getTaskHolderId)
|
||||
.eq(Task::getTaskProjectId, projectId).orderByAsc(Task::getTaskFatherId));
|
||||
List<Task> resList = baseMapper.selectList(Wrappers.<Task>lambdaQuery()
|
||||
.select(Task::getTaskId, Task::getTaskFatherId, Task::getTaskHolderId)
|
||||
.eq(Task::getTaskProjectId, projectId)
|
||||
.orderByAsc(Task::getTaskFatherId));
|
||||
List<Long> results = new ArrayList<>();
|
||||
ArrayList<Long> vec = new ArrayList<>();
|
||||
ArrayList<Boolean> isTarget = new ArrayList<>();
|
||||
List<Long> vec = new ArrayList<>();
|
||||
List<Boolean> isTarget = new ArrayList<>();
|
||||
vec.add(0L);
|
||||
isTarget.add(false);
|
||||
int id = 0;
|
||||
|
@ -247,7 +249,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
isTarget.add(resList.get(i).getTaskHolderId().equals(staffId));
|
||||
}
|
||||
}
|
||||
return baseMapper.selectList(Wrappers.<Task>lambdaQuery().in(Task::getTaskId, results));
|
||||
return baseMapper.selectTaskList(Wrappers.<Task>lambdaQuery()
|
||||
.eq(Task::getDeleted, false)
|
||||
.in(Task::getTaskId, results));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -323,7 +327,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
||||
}
|
||||
if (typeChangeValue == 1 && !canBeDone(task.getTaskId())) {
|
||||
throw new BadRequestException("还有子工作尚未完成");
|
||||
throw new BadRequestException("还有子工作项尚未完成");
|
||||
}
|
||||
try {
|
||||
boolean closed = false;
|
||||
|
|
|
@ -6,6 +6,27 @@
|
|||
<result property="attachedInfo" column="attached_info"
|
||||
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
|
||||
</resultMap>
|
||||
<select id="selectTaskList" resultMap="taskDto">
|
||||
SELECT task_id,
|
||||
task_name,
|
||||
task_project_id,
|
||||
task_holder_id,
|
||||
s.staff_fullname AS task_holder_name,
|
||||
task_status,
|
||||
task_type,
|
||||
t.task_father_id,
|
||||
task_created_time,
|
||||
task_start_time,
|
||||
task_end_time,
|
||||
task_closed_time,
|
||||
task_priority,
|
||||
task_description,
|
||||
attached_info,
|
||||
children_count
|
||||
FROM task AS t
|
||||
JOIN (SELECT staff_id, staff_fullname FROM staff) AS s ON t.task_holder_id = s.staff_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="selectSubTaskList" resultMap="taskDto">
|
||||
SELECT task_id,
|
||||
task_name,
|
||||
|
@ -43,7 +64,8 @@
|
|||
</if>
|
||||
GROUP BY task_type
|
||||
</select>
|
||||
<select id="selectProjectProcessOfEveryone" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskNumOfEveryoneDTO">
|
||||
<select id="selectProjectProcessOfEveryone"
|
||||
resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskNumOfEveryoneDTO">
|
||||
SELECT staff_fullname, completed_num
|
||||
FROM (SELECT task_holder_id, SUM(IF(task_closed_time IS NULL, 0, 1)) AS completed_num
|
||||
FROM task
|
||||
|
|
Loading…
Reference in New Issue