apputils

package
v0.0.0-...-971e649 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClassNotExists = errors.New("class doesn't exist")
)

Functions

func BuildClassIndex

func BuildClassIndex(tx *gorm.DB, req *model.ClassQueryRequest) *gorm.DB

func BuildQuerySQL

func BuildQuerySQL(tx *gorm.DB, query *model.QueryRequest, role ...string) *gorm.DB

func IgnoreStructCopy

func IgnoreStructCopy(to, from any, ignore string)

func IsValidPassword

func IsValidPassword(password string) bool

func OK

func OK[T any](c *gin.Context, data T)

func Throw

func Throw(c *gin.Context, errCode errhandle.ErrCode)

func ThrowError

func ThrowError(c *gin.Context, err error)

Types

type Class

type Class struct {
	*ServerUtils
}

func NewClass

func NewClass(db *ServerUtils) *Class

func (*Class) AddClass

func (c *Class) AddClass(name string) (id int64, err error)

func (*Class) BelongsTo

func (c *Class) BelongsTo(teacherid int64, classname ...string) *model.GetClassBelongsResponse

func (*Class) GetClassIDByName

func (c *Class) GetClassIDByName(name string) (int64, bool)

func (*Class) GetClassNameByID

func (c *Class) GetClassNameByID(id int64) (string, bool)

func (*Class) GetStudentClassID

func (c *Class) GetStudentClassID(studentid int64) (int64, error)

func (*Class) GetStudents

func (c *Class) GetStudents(id int64, classname string) (ret []*model.GetUserResponse)

func (*Class) GetTeacherClass

func (c *Class) GetTeacherClass(teacherid int64) (ret []int64, err error)

func (*Class) RemoveClassByID

func (c *Class) RemoveClassByID(id int64) (err error)

func (*Class) StudentJoin

func (c *Class) StudentJoin(studentid int64, name string, filter ...int64) (err error)

func (*Class) StudentLeave

func (c *Class) StudentLeave(studentid int64, filter ...int64) (err error)

func (*Class) TeacherJoin

func (c *Class) TeacherJoin(Teacherid int64, name string) (err error)

func (*Class) TeacherLeave

func (c *Class) TeacherLeave(Teacherid int64, classname string) (err error)

type ServerUtils

type ServerUtils struct {
	DB      *gorm.DB
	RedisDB *redis.Client
	Config  *config.Config
	Token   token.TokenGenerate
	Class   *Class
}

func NewServerUtils

func NewServerUtils(cfg *config.Config) *ServerUtils

Jump to

Keyboard shortcuts

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