models

package
v0.0.0-...-16d05a1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	gorm.Model
	User   User `gorm:"foreignkey:UserID" json:"user"`
	UserID uint `gorm:"column:user_id" json:"user_id"`
}

Admin represents an administrator's fields

func (*Admin) AfterFind

func (a *Admin) AfterFind(db *gorm.DB) error

type ContactInfo

type ContactInfo struct {
	gorm.Model
	FacebookURL         string `gorm:"column:facebook_url" json:"facebook_url"`
	MicrosoftTeamsEmail string `gorm:"column:msteams_email" json:"msteams_email"`
	TelegramNumber      string `gorm:"column:telegram_number" json:"telegram_number"`
}

ContactInfo represents a user's(any user on Ross) fields

type Contest

type Contest struct {
	gorm.Model
	ID                uint          `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	Name              string        `gorm:"column:name" json:"name"`
	StartsAt          int64         `gorm:"-" json:"starts_at"`
	StartsAt2         time.Time     `gorm:"column:starts_at"` // weird ain't it? :)
	RegistrationEnds  int64         `gorm:"-" json:"registration_ends"`
	RegistrationEnds2 time.Time     `gorm:"column:registration_ends"` // weird ain't it? :)
	Duration          time.Duration `gorm:"column:duration" json:"duration"`
	Location          string        `gorm:"column:location" json:"location"`
	LogoPath          string        `gorm:"column:logo_path" json:"logo_path"`
	CoverPath         string        `gorm:"column:cover_path" json:"cover_path"`
	Description       string        `gorm:"column:description" json:"description"`
	TeamsHidden       bool          `gorm:"column:teams_hidden" json:"teams_hidden"`

	ParticipationConditions ParticipationConditions `gorm:"foreignkey:PCsID" json:"participation_conditions"` // the conditions should be a part of the contest instance 🤷‍♂️
	PCsID                   uint                    `gorm:"column:pc_id"`

	AllowedContestantsCount uint `gorm:"allowed_contestant_count" json:"allowed_contestant_count"`
	CurrentContestantsCount uint `gorm:"current_contestant_count" json:"current_contestant_count"`

	Teams               []Team       `gorm:"many2many:register_teams;" json:"teams"`
	Organizers          []Organizer  `gorm:"many2many:organize_contests;" json:"organizers"`
	TeamlessContestants []Contestant `gorm:"-" json:"teamless_contestants"`
}

Contest represents a contest's fields

func (*Contest) AfterFind

func (c *Contest) AfterFind(db *gorm.DB) error

func (*Contest) BeforeCreate

func (c *Contest) BeforeCreate(db *gorm.DB) error

type Contestant

type Contestant struct {
	gorm.Model
	User   User `gorm:"foreignkey:UserID" json:"user"`
	UserID uint `gorm:"column:user_id" json:"user_id"`

	Team      Team        `gorm:"foreignkey:TeamID" json:"team"` // big surprise, a contestant gets their contests from here :)
	TeamID    uint        `gorm:"column:team_id" json:"team_id"`
	Major     enums.Major `gorm:"column:major;type:uint" json:"major"`
	MajorName string      `gorm:"-" json:"major_name"`

	TeamlessedAt      time.Time `gorm:"column:teamlessed_at" json:"teamlessed_at"`
	TeamlessContestID uint      `gorm:"column:teamless_contest_id" json:"teamless_contest_id"`

	Gender                     bool `gorm:"column:gender" json:"gender"`
	ParticipateWithOtherGender bool `gorm:"column:participate_with_other" json:"participate_with_other"`
}

Contestant represents a contestant's fields

func (*Contestant) AfterFind

func (c *Contestant) AfterFind(db *gorm.DB) error

func (*Contestant) BeforeCreate

func (c *Contestant) BeforeCreate(db *gorm.DB) error

type JoinRequest

type JoinRequest struct {
	gorm.Model
	ID                  uint         `gorm:"column:id;primaryKey;autoIncrement"`
	RequesterID         uint         `gorm:"column:requester_id" json:"requester_id"`
	RequestedTeamJoinID string       `gorm:"column:requested_team_join_id" json:"requested_team_join_id"`
	RequestedTeamID     uint         `gorm:"column:requested_team_id" json:"requested_team_id"`
	RequestedTeam       Team         `gorm:"foreignkey:RequestedTeamID" json:"requested_team"`
	RequestedContestID  uint         `gorm:"column:req_contest_id" json:"requested_contest_id"`
	RequestMessage      string       `gorm:"column:message" json:"request_message"`
	NotificationID      uint         `gorm:"column:notification_id"`
	Notification        Notification `gorm:"foreignkey:NotificationID"`
}

func (*JoinRequest) BeforeDelete

func (j *JoinRequest) BeforeDelete(db *gorm.DB) error

type Notification

type Notification struct {
	gorm.Model
	ID      uint      `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	UserID  uint      `gorm:"column:user_id" json:"user_id"`
	Content string    `gorm:"column:content" json:"content"`
	Seen    bool      `gorm:"column:seen" json:"seen"`
	SeenAt  time.Time `gorm:"column:seen_at" json:"seen_at"`
}

Notification represents a notification's fields

type OrganizeContest

type OrganizeContest struct {
	ContestID      uint                `gorm:"column:contest_id;primaryKey;"`
	OrganizerID    uint                `gorm:"column:organizer_id;primaryKey;"`
	OrganizerRoles enums.OrganizerRole `gorm:"column:organizer_roles;type:uint;"`
	CreatedAt      time.Time
}

type Organizer

type Organizer struct {
	gorm.Model
	ID     uint `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	User   User `gorm:"foreignkey:UserID" json:"user"`
	UserID uint `gorm:"column:user_id" json:"user_id"`

	DirectorID uint       `gorm:"column:director_id"`
	Director   *Organizer `gorm:"foreignkey:DirectorID" json:"director"`

	Contests []Contest `gorm:"many2many:organize_contests;" json:"contests"`
}

Organizer represents a contest's organizer

func (*Organizer) AfterFind

func (o *Organizer) AfterFind(db *gorm.DB) error

type ParticipationConditions

type ParticipationConditions struct {
	gorm.Model
	ID             uint        `gorm:"column:id;primaryKey;autoIncrement"`
	Majors         enums.Major `gorm:"column:majors;type:uint" json:"majors"`
	MajorsNames    []string    `gorm:"-" json:"majors_names"`
	MinTeamMembers uint        `gorm:"column:min_team_members" json:"min_team_members"`
	MaxTeamMembers uint        `gorm:"column:max_team_members" json:"max_team_members"`
}

ParticipationConditions represents the conditions needed to participate in a contest

type Session

type Session struct {
	ID        string `gorm:"column:id;primaryKey"`
	CreatedAt time.Time
	UserID    uint `gorm:"column:user_id"`
}

Session represents a session's fields

func (*Session) BeforeCreate

func (s *Session) BeforeCreate(db *gorm.DB) error

type Team

type Team struct {
	gorm.Model
	ID       uint        `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	Name     string      `gorm:"column:name" json:"name"`
	LeaderId uint        `gorm:"column:leader_id" json:"leader_id"` // not a foreign key to avoid cycling mess :)
	Leader   *Contestant `gorm:"-" json:"leader"`                   // using a pointer to avoid cycling :)
	JoinID   string      `gorm:"column:join_id;unique" json:"join_id"`

	Contests []Contest    `gorm:"many2many:register_teams;"` // a team may register in more than one contest
	Members  []Contestant `gorm:"-" json:"members"`          // each contestant has their team id :)
}

Team represents a team's fields

func (*Team) AfterCreate

func (t *Team) AfterCreate(db *gorm.DB) error

func (*Team) AfterFind

func (t *Team) AfterFind(db *gorm.DB) error

func (*Team) BeforeDelete

func (t *Team) BeforeDelete(db *gorm.DB) error

type User

type User struct {
	gorm.Model
	ID            uint                `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	Email         string              `gorm:"column:email;unique" json:"email"`
	Name          string              `gorm:"column:name" json:"name"`
	AvatarURL     string              `gorm:"column:avatar_url" json:"avatar_url"`
	ProfileStatus enums.ProfileStatus `gorm:"profile_status" json:"profile_status"`

	UserType     enums.UserType `gorm:"column:user_type" json:"user_type_base"`
	UserTypeText []string       `gorm:"-" json:"user_type"`

	ContactInfo   ContactInfo `gorm:"foreignkey:ContactInfoID" json:"contact_info"`
	ContactInfoID uint        `gorm:"column:contact_info_id"`

	// used only for organizers and contestants :)
	AttendedAt        time.Time `gorm:"column:attended_at" json:"attended_at"`
	AttendedContestID uint      `gorm:"column:attended_contest_id" json:"attended_contest_id"`
}

User represents a general user :)

func (*User) AfterFind

func (u *User) AfterFind(db *gorm.DB) error

func (*User) BeforeCreate

func (u *User) BeforeCreate(db *gorm.DB) error

Directories

Path Synopsis
Package enums includes enums used in the models
Package enums includes enums used in the models

Jump to

Keyboard shortcuts

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