feat: 新增标签导图列表接口

This commit is contained in:
2026-10-22 21:59:40 +08:00
parent a0a35faec8
commit 05939e3f08
6 changed files with 188 additions and 0 deletions
@@ -1,5 +1,7 @@
package com.guo.learningprogresstracker.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guo.learningprogresstracker.dto.TagMindMapSummary;
import com.guo.learningprogresstracker.dto.TagMindMapView;
import com.guo.learningprogresstracker.dto.TagScope;
import com.guo.learningprogresstracker.dto.request.TagScopeRequest;
@@ -56,6 +58,19 @@ public class TagMindMapController {
return CommonResult.success(reviewTagMindMapService.updateByOutline(scope, request.getOutline()));
}
/**
* 分页列出已经生成过导图的标签范围:「按标签复习」的主入口。
*
* <p>用户先看到已有导图(标签集合 + 取数模式),可直接进入复习或把新碎片补充进去,
* 不必先选标签再判断这个范围有没有导图。读取不触发生成。</p>
*/
@GetMapping("/list")
public CommonResult<Page<TagMindMapSummary>> list(
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize) {
return CommonResult.success(reviewTagMindMapService.listMaps(pageNum, pageSize));
}
/**
* 该范围的回忆对比记录(倒序,最近一次在最前);范围里没有记录时返回空列表。
*/
@@ -0,0 +1,46 @@
package com.guo.learningprogresstracker.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
* 已有标签导图的摘要(闭环-04):用于「已生成的标签导图」列表。
*
* <p>列表是「按标签复习」的主入口:用户先看到已经生成过导图的标签集合,
* 直接进入复习或把新碎片补充进去,不必先选标签再判断这个范围有没有导图。
* 导图生成后标签集合一般不再变化,因此列表只读地还原 {@code tags + mode},
* 前端可直接用它们发起复查或增量生成(与 {@code scopeKey} 一一对应)。</p>
*/
@Data
public class TagMindMapSummary {
@Schema(description = "标签导图 ID")
private Integer id;
@Schema(description = "范围键:标签集合与取数模式的稳定哈希,同时作为 AI 任务的 targetNum")
private String scopeKey;
@Schema(description = "范围的标签集合(展示用,按归一化名排序)")
private List<String> tags;
@Schema(description = "取数模式:UNION=并集 / INTERSECT=交集")
private String mode;
@Schema(description = "导图标题")
private String title;
@Schema(description = "生成来源:BUILTIN/AI/USER/USER_MERGE")
private String generator;
@Schema(description = "取材的碎片数量")
private Integer sourceFragmentCount;
@Schema(description = "素材变化后置 true:有新碎片待整理,重建由用户手动触发")
private Boolean needsUpdate;
@Schema(description = "导图生成时间")
private LocalDateTime generatedTime;
}
@@ -2,9 +2,11 @@ package com.guo.learningprogresstracker.service;
import com.guo.learningprogresstracker.dto.RecallCompareOutcome;
import com.guo.learningprogresstracker.dto.ReviewTiming;
import com.guo.learningprogresstracker.dto.TagMindMapSummary;
import com.guo.learningprogresstracker.dto.TagMindMapView;
import com.guo.learningprogresstracker.dto.TagScope;
import com.guo.learningprogresstracker.entity.ReviewRecallRecordEntity;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guo.learningprogresstracker.entity.ReviewTagMindMapEntity;
import com.guo.learningprogresstracker.exception.ErrorParameterException;
import com.guo.learningprogresstracker.exception.NotFindEntitiesException;
@@ -40,6 +42,14 @@ public interface ReviewTagMindMapService {
*/
TagMindMapView query(TagScope scope);
/**
* 分页列出当前用户已经生成过导图的标签范围(待更新优先,其次按生成时间倒序)。
*
* <p>「按标签复习」的主入口:用户先看到已经生成过导图的标签集合,
* 直接进入复习或把新碎片补充进去,不必先选标签再判断这个范围有没有导图。</p>
*/
Page<TagMindMapSummary> listMaps(int pageNum, int pageSize);
/**
* 用户手动编辑标签导图(用缩进大纲文本替换);该范围还没有导图时保存即为新建。
*/
@@ -123,6 +123,41 @@ public class ReviewTagMindMapServiceImpl implements ReviewTagMindMapService {
.orderByDesc(ReviewRecallRecordEntity::getCreatedTime));
}
// ============ 列表 ============
@Override
public Page<TagMindMapSummary> listMaps(int pageNum, int pageSize) {
// 待更新的导图排在前面(新碎片已经等着被整理),其余按生成时间倒序;
// id 兜底:生成时间相同的导图之间要有稳定次序,否则翻页会重复或漏掉
Page<ReviewTagMindMapEntity> page = tagMindMapMapper.selectPage(
new Page<>(pageNum, pageSize),
Wrappers.<ReviewTagMindMapEntity>lambdaQuery()
.orderByDesc(ReviewTagMindMapEntity::getNeedsUpdate)
.orderByDesc(ReviewTagMindMapEntity::getGeneratedTime)
.orderByDesc(ReviewTagMindMapEntity::getId));
Page<TagMindMapSummary> result = new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
result.setRecords(page.getRecords().stream()
.map(ReviewTagMindMapServiceImpl::toSummary)
.toList());
return result;
}
/** 列表项只还原只读状态:标签集合按范围名回读,供前端直接展示与复用 */
private static TagMindMapSummary toSummary(ReviewTagMindMapEntity entity) {
TagMindMapSummary summary = new TagMindMapSummary();
summary.setId(entity.getId());
summary.setScopeKey(entity.getScopeKey());
summary.setTags(TagScopeTool.parseStoredTags(entity.getTagNames()));
summary.setMode(entity.getCombineMode());
summary.setTitle(entity.getTitle());
summary.setGenerator(entity.getGenerator());
summary.setSourceFragmentCount(entity.getSourceFragmentCount());
summary.setNeedsUpdate(Boolean.TRUE.equals(entity.getNeedsUpdate()));
summary.setGeneratedTime(entity.getGeneratedTime());
return summary;
}
// ============ 用户编辑 ============
@Override