feat(service): 增加 Markdown 文件分组名称字段
- 在 MarkdownFileVO 类中添加 groupingName 字段 - 修改 getFilesByGroupingId 和 getRecentFiles 方法返回 MarkdownFileVO 列表- 在前端 HomePage 组件中显示分组名称 - 优化后端 SQL 查询,减少不必要的查询次数
This commit is contained in:
@@ -2,10 +2,27 @@ package com.test.bijihoudaun.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.test.bijihoudaun.entity.MarkdownFile;
|
||||
import com.test.bijihoudaun.entity.MarkdownFileVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MarkdownFileMapper extends BaseMapper<MarkdownFile> {
|
||||
// 自定义方法:根据用户ID获取文件列表
|
||||
// List<MarkdownFile> findByUserId(Integer userId);
|
||||
|
||||
@Select("SELECT mf.*, g.grouping as groupingName " +
|
||||
"FROM markdown_file mf " +
|
||||
"LEFT JOIN grouping g ON mf.grouping_id = g.id " +
|
||||
"ORDER BY mf.updated_at DESC " +
|
||||
"LIMIT #{limit}")
|
||||
List<MarkdownFileVO> selectRecentWithGrouping(@Param("limit") int limit);
|
||||
|
||||
@Select("SELECT mf.*, g.grouping as groupingName " +
|
||||
"FROM markdown_file mf " +
|
||||
"LEFT JOIN grouping g ON mf.grouping_id = g.id " +
|
||||
"WHERE mf.grouping_id = #{groupingId} " +
|
||||
"ORDER BY mf.updated_at DESC")
|
||||
List<MarkdownFileVO> selectByGroupingIdWithGrouping(@Param("groupingId") String groupingId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user