Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateClassInfoKey(classId string) string
- func GenerateClassInfosKey(stuId, xnm, xqm string) string
- func GenerateRecycleSetName(stuId, xnm, xqm string) string
- func GenerateSCID(stuId, classId, xnm, xqm string) string
- func GenerateScSetName(stuId, xnm, xqm string) string
- type Class
- type ClassCrawler
- type ClassInfo
- type ClassInfoCacheRepo
- type ClassInfoDBRepo
- type ClassInfoRepo
- type ClassRepo
- func (cla ClassRepo) AddClass(ctx context.Context, classInfo *ClassInfo, sc *StudentCourse, xnm, xqm string) error
- func (cla ClassRepo) CheckClassIdIsInRecycledBin(ctx context.Context, stuId, xnm, xqm, classId string) bool
- func (cla ClassRepo) CheckSCIdsExist(ctx context.Context, stuId, classId, xnm, xqm string) bool
- func (cla ClassRepo) DeleteClass(ctx context.Context, classId string, stuId string, xnm string, xqm string) error
- func (cla ClassRepo) GetAllClasses(ctx context.Context, stuId, xnm, xqm string) ([]*ClassInfo, error)
- func (cla ClassRepo) GetAllSchoolClassInfos(ctx context.Context, xnm, xqm string) []*ClassInfo
- func (cla ClassRepo) GetRecycledIds(ctx context.Context, stuId, xnm, xqm string) ([]string, error)
- func (cla ClassRepo) GetSpecificClassInfo(ctx context.Context, classId string) (*ClassInfo, error)
- func (cla ClassRepo) RemoveClassFromRecycledBin(ctx context.Context, stuId, xnm, xqm, classId string) error
- func (cla ClassRepo) SaveClasses(ctx context.Context, stuId, xnm, xqm string, claInfos []*ClassInfo, ...) error
- func (cla ClassRepo) UpdateClass(ctx context.Context, newClassInfo *ClassInfo, newSc *StudentCourse, ...) error
- type ClassRepoProxy
- type ClassUsercase
- func (cluc *ClassUsercase) AddClass(ctx context.Context, stuId string, info *ClassInfo) error
- func (cluc *ClassUsercase) CheckSCIdsExist(ctx context.Context, stuId, classId, xnm, xqm string) bool
- func (cluc *ClassUsercase) DeleteClass(ctx context.Context, classId string, stuId string, xnm string, xqm string) error
- func (cluc *ClassUsercase) GetAllSchoolClassInfosToOtherService(ctx context.Context, xnm, xqm string) []*ClassInfo
- func (cluc *ClassUsercase) GetClasses(ctx context.Context, StuId string, week int64, xnm, xqm string, cookie string) ([]*Class, error)
- func (cluc *ClassUsercase) GetRecycledClassInfos(ctx context.Context, stuId, xnm, xqm string) ([]*ClassInfo, error)
- func (cluc *ClassUsercase) RecoverClassInfo(ctx context.Context, stuId, xnm, xqm, classId string) error
- func (cluc *ClassUsercase) SearchClass(ctx context.Context, classId string) (*ClassInfo, error)
- func (cluc *ClassUsercase) UpdateClass(ctx context.Context, newClassInfo *ClassInfo, newSc *StudentCourse, ...) error
- type StudentAndCourseCacheRepo
- type StudentAndCourseDBRepo
- type StudentAndCourseRepo
- type StudentCourse
- type Transaction
Constants ¶
View Source
const ( ClassInfoTableName string = "class_info" StudentCourseTableName string = "student_course" )
Variables ¶
View Source
var ProviderSet = wire.NewSet(NewClassUsercase, NewClassInfoRepo, NewStudentAndCourseRepo, NewClassRepo)
ProviderSet is biz providers.
Functions ¶
func GenerateClassInfoKey ¶
func GenerateClassInfosKey ¶
func GenerateRecycleSetName ¶
func GenerateSCID ¶
func GenerateScSetName ¶
Types ¶
type ClassCrawler ¶
type ClassCrawler interface { GetClassInfosForUndergraduate(ctx context.Context, cookie string, xnm, xqm string) ([]*ClassInfo, []*StudentCourse, error) GetClassInfoForGraduateStudent(ctx context.Context, cookie string, xnm, xqm string) ([]*ClassInfo, []*StudentCourse, error) }
ClassCrawler 课程爬虫接口
type ClassInfo ¶
type ClassInfo struct { ID string `gorm:"primaryKey;column:id" json:"id"` //集合了课程信息的字符串,便于标识(课程ID) CreatedAt time.Time UpdatedAt time.Time //ClassId string `gorm:"column:class_id" json:"class_id"` //课程编号 Day int64 `gorm:"column:day;not null" json:"day"` //星期几 Teacher string `gorm:"column:teacher;not null" json:"teacher"` //任课教师 Where string `gorm:"column:where;not null" json:"where"` //上课地点 ClassWhen string `gorm:"column:class_when;not null" json:"class_when"` //上课是第几节(如1-2,3-4) WeekDuration string `gorm:"column:week_duration;not null" json:"week_duration"` //上课的周数 Classname string `gorm:"column:class_name;not null" json:"classname"` //课程名称 Credit float64 `gorm:"column:credit;default:1.0" json:"credit"` //学分 Weeks int64 `gorm:"column:weeks;not null" json:"weeks"` //哪些周 Semester string `gorm:"column:semester;not null;index" json:"semester"` //学期 Year string `gorm:"column:year;not null;index" json:"year"` //学年 }
func (*ClassInfo) SearchWeek ¶
type ClassInfoCacheRepo ¶
type ClassInfoCacheRepo interface { SaveManyClassInfosToCache(ctx context.Context, keys []string, classInfos []*ClassInfo) error OnlyAddClassInfoToCache(ctx context.Context, key string, classInfo *ClassInfo) error OnlyAddClassInfosToCache(ctx context.Context, key string, classInfos []*ClassInfo) error AddClassInfoToCache(ctx context.Context, classInfoKey, classInfosKey string, classInfo *ClassInfo) error GetClassInfoFromCache(ctx context.Context, key string) (*ClassInfo, error) GetClassInfosFromCache(ctx context.Context, key string) ([]*ClassInfo, error) DeleteClassInfoFromCache(ctx context.Context, deletedId, classInfosKey string) error FixClassInfoInCache(ctx context.Context, oldID, classInfoKey, classInfosKey string, classInfo *ClassInfo) error }
type ClassInfoDBRepo ¶
type ClassInfoDBRepo interface { SaveClassInfosToDB(ctx context.Context, classInfo []*ClassInfo) error AddClassInfoToDB(ctx context.Context, classInfo *ClassInfo) error GetClassInfoFromDB(ctx context.Context, ID string) (*ClassInfo, error) DeleteClassInfoInDB(ctx context.Context, ID string) error GetAllClassInfos(ctx context.Context, xnm, xqm string) ([]*ClassInfo, error) }
type ClassInfoRepo ¶
type ClassInfoRepo struct { DB ClassInfoDBRepo Cache ClassInfoCacheRepo }
func NewClassInfoRepo ¶
func NewClassInfoRepo(DB ClassInfoDBRepo, Cache ClassInfoCacheRepo) *ClassInfoRepo
type ClassRepo ¶
type ClassRepo struct { ClaRepo *ClassInfoRepo Sac *StudentAndCourseRepo TxCtrl Transaction //控制事务的开启 // contains filtered or unexported fields }
func NewClassRepo ¶
func NewClassRepo(ClaRepo *ClassInfoRepo, TxCtrl Transaction, Sac *StudentAndCourseRepo, log log.LogerPrinter) *ClassRepo
func (ClassRepo) CheckClassIdIsInRecycledBin ¶
func (ClassRepo) CheckSCIdsExist ¶
func (ClassRepo) DeleteClass ¶
func (ClassRepo) GetAllClasses ¶
func (ClassRepo) GetAllSchoolClassInfos ¶
func (ClassRepo) GetRecycledIds ¶
func (ClassRepo) GetSpecificClassInfo ¶
func (ClassRepo) RemoveClassFromRecycledBin ¶
func (ClassRepo) SaveClasses ¶
func (ClassRepo) UpdateClass ¶
type ClassRepoProxy ¶
type ClassRepoProxy interface { SaveClasses(ctx context.Context, stuId, xnm, xqm string, claInfos []*ClassInfo, scs []*StudentCourse) error GetAllClasses(ctx context.Context, stuId, xnm, xqm string) ([]*ClassInfo, error) GetSpecificClassInfo(ctx context.Context, classId string) (*ClassInfo, error) AddClass(ctx context.Context, classInfo *ClassInfo, sc *StudentCourse, xnm, xqm string) error DeleteClass(ctx context.Context, classId string, stuId string, xnm string, xqm string) error GetRecycledIds(ctx context.Context, stuId, xnm, xqm string) ([]string, error) RemoveClassFromRecycledBin(ctx context.Context, stuId, xnm, xqm, classId string) error UpdateClass(ctx context.Context, newClassInfo *ClassInfo, newSc *StudentCourse, stuId, oldClassId, xnm, xqm string) error CheckSCIdsExist(ctx context.Context, stuId, classId, xnm, xqm string) bool GetAllSchoolClassInfos(ctx context.Context, xnm, xqm string) []*ClassInfo CheckClassIdIsInRecycledBin(ctx context.Context, stuId, xnm, xqm, classId string) bool }
type ClassUsercase ¶
type ClassUsercase struct { ClassRepo ClassRepoProxy Crawler ClassCrawler // contains filtered or unexported fields }
func NewClassUsercase ¶
func NewClassUsercase(classRepo ClassRepoProxy, crawler ClassCrawler, log log2.LogerPrinter) *ClassUsercase
func (*ClassUsercase) CheckSCIdsExist ¶
func (cluc *ClassUsercase) CheckSCIdsExist(ctx context.Context, stuId, classId, xnm, xqm string) bool
func (*ClassUsercase) DeleteClass ¶
func (*ClassUsercase) GetAllSchoolClassInfosToOtherService ¶
func (cluc *ClassUsercase) GetAllSchoolClassInfosToOtherService(ctx context.Context, xnm, xqm string) []*ClassInfo
func (*ClassUsercase) GetClasses ¶
func (*ClassUsercase) GetRecycledClassInfos ¶
func (*ClassUsercase) RecoverClassInfo ¶
func (cluc *ClassUsercase) RecoverClassInfo(ctx context.Context, stuId, xnm, xqm, classId string) error
func (*ClassUsercase) SearchClass ¶
func (*ClassUsercase) UpdateClass ¶
func (cluc *ClassUsercase) UpdateClass(ctx context.Context, newClassInfo *ClassInfo, newSc *StudentCourse, stuId, oldClassId, xnm, xqm string) error
type StudentAndCourseCacheRepo ¶
type StudentAndCourseCacheRepo interface { SaveManyStudentAndCourseToCache(ctx context.Context, key string, classIds []string) error AddStudentAndCourseToCache(ctx context.Context, key string, ClassId string) error GetClassIdsFromCache(ctx context.Context, key string) ([]string, error) GetRecycledClassIds(ctx context.Context, key string) ([]string, error) DeleteStudentAndCourseFromCache(ctx context.Context, key string, ClassId string) error DeleteAndRecycleClassId(ctx context.Context, deleteKey string, recycleBinKey string, classId string) error CheckExists(ctx context.Context, key string, classId string) (bool, error) CheckRecycleIdIsExist(ctx context.Context, RecycledBinKey, classId string) bool RemoveClassFromRecycledBin(ctx context.Context, RecycledBinKey, classId string) error }
type StudentAndCourseDBRepo ¶
type StudentAndCourseDBRepo interface { SaveManyStudentAndCourseToDB(ctx context.Context, scs []*StudentCourse) error SaveStudentAndCourseToDB(ctx context.Context, sc *StudentCourse) error GetClassIDsFromSCInDB(ctx context.Context, stuId, xnm, xqm string) ([]string, error) DeleteStudentAndCourseInDB(ctx context.Context, ID string) error CheckExists(ctx context.Context, xnm, xqm, stuId, classId string) bool }
type StudentAndCourseRepo ¶
type StudentAndCourseRepo struct { DB StudentAndCourseDBRepo Cache StudentAndCourseCacheRepo }
func NewStudentAndCourseRepo ¶
func NewStudentAndCourseRepo(DB StudentAndCourseDBRepo, Cache StudentAndCourseCacheRepo) *StudentAndCourseRepo
type StudentCourse ¶
type StudentCourse struct { ID string `gorm:"primaryKey;column:id" json:"id"` StuID string `gorm:"column:stu_id;not null" json:"stu_id"` //学号 ClaID string `gorm:"column:cla_id;not null" json:"cla_id"` //课程ID Year string `gorm:"column:year;not null;index" json:"year"` //学年 Semester string `gorm:"column:semester;not null;index" json:"semester"` //学期 IsManuallyAdded bool `gorm:"column:is_manually_added;default:false" json:"is_manually_added"` //是否为手动添加 CreatedAt time.Time UpdatedAt time.Time }
func (*StudentCourse) BeforeCreate ¶
func (sc *StudentCourse) BeforeCreate(tx *gorm.DB) (err error)
func (*StudentCourse) BeforeUpdate ¶
func (sc *StudentCourse) BeforeUpdate(tx *gorm.DB) (err error)
func (*StudentCourse) TableName ¶
func (sc *StudentCourse) TableName() string
func (*StudentCourse) UpdateID ¶
func (sc *StudentCourse) UpdateID()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.