feat(service): 增加 Markdown 文件分组名称字段
- 在 MarkdownFileVO 类中添加 groupingName 字段 - 修改 getFilesByGroupingId 和 getRecentFiles 方法返回 MarkdownFileVO 列表- 在前端 HomePage 组件中显示分组名称 - 优化后端 SQL 查询,减少不必要的查询次数
This commit is contained in:
@@ -2,6 +2,7 @@ package com.test.bijihoudaun.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.test.bijihoudaun.entity.MarkdownFile;
|
||||
import com.test.bijihoudaun.entity.MarkdownFileVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,7 +27,7 @@ public interface MarkdownFileService extends IService<MarkdownFile> {
|
||||
* @param groupingId 分组ID
|
||||
* @return 文件列表
|
||||
*/
|
||||
List<MarkdownFile> getFilesByGroupingId(String groupingId);
|
||||
List<MarkdownFileVO> getFilesByGroupingId(String groupingId);
|
||||
|
||||
/**
|
||||
* 删除Markdown文件
|
||||
@@ -63,5 +64,5 @@ public interface MarkdownFileService extends IService<MarkdownFile> {
|
||||
* @param limit 数量
|
||||
* @return 文件列表
|
||||
*/
|
||||
List<MarkdownFile> getRecentFiles(int limit);
|
||||
List<MarkdownFileVO> getRecentFiles(int limit);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.test.bijihoudaun.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.test.bijihoudaun.entity.MarkdownFile;
|
||||
import com.test.bijihoudaun.entity.MarkdownFileVO;
|
||||
import com.test.bijihoudaun.mapper.MarkdownFileMapper;
|
||||
import com.test.bijihoudaun.service.MarkdownFileService;
|
||||
import com.test.bijihoudaun.util.SnowflakeIdGenerator;
|
||||
@@ -46,11 +46,8 @@ public class MarkdownFileServiceImpl
|
||||
|
||||
|
||||
@Override
|
||||
public List<MarkdownFile> getFilesByGroupingId(String groupingId) {
|
||||
QueryWrapper<MarkdownFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("grouping_id", groupingId)
|
||||
.orderByDesc("updated_at");
|
||||
return this.list(queryWrapper);
|
||||
public List<MarkdownFileVO> getFilesByGroupingId(String groupingId) {
|
||||
return markdownFileMapper.selectByGroupingIdWithGrouping(groupingId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,10 +85,7 @@ public class MarkdownFileServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MarkdownFile> getRecentFiles(int limit) {
|
||||
Page<MarkdownFile> page = new Page<>(1, limit);
|
||||
QueryWrapper<MarkdownFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("updated_at");
|
||||
return this.page(page, queryWrapper).getRecords();
|
||||
public List<MarkdownFileVO> getRecentFiles(int limit) {
|
||||
return markdownFileMapper.selectRecentWithGrouping(limit);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user