dao

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnswerElementTypeUnknown = iota
	AnswerElementTypeAnalysis
	AnswerElementTypeBasic
	AnswerElementTypeIntermedia
	AnswerElementTypeAdvanced
)

Variables

View Source
var (
	ErrInvalidQuestionID = errors.New("问题ID非法")
)

Functions

func InitTables

func InitTables(db *egorm.Component) error

Types

type AnswerElement

type AnswerElement struct {
	Id int64 `gorm:"primaryKey,autoIncrement"`
	// 问题 ID
	Qid int64 `gorm:"uniqueIndex:qid_type"`

	Type uint8 `gorm:"uniqueIndex:qid_type"`

	// 回答内容
	Content string

	// 关键字,辅助记忆,提取重点
	Keywords string
	// 速记,口诀
	Shorthand string

	// 亮点
	Highlight string

	// 引导点
	Guidance string

	Ctime int64
	Utime int64
}

AnswerElement 回答,对于一个问题来说,回答分成好几个部分 这个就是代表一个部分 理论上来说应该要考虑引入一个叫做 Answer 的表 但是个人觉得目前没有必要

type GORMQuestionDAO

type GORMQuestionDAO struct {
	// contains filtered or unexported fields
}

func (*GORMQuestionDAO) Count

func (g *GORMQuestionDAO) Count(ctx context.Context) (int64, error)

func (*GORMQuestionDAO) Create

func (g *GORMQuestionDAO) Create(ctx context.Context, q Question, eles []AnswerElement) (int64, error)

func (*GORMQuestionDAO) GetByID

func (g *GORMQuestionDAO) GetByID(ctx context.Context, id int64) (Question, []AnswerElement, error)

func (*GORMQuestionDAO) GetPubByID

func (*GORMQuestionDAO) GetPubByIDs added in v0.0.2

func (g *GORMQuestionDAO) GetPubByIDs(ctx context.Context, qids []int64) ([]PublishQuestion, error)

func (*GORMQuestionDAO) List

func (g *GORMQuestionDAO) List(ctx context.Context, offset int, limit int) ([]Question, error)

func (*GORMQuestionDAO) PubCount

func (g *GORMQuestionDAO) PubCount(ctx context.Context) (int64, error)

func (*GORMQuestionDAO) PubList

func (g *GORMQuestionDAO) PubList(ctx context.Context, offset int, limit int) ([]PublishQuestion, error)

func (*GORMQuestionDAO) Sync

func (g *GORMQuestionDAO) Sync(ctx context.Context, que Question, eles []AnswerElement) (int64, error)

func (*GORMQuestionDAO) Update

func (g *GORMQuestionDAO) Update(ctx context.Context, q Question, eles []AnswerElement) error

type GORMQuestionSetDAO

type GORMQuestionSetDAO struct {
	// contains filtered or unexported fields
}

func (*GORMQuestionSetDAO) Count

func (g *GORMQuestionSetDAO) Count(ctx context.Context) (int64, error)

func (*GORMQuestionSetDAO) Create

func (g *GORMQuestionSetDAO) Create(ctx context.Context, qs QuestionSet) (int64, error)

func (*GORMQuestionSetDAO) GetByID

func (g *GORMQuestionSetDAO) GetByID(ctx context.Context, id int64) (QuestionSet, error)

func (*GORMQuestionSetDAO) GetQuestionsByID

func (g *GORMQuestionSetDAO) GetQuestionsByID(ctx context.Context, id int64) ([]Question, error)

func (*GORMQuestionSetDAO) List

func (g *GORMQuestionSetDAO) List(ctx context.Context, offset, limit int) ([]QuestionSet, error)

func (*GORMQuestionSetDAO) UpdateNonZero

func (g *GORMQuestionSetDAO) UpdateNonZero(ctx context.Context, set QuestionSet) error

func (*GORMQuestionSetDAO) UpdateQuestionsByID

func (g *GORMQuestionSetDAO) UpdateQuestionsByID(ctx context.Context, id int64, qids []int64) error

type PublishAnswerElement

type PublishAnswerElement AnswerElement

type PublishQuestion

type PublishQuestion Question

type Question

type Question struct {
	Id int64 `gorm:"primaryKey,autoIncrement"`
	// 作者
	Uid int64 `gorm:"index"`

	Labels sqlx.JsonColumn[[]string] `gorm:"type:varchar(512)"`
	// 面试标题
	Title string `gorm:"type=varchar(512)"`
	// 面试题目内容
	Content string

	Ctime int64
	Utime int64 `gorm:"index"`
}

type QuestionDAO

type QuestionDAO interface {
	Update(ctx context.Context, q Question, eles []AnswerElement) error
	Create(ctx context.Context, q Question, eles []AnswerElement) (int64, error)
	GetByID(ctx context.Context, id int64) (Question, []AnswerElement, error)
	List(ctx context.Context, offset int, limit int) ([]Question, error)
	Count(ctx context.Context) (int64, error)

	Sync(ctx context.Context, que Question, eles []AnswerElement) (int64, error)

	// 线上库 API
	PubList(ctx context.Context, offset int, limit int) ([]PublishQuestion, error)
	PubCount(ctx context.Context) (int64, error)
	GetPubByID(ctx context.Context, qid int64) (PublishQuestion, []PublishAnswerElement, error)
	GetPubByIDs(ctx context.Context, qids []int64) ([]PublishQuestion, error)
}

func NewGORMQuestionDAO

func NewGORMQuestionDAO(db *egorm.Component) QuestionDAO

type QuestionSet

type QuestionSet struct {
	Id int64 `gorm:"primaryKey,autoIncrement"`
	// 所有者
	Uid int64 `gorm:"index"`
	// 题集标题
	Title string
	// 题集描述
	Description string

	Ctime int64
	Utime int64 `gorm:"index"`
}

QuestionSet 题集 属于个人

type QuestionSetDAO

type QuestionSetDAO interface {
	Create(ctx context.Context, qs QuestionSet) (int64, error)
	GetByID(ctx context.Context, id int64) (QuestionSet, error)

	GetQuestionsByID(ctx context.Context, id int64) ([]Question, error)
	UpdateQuestionsByID(ctx context.Context, id int64, qids []int64) error

	Count(ctx context.Context) (int64, error)
	List(ctx context.Context, offset, limit int) ([]QuestionSet, error)
	UpdateNonZero(ctx context.Context, set QuestionSet) error
}

func NewGORMQuestionSetDAO

func NewGORMQuestionSetDAO(db *egorm.Component) QuestionSetDAO

type QuestionSetQuestion

type QuestionSetQuestion struct {
	Id    int64 `gorm:"primaryKey,autoIncrement"`
	QSID  int64 `gorm:"uniqueIndex:qsid_qid"`
	QID   int64 `gorm:"uniqueIndex:qsid_qid"`
	Ctime int64
	Utime int64 `gorm:"index"`
}

QuestionSetQuestion 题集问题 —— 题集与题目的关联关系

Jump to

Keyboard shortcuts

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