model

package
v0.0.0-...-c301567 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VotesThreshold float64 = 0.7

Functions

func RandStringBytesRmndr

func RandStringBytesRmndr(n int) string

Types

type AvgResult

type AvgResult struct{ Avg float64 }

type Hadi

type Hadi struct {
	ID         int    `json:"id" gorm:"primary_key"`
	Name       string `json:"name"`
	Hypothesis string `json:"hypothesis"`
	Action     string `json:"action"`
	Metric     string `json:"metric"`
	Effect     string `json:"effect"`

	Overall    *int `json:"overall" gorm:"-"`
	Complexity *int `json:"complexity" gorm:"-"`
	Faith      *int `json:"faith" gorm:"-"`

	Votes  []*Vote `json:"votes" gorm:"foreignKey:HadiID"`
	UserID int
	User   *User `json:"user" gorm:"foreignKey:UserID"`
	TeamID int
	Team   *Team `json:"team" gorm:"foreignKey:TeamID"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func NewHadi

func NewHadi(input HadiInput) *Hadi

type HadiInput

type HadiInput struct {
	Name       string `json:"name"`
	Hypothesis string `json:"hypothesis"`
	Action     string `json:"action"`
	Metric     string `json:"metric"`
	Effect     string `json:"effect"`
	ResetVotes bool   `json:"resetVotes"`
}

type HadiRepository

type HadiRepository struct {
	Db *gorm.DB
}

func (*HadiRepository) FindById

func (r *HadiRepository) FindById(user User, hadiID int) *Hadi

type Invite

type Invite struct {
	ID     int    `json:"id" gorm:"primary_key"`
	Token  string `json:"token"`
	TeamID int
	Team   *Team `json:"team" gorm:"foreignKey:TeamID"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func NewInvite

func NewInvite(team Team) *Invite

type Jwt

type Jwt struct {
	Token        string `json:"token"`
	RefreshToken string `json:"refreshToken"`
}

func CreateJwt

func CreateJwt(user User) (*Jwt, error)

type LoginInput

type LoginInput struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type RegInput

type RegInput struct {
	Nickname string `json:"nickname"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

type Team

type Team struct {
	ID   int    `json:"id" gorm:"primary_key"`
	Name string `json:"name"`

	OwnerID int
	Owner   *User `gorm:"foreignKey:OwnerID"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func NewTeam

func NewTeam(teamInput TeamInput) *Team

type TeamInput

type TeamInput struct {
	Name string `json:"name"`
}

type User

type User struct {
	ID       int    `json:"id" gorm:"primary_key"`
	Nickname string `json:"nickname"`
	Email    string `json:"email"`

	Secret   string `gorm:"size:255"`
	Password string
	Salt     string

	Votes []*Vote `json:"votes" gorm:"foreignKey:UserID"`
	Teams []*Team `json:"teams" gorm:"many2many:user_has_team;"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func NewUser

func NewUser(regInput RegInput) *User

func (*User) CheckPlainPassword

func (u *User) CheckPlainPassword(password string) bool

func (*User) SetPlainPassword

func (u *User) SetPlainPassword(password string)

type Vote

type Vote struct {
	ID         int `gorm:"primary_key"`
	UserID     int
	User       *User `json:"user" gorm:"foreignKey:UserID"`
	HadiID     int
	Hadi       *Hadi `json:"hadi" gorm:"foreignKey:HadiID"`
	Complexity int   `json:"complexity"`
	Faith      int   `json:"faith"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

type VoteInput

type VoteInput struct {
	Complexity int `json:"complexity"`
	Faith      int `json:"faith"`
}

type VoteRepository

type VoteRepository struct {
	Db *gorm.DB
}

func (*VoteRepository) GetOrCreateNew

func (r *VoteRepository) GetOrCreateNew(user *User, hadi *Hadi) *Vote

Jump to

Keyboard shortcuts

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