model

package
v0.0.0-...-9972ab6 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcUserActiveByUser

func CalcUserActiveByUser(userID uint) (monthlyActive, weeklyActive int, err error)

func CasbinSetup

func CasbinSetup()

func CheckUser

func CheckUser(username, password string) (id uint, err error)

func CreateAdmin

func CreateAdmin() error

func CreateContest

func CreateContest(contest *Contest) error

func CreateContestant

func CreateContestant(contestant *Contestant) error

func CreateTeam

func CreateTeam(team *Team) error

func CreateUser

func CreateUser(user User) error

func DeleteContest

func DeleteContest(id uint) error

func DeleteContestant

func DeleteContestant(id uint) error

func DeleteTeam

func DeleteTeam(id uint) error

func DeleteUser

func DeleteUser(id uint) error

func GetTagCountsByUser

func GetTagCountsByUser(userID uint) (map[string]int, error)

Function to calculate the count of submissions for each tag by a single user

func GetUserIdByCfHandle

func GetUserIdByCfHandle(cfHandle string) (uint, error)

func OJCreateContest

func OJCreateContest(contest *OJContest) error

OJCreateContest function to create a contest

func Setup

func Setup()

func UpdateContest

func UpdateContest(contest *Contest) error

func UpdateContestant

func UpdateContestant(contestant *Contestant) error

func UpdatePassword

func UpdatePassword(id uint, password string) error

func UpdateTeam

func UpdateTeam(team *Team) error

func UpdateUser

func UpdateUser(user User) error

func UpdateUserAvatar

func UpdateUserAvatar(id uint, avatar string) error

func UpdateUserRole

func UpdateUserRole(id uint, role string) error

Types

type Contest

type Contest struct {
	gorm.Model
	Name      string    `gorm:"not null;unique" json:"name"`
	StartTime time.Time `json:"startTime"`
	EndTime   time.Time `json:"endTime"`
	Desc      string    `gorm:"type:text" json:"desc"`
	Teams     []Team    `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"teams"`
}

func GetAllContestList

func GetAllContestList() ([]Contest, error)

func GetContestInfo

func GetContestInfo(id uint) (Contest, error)

type Contestant

type Contestant struct {
	gorm.Model
	TeamID uint `gorm:"not null" json:"teamID"`
	UserID uint `gorm:"not null" json:"userID"`
	User   User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"user"`
}

type OJContest

type OJContest struct {
	gorm.Model
	Name            string    `json:"name"`
	ContestID       int       `json:"contestID"`
	OJ              string    `json:"oj"`
	Type            string    `json:"type"`
	DurationSeconds int       `json:"durationSeconds"`
	StartTime       time.Time `json:"startTime"`
}

OJContest struct definition

func GetContestsByMonth

func GetContestsByMonth(year int, month int) (contests []OJContest, err error)

GetContestsByMonth function to get contests by month

func GetContestsWithTime

func GetContestsWithTime(startTime, endTime time.Time) (contests []OJContest, err error)

GetContestsWithTime function to get contests within a time range

func OJGetContests

func OJGetContests() (contests []OJContest, err error)

OJGetContests function to get all contests

type OJSubmission

type OJSubmission struct {
	gorm.Model
	Name    string       `gorm:"not null" json:"name"`
	UserID  uint         `gorm:"not null" json:"userID"`
	Rating  int          `json:"rating"`
	Tags    []ProblemTag `gorm:"many2many:oj_submission_problem_tags;constraint:OnDelete:CASCADE;" json:"tags"`
	Verdict string       `json:"verdict"`
	OJ      string       `json:"oj"`
	Time    time.Time    `json:"time"`
}

func GetAllSubmissionsByUser

func GetAllSubmissionsByUser(userId uint) (submissions []OJSubmission, err error)

func GetSubmissionByTime

func GetSubmissionByTime(startTime, endTime time.Time) (submissions []OJSubmission, err error)

func GetUserSubmissionByTime

func GetUserSubmissionByTime(userId uint, startTime, endTime time.Time) (submissions []OJSubmission, err error)

func (*OJSubmission) Create

func (submission *OJSubmission) Create() error

Create a new OJSubmission

func (*OJSubmission) Delete

func (submission *OJSubmission) Delete() error

Delete an OJSubmission by ID (Unscoped and remove associations)

func (*OJSubmission) GetByID

func (submission *OJSubmission) GetByID(id uint) error

Get an OJSubmission by ID

func (*OJSubmission) Update

func (submission *OJSubmission) Update() error

Update an existing OJSubmission

type ProblemTag

type ProblemTag struct {
	gorm.Model
	Name string `gorm:"not null;unique" json:"name"`
}

func GetAllTags

func GetAllTags() (tags []ProblemTag, err error)

func (*ProblemTag) Create

func (tag *ProblemTag) Create() error

Create a new ProblemTag

func (*ProblemTag) Delete

func (tag *ProblemTag) Delete() error

Delete a ProblemTag by ID (Unscoped and remove associations)

func (*ProblemTag) GetByID

func (tag *ProblemTag) GetByID(id uint) error

Get a ProblemTag by ID

func (*ProblemTag) Update

func (tag *ProblemTag) Update() error

Update an existing ProblemTag

type Site

type Site struct {
	gorm.Model
	Host       string   `gorm:"not null;unique" json:"host" binding:"required"`
	Name       string   `gorm:"not null;unique" json:"name" binding:"required"`
	SiteTypeID uint     `gorm:"not null" json:"siteTypeID" binding:"required"`
	SiteType   SiteType `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"siteType"`
	Desc       string   `gorm:"type:text" json:"desc"`
}

func GetAllSiteList

func GetAllSiteList() ([]Site, error)

GetAllSiteList retrieves all Site records from the database, including their associated SiteTypes.

func (*Site) Create

func (s *Site) Create() error

Create inserts a new Site record into the database.

func (*Site) Delete

func (s *Site) Delete() error

Delete removes a Site record from the database, including associations.

func (*Site) Get

func (s *Site) Get() error

Get retrieves a Site record from the database by its ID, including its associated SiteType.

func (*Site) Update

func (s *Site) Update() error

Update modifies an existing Site record in the database.

type SiteType

type SiteType struct {
	gorm.Model
	Name string `gorm:"not null;unique" json:"name" binding:"required"`
	Desc string `gorm:"type:text" json:"desc"`
}

func GetAllSiteTypeList

func GetAllSiteTypeList() ([]SiteType, error)

GetAllSiteTypeList retrieves all SiteType records from the database.

func (*SiteType) Create

func (st *SiteType) Create() error

Create inserts a new SiteType record into the database.

func (*SiteType) Delete

func (st *SiteType) Delete() error

Delete removes a SiteType record from the database, including associations.

func (*SiteType) Get

func (st *SiteType) Get() error

Get retrieves a SiteType record from the database by its ID.

func (*SiteType) Update

func (st *SiteType) Update() error

Update modifies an existing SiteType record in the database.

type Team

type Team struct {
	gorm.Model
	ContestID   uint
	ZhName      string       `gorm:"not null;unique" json:"zhName"`
	EnName      string       `json:"enName"`
	CoachID     uint         `gorm:"foreignKey:UserID" json:"coachID"`
	Coach       User         `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"coach"`
	Contestants []Contestant `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"contestants"`
	Desc        string       `gorm:"type:text" json:"desc"`
}

type User

type User struct {
	gorm.Model
	Username      string         `gorm:"size:255;not null;unique" json:"username" binding:"required"`
	RealName      string         `gorm:"size:30" json:"realname" binding:"required"`
	Email         string         `gorm:"size:255;not null;unique" json:"email" binding:"required"`
	Sex           bool           `json:"sex"`
	StudentID     string         `gorm:"size:30" json:"studentID"`
	Class         string         `gorm:"size:30" json:"class"`
	Phone         string         `gorm:"size:30" json:"phone"`
	CFHandle      string         `gorm:"size:255" json:"cfHandle"`
	ATCHandle     string         `gorm:"size:255" json:"atcHandle"`
	Avatar        string         `gorm:"size:255" json:"avatar"`
	Desc          string         `gorm:"type:text" json:"desc"`
	Password      string         `gorm:"size:255;not null" json:"-"`
	Role          string         `gorm:"size:30;not null" json:"role"`
	OJSubmissions []OJSubmission `gorm:"constraint:OnDelete:CASCADE;" json:"-"`
}

func GetACMersList

func GetACMersList() ([]User, error)

func GetAllTeachersList

func GetAllTeachersList() ([]User, error)

func GetAllUsersList

func GetAllUsersList() ([]User, error)

func GetUserByCfHandle

func GetUserByCfHandle(cfHandle string) (User, error)

func GetUserInfo

func GetUserInfo(id uint) (User, error)

type UserStatus

type UserStatus struct {
	gorm.Model
	UserID          uint `json:"-" gorm:"constraint:OnDelete:CASCADE;"`
	CFRating        int  `json:"cfRating"`
	CFWeeklyRating  int  `json:"weeklyRating"`
	CFMonthlyRating int  `json:"monthlyRating"`
	WeeklyActive    int  `json:"weeklyActive"`
	MonthlyActive   int  `json:"monthlyActive"`
}

func GetAllUserStatusList

func GetAllUserStatusList() (statusList []UserStatus, err error)

func (*UserStatus) Create

func (status *UserStatus) Create() error

func (*UserStatus) Delete

func (status *UserStatus) Delete() error

func (*UserStatus) GetByUserID

func (status *UserStatus) GetByUserID(userID uint) error

func (*UserStatus) Update

func (status *UserStatus) Update() error

func (*UserStatus) UpdateByCFHandle

func (status *UserStatus) UpdateByCFHandle(cfHandle string) error

Jump to

Keyboard shortcuts

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