repository

package
v0.0.0-...-22fc0f8 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicatedUser = errors.New("username already exists")
	ErrUserNotFound   = gorm.ErrRecordNotFound
)
View Source
var ErrIDNotFound = gorm.ErrRecordNotFound

Functions

func InitTable

func InitTable(db *gorm.DB) error

Types

type GORMRetroRepository

type GORMRetroRepository struct {
	// contains filtered or unexported fields
}

func (*GORMRetroRepository) CreatePostit

func (repo *GORMRetroRepository) CreatePostit(ctx context.Context, p Postit) (Postit, error)

func (*GORMRetroRepository) CreateRetro

func (repo *GORMRetroRepository) CreateRetro(
	ctx context.Context,
	tid int64,
	uid int64,
	name string,
) (Retro, error)

func (*GORMRetroRepository) DeletePostitByID

func (repo *GORMRetroRepository) DeletePostitByID(ctx context.Context, pid int64) error

func (*GORMRetroRepository) DeleteRetroByID

func (repo *GORMRetroRepository) DeleteRetroByID(ctx context.Context, rid int64) error

func (*GORMRetroRepository) DeleteTemplateByID

func (repo *GORMRetroRepository) DeleteTemplateByID(ctx context.Context, tid int64) error

func (*GORMRetroRepository) GetPostitByID

func (repo *GORMRetroRepository) GetPostitByID(ctx context.Context, pid int64) (Postit, error)

func (*GORMRetroRepository) GetRetroByID

func (repo *GORMRetroRepository) GetRetroByID(ctx context.Context, rid int64) (Retro, error)

func (*GORMRetroRepository) GetRetros

func (repo *GORMRetroRepository) GetRetros(ctx context.Context) ([]Retro, error)

func (*GORMRetroRepository) GetTemplateByID

func (repo *GORMRetroRepository) GetTemplateByID(ctx context.Context, tid int64) (Template, error)

func (*GORMRetroRepository) GetTemplates

func (repo *GORMRetroRepository) GetTemplates(ctx context.Context) ([]Template, error)

func (*GORMRetroRepository) GetTopVotePostits

func (repo *GORMRetroRepository) GetTopVotePostits(
	ctx context.Context,
	rid int64,
	n int,
) ([]Postit, error)

func (*GORMRetroRepository) InsertTemplate

func (repo *GORMRetroRepository) InsertTemplate(ctx context.Context, t Template) (Template, error)

func (*GORMRetroRepository) UpdatePostit

func (repo *GORMRetroRepository) UpdatePostit(ctx context.Context, p Postit) (Postit, error)

func (*GORMRetroRepository) UpdateTemplate

func (repo *GORMRetroRepository) UpdateTemplate(ctx context.Context, t Template) (Template, error)

func (*GORMRetroRepository) VotePostitByID

func (repo *GORMRetroRepository) VotePostitByID(ctx context.Context, pid int64) error

type GORMUserRepository

type GORMUserRepository struct {
	// contains filtered or unexported fields
}

func (*GORMUserRepository) FindByID

func (repo *GORMUserRepository) FindByID(ctx context.Context, id int64) (User, error)

func (*GORMUserRepository) FindByUsername

func (repo *GORMUserRepository) FindByUsername(ctx context.Context, username string) (User, error)

func (*GORMUserRepository) Insert

func (repo *GORMUserRepository) Insert(ctx context.Context, u User) (User, error)

type Postit

type Postit struct {
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
	ID        int64          `json:"id"         gorm:"primarykey;autoIncrement"`

	// belongs to
	UserID int64 `json:"owner_id"`
	User   User  `json:"owner"`

	// belongs to
	QuestionID int64 `json:"question_id"`

	Votes int `json:"votes"`

	// Content
	Content   string `json:"content"`
	IsVisible bool   `json:"is_visible"`
}

type Question

type Question struct {
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
	ID        int64          `json:"id"         gorm:"primarykey;autoIncrement"`

	Content string `json:"content"`

	// fk
	RetroID int64 `json:"retro_id"`

	// has many
	Postits []Postit `json:"postIts"`
}

type Retro

type Retro struct {
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
	ID        int64          `json:"id"         gorm:"primarykey;autoIncrement"`

	Name string `gorm:"index" json:"name"`

	// belongs to
	UserID int64 `json:"owner_id"`
	User   User  `json:"owner"`

	// Questions are copied from the template
	// has many
	Questions []Question `json:"questions"`
}

type RetroRepository

type RetroRepository interface {
	InsertTemplate(ctx context.Context, t Template) (Template, error)
	UpdateTemplate(ctx context.Context, t Template) (Template, error)
	GetTemplates(ctx context.Context) ([]Template, error)
	GetTemplateByID(ctx context.Context, tid int64) (Template, error)
	DeleteTemplateByID(ctx context.Context, tid int64) error

	CreateRetro(ctx context.Context, tid int64, uid int64, name string) (Retro, error)
	GetRetros(ctx context.Context) ([]Retro, error)
	GetRetroByID(ctx context.Context, rid int64) (Retro, error)
	DeleteRetroByID(ctx context.Context, rid int64) error

	CreatePostit(ctx context.Context, p Postit) (Postit, error)
	GetPostitByID(ctx context.Context, pid int64) (Postit, error)
	DeletePostitByID(ctx context.Context, pid int64) error
	UpdatePostit(ctx context.Context, p Postit) (Postit, error)
	VotePostitByID(ctx context.Context, pid int64) error
	GetTopVotePostits(ctx context.Context, rid int64, n int) ([]Postit, error)
}

func NewRetroRepository

func NewRetroRepository(db *gorm.DB) RetroRepository

type Template

type Template struct {
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
	ID        int64          `json:"id"         gorm:"primarykey;autoIncrement"`

	Name string `gorm:"index" json:"name"`

	// belongs to
	UserID int64 `json:"owner_id"`
	User   User  `json:"owner"`

	// has many
	Questions []TemplateQuestion `json:"questions"`
}

type TemplateQuestion

type TemplateQuestion struct {
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
	ID        int64          `json:"id"         gorm:"primarykey;autoIncrement"`

	Content string `json:"content"`

	// fk
	TemplateID int64 `json:"template_id"`
}

type User

type User struct {
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
	ID        int64          `json:"id"         gorm:"primarykey;autoIncrement"`

	Username string `gorm:"unique" json:"username"`
	Password string `              json:"-"`
}

type UserRepository

type UserRepository interface {
	Insert(ctx context.Context, u User) (User, error)
	FindByUsername(ctx context.Context, username string) (User, error)
	FindByID(ctx context.Context, id int64) (User, error)
}

func NewUserRepository

func NewUserRepository(db *gorm.DB) UserRepository

Jump to

Keyboard shortcuts

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