Help us shape the future of Go! Take the 2026 Go Developer Survey

reader

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeKnown         = "known"         // 读者已知的信息
	TypeSuspense      = "suspense"      // 读者等待解答的悬念
	TypeMisconception = "misconception" // 读者误以为的情况(用于反转)
)

PerspectiveType 定义读者认知条目的类型。

Variables

This section is empty.

Functions

This section is empty.

Types

type ListByNovelOptions

type ListByNovelOptions struct {
	PageParams storage.PageParams
	Search     string // 空字符串=不过滤,按 content LIKE OR related_truth LIKE 模糊匹配
	Type       string // 空字符串=不过滤,"known"/"suspense"/"misconception"
	Order      string // 空字符串=默认 type, planted_chapter_id ASC
}

ListByNovelOptions 是 ListByNovel 的可选参数。

type ReaderPerspective

type ReaderPerspective struct {
	ID                int64     `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	NovelID           int64     `gorm:"column:novel_id;not null;index"      json:"novel_id"`
	Type              string    `gorm:"column:type;not null;index"          json:"type"`                    // "known" | "suspense" | "misconception"
	Content           string    `gorm:"column:content;not null"             json:"content"`                 // 条目内容:读者知道/想知道/误以为的事情
	RelatedTruth      string    `gorm:"column:related_truth"                json:"related_truth"`           // 作者视角:真实情况。所有类型可选,不只是 misconception
	PlantedChapterID  *int64    `gorm:"column:planted_chapter_id;index"        json:"planted_chapter_id"`   // 在哪章种下;nil 表示历史记录无法关联章节
	RevealedChapterID *int64    `gorm:"column:revealed_chapter_id;index"        json:"revealed_chapter_id"` // 在哪章回收,nil=未回收
	CreatedAt         time.Time `gorm:"column:created_at;autoCreateTime"    json:"created_at"`
}

ReaderPerspective 是读者认知条目,追踪"读者知道什么、在等什么答案、误以为是什么"。

三种类型驱动不同的查询和格式化行为:

  • known:全量返回,不过滤 revealed_chapter
  • suspense/misconception:只返回 revealed_chapter=0(未回收)的条目
  • 格式化时分三段输出:已知信息 / 活跃悬念 / 读者误知

字段精简:Python 9 字段直接平移,无删减。

related_truth 是作者全知视角——不仅 misconception,所有类型都可记录真相。 "谁杀了村长"是悬念,答案作者心里应该有数。

func (ReaderPerspective) TableName

func (ReaderPerspective) TableName() string

TableName 指定 GORM 表名。

type Store

type Store struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

Store 管理 ReaderPerspective 持久化。DB 导出供调用方做简单 CRUD。

func NewStore

func NewStore(db *gorm.DB, logger *slog.Logger) *Store

NewStore 创建 reader 存储。

func (*Store) ChapterDeletionBlockers added in v1.6.0

func (s *Store) ChapterDeletionBlockers(ctx context.Context, novelID, chapterID int64) ([]deletion.Blocker, error)

ChapterDeletionBlockers 返回引用指定章节的读者认知条目。

func (*Store) ListActive

func (s *Store) ListActive(ctx context.Context, novelID int64) ([]ReaderPerspective, error)

ListActive 返回全部未回收(revealed_chapter=0)的读者认知条目。 全量返回——活跃集合天然小,context builder 和 MCP 工具需要完整快照。

func (*Store) ListByNovel

func (s *Store) ListByNovel(ctx context.Context, novelID int64, opts ListByNovelOptions) (*storage.PageResult[ReaderPerspective], error)

ListByNovel 分页列出某小说的读者认知条目,支持搜索和按类型过滤。 前端全量拉取(Size=-1)和全局搜索复用。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL