feat: add getTaskReview API endpoint for fetching all reports and fragments by task number
This commit is contained in:
@@ -32,6 +32,14 @@ public class ReviewController {
|
|||||||
return CommonResult.success(reviewService.getReviewFeed(limit));
|
return CommonResult.success(reviewService.getReviewFeed(limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定任务下的所有报告和残片
|
||||||
|
*/
|
||||||
|
@GetMapping("/task/{taskNum}")
|
||||||
|
public CommonResult<List<ReviewFeedItem>> getTaskReview(@PathVariable String taskNum) {
|
||||||
|
return CommonResult.success(reviewService.getTaskReview(taskNum));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取报告详情
|
* 获取报告详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,4 +16,9 @@ public interface ReviewMapper {
|
|||||||
* 获取最近的学习报告和残片,合并排序后返回
|
* 获取最近的学习报告和残片,合并排序后返回
|
||||||
*/
|
*/
|
||||||
List<ReviewFeedItem> selectReviewFeed(@Param("limit") int limit);
|
List<ReviewFeedItem> selectReviewFeed(@Param("limit") int limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定任务下的所有报告和残片,按时间倒序
|
||||||
|
*/
|
||||||
|
List<ReviewFeedItem> selectTaskReview(@Param("taskNum") String taskNum);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ public interface ReviewService {
|
|||||||
*/
|
*/
|
||||||
List<ReviewFeedItem> getReviewFeed(int limit);
|
List<ReviewFeedItem> getReviewFeed(int limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定任务下的所有报告和残片
|
||||||
|
*/
|
||||||
|
List<ReviewFeedItem> getTaskReview(String taskNum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取报告详情
|
* 获取报告详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ public class ReviewServiceImpl implements ReviewService {
|
|||||||
return reviewMapper.selectReviewFeed(limit);
|
return reviewMapper.selectReviewFeed(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ReviewFeedItem> getTaskReview(String taskNum) {
|
||||||
|
return reviewMapper.selectTaskReview(taskNum);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StudyReportsEntity getReportDetail(int id) throws NotFindEntitiesException {
|
public StudyReportsEntity getReportDetail(int id) throws NotFindEntitiesException {
|
||||||
return Optional.ofNullable(studyReportsMapper.selectById(id))
|
return Optional.ofNullable(studyReportsMapper.selectById(id))
|
||||||
|
|||||||
@@ -28,4 +28,28 @@
|
|||||||
LIMIT #{limit}
|
LIMIT #{limit}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectTaskReview" resultType="com.guo.learningprogresstracker.dto.ReviewFeedItem">
|
||||||
|
SELECT
|
||||||
|
combined.id,
|
||||||
|
combined.session_num AS sessionNum,
|
||||||
|
combined.source_type AS sourceType,
|
||||||
|
combined.content,
|
||||||
|
combined.created_time AS createdTime,
|
||||||
|
t.task_num AS taskNum,
|
||||||
|
t.task_name AS taskName
|
||||||
|
FROM (
|
||||||
|
SELECT r.id, r.session_num, r.content, r.created_time, 'REPORT' AS source_type
|
||||||
|
FROM study_reports r
|
||||||
|
WHERE r.deleted = 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT f.id, f.session_num, f.content, f.created_time, 'FRAGMENT' AS source_type
|
||||||
|
FROM study_report_fragments f
|
||||||
|
WHERE f.deleted = 0
|
||||||
|
) combined
|
||||||
|
JOIN study_sessions ss ON combined.session_num = ss.session_num AND ss.deleted = 0
|
||||||
|
JOIN tasks t ON ss.task_num = t.task_num AND t.deleted = 0
|
||||||
|
WHERE t.task_num = #{taskNum}
|
||||||
|
ORDER BY combined.created_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user