dao

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRecordNotFound = gorm.ErrRecordNotFound

Functions

func InitTables

func InitTables(db *egorm.Component) error

Types

type Case

type Case struct {
	Id int64 `gorm:"primaryKey,autoIncrement"`
	// 作者
	Uid          int64 `gorm:"index"`
	Introduction string
	Labels       sqlx.JsonColumn[[]string] `gorm:"type:varchar(512)"`
	// Case 标题
	Title string `gorm:"type=varchar(512)"`
	// Case 内容
	Content string
	// 代码仓库地址
	GithubRepo string
	GiteeRepo  string
	// 关键字,辅助记忆,提取重点
	Keywords string
	// 速记,口诀
	Shorthand string
	// 亮点
	Highlight string
	// 引导点
	Guidance string
	Status   uint8  `gorm:"type:tinyint(3);comment:0-未知 1-未发表 2-已发表"`
	Biz      string `gorm:"type=varchar(256);index:biz;not null;default:'baguwen';"`
	BizId    int64  `gorm:"index:biz;not null;default:0;"`
	Ctime    int64
	Utime    int64 `gorm:"index"`
}

func (Case) TableName

func (Case) TableName() string

type CaseDAO

type CaseDAO interface {
	// 管理端操作 case表
	Save(ctx context.Context, c Case) (int64, error)
	GetCaseByID(ctx context.Context, id int64) (Case, error)
	List(ctx context.Context, offset, limit int) ([]Case, error)
	Count(ctx context.Context) (int64, error)

	Sync(ctx context.Context, c Case) (int64, error)
	// 提供给同步到知识库用
	Ids(ctx context.Context) ([]int64, error)
	// 线上库
	PublishCaseList(ctx context.Context, offset, limit int) ([]PublishCase, error)
	PublishCaseCount(ctx context.Context) (int64, error)
	GetPublishCase(ctx context.Context, caseId int64) (PublishCase, error)
	GetPubByIDs(ctx context.Context, ids []int64) ([]PublishCase, error)

	NotInTotal(ctx context.Context, ids []int64) (int64, error)
	NotIn(ctx context.Context, ids []int64, offset int, limit int) ([]Case, error)
}

func NewCaseDao

func NewCaseDao(db *egorm.Component) CaseDAO

type CaseExamineRecord added in v0.2.1

type CaseExamineRecord struct {
	Id  int64
	Uid int64
	Cid int64
	// 代表这一次测试的 ID
	// 这个主要是为了和 AI 打交道,有一个唯一凭证
	Tid    string
	Result uint8
	// 原始的 AI 回答
	RawResult string
	// 冗余字段,使用的 tokens 数量
	Tokens int64
	// 冗余字段,花费的金额
	Amount int64

	Ctime int64
	Utime int64
}

CaseExamineRecord 业务层面上记录

type CaseResult added in v0.2.1

type CaseResult struct {
	Id int64
	// 目前来看,查询至少会有一个 uid,所以我们把 uid 放在唯一索引最前面
	Uid    int64 `gorm:"uniqueIndex:uid_cid"`
	Cid    int64 `gorm:"uniqueIndex:uid_cid"`
	Result uint8
	Ctime  int64
	Utime  int64
}

CaseResult 某人是否已经回答出来了

type CaseSet added in v0.2.1

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

	Biz   string `gorm:"type=varchar(256);index:biz;not null;default:'baguwen';"`
	BizId int64  `gorm:"index:biz;not null;default:0;"`

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

type CaseSetCase added in v0.2.1

type CaseSetCase struct {
	Id    int64 `gorm:"primaryKey,autoIncrement"`
	CSID  int64 `gorm:"column:cs_id;uniqueIndex:csid_cid"`
	CID   int64 `gorm:"column:cid;uniqueIndex:csid_cid"`
	Ctime int64
	Utime int64 `gorm:"index"`
}

CaseSetCase 案例集和案例的关联关系

type CaseSetDAO added in v0.2.1

type CaseSetDAO interface {
	Create(ctx context.Context, cs CaseSet) (int64, error)
	GetByID(ctx context.Context, id int64) (CaseSet, error)

	GetCasesByID(ctx context.Context, id int64) ([]Case, error)
	UpdateCasesByID(ctx context.Context, id int64, cids []int64) error

	Count(ctx context.Context) (int64, error)
	CountByBiz(ctx context.Context, biz string) (int64, error)
	List(ctx context.Context, offset, limit int) ([]CaseSet, error)
	UpdateNonZero(ctx context.Context, set CaseSet) error
	GetByIDs(ctx context.Context, ids []int64) ([]CaseSet, error)

	ListByBiz(ctx context.Context, offset int, limit int, biz string) ([]CaseSet, error)
	GetByBiz(ctx context.Context, biz string, bizId int64) (CaseSet, error)
	GetRefCasesByIDs(ctx context.Context, ids []int64) ([]CaseSetCase, error)
}

func NewCaseSetDAO added in v0.2.1

func NewCaseSetDAO(db *egorm.Component) CaseSetDAO

type ExamineDAO added in v0.2.1

type ExamineDAO interface {
	SaveResult(ctx context.Context, record CaseExamineRecord) error
	GetResultByUidAndCid(ctx context.Context, uid int64, cid int64) (CaseResult, error)
	GetResultByUidAndCids(ctx context.Context, uid int64, cids []int64) ([]CaseResult, error)
}

func NewGORMExamineDAO added in v0.2.1

func NewGORMExamineDAO(db *egorm.Component) ExamineDAO

type GORMExamineDAO added in v0.2.1

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

func (*GORMExamineDAO) GetResultByUidAndCid added in v0.2.1

func (dao *GORMExamineDAO) GetResultByUidAndCid(ctx context.Context, uid int64, cid int64) (CaseResult, error)

func (*GORMExamineDAO) GetResultByUidAndCids added in v0.2.1

func (dao *GORMExamineDAO) GetResultByUidAndCids(ctx context.Context, uid int64, cids []int64) ([]CaseResult, error)

func (*GORMExamineDAO) SaveResult added in v0.2.1

func (dao *GORMExamineDAO) SaveResult(ctx context.Context, record CaseExamineRecord) error

type PublishCase

type PublishCase Case

func (PublishCase) TableName

func (PublishCase) TableName() string

Jump to

Keyboard shortcuts

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