feat(会话):分页查询任务的历史残片/报告接口
StudySessionsService 新增:
- getTaskFragments(taskNum, page, size, keyword) → Page<FragmentsEntity>
- getTaskReports(taskNum, page, size, keyword) → Page<ReportsEntity>
通过子查询 session_num in (select session_num from study_sessions
where task_num = ?) 实现跨 session 聚合,keyword 支持 content
字段 LIKE 搜索。接口使用 MyBatis-Plus Page 分页。
控制器新增两个 GET 端点:
- /study-sessions/tasks/{taskNum}/fragments
- /study-sessions/tasks/{taskNum}/reports
This commit is contained in:
@@ -4,8 +4,11 @@ import com.google.protobuf.ServiceException;
|
|||||||
import com.guo.learningprogresstracker.dto.request.EndedStudySessionRequest;
|
import com.guo.learningprogresstracker.dto.request.EndedStudySessionRequest;
|
||||||
import com.guo.learningprogresstracker.dto.request.UpsertExpectationRequest;
|
import com.guo.learningprogresstracker.dto.request.UpsertExpectationRequest;
|
||||||
import com.guo.learningprogresstracker.dto.response.StudySessionResponse;
|
import com.guo.learningprogresstracker.dto.response.StudySessionResponse;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.guo.learningprogresstracker.entity.CommonResult;
|
import com.guo.learningprogresstracker.entity.CommonResult;
|
||||||
import com.guo.learningprogresstracker.entity.StudyExpectationsEntity;
|
import com.guo.learningprogresstracker.entity.StudyExpectationsEntity;
|
||||||
|
import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity;
|
||||||
|
import com.guo.learningprogresstracker.entity.StudyReportsEntity;
|
||||||
import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
||||||
import com.guo.learningprogresstracker.service.StudyExpectationsService;
|
import com.guo.learningprogresstracker.service.StudyExpectationsService;
|
||||||
import com.guo.learningprogresstracker.service.impl.StudySessionsServiceImpl;
|
import com.guo.learningprogresstracker.service.impl.StudySessionsServiceImpl;
|
||||||
@@ -107,4 +110,24 @@ public class StudySessionController {
|
|||||||
public CommonResult<String> getReportDraft(@PathVariable("sessionNum") String sessionNum) throws ErrorParameterException {
|
public CommonResult<String> getReportDraft(@PathVariable("sessionNum") String sessionNum) throws ErrorParameterException {
|
||||||
return CommonResult.success("请求成功", studySessionsServiceImpl.generateReportDraft(sessionNum));
|
return CommonResult.success("请求成功", studySessionsServiceImpl.generateReportDraft(sessionNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 分页查询任务的残片历史 */
|
||||||
|
@GetMapping("/tasks/{taskNum}/fragments")
|
||||||
|
public CommonResult<Page<StudyReportFragmentsEntity>> getTaskFragments(
|
||||||
|
@PathVariable String taskNum,
|
||||||
|
@RequestParam(defaultValue = "1") int page,
|
||||||
|
@RequestParam(defaultValue = "10") int size,
|
||||||
|
@RequestParam(required = false) String keyword) {
|
||||||
|
return CommonResult.success(studySessionsServiceImpl.getTaskFragments(taskNum, page, size, keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页查询任务的报告历史 */
|
||||||
|
@GetMapping("/tasks/{taskNum}/reports")
|
||||||
|
public CommonResult<Page<StudyReportsEntity>> getTaskReports(
|
||||||
|
@PathVariable String taskNum,
|
||||||
|
@RequestParam(defaultValue = "1") int page,
|
||||||
|
@RequestParam(defaultValue = "10") int size,
|
||||||
|
@RequestParam(required = false) String keyword) {
|
||||||
|
return CommonResult.success(studySessionsServiceImpl.getTaskReports(taskNum, page, size, keyword));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ package com.guo.learningprogresstracker.service;
|
|||||||
|
|
||||||
import com.google.protobuf.ServiceException;
|
import com.google.protobuf.ServiceException;
|
||||||
import com.guo.learningprogresstracker.dto.response.StudySessionResponse;
|
import com.guo.learningprogresstracker.dto.response.StudySessionResponse;
|
||||||
|
import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity;
|
||||||
|
import com.guo.learningprogresstracker.entity.StudyReportsEntity;
|
||||||
import com.guo.learningprogresstracker.entity.StudySessionsEntity;
|
import com.guo.learningprogresstracker.entity.StudySessionsEntity;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
||||||
|
|
||||||
@@ -25,4 +29,8 @@ public interface StudySessionsService extends IService<StudySessionsEntity> {
|
|||||||
void pauseStudySession(String sessionNum, LocalDateTime endTime) throws ErrorParameterException, ServiceException;
|
void pauseStudySession(String sessionNum, LocalDateTime endTime) throws ErrorParameterException, ServiceException;
|
||||||
|
|
||||||
void continueStudySession(String sessionNum) throws ErrorParameterException, ServiceException;
|
void continueStudySession(String sessionNum) throws ErrorParameterException, ServiceException;
|
||||||
|
|
||||||
|
Page<StudyReportFragmentsEntity> getTaskFragments(String taskNum, int page, int size, String keyword);
|
||||||
|
|
||||||
|
Page<StudyReportsEntity> getTaskReports(String taskNum, int page, int size, String keyword);
|
||||||
}
|
}
|
||||||
|
|||||||
+27
@@ -1,6 +1,7 @@
|
|||||||
package com.guo.learningprogresstracker.service.impl;
|
package com.guo.learningprogresstracker.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.google.protobuf.ServiceException;
|
import com.google.protobuf.ServiceException;
|
||||||
import com.guo.learningprogresstracker.dto.StudySessionsDto;
|
import com.guo.learningprogresstracker.dto.StudySessionsDto;
|
||||||
@@ -190,4 +191,30 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
|||||||
.orElseGet(() -> String.join("\n", fragments));
|
.orElseGet(() -> String.join("\n", fragments));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============ 分页查询任务的历史残片/报告 ============
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<StudyReportFragmentsEntity> getTaskFragments(String taskNum, int page, int size, String keyword) {
|
||||||
|
Page<StudyReportFragmentsEntity> pg = new Page<>(page, size);
|
||||||
|
var wrapper = Wrappers.lambdaQuery(StudyReportFragmentsEntity.class)
|
||||||
|
.apply("session_num in (select session_num from study_sessions where task_num = {0})", taskNum)
|
||||||
|
.orderByDesc(StudyReportFragmentsEntity::getCreatedTime);
|
||||||
|
if (keyword != null && !keyword.isBlank()) {
|
||||||
|
wrapper.like(StudyReportFragmentsEntity::getContent, keyword);
|
||||||
|
}
|
||||||
|
return studyReportFragmentsMapper.selectPage(pg, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<StudyReportsEntity> getTaskReports(String taskNum, int page, int size, String keyword) {
|
||||||
|
Page<StudyReportsEntity> pg = new Page<>(page, size);
|
||||||
|
var wrapper = Wrappers.lambdaQuery(StudyReportsEntity.class)
|
||||||
|
.apply("session_num in (select session_num from study_sessions where task_num = {0})", taskNum)
|
||||||
|
.orderByDesc(StudyReportsEntity::getCreatedTime);
|
||||||
|
if (keyword != null && !keyword.isBlank()) {
|
||||||
|
wrapper.like(StudyReportsEntity::getContent, keyword);
|
||||||
|
}
|
||||||
|
return studyReportsMapper.selectPage(pg, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user