objects

package
v0.0.0-...-cec39cb Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ability

type Ability struct {
	Model

	Name  string `gorm:"size:128;unique_index;not null" json:"name" spacedock:"lock"`
	Roles []Role `gorm:"many2many:role_abilities" json:"-" spacedock:"lock"`
}

func (*Ability) AfterFind

func (s *Ability) AfterFind()

type DownloadEvent

type DownloadEvent struct {
	Model

	Mod       Mod        `json:"-" gorm:"ForeignKey:ModID" spacedock:"lock"`
	ModID     uint       `json:"mod" spacedock:"lock"`
	Version   ModVersion `json:"-" gorm:"ForeignKey:VersionID" spacedock:"lock"`
	VersionID uint       `json:"version" spacedock:"lock"`
	Downloads int        `json:"downloads" spacedock:"lock"`
}

func NewDownloadEvent

func NewDownloadEvent(mod Mod, version ModVersion) *DownloadEvent

func (*DownloadEvent) AfterFind

func (s *DownloadEvent) AfterFind()
type Featured struct {
	Model

	Mod   Mod  `json:"mod" gorm:"ForeignKey:ModID" spacedock:"lock;tomap"`
	ModID uint `json:"mod_id" spacedock:"lock"`
}

func NewFeatured

func NewFeatured(mod Mod) *Featured

func (*Featured) AfterFind

func (s *Featured) AfterFind()

type FollowEvent

type FollowEvent struct {
	Model

	Mod    Mod  `json:"-" gorm:"ForeignKey:ModID" spacedock:"lock"`
	ModID  uint `json:"mod" spacedock:"lock"`
	Events int  `json:"events" spacedock:"lock"`
	Delta  int  `json:"delta" spacedock:"lock"`
}

func NewFollowEvent

func NewFollowEvent(mod Mod) *FollowEvent

func (*FollowEvent) AfterFind

func (s *FollowEvent) AfterFind()

type Game

type Game struct {
	Model

	Name             string        `gorm:"size:1024;unique_index;not null" json:"name"`
	Active           bool          `json:"active"`
	Altname          string        `gorm:"size:1024" json:"altname"`
	Rating           float32       `json:"rating" spacedock:"lock"`
	Releasedate      time.Time     `json:"releasedate" spacedock:"lock"`
	Short            string        `gorm:"size:1024" json:"short" spacedock:"lock"`
	Publisher        Publisher     `json:"-" gorm:"ForeignKey:PublisherID" spacedock:"lock"`
	PublisherID      uint          `json:"publisher" spacedock:"lock"`
	Description      string        `gorm:"size:100000" json:"description"`
	ShortDescription string        `gorm:"size:1000" json:"short_description"`
	Mods             []Mod         `json:"-" spacedock:"lock"`
	Modlists         []ModList     `json:"-" spacedock:"lock"`
	Versions         []GameVersion `json:"-" spacedock:"lock"`
}

func NewGame

func NewGame(name string, publisher Publisher, short string) *Game

func (*Game) AfterFind

func (s *Game) AfterFind()

type GameVersion

type GameVersion struct {
	Model

	Game            Game   `json:"-" spacedock:"lock"`
	GameID          uint   `json:"game" spacedock:"lock"`
	FriendlyVersion string `gorm:"size:128;" json:"friendly_version" spacedock:"lock"`
	Beta            bool   `json:"beta"`
}

func NewGameVersion

func NewGameVersion(friendly_version string, game Game, beta bool) *GameVersion

func (*GameVersion) AfterFind

func (s *GameVersion) AfterFind()

type Mod

type Mod struct {
	Model

	User             User            `json:"-" gorm:"ForeignKey:UserID" spacedock:"lock"`
	UserID           uint            `json:"user" spacedock:"lock"`
	Game             Game            `json:"-" gorm:"ForeignKey:GameID" spacedock:"lock"`
	GameID           uint            `json:"game" spacedock:"lock"`
	SharedAuthors    []SharedAuthor  `json:"shared_authors" spacedock:"lock"`
	Name             string          `json:"name" gorm:"size:1024;unique_index;not null"`
	Description      string          `json:"description" gorm:"size:100000"`
	ShortDescription string          `json:"short_description" gorm:"size:1000"`
	Approved         bool            `json:"approved" spacedock:"lock"`
	Published        bool            `json:"published" spacedock:"lock"`
	License          string          `json:"license" gorm:"size:512"`
	DefaultVersion   ModVersion      `json:"default_version" gorm:"ForeignKey:DefaultVersionID" spacedock:"lock;tomap"`
	DefaultVersionID uint            `json:"default_version_id"`
	Versions         []ModVersion    `json:"versions" spacedock:"lock"`
	DownloadEvents   []DownloadEvent `json:"-" spacedock:"lock"`
	FollowEvents     []FollowEvent   `json:"-" spacedock:"lock"`
	ReferralEvents   []ReferralEvent `json:"-" spacedock:"lock"`
	Followers        []User          `json:"-" gorm:"many2many:mod_followers" spacedock:"lock"`
	Ratings          []Rating        `json:"-" spacedock:"lock"`
	TotalScore       float64         `json:"total_score" gorm:"not null" spacedock:"lock"`
	DownloadCount    int64           `json:"download_count" spacedock:"lock"`
}

func NewMod

func NewMod(name string, user User, game Game, license string) *Mod

func (*Mod) AfterFind

func (s *Mod) AfterFind()

func (*Mod) CalculateScore

func (mod *Mod) CalculateScore()

type ModList

type ModList struct {
	Model

	User             User          `json:"-" gorm:"ForeignKey:UserID" spacedock:"lock"`
	UserID           uint          `json:"user" spacedock:"lock"`
	Game             Game          `json:"-" gorm:"ForeignKey:GameID" spacedock:"lock"`
	GameID           uint          `json:"game" spacedock:"lock"`
	Description      string        `gorm:"size:100000"`
	ShortDescription string        `gorm:"size:1000"`
	Name             string        `json:"name" gorm:"size:1024;unique_index;not null"`
	Mods             []ModListItem `json:"-" spacedock:"lock"`
}

func NewModList

func NewModList(name string, user User, game Game) *ModList

func (*ModList) AfterFind

func (s *ModList) AfterFind()

type ModListItem

type ModListItem struct {
	Model

	Mod       Mod     `json:"-" gorm:"ForeignKey:ModID" spacedock:"lock"`
	ModID     uint    `json:"mod" spacedock:"lock"`
	ModList   ModList `json:"-" gorm:"ForeignKey:ModListID" spacedock:"lock"`
	ModListID uint    `json:"mod_list" spacedock:"lock"`
	SortIndex uint    `json:"sort_index" spacedock:"lock"`
}

func NewModListItem

func NewModListItem(mod Mod, list ModList) *ModListItem

func (*ModListItem) AfterFind

func (s *ModListItem) AfterFind()

type ModVersion

type ModVersion struct {
	Model

	ModID           uint        `json:"mod" spacedock:"lock"`
	FriendlyVersion string      `json:"friendly_version" gorm:"size:64;" spacedock:"lock"`
	Beta            bool        `json:"beta"`
	GameVersion     GameVersion `json:"gameversion" gorm:"ForeignKey:GameVersionID" spacedock:"lock;tomap"`
	GameVersionID   uint        `json:"gameversion_id" spacedock:"lock"`
	DownloadPath    string      `json:"download_path" gorm:"size:512" spacedock:"lock"`
	Changelog       string      `json:"changelog" gorm:"size:10000"`
	SortIndex       int         `json:"sort_index" spacedock:"lock"`
	FileSize        int64       `json:"file_size" spacedock:"lock"`
}

func NewModVersion

func NewModVersion(mod Mod, friendly_version string, gameversion GameVersion, download_path string, beta bool) *ModVersion

func (*ModVersion) AfterFind

func (s *ModVersion) AfterFind()

type Model

type Model struct {
	ID        uint       `gorm:"primary_key" json:"id" spacedock:"lock"`
	CreatedAt time.Time  `json:"created" spacedock:"lock"`
	UpdatedAt time.Time  `json:"updated" spacedock:"lock"`
	DeletedAt *time.Time `sql:"index" json:"-" spacedock:"lock"`
	Meta      string     `gorm:"size:4096" json:"meta"`
}

func (*Model) GetValue

func (meta *Model) GetValue(key string) (error, interface{})

func (*Model) SetValue

func (meta *Model) SetValue(key string, value interface{}) error

type Publisher

type Publisher struct {
	Model

	Name             string `gorm:"size:1024;unique_index;not null" json:"name"`
	Description      string `gorm:"size:100000" json:"description"`
	ShortDescription string `gorm:"size:1000" json:"short_description"`
	Games            []Game `json:"-" spacedock:"lock"`
}

func NewPublisher

func NewPublisher(name string) *Publisher

func (*Publisher) AfterFind

func (s *Publisher) AfterFind()

type Rating

type Rating struct {
	Model

	User   User    `json:"-" gorm:"ForeignKey:UserID" spacedock:"lock"`
	UserID uint    `json:"user" spacedock:"lock"`
	Mod    Mod     `json:"-" gorm:"ForeignKey:ModID" spacedock:"lock"`
	ModID  uint    `json:"mod" spacedock:"lock"`
	Score  float64 `gorm:"not null" json:"score"`
}

func NewRating

func NewRating(user User, mod Mod, score float64) *Rating

func (*Rating) AfterFind

func (s *Rating) AfterFind()

type ReferralEvent

type ReferralEvent struct {
	Model

	Mod    Mod    `json:"-" gorm:"ForeignKey:Mod" spacedock:"lock"`
	ModID  uint   `json:"mod" spacedock:"lock"`
	Events int    `json:"events" spacedock:"lock"`
	Host   string `json:"host" gorm:"size:128" spacedock:"lock"`
}

func NewReferralEvent

func NewReferralEvent(mod Mod, host string) *ReferralEvent

func (*ReferralEvent) AfterFind

func (s *ReferralEvent) AfterFind()

type Role

type Role struct {
	Model

	Name      string    `gorm:"size:128;unique_index;not null" spacedock:"lock"`
	Params    string    `gorm:"size:4096" spacedock:"json" spacedock:"lock"`
	Abilities []Ability `gorm:"many2many:role_abilities" json:"-" spacedock:"lock"`
	Users     []User    `gorm:"many2many:role_users" json:"-" spacedock:"lock"`
}

func (*Role) AddAbility

func (role *Role) AddAbility(name string) *Ability

func (*Role) AddParam

func (role *Role) AddParam(ability string, param string, value string) error

func (*Role) AfterFind

func (s *Role) AfterFind()

func (*Role) GetParams

func (role *Role) GetParams(ability string, param string) []string

func (*Role) HasAbility

func (role *Role) HasAbility(name string) bool

func (*Role) RemoveAbility

func (role *Role) RemoveAbility(name string)

func (*Role) RemoveParam

func (role *Role) RemoveParam(ability string, param string, value string) error

type SharedAuthor

type SharedAuthor struct {
	Model

	User     User `json:"-" gorm:"ForeignKey:UserID" spacedock:"lock"`
	UserID   uint `json:"user" spacedock:"lock"`
	Mod      Mod  `json:"-" gorm:"ForeignKey:ModID" spacedock:"lock"`
	ModID    uint `json:"mod" spacedock:"lock"`
	Accepted bool `gorm:"not null" json:"accepted"`
}

func NewSharedAuthor

func NewSharedAuthor(user User, mod Mod) *SharedAuthor

func (*SharedAuthor) AfterFind

func (s *SharedAuthor) AfterFind()

type Token

type Token struct {
	Model

	Token string `gorm:"size:32" spacedock:"lock" json:"token"`
}

func NewToken

func NewToken() *Token

type User

type User struct {
	Model

	Username            string    `gorm:"size:128;unique_index;not null" json:"username"`
	Email               string    `gorm:"size:256;unique_index;not null" json:"email"`
	ShowEmail           bool      `json:"showEmail"`
	Public              bool      `json:"public"`
	Password            string    `gorm:"size:128" json:"-" spacedock:"lock"`
	Description         string    `gorm:"size:10000" json:"description"`
	Confirmation        string    `gorm:"size:128" json:"-" spacedock:"lock"`
	PasswordReset       string    `gorm:"size:128" json:"-" spacedock:"lock"`
	PasswordResetExpiry time.Time `json:"-" spacedock:"lock"`
	Roles               []Role    `gorm:"many2many:role_users" json:"-" spacedock:"lock"`

	SharedAuthors []SharedAuthor `json:"-" spacedock:"lock"`
	Following     []Mod          `json:"following" gorm:"many2many:mod_followers" spacedock:"lock"`
	// contains filtered or unexported fields
}

func NewUser

func NewUser(name string, email string, password string) *User

func (*User) AddRole

func (user *User) AddRole(name string) *Role

func (*User) AfterFind

func (s *User) AfterFind()

func (*User) Format

func (user *User) Format(admin bool) map[string]interface{}

func (*User) GetAbilities

func (user *User) GetAbilities() []string

func (*User) GetById

func (user *User) GetById(id uint) error

func (*User) HasRole

func (user *User) HasRole(name string) bool

func (*User) IsAuthenticated

func (user *User) IsAuthenticated() bool

func (*User) Login

func (user *User) Login()

func (*User) Logout

func (user *User) Logout()

func (*User) RemoveRole

func (user *User) RemoveRole(name string)

func (*User) SetPassword

func (user *User) SetPassword(password string)

Jump to

Keyboard shortcuts

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