diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/todo/TodoMapper.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/todo/TodoMapper.java index 701d6b2..d224497 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/todo/TodoMapper.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/todo/TodoMapper.java @@ -54,7 +54,7 @@ public interface TodoMapper extends BaseMapper { * * @param todoId todoid */ - List listTask(@Param("todoId") String todoId); + List listTask(@Param("userId") Long userId, @Param("todoId") String todoId); /** * 事项统计信息 diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/todo/TodoService.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/todo/TodoService.java index 787e75c..c013ab0 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/todo/TodoService.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/todo/TodoService.java @@ -111,7 +111,7 @@ public class TodoService extends ServiceImpl { * @param todoId todoId, 每日待办事项, 则 todoId 为 yyyy-MM-dd 格式, 如果是阶段性事项, 则为字符串ID */ public TaskRes listTask(String todoId) { - List tasks = baseMapper.listTask(todoId); + List tasks = baseMapper.listTask(AuthContext.getUserId(), todoId); if (CollUtil.isEmpty(tasks)) { return TaskRes.build(); } @@ -144,12 +144,43 @@ public class TodoService extends ServiceImpl { // 今日中午12点 Date noon = DateUtils.parse(todoId + " 12:00:00", DateUtils.PATTERN_YYYYMMDDHHMMSS); List processing = res.getProcessing(); - addNoon(noon, processing); + addDateDivider(noon, processing, TaskStatusEnum.PROCESSING); List completed = res.getCompleted(); - addNoon(noon, completed); + addDateDivider(noon, completed, TaskStatusEnum.COMPLETED); return res; } + /** + * 添加时间分割节点, 只有每日待办事项具有分割节点 + * + * @param divideDate 分割的日期, 注意 + * @param tasks 任务列表 + */ + private void addDateDivider(Date divideDate, List 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 { return baseMapper.count(todoId); } - /** - * 添加中午12点的分割节点 - * - * @param noon 中午的日期 - * @param tasks 任务列表 - */ - private void addNoon(Date noon, List 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; - } - } - } /** * 查询任务信息 diff --git a/blossom-backend/backend/src/main/resources/config/application-dev.yml b/blossom-backend/backend/src/main/resources/config/application-dev.yml index 1dafd78..8d959d8 100644 --- a/blossom-backend/backend/src/main/resources/config/application-dev.yml +++ b/blossom-backend/backend/src/main/resources/config/application-dev.yml @@ -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 diff --git a/blossom-backend/backend/src/main/resources/config/application-prod.yml b/blossom-backend/backend/src/main/resources/config/application-prod.yml index 71fee09..f073037 100644 --- a/blossom-backend/backend/src/main/resources/config/application-prod.yml +++ b/blossom-backend/backend/src/main/resources/config/application-prod.yml @@ -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 diff --git a/blossom-backend/backend/src/main/resources/mapper/TodoMapper.xml b/blossom-backend/backend/src/main/resources/mapper/TodoMapper.xml index bd35c5d..9a5911c 100644 --- a/blossom-backend/backend/src/main/resources/mapper/TodoMapper.xml +++ b/blossom-backend/backend/src/main/resources/mapper/TodoMapper.xml @@ -91,6 +91,7 @@ cre_time from blossom_todo where todo_id = #{todoId} + and user_id = #{userId}