修改任务排序

This commit is contained in:
jasminexz 2023-09-19 20:42:59 +08:00
parent 92dd401f0f
commit ec0d68cdaa
5 changed files with 37 additions and 26 deletions

View File

@ -54,7 +54,7 @@ public interface TodoMapper extends BaseMapper<TodoEntity> {
*
* @param todoId todoid
*/
List<TodoEntity> listTask(@Param("todoId") String todoId);
List<TodoEntity> listTask(@Param("userId") Long userId, @Param("todoId") String todoId);
/**
* 事项统计信息

View File

@ -111,7 +111,7 @@ public class TodoService extends ServiceImpl<TodoMapper, TodoEntity> {
* @param todoId todoId, 每日待办事项, todoId yyyy-MM-dd 格式, 如果是阶段性事项, 则为字符串ID
*/
public TaskRes listTask(String todoId) {
List<TodoEntity> tasks = baseMapper.listTask(todoId);
List<TodoEntity> tasks = baseMapper.listTask(AuthContext.getUserId(), todoId);
if (CollUtil.isEmpty(tasks)) {
return TaskRes.build();
}
@ -144,12 +144,43 @@ public class TodoService extends ServiceImpl<TodoMapper, TodoEntity> {
// 今日中午12点
Date noon = DateUtils.parse(todoId + " 12:00:00", DateUtils.PATTERN_YYYYMMDDHHMMSS);
List<TodoEntity> processing = res.getProcessing();
addNoon(noon, processing);
addDateDivider(noon, processing, TaskStatusEnum.PROCESSING);
List<TodoEntity> completed = res.getCompleted();
addNoon(noon, completed);
addDateDivider(noon, completed, TaskStatusEnum.COMPLETED);
return res;
}
/**
* 添加时间分割节点, 只有每日待办事项具有分割节点
*
* @param divideDate 分割的日期, 注意
* @param tasks 任务列表
*/
private void addDateDivider(Date divideDate, List<TodoEntity> tasks, TaskStatusEnum taskStatus) {
if (CollUtil.isEmpty(tasks)) {
return;
}
for (int i = 0; i < tasks.size(); i++) {
Date date;
if (taskStatus == TaskStatusEnum.PROCESSING) {
date = tasks.get(i).getStartTime();
} else if (taskStatus == TaskStatusEnum.COMPLETED) {
date = tasks.get(i).getEndTime();
} else {
continue;
}
if (date == null) {
continue;
}
if (DateUtils.compare(divideDate, date) < 0) {
TodoEntity placeHolder = new TodoEntity();
placeHolder.setTodoType(TodoTypeEnum.NOON_AM_12.getType());
tasks.add(i, placeHolder);
break;
}
}
}
/**
* 查看事项的任务数量
*
@ -159,26 +190,6 @@ public class TodoService extends ServiceImpl<TodoMapper, TodoEntity> {
return baseMapper.count(todoId);
}
/**
* 添加中午12点的分割节点
*
* @param noon 中午的日期
* @param tasks 任务列表
*/
private void addNoon(Date noon, List<TodoEntity> tasks) {
if (CollUtil.isEmpty(tasks)) {
return;
}
for (int i = 0; i < tasks.size(); i++) {
Date start = tasks.get(i).getStartTime();
if (DateUtils.compare(noon, start) < 0) {
TodoEntity placeHolder = new TodoEntity();
placeHolder.setTodoType(TodoTypeEnum.NOON_AM_12.getType());
tasks.add(i, placeHolder);
break;
}
}
}
/**
* 查询任务信息

View File

@ -17,7 +17,7 @@ logging:
level:
com.blossom: debug
com.blossom.expand.tracker: info
com.blossom.admin.base.test: trace
com.blossom.backend.base.auth: info
org.springframework.boot.web.embedded.tomcat.TomcatWebServer: warn
com.baomidou.dynamic.datasource.DynamicRoutingDataSource: warn
com.zaxxer.hikari.HikariDataSource: warn

View File

@ -11,7 +11,6 @@ logging:
level:
com.blossom: info
com.blossom.expand.tracker: info
com.blossom.admin.base.test: trace
org.springframework.boot.web.embedded.tomcat.TomcatWebServer: warn
com.baomidou.dynamic.datasource.DynamicRoutingDataSource: warn
com.zaxxer.hikari.HikariDataSource: warn

View File

@ -91,6 +91,7 @@
cre_time
from blossom_todo
where todo_id = #{todoId}
and user_id = #{userId}
</select>
<select id="statisticTask" resultType="com.blossom.backend.server.todo.pojo.TodoEntity">