添加了需求,优化了接口
parent
9dab2d8e10
commit
b42b6b0b77
30
README.md
30
README.md
|
@ -1,11 +1,25 @@
|
|||
# 项目管理模块-后端部分
|
||||
|
||||
----
|
||||
任务列表
|
||||
- [ ] 用户管理-权限部分
|
||||
- [ ] 完成服务器部署
|
||||
- [ ] 完成初步接口文档
|
||||
- [ ] 任务管理
|
||||
- [ ] 需求管理
|
||||
- [ ] 团队管理
|
||||
- [ ] 个人信息
|
||||
task /project/{projectId}/task
|
||||
|
||||
- [ ] 新建工作项 POST /
|
||||
- [x] 拉取指定father的子工作项 GET /subtask/{fatherId}
|
||||
- [x] 筛选“我的”工作项 GET /mine
|
||||
- [ ] 修改工作项信息/状态 PUT /
|
||||
|
||||
name holder starttime endtime priority attachedinfo description status
|
||||
- [ ] 删除工作项 DELETE /
|
||||
- [ ] 是否存在孩子 GET /subtask/exist
|
||||
----
|
||||
group /project/{projectId}/group
|
||||
|
||||
- [ ] 拉取当前项目所有组员 GET /
|
||||
- [ ] 岗位统计 GET
|
||||
- [ ] 加人
|
||||
- [ ] 改岗位
|
||||
---
|
||||
项目日志 项目统计
|
||||
|
||||
---
|
||||
导入账户 大权限
|
|
@ -15,35 +15,37 @@ import java.util.List;
|
|||
* created at 2022/7/4 15:02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/task")
|
||||
@RequestMapping("/project/{projectId}/task")
|
||||
public class TaskController {
|
||||
@Autowired
|
||||
private ITaskService taskService;
|
||||
|
||||
@SneakyThrows
|
||||
@GetMapping("/{projectId}")
|
||||
public ResponseList getTaskList(@RequestHeader("Token") String token,@PathVariable Integer projectId){
|
||||
List<Task> result = taskService.getTaskList(token,projectId,0L);
|
||||
return ResponseList.ofSuccess("查询成功",result);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@GetMapping("/getSubTask")
|
||||
public ResponseList getSubTaskList(@RequestHeader("Token") String token,@RequestParam("projectId") Integer projectId,@RequestParam("fatherId") Long fatherId){
|
||||
@GetMapping("/subtask/{fatherId}")
|
||||
public ResponseList<Task> getSubTaskList(
|
||||
@RequestHeader("Token") String token,
|
||||
@PathVariable("projectId") Integer projectId,
|
||||
@PathVariable("fatherId") Long fatherId
|
||||
) {
|
||||
List<Task> result = taskService.getTaskList(token, projectId, fatherId);
|
||||
return ResponseList.ofSuccess("查询成功", result);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@GetMapping("/getMyTasks")
|
||||
public ResponseList getMyTasks(@RequestHeader("Token") String token,@RequestParam("projectId") Integer projectId){
|
||||
@GetMapping("/mine")
|
||||
public ResponseList<Task> getMyTasks(@RequestHeader("Token") String token, @PathVariable("projectId") Integer projectId) {
|
||||
List<Task> result = taskService.getMyTaskList(token, projectId);
|
||||
return ResponseList.ofSuccess("查询成功", result);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@PostMapping("/createTask")
|
||||
public ResponseMap createTask(@RequestHeader("Token") String token, @RequestBody Task task){
|
||||
@PostMapping
|
||||
public ResponseMap createTask(
|
||||
@RequestHeader("Token") String token,
|
||||
@PathVariable("projectId") Integer projectId,
|
||||
@RequestBody Task task
|
||||
) {
|
||||
task.setTaskProjectId(projectId);
|
||||
task = taskService.insertTask(token, task);
|
||||
return ResponseMap.ofSuccess("新建成功", task);
|
||||
}
|
||||
|
|
|
@ -19,14 +19,15 @@ public class Task {
|
|||
private String taskName;
|
||||
private Integer taskProjectId;
|
||||
private Integer taskHolderId;
|
||||
private String taskType;
|
||||
private String taskStatus;
|
||||
private Long taskFatherId;
|
||||
private LocalDateTime taskBuiltTime;
|
||||
private LocalDateTime taskCreatedTime;
|
||||
private LocalDateTime taskStartTime;
|
||||
private LocalDateTime taskEndTime;
|
||||
private LocalDateTime taskCloseTime;
|
||||
private LocalDateTime taskClosedTime;
|
||||
private Integer taskPriority;
|
||||
private String taskDescription;
|
||||
private String attachedInfo; //TODO: 验证
|
||||
@TableField("is_deleted")
|
||||
@TableLogic
|
||||
private Boolean deleted;
|
||||
|
@ -34,8 +35,6 @@ public class Task {
|
|||
public Boolean checkInsert() {
|
||||
if (this.getTaskName() == null || this.getTaskName().length() <= 0 || this.getTaskName().length() >= 100)
|
||||
return false;
|
||||
if(this.getTaskEndTime().isBefore(this.getTaskStartTime()))
|
||||
return false;
|
||||
return true;
|
||||
return !this.getTaskEndTime().isBefore(this.getTaskStartTime());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
|||
projectGroup.setProjectStaffPosition("负责人");
|
||||
return baseMapper.insert(projectGroup) == 1;
|
||||
}
|
||||
//TODO:权限分级
|
||||
|
||||
//TODO:
|
||||
@Override
|
||||
public Integer getUserLevelInGroup(String token,Integer projectId){
|
||||
try{
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.StaffMapper;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
||||
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.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
|
@ -25,10 +23,12 @@ import java.util.stream.Collectors;
|
|||
* @author 张韬
|
||||
* created at 2022/7/4 14:51
|
||||
*/
|
||||
//FIXME: 修改delete/close函数
|
||||
@Service
|
||||
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements ITaskService {
|
||||
@Autowired
|
||||
private ProjectGroupServiceImpl projectGroupService;
|
||||
|
||||
@Override
|
||||
public List<Task> getTaskList(String token, Integer projectId, Long fatherId) throws BadRequestException {
|
||||
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0 || fatherId == null) {
|
||||
|
@ -37,6 +37,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
return baseMapper.selectList(Wrappers.<Task>lambdaQuery().eq(Task::getTaskProjectId, projectId).eq(Task::getTaskFatherId, fatherId));
|
||||
}
|
||||
|
||||
//FIXME:
|
||||
@Override
|
||||
public List<List<Long>> getTaskAndSubTask(Long taskId) {
|
||||
List<List<Long>> resList = new ArrayList<>();
|
||||
|
@ -52,6 +53,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
return resList;
|
||||
}
|
||||
|
||||
//FIXME:
|
||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Boolean deleteTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
||||
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
||||
|
@ -71,6 +74,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
}
|
||||
}
|
||||
|
||||
//FIXME:
|
||||
@Override
|
||||
public Boolean closeTaskAndSubTask(String token, Integer projectId, Long taskId) throws BadRequestException {
|
||||
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
||||
|
@ -82,7 +86,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
List<List<Long>> resList = getTaskAndSubTask(taskId);
|
||||
try {
|
||||
for (List<Long> list : resList) {
|
||||
baseMapper.update(null, Wrappers.<Task>lambdaUpdate().in(Task::getTaskId, list).set(Task::getTaskType, "关闭"));
|
||||
baseMapper.update(null, Wrappers.<Task>lambdaUpdate().in(Task::getTaskId, list).set(Task::getTaskStatus, "关闭"));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
@ -106,23 +110,17 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkHolder(String token, Long taskId) {
|
||||
try {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
Task task=baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId,taskId));
|
||||
if(task==null||staffId==null||staffId<=0)
|
||||
return false;
|
||||
while(task.getTaskFatherId()!=0){
|
||||
if(Objects.equals(task.getTaskHolderId(), staffId))
|
||||
return true;
|
||||
task=baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId,task.getTaskFatherId()));
|
||||
}
|
||||
return false;
|
||||
return checkHolder(staffId, taskId);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> getMyTaskList(String token, Integer projectId) throws BadRequestException {
|
||||
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
||||
|
@ -134,19 +132,23 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
} catch (TokenException e) {
|
||||
//impossible
|
||||
}
|
||||
return baseMapper.selectList(Wrappers.<Task>lambdaQuery().eq(Task::getTaskHolderId,staffId).eq(Task::getTaskProjectId,projectId));
|
||||
return baseMapper.selectList(Wrappers.<Task>lambdaQuery()
|
||||
.eq(Task::getTaskHolderId, staffId)
|
||||
.eq(Task::getTaskProjectId, projectId)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean canBeDone(Long taskId) {
|
||||
try {
|
||||
Task task = baseMapper.selectOne(Wrappers.<Task>lambdaQuery().eq(Task::getTaskId, taskId));
|
||||
if(task==null||!"打开".equals(task.getTaskType())||!"进行中".equals(task.getTaskType()))
|
||||
if (task == null || !"打开".equals(task.getTaskStatus()) || !"进行中".equals(task.getTaskStatus()))
|
||||
return false;
|
||||
List<Task> childTask = baseMapper.selectList(Wrappers.<Task>lambdaQuery().eq(Task::getTaskFatherId, task.getTaskId()));
|
||||
if (childTask == null || childTask.isEmpty())
|
||||
return true;
|
||||
for (Task cTask : childTask) {
|
||||
if(cTask.getTaskType().equals("打开")||cTask.getTaskType().equals("进行中"))
|
||||
if (cTask.getTaskStatus().equals("打开") || cTask.getTaskStatus().equals("进行中"))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -154,6 +156,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task insertTask(String token, Task task) throws BadRequestException {
|
||||
task.setTaskId(null);
|
||||
|
@ -169,9 +172,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
throw new BadRequestException("非法的父级参数");
|
||||
}
|
||||
try {
|
||||
task.setTaskBuiltTime(LocalDateTime.now());
|
||||
task.setTaskType("打开");
|
||||
task.setTaskCloseTime(null);
|
||||
task.setTaskCreatedTime(LocalDateTime.now());
|
||||
task.setTaskStatus("打开");
|
||||
task.setTaskClosedTime(null);
|
||||
if (baseMapper.insert(task) == 0) {
|
||||
throw new BadRequestException("新建失败");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue