domain

package
v0.0.0-...-b36981d Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound means resource not found
	ErrNotFound    = &AppError{Code: "NOT_FOUND", Message: "resource was not found", Status: codes.NotFound}
	ErrWrongStatus = &AppError{Code: "WRONG_STATUS", Message: "status of resource is wrong", Status: codes.Internal}
	ErrStale       = &AppError{Code: "STALE", Message: "resource is stale.  please retry", Status: codes.Internal}
)

Functions

This section is empty.

Types

type AppError

type AppError struct {
	Code    string                 `json:"code"`
	Message string                 `json:"message"`
	Status  codes.Code             `json:"status"`
	Details map[string]interface{} `json:"details"`
}

AppError handles application exception.

func New

func New(code, message string) AppError

New functions create a new AppError instance

func (AppError) Error

func (e AppError) Error() string

type Event

type Event struct {
	ID              int64           `gorm:"column:id;primary_key" json:"id"`
	Title           string          `gorm:"column:title" json:"title"`
	Description     string          `gorm:"column:description" json:"description"`
	PublishedStatus PublishedStatus `gorm:"column:published_status" json:"published_status"`
	Version         int64           `gorm:"column:version" json:"version"`
	CreatedAt       time.Time       `gorm:"column:created_at" json:"created_at"`
	UpdatedAt       time.Time       `gorm:"column:updated_at" json:"updated_at"`
}

Event is Event

func (*Event) TableName

func (e *Event) TableName() string

TableName sets the insert table name for this struct type

type EventRepository

type EventRepository interface {
	WithTX(tx *gorm.DB) EventRepository
	Event(ctx context.Context, id int64) (Event, error)
	Events(ctx context.Context, opts FindEventOptions) ([]Event, error)
	UpdatePublishStatus(ctx context.Context, request UpdateEventStatusRequest) error
}

EventRepository represents the event's repository contract

type EventUsecase

type EventUsecase interface {
	Events(ctx context.Context, opts FindEventOptions) ([]Event, error)
	UpdatePublishStatus(ctx context.Context, request UpdateEventStatusRequest) error
}

EventUsecase represents the wallet's usecases

type FindEventOptions

type FindEventOptions struct {
	ID             int64  `gorm:"column:id;primary_key" json:"id"`
	Title          string `gorm:"column:title" json:"title"`
	CreatedAtStart time.Time
	CreatedAtEnd   time.Time
}

FindEventOptions is a query condition for finding events

func (*FindEventOptions) TableName

func (f *FindEventOptions) TableName() string

type PublishedStatus

type PublishedStatus int32

PublishedStatus identifies event published status.

const (
	// Draft ...
	Draft PublishedStatus = 1
	// Published ...
	Published PublishedStatus = 2
)

type UpdateEventStatusRequest

type UpdateEventStatusRequest struct {
	EventID         int64
	TransID         string
	PublishedStatus PublishedStatus
	Version         int64
}

UpdateEventStatusRequest ...

type Wallet

type Wallet struct {
	ID        int64
	Amount    int64
	UpdatedAt time.Time
}

Wallet is Wallet

type WalletUsecase

type WalletUsecase interface {
	Wallet(ctx context.Context) (*Wallet, error)
	Withdraw(ctx context.Context, transID string, amount int64) error
}

WalletUsecase represents the wallet's usecases

Jump to

Keyboard shortcuts

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