Documentation
¶
Index ¶
- Constants
- func CreateHandler(svc ObjectService, w http.ResponseWriter, r *http.Request) error
- func DeleteHandler(svc ObjectService, w http.ResponseWriter, r *http.Request) error
- func GetHandler(svc ObjectService, w http.ResponseWriter, r *http.Request) error
- func ListHandler(svc ObjectService, w http.ResponseWriter, r *http.Request) error
- type CreateObjectSpec
- type FilterOptions
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, error)
- type Object
- func (object Object) GetCreatedAt() time.Time
- func (object Object) GetDeletedAt() *time.Time
- func (object Object) GetID() int64
- func (object Object) GetObjectId() string
- func (object Object) GetObjectType() string
- func (object Object) GetUpdatedAt() time.Time
- func (object Object) ToObjectSpec() *ObjectSpec
- type ObjectListParamParser
- type ObjectRepository
- type ObjectService
- func (svc ObjectService) Create(ctx context.Context, objectSpec ObjectSpec) (*ObjectSpec, error)
- func (svc ObjectService) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (svc ObjectService) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*ObjectSpec, error)
- func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]ObjectSpec, error)
- func (svc ObjectService) Routes() ([]service.Route, error)
- type ObjectSpec
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, error)
- type SQLiteRepository
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
- func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, error)
Constants ¶
View Source
const DefaultSortBy = "objectId"
Variables ¶
This section is empty.
Functions ¶
func CreateHandler ¶ added in v0.11.0
func CreateHandler(svc ObjectService, w http.ResponseWriter, r *http.Request) error
func DeleteHandler ¶ added in v0.11.0
func DeleteHandler(svc ObjectService, w http.ResponseWriter, r *http.Request) error
func GetHandler ¶ added in v0.11.0
func GetHandler(svc ObjectService, w http.ResponseWriter, r *http.Request) error
func ListHandler ¶ added in v0.11.0
func ListHandler(svc ObjectService, w http.ResponseWriter, r *http.Request) error
Types ¶
type CreateObjectSpec ¶
type FilterOptions ¶
type FilterOptions struct {
ObjectType string
}
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) MySQLRepository
func (MySQLRepository) DeleteByObjectTypeAndId ¶
func (MySQLRepository) GetByObjectTypeAndId ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, error)
type Object ¶
type Object struct {
ID int64 `mysql:"id" postgres:"id" sqlite:"id"`
ObjectType string `mysql:"objectType" postgres:"object_type" sqlite:"objectType"`
ObjectId string `mysql:"objectId" postgres:"object_id" sqlite:"objectId"`
CreatedAt time.Time `mysql:"createdAt" postgres:"created_at" sqlite:"createdAt"`
UpdatedAt time.Time `mysql:"updatedAt" postgres:"updated_at" sqlite:"updatedAt"`
DeletedAt *time.Time `mysql:"deletedAt" postgres:"deleted_at" sqlite:"deletedAt"`
}
func (Object) GetCreatedAt ¶ added in v0.8.0
func (Object) GetDeletedAt ¶ added in v0.8.0
func (Object) GetObjectId ¶ added in v0.8.0
func (Object) GetObjectType ¶ added in v0.8.0
func (Object) GetUpdatedAt ¶ added in v0.8.0
func (Object) ToObjectSpec ¶
func (object Object) ToObjectSpec() *ObjectSpec
type ObjectListParamParser ¶
type ObjectListParamParser struct{}
func (ObjectListParamParser) GetDefaultSortBy ¶
func (parser ObjectListParamParser) GetDefaultSortBy() string
func (ObjectListParamParser) GetSupportedSortBys ¶
func (parser ObjectListParamParser) GetSupportedSortBys() []string
func (ObjectListParamParser) ParseValue ¶
func (parser ObjectListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type ObjectRepository ¶
type ObjectRepository interface {
Create(ctx context.Context, object Model) (int64, error)
GetById(ctx context.Context, id int64) (Model, error)
GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, error)
DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (ObjectRepository, error)
type ObjectService ¶
type ObjectService struct {
service.BaseService
Repository ObjectRepository
EventSvc event.EventService
WarrantSvc warrant.WarrantService
}
func NewService ¶
func NewService(env service.Env, repository ObjectRepository, eventSvc event.EventService, warrantSvc warrant.WarrantService) ObjectService
func (ObjectService) Create ¶
func (svc ObjectService) Create(ctx context.Context, objectSpec ObjectSpec) (*ObjectSpec, error)
func (ObjectService) DeleteByObjectTypeAndId ¶
func (ObjectService) GetByObjectTypeAndId ¶ added in v0.12.0
func (svc ObjectService) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*ObjectSpec, error)
func (ObjectService) List ¶
func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]ObjectSpec, error)
type ObjectSpec ¶
type ObjectSpec struct {
// NOTE: ID is required here for internal use.
// However, we don't return it to the client.
ID int64 `json:"-"`
ObjectType string `json:"objectType" validate:"required,valid_object_type"`
ObjectId string `json:"objectId" validate:"required,valid_object_id"`
CreatedAt time.Time `json:"createdAt"`
}
func (ObjectSpec) ToObject ¶
func (spec ObjectSpec) ToObject() *Object
type PostgresRepository ¶ added in v0.4.0
type PostgresRepository struct {
database.SQLRepository
}
func NewPostgresRepository ¶ added in v0.4.0
func NewPostgresRepository(db *database.Postgres) PostgresRepository
func (PostgresRepository) DeleteByObjectTypeAndId ¶ added in v0.4.0
func (PostgresRepository) GetByObjectTypeAndId ¶ added in v0.4.0
func (PostgresRepository) List ¶ added in v0.4.0
func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, error)
type SQLiteRepository ¶ added in v0.11.0
type SQLiteRepository struct {
database.SQLRepository
}
func NewSQLiteRepository ¶ added in v0.11.0
func NewSQLiteRepository(db *database.SQLite) SQLiteRepository
func (SQLiteRepository) DeleteByObjectTypeAndId ¶ added in v0.11.0
func (SQLiteRepository) GetByObjectTypeAndId ¶ added in v0.11.0
func (SQLiteRepository) List ¶ added in v0.11.0
func (repo SQLiteRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, error)
Click to show internal directories.
Click to hide internal directories.