feat 历史记录

This commit is contained in:
2026-01-14 18:15:40 +08:00
parent 90dd60e6c6
commit 8b26534a15
11 changed files with 520 additions and 186 deletions

View File

@@ -20,6 +20,7 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
db: db,
Category: newCategory(db, opts...),
Question: newQuestion(db, opts...),
Record: newRecord(db, opts...),
}
}
@@ -28,6 +29,7 @@ type Query struct {
Category category
Question question
Record record
}
func (q *Query) Available() bool { return q.db != nil }
@@ -37,6 +39,7 @@ func (q *Query) clone(db *gorm.DB) *Query {
db: db,
Category: q.Category.clone(db),
Question: q.Question.clone(db),
Record: q.Record.clone(db),
}
}
@@ -53,18 +56,21 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
db: db,
Category: q.Category.replaceDB(db),
Question: q.Question.replaceDB(db),
Record: q.Record.replaceDB(db),
}
}
type queryCtx struct {
Category *categoryDo
Question *questionDo
Record *recordDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
Category: q.Category.WithContext(ctx),
Question: q.Question.WithContext(ctx),
Record: q.Record.WithContext(ctx),
}
}