event

package
v0.0.0-...-92f7cd3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MaxLIstLimit = 1000

MaxLIstLimit const

View Source
const (
	// TableName const
	TableName = "event"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	ID           uint    `json:"id"`
	UserID       uint    `db:"user_id" json:"userId"`
	Title        string  `json:"title"`
	Description  *string `json:"description,omitempty"`
	Time         time.Time
	Duration     time.Duration  `json:"duration"`
	NoticePeriod *time.Duration `db:"notice_period" json:"noticePeriod,omitempty"`
	NoticeTime   *time.Time     `db:"notice_time" json:"noticeTime"`
}

Event entity

func New

func New() *Event

New func is a constructor

func (Event) Notification

func (e Event) Notification() *notification.Notification

Notification returns a Notification object for a current Event object

func (Event) String

func (e Event) String() string

String func is a func for the Stringer interface

func (Event) TableName

func (e Event) TableName() string

TableName func

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON is unmarshal func for an entity

func (Event) Validate

func (e Event) Validate() error

Validate func

type IRepository

type IRepository interface {
	// Get returns an entity with the specified ID.
	Get(ctx context.Context, id uint) (*Event, error)
	// Count returns the number of entities.
	//Count(ctx context.Context) (uint, error)
	// Query returns the list of entities with the given offset and limit.
	Query(ctx context.Context, query *QueryCondition, offset, limit uint) ([]Event, error)
	// Create saves a new entity in the storage.
	Create(ctx context.Context, entity *Event) error
	// Update updates an entity with given ID in the storage.
	Update(ctx context.Context, entity *Event) error
	// Delete removes an entity with given ID from the storage.
	Delete(ctx context.Context, id uint) error
	// ListForNotifications returns list of events for notification
	ListForNotifications(ctx context.Context, offset, limit uint) ([]Event, error)
	// SetHadNoticed set event had noticed
	SetHadNoticed(ctx context.Context, id uint) error
}

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

type IService

type IService interface {
	// NewEntity returns new empty entity
	NewEntity() *Event
	// Get returns an entity with given ID
	Get(ctx context.Context, id uint) (*Event, error)
	//First(ctx context.Context, entity *Event) (*Event, error)
	// Query returns a list with pagination
	Query(ctx context.Context, offset, limit uint) ([]Event, error)
	// List entity
	List(ctx context.Context, condition *QueryCondition) ([]Event, error)
	//Count(ctx context.Context) (uint, error)
	// Create entity
	Create(ctx context.Context, entity *Event) error
	// Update entity
	Update(ctx context.Context, entity *Event) error
	// Delete entity
	Delete(ctx context.Context, id uint) error
	// NotificationsList returns a list of notification.
	NotificationsList(ctx context.Context) ([]*notification.Notification, error)
	// SetHadNoticed set event had noticed
	SetHadNoticed(ctx context.Context, id uint) error
}

IService encapsulates usecase logic for event.

func NewService

func NewService(repo IRepository, logger log.ILogger) IService

NewService creates a new service.

type QueryCondition

type QueryCondition struct {
	Where *WhereCondition
}

QueryCondition struct for defining a query condition

type WhereCondition

type WhereCondition struct {
	Time *WhereConditionTime
}

WhereCondition struct

type WhereConditionTime

type WhereConditionTime struct {
	Between *[2]time.Time
}

WhereConditionTime struct

Jump to

Keyboard shortcuts

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