Documentation
¶
Index ¶
- type Chapter
- type ListByNovelOptions
- type Store
- func (s *Store) GetByNovelAndNumber(ctx context.Context, novelID int64, chapterNumber int) (*Chapter, error)
- func (s *Store) GetLatestNumber(ctx context.Context, novelID int64) (int, error)
- func (s *Store) GetRecent(ctx context.Context, novelID int64, limit int) ([]Chapter, error)
- func (s *Store) ListAllByNovel(ctx context.Context, novelID int64) ([]Chapter, error)
- func (s *Store) ListByNovel(ctx context.Context, novelID int64, opts ListByNovelOptions) (*storage.PageResult[Chapter], error)
- func (s *Store) SearchByNovel(ctx context.Context, novelID int64, query string, limit int) ([]Chapter, error)
- func (s *Store) UpdateTitle(ctx context.Context, novelID int64, chapterNumber int, title string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chapter ¶
type Chapter struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
NovelID int64 `gorm:"column:novel_id;not null;uniqueIndex:uk_novel_chapter;index" json:"novel_id"`
ChapterNumber int `gorm:"column:chapter_number;not null;uniqueIndex:uk_novel_chapter" json:"chapter_number"`
Title string `gorm:"column:title" json:"title"`
Summary string `gorm:"column:summary" json:"summary"` // AI 生成的章节简介
WordCount int `gorm:"column:word_count;default:0" json:"word_count"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
FilePath string `gorm:"-" json:"file_path"` // 不存 DB,由 git.ChapterPath 计算
}
Chapter 是章节元数据,正文和大纲以文件形式存储在 Git 仓库中。 DB 仅保存索引和统计信息,不存实际内容。
type ListByNovelOptions ¶
type ListByNovelOptions struct {
PageParams storage.PageParams
Order string // "asc"(默认) 或 "desc",按 chapter_number 排序
}
ListByNovelOptions 是 ListByNovel 的可选参数。零值即可直接使用(默认升序)。
type Store ¶
Store 管理 Chapter 持久化。DB 导出供调用方做简单 CRUD。
func (*Store) GetByNovelAndNumber ¶
func (s *Store) GetByNovelAndNumber(ctx context.Context, novelID int64, chapterNumber int) (*Chapter, error)
GetByNovelAndNumber 按 novel_id + chapter_number 取单章。
func (*Store) GetLatestNumber ¶
GetLatestNumber 返回该小说当前最大的章节编号,无章节时返回 0。
func (*Store) ListAllByNovel ¶
ListAllByNovel 返回某小说的全部章节(不分页),按 chapter_number 升序。
func (*Store) ListByNovel ¶
func (s *Store) ListByNovel(ctx context.Context, novelID int64, opts ListByNovelOptions) (*storage.PageResult[Chapter], error)
ListByNovel 分页列出某小说的章节。
Click to show internal directories.
Click to hide internal directories.