activity

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandlers

func RegisterHandlers(g *echo.Group, service Service,
	requireLogin echo.MiddlewareFunc, logger log.Logger)

Types

type Activity

type Activity struct {
	entity.Activity
}

Activity represents the data about an activity.

type CreateActivityRequest

type CreateActivityRequest struct {
	Kind     string `json:"kind" validate:"required,alpha"`
	Username string `json:"username" validate:"required,alpha"`
	Target   string `json:"target" validate:"required,alpha"`
}

CreateActivityRequest represents a user creation request.

type Repository

type Repository interface {
	// Get returns the activity with the specified activity ID.
	Get(ctx context.Context, id string, fields []string) (entity.Activity, error)
	// Count returns the number of activities.
	Count(ctx context.Context) (int, error)
	// Query returns the list of activities with the given offset and limit.
	Query(ctx context.Context, offset, limit int) ([]interface{}, error)
	// Create saves a new activity in the storage.
	Create(ctx context.Context, activity entity.Activity) error
	// Update updates the whole activity with given ID in the storage.
	Update(ctx context.Context, key string, activity entity.Activity) error
	// Patch patches a sub entry in the activity with given ID in the storage.
	Patch(ctx context.Context, key, path string, val interface{}) error
	// Delete removes the activity with given ID from the storage.
	Delete(ctx context.Context, id string) error
}

Repository encapsulates the logic to access users from the data source.

func NewRepository

func NewRepository(db *dbcontext.DB, logger log.Logger) Repository

NewRepository creates a new activity repository.

type Service

type Service interface {
	Get(ctx context.Context, id string, fields []string) (Activity, error)
	Query(ctx context.Context, offset, limit int) ([]interface{}, error)
	Count(ctx context.Context) (int, error)
	Create(ctx context.Context, input CreateActivityRequest) (Activity, error)
	Update(ctx context.Context, id string, input UpdateActivityRequest) (Activity, error)
	Delete(ctx context.Context, id string) (Activity, error)
}

Service encapsulates usecase logic for users.

func NewService

func NewService(repo Repository, logger log.Logger) Service

NewService creates a new user service.

type UpdateActivityRequest

type UpdateActivityRequest struct {
	Target string `json:"target" validate:"required,alpha"`
}

UpdateActivityRequest represents a user update request.

Jump to

Keyboard shortcuts

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