topic

package
v0.0.0-...-780089a Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category string
const (
	Software       Category = "software"
	SocialSciences Category = "social_sciences"
	Other          Category = "other"
)

type CreateInput

type CreateInput struct {
	Capacity int      `json:"capacity" validate:"required,min=1"`
	Category Category `json:"category" validate:"required"`
	Title    string   `json:"title" validate:"required,min=3"`
}

type CreateTopicOpts

type CreateTopicOpts struct {
	Category Category  `json:"category"`
	Title    string    `json:"title"`
	Capacity int       `json:"capacity"`
	Owner    uuid.UUID `json:"owner"`
}

CreateTopicOpts are options struct to create a new Topic

type PgRepo

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

func NewPgRepo

func NewPgRepo(pool *pgxpool.Pool) *PgRepo

func (*PgRepo) Delete

func (r *PgRepo) Delete(ctx context.Context, id uuid.UUID) error

func (*PgRepo) FindByID

func (r *PgRepo) FindByID(ctx context.Context, id uuid.UUID) (*Topic, error)

func (*PgRepo) FindByOwner

func (r *PgRepo) FindByOwner(ctx context.Context, id uuid.UUID) ([]Topic, error)

func (*PgRepo) FindInvolved

func (r *PgRepo) FindInvolved(ctx context.Context, id uuid.UUID) ([]Topic, error)

func (*PgRepo) Save

func (r *PgRepo) Save(ctx context.Context, t *Topic) error

func (*PgRepo) Update

func (r *PgRepo) Update(ctx context.Context, t *Topic) error

type Repo

type Repo interface {
	Save(ctx context.Context, t *Topic) error
	FindByID(ctx context.Context, id uuid.UUID) (*Topic, error)
	FindByOwner(ctx context.Context, id uuid.UUID) ([]Topic, error)
	FindInvolved(ctx context.Context, id uuid.UUID) ([]Topic, error)
	Update(ctx context.Context, t *Topic) error
	Delete(ctx context.Context, id uuid.UUID) error
}

type Routes

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

func NewRoutes

func NewRoutes(repo Repo, validator *validate.Validate) *Routes

func (*Routes) Create

func (r *Routes) Create(c *fiber.Ctx) error

Create

@ID			Topic-Create
@Summary	Create Topic
@Tags		topics
@Security	BearerAuth
@Accept		json
@Produce	json
@Param		options	body	CreateInput	true	"New Topic Information"
@Success	201
@Failure	400
@Failure	500
@Router		/topics [post]

func (*Routes) Delete

func (r *Routes) Delete(c *fiber.Ctx) error

Delete

@ID			Topic-Delete
@Summary	Delete Topic
@Tags		topics
@Security	BearerAuth
@Produce	json
@Param		id	path	string	true	"Topic ID"
@Success	200
@Failure	400
@Failure	404
@Failure	500
@Router		/topics/{id} [delete]

func (*Routes) FindByID

func (r *Routes) FindByID(c *fiber.Ctx) error

FindByID

@ID			Topic-Find
@Summary	Find Topic By ID
@Tags		topics
@Produce	json
@Param		id	path		string	true	"Topic ID"
@Success	200	{object}	Topic
@Failure	400
@Failure	404
@Failure	500
@Router		/topics/{id} [get]

func (*Routes) FindByOwnerID

func (r *Routes) FindByOwnerID(c *fiber.Ctx) error

FindByOwnerID

@ID			Topic-Find-Owned
@Summary	Find Topics By Owner ID
@Tags		topics
@Produce	json
@Param		id	path		string	true	"Owner ID"
@Success	200	{object}	[]Topic
@Failure	400
@Failure	500
@Router		/topics/owner/{id} [get]

func (*Routes) FindInvolved

func (r *Routes) FindInvolved(c *fiber.Ctx) error

FindInvolved

@ID			Topic-Find-Paired
@Summary	Find Paired Topics By User ID
@Tags		topics
@Produce	json
@Param		id	path		string	true	"Involved ID"
@Success	200	{object}	[]Topic
@Failure	400
@Failure	500
@Router		/topics/pair/{id} [get]

type Topic

type Topic struct {
	ID       uuid.UUID `json:"id"`
	Category Category  `json:"category"`
	Title    string    `json:"title"`

	// Max expected parties
	Capacity int `json:"capacity"`

	// ID of the owner User
	Owner uuid.UUID `json:"owner"`

	// IDs of invloved Users
	Parties []uuid.UUID `json:"parties"`

	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	FinishedAt time.Time `json:"finished_at"`
}

Topic represents a topic to study and ID's of users involved

func CreateTopic

func CreateTopic(opts CreateTopicOpts) Topic

CreateTopic creates a new Topic with new ID

func (*Topic) AddParties

func (t *Topic) AddParties(ids ...uuid.UUID) error

func (*Topic) Finish

func (t *Topic) Finish()

func (*Topic) IsFinished

func (t *Topic) IsFinished() bool

func (*Topic) RemoveParties

func (t *Topic) RemoveParties(ids ...uuid.UUID)

func (*Topic) UpdateCapacity

func (t *Topic) UpdateCapacity(newCapactiy int)

Jump to

Keyboard shortcuts

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