model

package
v0.0.0-...-699dfa3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: MIT Imports: 7 Imported by: 15

Documentation

Index

Constants

View Source
const (
	BelongToPublic = BelongType(iota)
	BelongToGroup
	BelongToContest
)
View Source
const (
	Easy = Difficulty(iota)
	Medium
	Hard
)
View Source
const (
	Administrator = Role(iota)
	Maintainer
	Normal
)
View Source
const (
	Down       = Attitude(-1)
	NoAttitude = Attitude(0)
	Up         = Attitude(1)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attitude

type Attitude int

type BelongType

type BelongType int

type Catalog

type Catalog struct {
	ID        int       `gorm:"column:id;primary_key" json:"id"`
	Name      string    `gorm:"column:name" json:"name" binding:"required,min=1,max=50"`
	CreatedAt time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
	Problems  []Problem `json:"-"`
}

func (*Catalog) TableName

func (c *Catalog) TableName() string

TableName sets the insert table name for this struct type

type Comment

type Comment struct {
	ID         int       `gorm:"column:id;primary_key" json:"id"`
	CreatedAt  time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt  time.Time `gorm:"column:updated_at" json:"updated_at"`
	FromID     int       `gorm:"column:from_id" json:"from_id"`
	ToID       int       `gorm:"column:to_id" json:"to_id"`
	ProblemID  int       `gorm:"column:problem_id" json:"problem_id"`
	ForComment int       `gorm:"column:for_comment" json:"for_comment"`
	Content    string    `gorm:"column:content" json:"content"`
	From       User      `json:"from" gorm:"foreignkey:FromID;" binding:"-"`
	To         User      `json:"to" gorm:"foreignkey:ToID;" binding:"-"`
}

func (*Comment) TableName

func (c *Comment) TableName() string

TableName sets the insert table name for this struct type

type Contest

type Contest struct {
	ID        int       `gorm:"column:id;primary_key" json:"id"`
	Name      string    `gorm:"column:name" json:"name" binding:"required,min=1,max=50"`
	OwnerID   int       `gorm:"column:owner_id" json:"owner_id"`
	StartTime time.Time `gorm:"column:start_time" json:"start_time" binding:"required,gte"`
	EndTime   time.Time `gorm:"column:end_time" json:"end_time" binding:"required,gtfield=StartTime"`
	CreatedAt time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
	Users     []User    `gorm:"many2many:user_in_contest;" json:"-"`
	Problems  []Problem `gorm:"foreignkey:BelongToID" json:"-"`
	Owner     User      `json:"owner" binding:"-"`
}

func (*Contest) TableName

func (c *Contest) TableName() string

TableName sets the insert table name for this struct type

type Difficulty

type Difficulty int

type Group

type Group struct {
	ID        int       `gorm:"column:id;primary_key" json:"id"`
	OwnerID   int       `gorm:"column:owner_id" json:"owner_id"`
	Name      string    `gorm:"column:name" json:"name" binding:"required,max=50"`
	CreatedAt time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
	Users     []User    `gorm:"many2many:user_in_group;" json:"-"`
	Problems  []Problem `gorm:"foreignkey:BelongToID" json:"-"`
	Owner     User      `json:"owner" binding:"-"`
}

func (*Group) TableName

func (g *Group) TableName() string

TableName sets the insert table name for this struct type

type JSON

type JSON []byte

func (JSON) Equals

func (j JSON) Equals(j1 JSON) bool

func (JSON) IsNull

func (j JSON) IsNull() bool

func (JSON) MarshalJSON

func (m JSON) MarshalJSON() ([]byte, error)

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

func (*JSON) UnmarshalJSON

func (m *JSON) UnmarshalJSON(data []byte) error

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

type Limit

type Limit struct {
	TimeLimit   int `json:"time_limit"`
	MemoryLimit int `json:"memory_limit"`
}

type Playground

type Playground struct {
	ID         int    `gorm:"column:id;primary_key" json:"id"`
	UserID     int    `gorm:"column:user_id" json:"user_id"`
	SourceCode string `gorm:"column:source_code" json:"source_code"`
	CodeName   string `gorm:"column:code_name" json:"code_name"`
	Language   int    `gorm:"column:language" json:"language"`
}

func (*Playground) TableName

func (p *Playground) TableName() string

TableName sets the insert table name for this struct type

type PlaygroundHistory

type PlaygroundHistory struct {
	ID           int         `gorm:"column:id;primary_key" json:"id"`
	SourceCode   null.String `gorm:"column:source_code" json:"source_code"`
	PlaygroundID int         `gorm:"column:playground_id" json:"playground_id"`
}

func (*PlaygroundHistory) TableName

func (p *PlaygroundHistory) TableName() string

TableName sets the insert table name for this struct type

type Problem

type Problem struct {
	ID               int               `gorm:"column:id;primary_key" json:"id"`
	Name             string            `gorm:"column:name" json:"name" binding:"required,max=100"`
	CreatedAt        time.Time         `gorm:"column:created_at" json:"created_at"`
	UpdatedAt        time.Time         `gorm:"column:updated_at" json:"updated_at"`
	OwnerID          int               `gorm:"column:owner_id" json:"owner_id"`
	Desc             string            `gorm:"column:desc" json:"desc" binding:"required"`
	Input            string            `gorm:"column:input" json:"input" binding:"required"`
	Output           string            `gorm:"column:output" json:"output" binding:"required"`
	Hint             string            `gorm:"column:hint" json:"hint"`
	Source           string            `gorm:"column:source" json:"source" binding:"max=100"`
	TimeLimit        int               `gorm:"column:time_limit" json:"time_limit"`
	MemoryLimit      int               `gorm:"column:memory_limit" json:"memory_limit"`
	Difficulty       Difficulty        `gorm:"column:difficulty" json:"difficulty" binding:"exists,oneof=0 1 2"`
	BelongType       BelongType        `gorm:"column:belong_type" json:"belong_type" binding:"exists,oneof=0 1 2"`
	BelongToID       int               `gorm:"column:belong_to_id" json:"belong_to_id"`
	CatalogID        int               `gorm:"column:catalog_id" json:"catalog_id" binding:"required"`
	Catalog          Catalog           `json:"catalog" gorm:"association_autoupdate:false;association_autocreate:false" binding:"-"`
	Tags             []Tag             `gorm:"many2many:problem_has_tag;" json:"tags" binding:"dive"`
	ProblemSamples   []ProblemSample   `json:"samples" binding:"dive"`
	ProblemTestCases []ProblemTestCase `json:"test_cases,omitempty" binding:"required,dive"`
	UpVoteUsers      []UserWithOnlyID  `` /* 166-byte string literal not displayed */
	DownVoteUsers    []UserWithOnlyID  `` /* 168-byte string literal not displayed */
	Comments         []Comment         `json:"comments" gorm:"association_autoupdate:false;association_autocreate:false" binding:"-"`
	Owner            User              `json:"owner" gorm:"foreignkey:OwnerID;association_autoupdate:false;association_autocreate:false" binding:"-"`
	Limit            JSON              `gorm:"column:limit" json:"limit" binding:"required"` // todo store json in db may unreasonable
}

func (*Problem) TableName

func (p *Problem) TableName() string

TableName sets the insert table name for this struct type

type ProblemHasTag

type ProblemHasTag struct {
	ID        int       `gorm:"column:id;primary_key" json:"id"`
	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
	TagID     int       `gorm:"column:tag_id" json:"tag_id"`
	ProblemID int       `gorm:"column:problem_id" json:"problem_id"`
}

func (*ProblemHasTag) TableName

func (p *ProblemHasTag) TableName() string

TableName sets the insert table name for this struct type

type ProblemSample

type ProblemSample struct {
	ID        int       `gorm:"column:id;primary_key" json:"id" binding:"requiredwhenfield=DeleteIt"`
	ProblemID int       `gorm:"column:problem_id" json:"-"`
	CreatedAt time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
	Input     string    `gorm:"column:input" json:"input" binding:"required"`
	Output    string    `gorm:"column:output" json:"output" binding:"required"`
	DeleteIt  bool      `gorm:"-" json:"delete_it,omitempty"`
}

func (*ProblemSample) MarshalJSON

func (p *ProblemSample) MarshalJSON() ([]byte, error)

ignore delete_it

func (*ProblemSample) TableName

func (p *ProblemSample) TableName() string

TableName sets the insert table name for this struct type

type ProblemTestCase

type ProblemTestCase struct {
	ID             int    `gorm:"column:id;primary_key" json:"id" binding:"requiredwhenfield=DeleteIt"`
	ProblemID      int    `gorm:"column:problem_id" json:"-"`
	InputData      string `gorm:"column:input_data" json:"input_data" binding:"required"`
	ExpectedOutput string `gorm:"column:expected_output" json:"expected_output" binding:"required"`
	DeleteIt       bool   `gorm:"-" json:"delete_it,omitempty"`
}

func (*ProblemTestCase) TableName

func (p *ProblemTestCase) TableName() string

TableName sets the insert table name for this struct type

type ProblemUpdateLog

type ProblemUpdateLog struct {
	LogID     int    `gorm:"column:log_id;primary_key" json:"log_id"`
	UserID    int    `gorm:"column:user_id" json:"user_id"`
	ProblemID int    `gorm:"column:problem_id" json:"problem_id"`
	BeforeLog string `gorm:"column:before_log" json:"before_log"`
	Commit    string `gorm:"column:commit" json:"commit"`
	AfterLog  string `gorm:"column:after_log" json:"after_log"`
}

func (*ProblemUpdateLog) TableName

func (p *ProblemUpdateLog) TableName() string

TableName sets the insert table name for this struct type

type Role

type Role int

type Submit

type Submit struct {
	ID          int       `gorm:"column:id;primary_key" json:"id"`
	CreatedAt   time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt   time.Time `gorm:"column:updated_at" json:"update_at"`
	ProblemID   int       `gorm:"column:problem_id" json:"problem_id"`
	UserID      int       `gorm:"column:user_id" json:"user_id"`
	SourceCode  string    `gorm:"column:source_code" json:"source_code"`
	Language    int       `gorm:"column:language" json:"language"`
	Result      int       `gorm:"column:result" json:"result"`
	RunTime     int       `gorm:"column:run_time" json:"run_time"`
	MemoryUsage int       `gorm:"column:memory_usage" json:"memory_usage"`
	IsComplete  bool      `gorm:"column:is_complete" json:"is_complete"`
	Problem     Problem   `json:"problem" binding:"-"`
	User        User      `json:"user" binding:"-"`
}

func (*Submit) TableName

func (s *Submit) TableName() string

TableName sets the insert table name for this struct type

type Tag

type Tag struct {
	ID        int       `gorm:"column:id;primary_key" json:"id" binding:"requiredwhenfield=DeleteIt"`
	Name      string    `gorm:"column:name" json:"name" binding:"required,min=1,max=50"`
	CreatedAt time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
	DeleteIt  bool      `gorm:"-" json:"delete_it,omitempty"`
}

func (*Tag) MarshalJSON

func (t *Tag) MarshalJSON() ([]byte, error)

ignore delete_it

func (*Tag) TableName

func (t *Tag) TableName() string

TableName sets the insert table name for this struct type

type Template

type Template struct {
	ID        int       `gorm:"column:id;primary_key" json:"id"`
	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
	Template  string    `gorm:"column:template" json:"template" binding:"required"`
	Language  int       `gorm:"column:language" json:"language" binding:"required,oneof=0 1 2 3"`
}

func (*Template) TableName

func (t *Template) TableName() string

TableName sets the insert table name for this struct type

type Theme

type Theme struct {
	ID        int       `gorm:"column:id;primary_key" json:"id"`
	UserID    int       `gorm:"column:user_id" json:"user_id"`
	CreatedAt time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
	Theme     int       `gorm:"column:theme" json:"theme" binding:"exists,oneof=0 1"`
	SidebarBg string    `gorm:"column:sidebar_bg" json:"sidebar_bg" binding:"required,oneof=vue green blue purple"`
	Direction int       `gorm:"column:direction" json:"direction" binding:"exists,oneof=0 1"`
}

func (*Theme) TableName

func (t *Theme) TableName() string

TableName sets the insert table name for this struct type

type User

type User struct {
	ID           int       `gorm:"column:id;primary_key" json:"id"`
	GithubUserID string    `gorm:"column:github_user_id" json:"github_user_id,omitempty"`
	GithubName   string    `gorm:"column:github_name" json:"github_name"`
	Email        string    `gorm:"column:email" json:"email" binding:"required,email,max=100"`
	Name         string    `gorm:"column:name" json:"name" binding:"required,max=100,excludesall=!@#?"`
	CreatedAt    time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt    time.Time `gorm:"column:updated_at" json:"-"`
	Role         int       `gorm:"column:role" json:"role"`

	// password from user input, password should't response to user,
	// so set omitempty && set this field to nil before return
	Password         string `gorm:"-" json:"password,omitempty" binding:"omitempty,min=6,max=30"`
	EncryptedPasswd  string `gorm:"column:passwd" json:"-"` // encrypted password in db
	Signature        string `gorm:"column:signature" json:"signature" binding:"max=800"`
	NoInOrganization string `gorm:"column:no_in_organization" json:"no_in_organization" binding:"max=30"`
	Organization     string `gorm:"column:organization" json:"organization" binding:"max=50"`
	Site             string `gorm:"column:site" json:"site" binding:"max=50"`
	AvatarUrl        string `gorm:"column:avatar_url" json:"avatar" binding:"max=600"`
	WeiboName        string `gorm:"column:weibo_name" json:"weibo_name" binding:"max=50"`
	ZhihuName        string `gorm:"column:zhihu_name" json:"zhihu_name" binding:"max=50"`

	// theme
	Theme *Theme `json:"theme,omitempty" binding:"-"`

	// group
	Groups   []Group   `gorm:"many2many:user_in_group;" json:"-"`
	Contests []Contest `gorm:"many2many:user_in_contest;" json:"-"`
}

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

ignore password and github user id

func (*User) TableName

func (u *User) TableName() string

TableName sets the insert table name for this struct type

type UserInContest

type UserInContest struct {
	ID        int       `gorm:"column:id;primary_key" json:"id"`
	ContestID int       `gorm:"column:contest_id" json:"contest_id"`
	UserID    int       `gorm:"column:user_id" json:"user_id"`
	CreatedAt time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
}

func (*UserInContest) TableName

func (u *UserInContest) TableName() string

TableName sets the insert table name for this struct type

type UserInGroup

type UserInGroup struct {
	ID        int       `gorm:"column:id;primary_key" json:"id"`
	GroupID   int       `gorm:"column:group_id" json:"group_id"`
	UserID    int       `gorm:"column:user_id" json:"user_id"`
	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
}

func (*UserInGroup) TableName

func (u *UserInGroup) TableName() string

TableName sets the insert table name for this struct type

type UserVoteProblem

type UserVoteProblem struct {
	CreatedAt time.Time `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
	UserID    int       `gorm:"column:user_id;primary_key" json:"-"`
	ProblemID int       `gorm:"column:problem_id;primary_key" json:"problem_id"`
	Attitude  int       `gorm:"column:attitude" json:"attitude" form:"attitude" binding:"oneof=-1 0 1"`
}

func (*UserVoteProblem) TableName

func (u *UserVoteProblem) TableName() string

TableName sets the insert table name for this struct type

type UserWithOnlyID

type UserWithOnlyID struct {
	ID int `gorm:"column:id;primary_key" json:"id"`
}

func (*UserWithOnlyID) TableName

func (u *UserWithOnlyID) TableName() string

TableName sets the insert table name for this struct type

Jump to

Keyboard shortcuts

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