refactor:
This commit is contained in:
parent
ad8d145986
commit
3c0f01630f
29 changed files with 360 additions and 1377 deletions
8
internal/models/contest.go
Normal file
8
internal/models/contest.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
package models
|
||||
|
||||
type Contest struct {
|
||||
Id *int `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
//CreatedAt time.Time `db:"created_at"` FIXME
|
||||
//UpdatedAt time.Time `db:"updated_at"` FIXME
|
||||
}
|
12
internal/models/language.go
Normal file
12
internal/models/language.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Language struct {
|
||||
Id *int32 `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
BuildFileHash *string `db:"build_file_hash"`
|
||||
ExecuteFileHash *string `db:"execute_file_hash"`
|
||||
CreatedAt *time.Time `db:"created_at"`
|
||||
UpdatedAt *time.Time `db:"updated_at"`
|
||||
}
|
13
internal/models/problem.go
Normal file
13
internal/models/problem.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Problem struct {
|
||||
Id *int32 `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
Description *string `db:"description"`
|
||||
TimeLimit *int32 `db:"time_limit"`
|
||||
MemoryLimit *int32 `db:"memory_limit"`
|
||||
CreatedAt *time.Time `db:"created_at"`
|
||||
UpdatedAt *time.Time `db:"updated_at"`
|
||||
}
|
44
internal/models/role.go
Normal file
44
internal/models/role.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package models
|
||||
|
||||
import "git.sch9.ru/new_gate/ms-tester/internal/lib"
|
||||
|
||||
type Role int32
|
||||
|
||||
const (
|
||||
RoleSpectator Role = 0
|
||||
RoleParticipant Role = 1
|
||||
RoleModerator Role = 2
|
||||
RoleAdmin Role = 3
|
||||
)
|
||||
|
||||
func (role Role) IsAdmin() bool {
|
||||
return role == RoleAdmin
|
||||
}
|
||||
|
||||
func (role Role) IsModerator() bool {
|
||||
return role == RoleModerator
|
||||
}
|
||||
|
||||
func (role Role) IsParticipant() bool {
|
||||
return role == RoleParticipant
|
||||
}
|
||||
|
||||
func (role Role) IsSpectator() bool {
|
||||
return role == RoleSpectator
|
||||
}
|
||||
|
||||
func (role Role) AtLeast(other Role) bool {
|
||||
return role >= other
|
||||
}
|
||||
|
||||
func (role Role) AtMost(other Role) bool {
|
||||
return role <= other
|
||||
}
|
||||
|
||||
func (role Role) Valid() error {
|
||||
switch role {
|
||||
case RoleSpectator, RoleParticipant, RoleModerator, RoleAdmin:
|
||||
return nil
|
||||
}
|
||||
return lib.ErrBadRole
|
||||
}
|
14
internal/models/solution.go
Normal file
14
internal/models/solution.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Solution struct {
|
||||
Id *int32 `db:"id"`
|
||||
ParticipantId *int32 `db:"participant_id"`
|
||||
ProblemId *int32 `db:"problem_id"`
|
||||
LanguageId *int32 `db:"language_id"`
|
||||
ContestId *int32 `db:"contest_id"`
|
||||
SolutionHash *string `db:"solution_hash"`
|
||||
Result *int32 `db:"result"`
|
||||
CreatedAt *time.Time `db:"created_at"`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue