Documentation
¶
Index ¶
- Constants
- func CreateHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
- func DeleteHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
- func GetHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
- func ListHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
- func UpdateHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
- type Feature
- func (feature Feature) GetCreatedAt() time.Time
- func (feature Feature) GetDeletedAt() *time.Time
- func (feature Feature) GetDescription() *string
- func (feature Feature) GetFeatureId() string
- func (feature Feature) GetID() int64
- func (feature Feature) GetName() *string
- func (feature Feature) GetObjectId() int64
- func (feature Feature) GetUpdatedAt() time.Time
- func (feature *Feature) SetDescription(newDescription *string)
- func (feature *Feature) SetName(newName *string)
- func (feature Feature) ToFeatureSpec() *FeatureSpec
- type FeatureListParamParser
- type FeatureRepository
- type FeatureService
- func (svc FeatureService) Create(ctx context.Context, featureSpec FeatureSpec) (*FeatureSpec, error)
- func (svc FeatureService) DeleteByFeatureId(ctx context.Context, featureId string) error
- func (svc FeatureService) GetByFeatureId(ctx context.Context, featureId string) (*FeatureSpec, error)
- func (svc FeatureService) List(ctx context.Context, listParams service.ListParams) ([]FeatureSpec, error)
- func (svc FeatureService) Routes() ([]service.Route, error)
- func (svc FeatureService) UpdateByFeatureId(ctx context.Context, featureId string, featureSpec UpdateFeatureSpec) (*FeatureSpec, error)
- type FeatureSpec
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) DeleteByFeatureId(ctx context.Context, featureId string) error
- func (repo MySQLRepository) GetByFeatureId(ctx context.Context, featureId string) (Model, error)
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo MySQLRepository) UpdateByFeatureId(ctx context.Context, featureId string, model Model) error
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByFeatureId(ctx context.Context, featureId string) error
- func (repo PostgresRepository) GetByFeatureId(ctx context.Context, featureId string) (Model, error)
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo PostgresRepository) UpdateByFeatureId(ctx context.Context, featureId string, model Model) error
- type SQLiteRepository
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) DeleteByFeatureId(ctx context.Context, featureId string) error
- func (repo SQLiteRepository) GetByFeatureId(ctx context.Context, featureId string) (Model, error)
- func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo SQLiteRepository) UpdateByFeatureId(ctx context.Context, featureId string, model Model) error
- type UpdateFeatureSpec
Constants ¶
View Source
const DefaultSortBy = "featureId"
View Source
const ResourceTypeFeature = "feature"
Variables ¶
This section is empty.
Functions ¶
func CreateHandler ¶ added in v0.11.0
func CreateHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
func DeleteHandler ¶ added in v0.11.0
func DeleteHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
func GetHandler ¶ added in v0.11.0
func GetHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
func ListHandler ¶ added in v0.11.0
func ListHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
func UpdateHandler ¶ added in v0.11.0
func UpdateHandler(svc FeatureService, w http.ResponseWriter, r *http.Request) error
Types ¶
type Feature ¶
type Feature struct {
ID int64 `mysql:"id" postgres:"id" sqlite:"id"`
ObjectId int64 `mysql:"objectId" postgres:"object_id" sqlite:"objectId"`
FeatureId string `mysql:"featureId" postgres:"feature_id" sqlite:"featureId"`
Name *string `mysql:"name" postgres:"name" sqlite:"name"`
Description *string `mysql:"description" postgres:"description" sqlite:"description"`
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 (Feature) GetCreatedAt ¶ added in v0.8.0
func (Feature) GetDeletedAt ¶ added in v0.8.0
func (Feature) GetDescription ¶ added in v0.8.0
func (Feature) GetFeatureId ¶ added in v0.8.0
func (Feature) GetObjectId ¶ added in v0.8.0
func (Feature) GetUpdatedAt ¶ added in v0.8.0
func (*Feature) SetDescription ¶ added in v0.8.0
func (Feature) ToFeatureSpec ¶
func (feature Feature) ToFeatureSpec() *FeatureSpec
type FeatureListParamParser ¶
type FeatureListParamParser struct{}
func (FeatureListParamParser) GetDefaultSortBy ¶
func (parser FeatureListParamParser) GetDefaultSortBy() string
func (FeatureListParamParser) GetSupportedSortBys ¶
func (parser FeatureListParamParser) GetSupportedSortBys() []string
func (FeatureListParamParser) ParseValue ¶
func (parser FeatureListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type FeatureRepository ¶
type FeatureRepository interface {
Create(ctx context.Context, feature Model) (int64, error)
GetById(ctx context.Context, id int64) (Model, error)
GetByFeatureId(ctx context.Context, pricingTierId string) (Model, error)
List(ctx context.Context, listParams service.ListParams) ([]Model, error)
UpdateByFeatureId(ctx context.Context, pricingTierId string, feature Model) error
DeleteByFeatureId(ctx context.Context, pricingTierId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (FeatureRepository, error)
type FeatureService ¶
type FeatureService struct {
service.BaseService
Repository FeatureRepository
EventSvc event.EventService
ObjectSvc object.ObjectService
}
func NewService ¶
func NewService(env service.Env, repository FeatureRepository, eventSvc event.EventService, objectSvc object.ObjectService) FeatureService
func (FeatureService) Create ¶
func (svc FeatureService) Create(ctx context.Context, featureSpec FeatureSpec) (*FeatureSpec, error)
func (FeatureService) DeleteByFeatureId ¶
func (svc FeatureService) DeleteByFeatureId(ctx context.Context, featureId string) error
func (FeatureService) GetByFeatureId ¶
func (svc FeatureService) GetByFeatureId(ctx context.Context, featureId string) (*FeatureSpec, error)
func (FeatureService) List ¶
func (svc FeatureService) List(ctx context.Context, listParams service.ListParams) ([]FeatureSpec, error)
func (FeatureService) Routes ¶ added in v0.8.0
func (svc FeatureService) Routes() ([]service.Route, error)
GetRoutes registers all route handlers for this module
func (FeatureService) UpdateByFeatureId ¶
func (svc FeatureService) UpdateByFeatureId(ctx context.Context, featureId string, featureSpec UpdateFeatureSpec) (*FeatureSpec, error)
type FeatureSpec ¶
type FeatureSpec struct {
FeatureId string `json:"featureId" validate:"required,valid_object_id"`
Name *string `json:"name"`
Description *string `json:"description"`
CreatedAt time.Time `json:"createdAt"`
}
func (FeatureSpec) ToFeature ¶
func (spec FeatureSpec) ToFeature(objectId int64) *Feature
func (FeatureSpec) ToObjectSpec ¶
func (spec FeatureSpec) ToObjectSpec() *object.ObjectSpec
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) MySQLRepository
func (MySQLRepository) DeleteByFeatureId ¶
func (repo MySQLRepository) DeleteByFeatureId(ctx context.Context, featureId string) error
func (MySQLRepository) GetByFeatureId ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
func (MySQLRepository) UpdateByFeatureId ¶
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) DeleteByFeatureId ¶ added in v0.4.0
func (repo PostgresRepository) DeleteByFeatureId(ctx context.Context, featureId string) error
func (PostgresRepository) GetByFeatureId ¶ added in v0.4.0
func (PostgresRepository) List ¶ added in v0.4.0
func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
func (PostgresRepository) UpdateByFeatureId ¶ added in v0.4.0
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) DeleteByFeatureId ¶ added in v0.11.0
func (repo SQLiteRepository) DeleteByFeatureId(ctx context.Context, featureId string) error
func (SQLiteRepository) GetByFeatureId ¶ added in v0.11.0
func (SQLiteRepository) List ¶ added in v0.11.0
func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
func (SQLiteRepository) UpdateByFeatureId ¶ added in v0.11.0
type UpdateFeatureSpec ¶
Click to show internal directories.
Click to hide internal directories.