data

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Expiration          = 5 * 24 * time.Hour
	RecycleExpiration   = 2 * 30 * 24 * time.Hour
	BlackListExpiration = 1 * time.Minute
)
View Source
const RedisNull = "redis_Null"

Variables

ProviderSet is data providers.

Functions

func NewDB

func NewDB(c *conf.Data, logfile *os.File) *gorm.DB

NewDB 连接mysql数据库

func NewRedisDB

func NewRedisDB(c *conf.Data) *redis.Client

NewRedisDB 连接redis

func NewTransaction

func NewTransaction(d *Data) biz.Transaction

NewTransaction .

Types

type ClassInfoCacheRepo

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

func NewClassInfoCacheRepo

func NewClassInfoCacheRepo(rdb *redis.Client, logger classLog.Clogger) *ClassInfoCacheRepo

func (ClassInfoCacheRepo) AddClaInfosToCache

func (c ClassInfoCacheRepo) AddClaInfosToCache(ctx context.Context, key string, classInfos []*model.ClassInfo) error

AddClaInfosToCache 将整个课表转换成json格式,然后存到缓存中去

func (ClassInfoCacheRepo) DeleteClassInfoFromCache

func (c ClassInfoCacheRepo) DeleteClassInfoFromCache(ctx context.Context, classInfosKey ...string) error

func (ClassInfoCacheRepo) GetClassInfosFromCache

func (c ClassInfoCacheRepo) GetClassInfosFromCache(ctx context.Context, key string) ([]*model.ClassInfo, error)

type ClassInfoDBRepo

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

func NewClassInfoDBRepo

func NewClassInfoDBRepo(data *Data, logger classLog.Clogger) *ClassInfoDBRepo

func (ClassInfoDBRepo) AddClassInfoToDB

func (c ClassInfoDBRepo) AddClassInfoToDB(ctx context.Context, classInfo *model.ClassInfo) error

func (ClassInfoDBRepo) DeleteClassInfoInDB

func (c ClassInfoDBRepo) DeleteClassInfoInDB(ctx context.Context, ID string) error

func (ClassInfoDBRepo) GetClassInfoFromDB

func (c ClassInfoDBRepo) GetClassInfoFromDB(ctx context.Context, ID string) (*model.ClassInfo, error)

func (ClassInfoDBRepo) GetClassInfos

func (c ClassInfoDBRepo) GetClassInfos(ctx context.Context, stuId, xnm, xqm string) ([]*model.ClassInfo, error)

func (ClassInfoDBRepo) SaveClassInfosToDB

func (c ClassInfoDBRepo) SaveClassInfosToDB(ctx context.Context, classInfos []*model.ClassInfo) error

func (ClassInfoDBRepo) UpdateClassInfoInDB

func (c ClassInfoDBRepo) UpdateClassInfoInDB(ctx context.Context, classInfo *model.ClassInfo) error

type Data

type Data struct {
	Mysql *gorm.DB
}

Data .

func NewData

func NewData(c *conf.Data, mysqlDB *gorm.DB, logger log.Logger) (*Data, func(), error)

NewData .

func (*Data) DB

func (d *Data) DB(ctx context.Context) *gorm.DB

DB 在事务执行ORM操作的话 得需要使用这个方法获取tx!

func (*Data) InTx

func (d *Data) InTx(ctx context.Context, fn func(ctx context.Context) error) error

type JxbDBRepo

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

func NewJxbDBRepo

func NewJxbDBRepo(data *Data, logger classLog.Clogger) *JxbDBRepo

func (*JxbDBRepo) FindStuIdsByJxbId

func (j *JxbDBRepo) FindStuIdsByJxbId(ctx context.Context, jxbId string) ([]string, error)

func (*JxbDBRepo) SaveJxb

func (j *JxbDBRepo) SaveJxb(ctx context.Context, stuID string, jxbID []string) error

type StudentAndCourseCacheRepo

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

func NewStudentAndCourseCacheRepo

func NewStudentAndCourseCacheRepo(rdb *redis.Client, logger classLog.Clogger) *StudentAndCourseCacheRepo

func (StudentAndCourseCacheRepo) CheckRecycleIdIsExist

func (s StudentAndCourseCacheRepo) CheckRecycleIdIsExist(ctx context.Context, RecycledBinKey, classId string) bool

func (StudentAndCourseCacheRepo) GetRecycledClassIds

func (s StudentAndCourseCacheRepo) GetRecycledClassIds(ctx context.Context, key string) ([]string, error)

func (StudentAndCourseCacheRepo) RecycleClassId

func (s StudentAndCourseCacheRepo) RecycleClassId(ctx context.Context, recycleBinKey string, classId ...string) error

func (StudentAndCourseCacheRepo) RemoveClassFromRecycledBin

func (s StudentAndCourseCacheRepo) RemoveClassFromRecycledBin(ctx context.Context, RecycledBinKey, classId string) error

type StudentAndCourseDBRepo

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

func NewStudentAndCourseDBRepo

func NewStudentAndCourseDBRepo(data *Data, logger classLog.Clogger) *StudentAndCourseDBRepo

func (StudentAndCourseDBRepo) CheckExists

func (s StudentAndCourseDBRepo) CheckExists(ctx context.Context, xnm, xqm, stuId, classId string) bool

func (StudentAndCourseDBRepo) DeleteStudentAndCourseInDB

func (s StudentAndCourseDBRepo) DeleteStudentAndCourseInDB(ctx context.Context, stuID, year, semester string, claID []string) error

func (StudentAndCourseDBRepo) GetClassNum

func (s StudentAndCourseDBRepo) GetClassNum(ctx context.Context, stuID, year, semester string, isManuallyAdded bool) (num int64, err error)

func (StudentAndCourseDBRepo) SaveManyStudentAndCourseToDB

func (s StudentAndCourseDBRepo) SaveManyStudentAndCourseToDB(ctx context.Context, scs []*model.StudentCourse) error

func (StudentAndCourseDBRepo) SaveStudentAndCourseToDB

func (s StudentAndCourseDBRepo) SaveStudentAndCourseToDB(ctx context.Context, sc *model.StudentCourse) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳