album

package
v0.0.0-...-6dde671 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandlers

func RegisterHandlers(r *routing.RouteGroup, service Service, authHandler routing.Handler, logger log.Logger)

RegisterHandlers sets up the routing of the HTTP handlers.

Types

type Album

type Album struct {
	entity.Album
}

Album represents the data about an album.

type CreateAlbumRequest

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

CreateAlbumRequest represents an album creation request.

func (CreateAlbumRequest) Validate

func (m CreateAlbumRequest) Validate() error

Validate validates the CreateAlbumRequest fields.

type Repository

type Repository interface {
	// Get returns the album with the specified album ID.
	Get(ctx context.Context, id string) (entity.Album, error)
	// Count returns the number of albums.
	//Count(ctx context.Context) (int, error)
	//// Query returns the list of albums with the given offset and limit.
	//Query(ctx context.Context, offset, limit int) ([]entity.Album, error)
	// Create saves a new album in the storage.
	Create(ctx context.Context, album entity.Album) error
	// Update updates the album with given ID in the storage.
	Update(ctx context.Context, album entity.Album) error
	// Delete removes the album with given ID from the storage.
	Delete(ctx context.Context, id string) error
}

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

func NewRepository

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

type Service

type Service interface {
	Get(ctx context.Context, id string) (Album, error)
	Query(ctx context.Context, offset, limit int) ([]Album, error)
	Count(ctx context.Context) (int, error)
	Create(ctx context.Context, input CreateAlbumRequest) (Album, error)
	Update(ctx context.Context, id string, input UpdateAlbumRequest) (Album, error)
	Delete(ctx context.Context, id string) (Album, error)
}

Service encapsulates usecase logic for albums.

func NewService

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

NewService creates a new album service.

type UpdateAlbumRequest

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

UpdateAlbumRequest represents an album update request.

func (UpdateAlbumRequest) Validate

func (m UpdateAlbumRequest) Validate() error

Validate validates the CreateAlbumRequest fields.

Jump to

Keyboard shortcuts

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