unit

package
v0.0.0-...-c2300e3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StatusActive  = Status{"ACTIVE"}
	StatusDeleted = Status{"DELETED"}
)

Set of possible status for a user.

View Source
var (
	ErrNotFound      = errors.New("unit not found")
	ErrLimitExceeded = errors.New("max number of units exceeded")
	ErrBlockNotFound = errors.New("block not found")
	ErrFloorNotFound = errors.New("floor not found")
)

Functions

This section is empty.

Types

type Core

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

func NewCore

func NewCore(
	log *logger.Logger,
	store Storer,
	property *property.Core,
	block *block.Core,
	floor *floor.Core,
) *Core

func (*Core) BatchCreate

func (c *Core) BatchCreate(ctx context.Context, cores []NewUnit) ([]Unit, error)

func (*Core) Create

func (c *Core) Create(ctx context.Context, core NewUnit) (Unit, error)

func (*Core) Delete

func (c *Core) Delete(ctx context.Context, core Unit) (Unit, error)

func (*Core) DeleteByPropertyID

func (c *Core) DeleteByPropertyID(ctx context.Context, propertyID uuid.UUID) error

func (*Core) ExecuteUnderTransaction

func (c *Core) ExecuteUnderTransaction(tx transaction.Transaction) (*Core, error)

ExecuteUnderTransaction constructs a new Core value that will use the specified transaction in any store related calls.

func (*Core) QueryByFloorID

func (c *Core) QueryByFloorID(ctx context.Context, id uuid.UUID) ([]Unit, error)

func (*Core) QueryByID

func (c *Core) QueryByID(ctx context.Context, id uuid.UUID) (Unit, error)

func (*Core) QueryByPropertyID

func (c *Core) QueryByPropertyID(ctx context.Context, id uuid.UUID) ([]Unit, error)

func (*Core) Update

func (c *Core) Update(ctx context.Context, o Unit, n UpdateUnit) (Unit, error)

type NewUnit

type NewUnit struct {
	ID         uuid.UUID
	Name       string
	PropertyID uuid.UUID
	BlockID    uuid.UUID
	FloorID    uuid.UUID
}

type Status

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

Status represents a user status in the system.

func MustParseStatus

func MustParseStatus(value string) Status

MustParseStatus parses the string value and returns a status if one exists. If an error occurs the function panics.

func ParseStatus

func ParseStatus(value string) (Status, error)

ParseStatus parses the string value and returns a status if one exists.

func (*Status) Equal

func (r *Status) Equal(r2 Status) bool

Equal provides support for the go-cmp package and testing.

func (*Status) MarshalText

func (r *Status) MarshalText() ([]byte, error)

MarshalText implement the marshal interface for JSON conversions.

func (*Status) Name

func (r *Status) Name() string

Name returns the name of the status.

func (*Status) UnmarshalText

func (r *Status) UnmarshalText(data []byte) error

UnmarshalText implement the unmarshal interface for JSON conversions.

type Storer

type Storer interface {
	Create(ctx context.Context, core Unit) error
	BatchCreate(ctx context.Context, cores []Unit) error
	DeleteByPropertyID(ctx context.Context, id uuid.UUID) error
	Update(ctx context.Context, core Unit) error
	QueryByID(ctx context.Context, id uuid.UUID) (Unit, error)
	QueryByFloorID(ctx context.Context, id uuid.UUID) ([]Unit, error)
	QueryByPropertyID(ctx context.Context, id uuid.UUID) ([]Unit, error)
	ExecuteUnderTransaction(tx transaction.Transaction) (Storer, error)
}

type Unit

type Unit struct {
	ID         uuid.UUID
	Name       string
	Status     Status
	PropertyID uuid.UUID
	BlockID    uuid.UUID
	FloorID    uuid.UUID
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

type UpdateUnit

type UpdateUnit struct {
	Name *string
}

Directories

Path Synopsis
stores

Jump to

Keyboard shortcuts

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