dependency

package
v0.0.0-...-ddd43b2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity interface {
	// Identity returns identity of entity
	Identity() string
	// IsDeleted checks if delete flag had been set
	IsDeleted() bool
	// GetCreateTime returns created time of entity
	GetCreateTime() time.Time
	// GetLastUpdateTime returns last updated time of entity
	GetLastUpdateTime() time.Time
	// Get returns value of given field
	Get(field string) (interface{}, error)
	// Set sets entity with given fields, key is the field name and value is the relevant value of the key
	Set(fields map[string]interface{}) error
	// Delete set DelFlag to true
	Delete()
	// MarshalJSON marshals entity to json string
	MarshalJSON() ([]byte, error)
	// MarshalJSONWithFields marshals only specified field of entity to json string
	MarshalJSONWithFields(fields ...string) ([]byte, error)
}

type Repository

type Repository interface {
	// Execute executes given command and placeholders on the middleware
	Execute(command string, args ...interface{}) (middleware.Result, error)
	// Transaction returns middleware.PoolConn, so it can run multiple statements in the same transaction
	Transaction() (middleware.Transaction, error)
	// SelectAll returns all entities
	GetAll() ([]Entity, error)
	// Select returns an entity of the given id
	GetByID(id string) (Entity, error)
	// Create creates data with given entity in the middleware
	Create(entity Entity) (Entity, error)
	// Update updates data with given entity in the middleware
	Update(entity Entity) error
	// Delete deletes data in the middleware, it's recommended to use soft deletion
	Delete(id string) error
}

type Service

type Service interface {
	// GetEntities returns entities of the service
	GetEntities() []Entity
	// GetAll gets all environment entities from the middleware
	GetAll() error
	// GetByID gets an environment entity that contains the given id from the middleware
	GetByID(id string) error
	// Create creates a new environment entity and insert it into the middleware
	Create(fields map[string]interface{}) error
	// Update gets an environment entity that contains the given id from the middleware,
	// and then update its fields that was specified in fields argument,
	// key is the filed name and value is the new field value,
	// it saves the changes to the middlewareUpdate(id string, fields map[string]interface{}) message
	Delete(id string) error
	// Marshal marshals service.Entities
	Marshal() ([]byte, error)
	// Marshal marshals service.Entities with given fields
	MarshalWithFields(fields ...string) ([]byte, error)
}

Jump to

Keyboard shortcuts

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