whatson

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateInput

type CreateInput struct {
	Title       string
	Content     string
	DateOfEvent time.Time
}

CreateInput is a new event. Content is sanitised HTML.

type Event

type Event struct {
	ID          int       `json:"id"`
	Title       string    `json:"title"`
	Content     string    `json:"content"`
	Date        time.Time `json:"date"`
	DateOfEvent time.Time `json:"dateOfEvent"`
	ImageURL    string    `json:"imageUrl,omitempty"`
}

Event is a what's-on entry as the API returns it.

type Handlers

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

Handlers serves /whatson.

func NewHandlers

func NewHandlers(svc *Service) *Handlers

func (*Handlers) Register

func (h *Handlers) Register(g *echo.Group, guards web.Guards)

Register mounts the what's-on routes on the /api/v1 group.

type Period

type Period string

Period filters events by date of event relative to today.

const (
	PeriodAll    Period = "all"
	PeriodFuture Period = "future"
	PeriodPast   Period = "past"
)

type Service

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

Service is the what's-on business logic.

func NewService

func NewService(store store, files *upload.Files) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, in CreateInput, image *upload.File) (Event, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id int) (Event, error)

Delete removes the event and its image, returning what was deleted.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id int) (Event, error)

func (*Service) List

func (s *Service) List(ctx context.Context, period Period) ([]Event, error)

List returns events for period; an empty period means all.

func (*Service) Next

func (s *Service) Next(ctx context.Context) (Event, bool, error)

Next returns the soonest upcoming event; ok is false when there is none.

func (*Service) Update

func (s *Service) Update(ctx context.Context, id int, in UpdateInput, image *upload.File) (Event, error)

type Store

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

Store stores the dependencies

func NewWhatsOnRepo

func NewWhatsOnRepo(db *sqlx.DB) *Store

NewWhatsOnRepo stores our dependency

func (*Store) AddWhatsOn

func (s *Store) AddWhatsOn(ctx context.Context, whatsOnParam WhatsOn) (WhatsOn, error)

func (*Store) DeleteWhatsOn

func (s *Store) DeleteWhatsOn(ctx context.Context, whatsOnParam WhatsOn) error

func (*Store) EditWhatsOn

func (s *Store) EditWhatsOn(ctx context.Context, whatsOnParam WhatsOn) (WhatsOn, error)

func (*Store) GetWhatsOn

func (s *Store) GetWhatsOn(ctx context.Context) ([]WhatsOn, error)

func (*Store) GetWhatsOnArticle

func (s *Store) GetWhatsOnArticle(ctx context.Context, whatsOnParam WhatsOn) (WhatsOn, error)

func (*Store) GetWhatsOnFuture

func (s *Store) GetWhatsOnFuture(ctx context.Context) ([]WhatsOn, error)

func (*Store) GetWhatsOnLatest

func (s *Store) GetWhatsOnLatest(ctx context.Context) (WhatsOn, error)

func (*Store) GetWhatsOnPast

func (s *Store) GetWhatsOnPast(ctx context.Context) ([]WhatsOn, error)

type UpdateInput

type UpdateInput struct {
	Title       *string
	Content     *string
	DateOfEvent *time.Time
	RemoveImage bool
}

UpdateInput changes an event; nil fields are left unchanged.

type WhatsOn

type WhatsOn struct {
	ID          int         `db:"id" json:"id"`
	Title       string      `db:"title" json:"title"`
	FileName    null.String `db:"file_name" json:"file_name"`
	Content     null.String `db:"content" json:"content"`
	Date        time.Time   `db:"date" json:"date"`
	DateOfEvent time.Time   `db:"date_of_event" json:"date_of_event"`
}

WhatsOn represents relevant whatsOn fields

Jump to

Keyboard shortcuts

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