Documentation ¶
Index ¶
- Constants
- type Class
- type Config
- type EmailVerificationToken
- type Grade
- type HasRole
- type Image
- type Language
- type Permission
- type Problem
- type ProblemSet
- type ProblemTag
- type Role
- type Run
- type Script
- type Submission
- type Tag
- type TestCase
- type Token
- type User
- func (u *User) Can(permission string, target ...HasRole) bool
- func (u *User) DeleteRole(name string, target ...HasRole)
- func (u *User) GrantRole(name string, target ...HasRole)
- func (u *User) HasRole(name string, target ...HasRole) bool
- func (u *User) In(users []User) bool
- func (u *User) LoadRoles()
- func (u *User) WebAuthnCredentials() []webauthn.Credential
- func (u *User) WebAuthnDisplayName() string
- func (u *User) WebAuthnID() (ret []byte)
- func (u *User) WebAuthnIcon() string
- func (u *User) WebAuthnName() string
- type UserHasRole
- type WebauthnCredential
Constants ¶
View Source
const PriorityDefault = uint8(127)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Class ¶
type Class struct { ID uint `gorm:"primaryKey" json:"id"` Name string `json:"name" gorm:"size:255;default:'';not null"` CourseName string `json:"course_name" gorm:"size:255;default:'';not null"` Description string `json:"description"` InviteCode string `json:"invite_code" gorm:"size:255;default:'';not null"` Managers []*User `json:"managers" gorm:"many2many:user_manage_classes"` Students []*User `json:"students" gorm:"many2many:user_in_classes"` ProblemSets []*ProblemSet `json:"problem_sets"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"` }
func (*Class) AddStudents ¶
func (*Class) DeleteStudents ¶
type EmailVerificationToken ¶
type Grade ¶
type Grade struct { ID uint `gorm:"primaryKey" json:"id"` UserID uint `json:"user_id"` User *User `json:"user"` ProblemSetID uint `json:"problem_set_id"` ProblemSet *ProblemSet `json:"problem_set"` ClassID uint `json:"class_id"` Class *Class `json:"class"` Detail datatypes.JSON `json:"detail"` Total uint `json:"total"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"-"` }
type Language ¶
type Language struct { Name string `gorm:"primaryKey" json:"name"` ExtensionAllowed database.StringArray `gorm:"type:string" json:"extension_allowed"` BuildScriptName string `json:"-"` BuildScript *Script `gorm:"foreignKey:BuildScriptName" json:"build_script"` RunScriptName string `json:"-"` RunScript *Script `gorm:"foreignKey:RunScriptName" json:"run_script"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
type Permission ¶
type Problem ¶
type Problem struct { ID uint `gorm:"primaryKey" json:"id"` Name string `sql:"index" json:"name" gorm:"size:255;default:'';not null"` Description string `json:"description"` AttachmentFileName string `json:"attachment_file_name" gorm:"size:255;default:'';not null"` Public bool `json:"public" gorm:"default:false;not null"` Privacy bool `json:"privacy" gorm:"default:false;not null"` MemoryLimit uint64 `json:"memory_limit" gorm:"default:0;not null;type:bigint"` // Byte TimeLimit uint `json:"time_limit" gorm:"default:0;not null"` // ms LanguageAllowed database.StringArray `json:"language_allowed" gorm:"size:255;default:'';not null;type:string"` // E.g. cpp,c,java,python BuildArg string `json:"build_arg" gorm:"size:2047;default:'';not null"` // E.g. O2=false CompareScriptName string `json:"compare_script_name" gorm:"default:0;not null"` CompareScript Script `json:"compare_script"` TestCases []TestCase `json:"test_cases"` Tags []Tag `json:"tags" gorm:"OnDelete:CASCADE"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
func (*Problem) LoadTestCases ¶
func (p *Problem) LoadTestCases()
type ProblemSet ¶
type ProblemSet struct { ID uint `gorm:"primaryKey" json:"id"` ClassID uint `sql:"index" json:"class_id" gorm:"not null"` Class *Class `json:"class"` Name string `json:"name" gorm:"not null;size:255"` Description string `json:"description"` Problems []*Problem `json:"problems" gorm:"many2many:problems_in_problem_sets"` Grades []*Grade `json:"grades"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
func (*ProblemSet) AddProblems ¶
func (p *ProblemSet) AddProblems(ids []uint) error
func (*ProblemSet) AfterDelete ¶
func (p *ProblemSet) AfterDelete(tx *gorm.DB) error
func (*ProblemSet) DeleteProblems ¶
func (p *ProblemSet) DeleteProblems(ids []uint) error
type ProblemTag ¶
type Role ¶
type Role struct { ID uint `gorm:"primaryKey" json:"id"` Name string `json:"name"` Target *string `json:"target"` Permissions []Permission }
func (*Role) AddPermission ¶
type Run ¶
type Run struct { ID uint `gorm:"primaryKey" json:"id"` UserID uint `sql:"index" json:"user_id"` User *User `json:"user"` ProblemID uint `sql:"index" json:"problem_id"` Problem *Problem `json:"problem"` ProblemSetID uint `sql:"index" json:"problem_set_id"` TestCaseID uint `json:"test_case_id"` TestCase *TestCase `json:"test_case"` Sample bool `json:"sample" gorm:"not null"` SubmissionID uint `json:"submission_id"` Submission *Submission `json:"submission"` Priority uint8 `json:"priority"` Judged bool `json:"judged"` JudgerName string JudgerMessage string /* PENDING / JUDGING / JUDGEMENT_FAILED / NO_COMMENT ACCEPTED / WRONG_ANSWER / RUNTIME_ERROR / TIME_LIMIT_EXCEEDED / MEMORY_LIMIT_EXCEEDED / DANGEROUS_SYSTEM_CALLS */ Status string `json:"status"` MemoryUsed uint `json:"memory_used"` // Byte TimeUsed uint `json:"time_used"` // ms OutputStrippedHash string `json:"output_stripped_hash"` CreatedAt time.Time `sql:"index" json:"created_at"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
type Submission ¶
type Submission struct { ID uint `gorm:"primaryKey" json:"id"` UserID uint `sql:"index" json:"user_id"` User *User `json:"user"` ProblemID uint `sql:"index" json:"problem_id"` Problem *Problem `json:"problem"` ProblemSetID uint `sql:"index" json:"problem_set_id"` ProblemSet *ProblemSet `json:"problem_set"` LanguageName string `json:"language_name"` Language *Language `json:"language"` FileName string `json:"file_name"` Priority uint8 `json:"priority"` Judged bool `json:"judged"` Score uint `json:"score"` /* PENDING / JUDGEMENT_FAILED / NO_COMMENT ACCEPTED / WRONG_ANSWER / RUNTIME_ERROR / TIME_LIMIT_EXCEEDED / MEMORY_LIMIT_EXCEEDED / DANGEROUS_SYSTEM_CALLS */ Status string `json:"status"` Runs []Run `json:"runs"` CreatedAt time.Time `sql:"index" json:"created_at"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
func (*Submission) AfterDelete ¶
func (s *Submission) AfterDelete(tx *gorm.DB) (err error)
func (*Submission) LoadRuns ¶
func (s *Submission) LoadRuns()
type TestCase ¶
type TestCase struct { ID uint `gorm:"primaryKey" json:"id"` ProblemID uint `sql:"index" json:"problem_id" gorm:"not null"` Score uint `json:"score" gorm:"default:0;not null"` // 0 for 平均分配 Sample bool `json:"sample" gorm:"default:false;not null"` InputFileName string `json:"input_file_name" gorm:"size:255;default:'';not null"` OutputFileName string `json:"output_file_name" gorm:"size:255;default:'';not null"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
type User ¶
type User struct { ID uint `gorm:"primaryKey" json:"id"` Username string `gorm:"unique_index" json:"username" validate:"required,max=30,min=5,username"` Nickname string `gorm:"index:nickname" json:"nickname"` Email string `gorm:"unique_index" json:"email"` Password string `json:"-"` EmailVerified bool `json:"email_verified"` Roles []UserHasRole `json:"roles"` RoleLoaded bool `gorm:"-" json:"-"` ClassesManaging []*Class `json:"class_managing" gorm:"many2many:user_manage_classes"` ClassesTaking []*Class `json:"class_taking" gorm:"many2many:user_in_classes"` Grades []*Grade `json:"grades"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `sql:"index" json:"deleted_at"` Credentials []WebauthnCredential }
func (*User) DeleteRole ¶
func (*User) WebAuthnCredentials ¶
func (u *User) WebAuthnCredentials() []webauthn.Credential
func (*User) WebAuthnDisplayName ¶
func (*User) WebAuthnID ¶
func (*User) WebAuthnIcon ¶
func (*User) WebAuthnName ¶
type UserHasRole ¶
type UserHasRole struct { ID uint `gorm:"primaryKey" json:"id"` UserID uint `json:"user_id"` RoleID uint `json:"role_id"` Role Role `json:"role"` TargetID uint `json:"target_id"` }
func (UserHasRole) MarshalJSON ¶
func (u UserHasRole) MarshalJSON() ([]byte, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.