Version: v1.0.0 Latest Latest

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 3 Imported by: 0




View Source
const (
	FeeColumn         = "fee"
	DescriptionColumn = "description"
	LocationColumn    = "location"
	LogoColumn        = "logo"
	ManagedClubColumn = "Managed"
	ClubIDVar         = "cid"
	AllClubInfo       = "all"
	AllClubEventsHost = "events"
	ClubTagTable      = "club_tag"
	SetsColumn        = "Sets"
	HostsColumn       = "Hosts"
	SizeColumn        = "size"
	BioColumn         = "bio"
	ClubTable         = "club"
	NameColumn        = "name"
	ActiveColumn      = "active"

Club variables for db columns/route variables

View Source
const (
	UsernameVar    = "username"
	UsernameColumn = "username"
	EmailColumn    = "email"
	PasswordColumn = "password"

Credential variables for db columns/route variables

View Source
const (
	DateTimeColumn = "date_time"
	EventIDVar     = "eid"
	EventTable     = "event"

Event variables for db columns/route variables

View Source
const (
	OpAdd    = "ADD"
	OpRemove = "REMOVE"

Operation variables for adding/removing models

View Source
const (
	TagNameVar     = "tagName"
	TagTable       = "tag"
	IsActiveColumn = "IsActive"

Tag variables for db columns/route variables

View Source
const (
	RefreshTokenVar = "RefreshToken"
	TokenVar        = "token"

Token variable constants

View Source
const (
	AllUserInfo         = "all"
	AllUserClubsManage  = "clubs"
	AllUserEventsAttend = "events"
	ChoosesColumn       = "Chooses"
	AttendsColumn       = "Attends"
	SwipedColumn        = "Swiped"
	UserClubTable       = "user_club"
	UserTable           = "user"
	ManagesColumn       = "Manages"
	IsApprovedColumn    = "is_approved"
	IDColumn            = "id"

User variables for db columns/route variables


View Source
var IsOwnerColumn = "is_owner"

IsOwnerColumn represents the is_owner column in the UserClub joint table


This section is empty.


type Base

type Base struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"-" json:"createdAt"`
	UpdatedAt time.Time      `json:"-" json:"updatedAt"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index" json:"deletedAt"`

Base - Revamped the current default base GORM model to provide more flexibility when encoding to JSON This reduces extra DisplayWrappers in order to obtain the ID

type Club

type Club struct {
	Name    string  `validate:"required,min=3,max=50" json:"name"`
	Email   string  `validate:"required,email" json:"email"`
	Bio     string  `validate:"required,min=1,max=300" json:"bio"`
	Size    int     `validate:"required,gt=0" json:"size"`
	Active  bool    `json:"-"`
	Sets    []Tag   `gorm:"many2many:club_tag;foreignKey:id;References:Name;" json:"tags"`
	Hosts   []Event `gorm:"many2many:club_event;" json:"hosts"`
	Managed []User  `gorm:"many2many:user_club;" json:"-"`

Club - Base Club struct

func NewClub

func NewClub() *Club

NewClub - Create new default Club

func (*Club) DisplayBaseClubInfo

func (c *Club) DisplayBaseClubInfo() ClubBaseInfo

DisplayBaseClubInfo displays base club data

type ClubBaseInfo

type ClubBaseInfo struct {
	ID   uint   `json:"id"`
	Name string `json:"name"`

ClubBaseInfo - Displaying basic club data

type ClubUpdateInfo

type ClubUpdateInfo struct {
	Size int    `validate:"required,gt=0"`
	Bio  string `validate:"required,max=300"`

ClubUpdateInfo - Payload for updating a club's info

func NewClubUpdate

func NewClubUpdate() *ClubUpdateInfo

NewClubUpdate returns a struct to update club info

type Credentials

type Credentials struct {
	Username string `gorm:"UNIQUE" validate:"alpha,min=2,max=15,required" json:"username"`
	Email    string `gorm:"UNIQUE" validate:"required,email" json:"email"`

	// Max 45 due to 50 length limitation of bcrypt
	Password string `validate:"required,min=3,max=45" json:"password"`

Credentials struct for user login/signup

func NewCredentials

func NewCredentials() *Credentials

NewCredentials - Create new default Credentials

type Event

type Event struct {
	Name        string    `validate:"required,min=1,max=50" json:"name"`
	DateTime    time.Time `validate:"required" json:"datetime"`
	Description string    `validate:"required,max=300" json:"description"`
	Location    string    `validate:"required,max=300" json:"location"`
	Fee         float64   `validate:"gte=0" json:"fee"`

Event - Basic Event Struct

func NewEvent

func NewEvent() *Event

NewEvent - Create new default Event

type EventRequirement

type EventRequirement struct {
	Admin       string `json:"admin"`
	Name        string `json:"name"`
	DateTime    string `json:"datetime"`
	Description string `json:"description"`
	Location    string `json:"location"`
	Fee         string `json:"fee"`

EventRequirement - Listing out requirements for an event to be successfully created

func NewEventRequirement

func NewEventRequirement() *EventRequirement

NewEventRequirement returns the requirements when creating an event See model.event or docs for event constraints

type ManagesDisplay

type ManagesDisplay struct {
	IsOwner bool `json:"isOwner"`

ManagesDisplay is used as a display wrapper for the ClubDisplay For a users managed club, whether they're an owner or not is also displayed

type PasswordChange

type PasswordChange struct {
	OldPassword string `validate:"required"`
	NewPassword string `validate:"required"`

PasswordChange - Resetting a user password given the old and new passwords

func NewPasswordChange

func NewPasswordChange() *PasswordChange

NewPasswordChange - Create new default PasswordChange

type Tag

type Tag struct {
	ID        uint           `gorm:"autoIncrement" json:"id"`
	CreatedAt time.Time      `json:"-"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
	Name      string         `gorm:"primarykey" validate:"required,min=1,max=25" json:"name"`
	IsActive  bool           `json:"isActive"`

Tag - Basic Tag Struct

func NewTag

func NewTag() *Tag

NewTag - Create new default Tag

type TokenInfo

type TokenInfo struct {
	// Life span of 5 minutes
	AccessToken string

	// Life span of 1 hour
	RefreshToken string

TokenInfo struct containing the Access and Refresh token

func NewTokenInfo

func NewTokenInfo() *TokenInfo

NewTokenInfo Create new default TokenInfo

type User

type User struct {
	*Credentials `json:"-"`
	Manages      []Club  `gorm:"many2many:user_club;" json:"-"`
	Chooses      []Tag   `gorm:"many2many:user_tag;foreignKey:id;References:Name" json:"-"`
	Attends      []Event `gorm:"many2many:user_event;" json:"-"`
	IsAdmin      bool    `json:"-"`
	IsApproved   bool    `json:"-"`
	Swiped       []Club  `gorm:"many2many:user_swipe_club;" json:"-"`

User base struct

func NewUser

func NewUser() *User

NewUser - Create new default User

func (*User) DisplayAllInfo

func (u *User) DisplayAllInfo() *UserDisplay

DisplayAllInfo public user data

func (*User) DisplayBaseUserInfo

func (u *User) DisplayBaseUserInfo() UserBaseInfo

DisplayBaseUserInfo displays base user data

type UserBaseInfo

type UserBaseInfo struct {
	ID       uint   `json:"id"`
	Username string `json:"username"`

UserBaseInfo - Displaying basic user data

type UserClub

type UserClub struct {
	UserId  int
	ClubId  int
	IsOwner bool

UserClub - Database format for many to many relation with User and Club Keeping a record of users to clubs and whether they're an associated owner of the club or not

func NewUserClub

func NewUserClub() *UserClub

NewUserClub - Create new default UserClub

type UserDisplay

type UserDisplay struct {
	Email   string            `json:"email"`
	Manages []*ManagesDisplay `json:"manages"`
	Tags    []Tag             `json:"tags"`
	Attends []Event           `json:"attends"`
	Swiped  []Club            `json:"swiped"`

UserDisplay - Displaying public user data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL