更改了Task相关以适配需求,格式化了代码
parent
58e0701d07
commit
c4ce74c365
|
@ -1,6 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.query.ResultTask;
|
||||||
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.http.ResponseList;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
||||||
|
@ -26,12 +27,12 @@ public class TaskController {
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping("/{fatherId}/subtask")
|
@GetMapping("/{fatherId}/subtask")
|
||||||
public ResponseList<Task> getSubTaskList(
|
public ResponseList<ResultTask> getSubTaskList(
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@PathVariable("projectId") Integer projectId,
|
@PathVariable("projectId") Integer projectId,
|
||||||
@PathVariable("fatherId") Long fatherId
|
@PathVariable("fatherId") Long fatherId
|
||||||
) {
|
) {
|
||||||
List<Task> result = taskService.getSubTaskList(token, projectId, fatherId);
|
List<ResultTask> result = taskService.getSubTaskList(token, projectId, fatherId);
|
||||||
return ResponseList.ofSuccess("查询成功", result);
|
return ResponseList.ofSuccess("查询成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.entity.query;
|
package cn.edu.hfut.rmdjzz.projectmanagement.entity.query;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
|
@ -30,5 +30,4 @@ public class ResultTask {
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
private Map<String, Object> attachedInfo;
|
private Map<String, Object> attachedInfo;
|
||||||
private Boolean hasChildren;
|
private Boolean hasChildren;
|
||||||
private Boolean deleted;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.query.ResultTask;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 张韬
|
* @author 张韬
|
||||||
* created at 2022/7/4 14:52
|
* created at 2022/7/4 14:52
|
||||||
*/
|
*/
|
||||||
public interface TaskMapper extends BaseMapper<Task> {
|
public interface TaskMapper extends BaseMapper<Task> {
|
||||||
|
List<ResultTask> selectSubTaskList(@Param("projectId") Integer projectId, @Param("fatherId") Long fatherId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.query.ResultTask;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ import java.util.List;
|
||||||
* created at 2022/7/4 14:49
|
* created at 2022/7/4 14:49
|
||||||
*/
|
*/
|
||||||
public interface ITaskService extends IService<Task> {
|
public interface ITaskService extends IService<Task> {
|
||||||
List<Task> getSubTaskList(String token, Integer projectId, Long fatherId) throws BadRequestException;
|
List<ResultTask> getSubTaskList(String token, Integer projectId, Long fatherId) throws BadRequestException;
|
||||||
|
|
||||||
Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
Boolean existSubTask(String token, Integer projectId, Long taskId) throws BadRequestException;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.query.ResultTask;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper;
|
||||||
|
@ -30,11 +31,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
|
|
||||||
//FIXME: 抛出未授权异常
|
//FIXME: 抛出未授权异常
|
||||||
@Override
|
@Override
|
||||||
public List<Task> getSubTaskList(String token, Integer projectId, Long fatherId) throws BadRequestException {
|
public List<ResultTask> getSubTaskList(String token, Integer projectId, Long fatherId) throws BadRequestException {
|
||||||
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0 || fatherId == null) {
|
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0 || fatherId == null) {
|
||||||
throw new BadRequestException("错误的访问参数");
|
throw new BadRequestException("错误的访问参数");
|
||||||
}
|
}
|
||||||
return baseMapper.selectList(Wrappers.<Task>lambdaQuery().eq(Task::getTaskProjectId, projectId).eq(Task::getTaskFatherId, fatherId));
|
return baseMapper.selectSubTaskList(projectId, fatherId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,7 +98,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
||||||
Wrappers.<Task>lambdaUpdate()
|
Wrappers.<Task>lambdaUpdate()
|
||||||
.in(Task::getTaskId, res)
|
.in(Task::getTaskId, res)
|
||||||
.set(Task::getTaskStatus, "关闭")
|
.set(Task::getTaskStatus, "关闭")
|
||||||
.set(Task::getTaskClosedTime,LocalDateTime.now())
|
.set(Task::getTaskClosedTime, LocalDateTime.now())
|
||||||
);
|
);
|
||||||
if (list == null || list.isEmpty()) break;
|
if (list == null || list.isEmpty()) break;
|
||||||
res = list.stream().map(Task::getTaskId).collect(Collectors.toList());
|
res = list.stream().map(Task::getTaskId).collect(Collectors.toList());
|
||||||
|
|
|
@ -2,20 +2,21 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper">
|
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper">
|
||||||
<select id="findMyProject" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.query.ResultProject">
|
<select id="findMyProject" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.query.ResultProject">
|
||||||
SELECT * FROM
|
SELECT *
|
||||||
(SELECT project_id,
|
FROM (SELECT project_id,
|
||||||
project_name,
|
project_name,
|
||||||
contract_amount,
|
contract_amount,
|
||||||
project_importance,
|
project_importance,
|
||||||
project_creator,
|
project_creator,
|
||||||
pt1.project_class_name as project_class_name,
|
pt1.project_class_name AS project_class_name,
|
||||||
pt2.project_class_name as project_subclass_name,
|
pt2.project_class_name AS project_subclass_name,
|
||||||
is_completed as completed,
|
is_completed AS completed,
|
||||||
is_deleted as deleted,
|
is_deleted AS deleted,
|
||||||
project_closed_date
|
project_closed_date
|
||||||
FROM project join project_type pt1 on project.project_class_id = pt1.project_class_id
|
FROM project
|
||||||
join project_type pt2 on project.project_subclass_id = pt2.project_class_id
|
JOIN project_type pt1 ON project.project_class_id = pt1.project_class_id
|
||||||
WHERE project_id IN (SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})) AS T
|
JOIN project_type pt2 ON project.project_subclass_id = pt2.project_class_id
|
||||||
|
WHERE project_id IN (SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})) AS T
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.edu.hfut.rmdjzz.projectmanagement.mapper.TaskMapper">
|
||||||
|
<select id="selectSubTaskList" resultType="cn.edu.hfut.rmdjzz.projectmanagement.entity.query.ResultTask">
|
||||||
|
SELECT task_id,
|
||||||
|
task_name,
|
||||||
|
task_project_id,
|
||||||
|
task_holder_id,
|
||||||
|
s.staff_fullname AS task_holder_name,
|
||||||
|
task_status,
|
||||||
|
task_type,
|
||||||
|
task_father_id,
|
||||||
|
task_created_time,
|
||||||
|
task_start_time,
|
||||||
|
task_end_time,
|
||||||
|
task_closed_time,
|
||||||
|
task_priority,
|
||||||
|
task_description,
|
||||||
|
attached_info,
|
||||||
|
EXISTS(SELECT task_id FROM task WHERE task_father_id = task.task_id) AS has_children
|
||||||
|
FROM task
|
||||||
|
JOIN (SELECT staff_id, staff_fullname FROM staff) AS s ON task.task_holder_id = s.staff_id
|
||||||
|
WHERE is_deleted = 0
|
||||||
|
AND task_project_id = #{projectId}
|
||||||
|
AND task_father_id = #{fatherId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue