Documentation
¶
Index ¶
- Constants
- func CreateHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
- func DeleteHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
- func GetHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
- func ListHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
- func UpdateHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) DeleteByPermissionId(ctx context.Context, permissionId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetByPermissionId(ctx context.Context, permissionId string) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
- func (repo MySQLRepository) UpdateByPermissionId(ctx context.Context, permissionId string, model Model) error
- type Permission
- func (permission Permission) GetCreatedAt() time.Time
- func (permission Permission) GetDeletedAt() *time.Time
- func (permission Permission) GetDescription() *string
- func (permission Permission) GetID() int64
- func (permission Permission) GetName() *string
- func (permission Permission) GetObjectId() int64
- func (permission Permission) GetPermissionId() string
- func (permission Permission) GetUpdatedAt() time.Time
- func (permission *Permission) SetDescription(newDescription *string)
- func (permission *Permission) SetName(newName *string)
- func (permission Permission) ToPermissionSpec() *PermissionSpec
- type PermissionListParamParser
- type PermissionRepository
- type PermissionService
- func (svc PermissionService) Create(ctx context.Context, permissionSpec PermissionSpec) (*PermissionSpec, error)
- func (svc PermissionService) DeleteByPermissionId(ctx context.Context, permissionId string) error
- func (svc PermissionService) GetByPermissionId(ctx context.Context, permissionId string) (*PermissionSpec, error)
- func (svc PermissionService) List(ctx context.Context, listParams middleware.ListParams) ([]PermissionSpec, error)
- func (svc PermissionService) Routes() ([]service.Route, error)
- func (svc PermissionService) UpdateByPermissionId(ctx context.Context, permissionId string, permissionSpec UpdatePermissionSpec) (*PermissionSpec, error)
- type PermissionSpec
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByPermissionId(ctx context.Context, permissionId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetByPermissionId(ctx context.Context, permissionId string) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
- func (repo PostgresRepository) UpdateByPermissionId(ctx context.Context, permissionId string, model Model) error
- type SQLiteRepository
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) DeleteByPermissionId(ctx context.Context, permissionId string) error
- func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) GetByPermissionId(ctx context.Context, permissionId string) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
- func (repo SQLiteRepository) UpdateByPermissionId(ctx context.Context, permissionId string, model Model) error
- type UpdatePermissionSpec
Constants ¶
View Source
const ResourceTypePermission = "permission"
Variables ¶
This section is empty.
Functions ¶
func CreateHandler ¶ added in v0.11.0
func CreateHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
func DeleteHandler ¶ added in v0.11.0
func DeleteHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
func GetHandler ¶ added in v0.11.0
func GetHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
func ListHandler ¶ added in v0.11.0
func ListHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
func UpdateHandler ¶ added in v0.11.0
func UpdateHandler(svc PermissionService, w http.ResponseWriter, r *http.Request) error
Types ¶
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) MySQLRepository
func (MySQLRepository) DeleteByPermissionId ¶
func (repo MySQLRepository) DeleteByPermissionId(ctx context.Context, permissionId string) error
func (MySQLRepository) GetByPermissionId ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
func (MySQLRepository) UpdateByPermissionId ¶
type Permission ¶
type Permission struct {
ID int64 `mysql:"id" postgres:"id" sqlite:"id"`
ObjectId int64 `mysql:"objectId" postgres:"object_id" sqlite:"objectId"`
PermissionId string `mysql:"permissionId" postgres:"permission_id" sqlite:"permissionId"`
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 (Permission) GetCreatedAt ¶ added in v0.8.0
func (permission Permission) GetCreatedAt() time.Time
func (Permission) GetDeletedAt ¶ added in v0.8.0
func (permission Permission) GetDeletedAt() *time.Time
func (Permission) GetDescription ¶ added in v0.8.0
func (permission Permission) GetDescription() *string
func (Permission) GetID ¶ added in v0.8.0
func (permission Permission) GetID() int64
func (Permission) GetName ¶ added in v0.8.0
func (permission Permission) GetName() *string
func (Permission) GetObjectId ¶ added in v0.8.0
func (permission Permission) GetObjectId() int64
func (Permission) GetPermissionId ¶ added in v0.8.0
func (permission Permission) GetPermissionId() string
func (Permission) GetUpdatedAt ¶ added in v0.8.0
func (permission Permission) GetUpdatedAt() time.Time
func (*Permission) SetDescription ¶ added in v0.8.0
func (permission *Permission) SetDescription(newDescription *string)
func (*Permission) SetName ¶ added in v0.8.0
func (permission *Permission) SetName(newName *string)
func (Permission) ToPermissionSpec ¶
func (permission Permission) ToPermissionSpec() *PermissionSpec
type PermissionListParamParser ¶
type PermissionListParamParser struct{}
func (PermissionListParamParser) GetDefaultSortBy ¶
func (parser PermissionListParamParser) GetDefaultSortBy() string
func (PermissionListParamParser) GetSupportedSortBys ¶
func (parser PermissionListParamParser) GetSupportedSortBys() []string
func (PermissionListParamParser) ParseValue ¶
func (parser PermissionListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type PermissionRepository ¶
type PermissionRepository interface {
Create(ctx context.Context, permission Model) (int64, error)
GetById(ctx context.Context, id int64) (Model, error)
GetByPermissionId(ctx context.Context, permissionId string) (Model, error)
List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
UpdateByPermissionId(ctx context.Context, permissionId string, permission Model) error
DeleteByPermissionId(ctx context.Context, permissionId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (PermissionRepository, error)
type PermissionService ¶
type PermissionService struct {
service.BaseService
Repository PermissionRepository
EventSvc event.EventService
ObjectSvc object.ObjectService
}
func NewService ¶
func NewService(env service.Env, repository PermissionRepository, eventSvc event.EventService, objectSvc object.ObjectService) PermissionService
func (PermissionService) Create ¶
func (svc PermissionService) Create(ctx context.Context, permissionSpec PermissionSpec) (*PermissionSpec, error)
func (PermissionService) DeleteByPermissionId ¶
func (svc PermissionService) DeleteByPermissionId(ctx context.Context, permissionId string) error
func (PermissionService) GetByPermissionId ¶
func (svc PermissionService) GetByPermissionId(ctx context.Context, permissionId string) (*PermissionSpec, error)
func (PermissionService) List ¶
func (svc PermissionService) List(ctx context.Context, listParams middleware.ListParams) ([]PermissionSpec, error)
func (PermissionService) Routes ¶ added in v0.8.0
func (svc PermissionService) Routes() ([]service.Route, error)
GetRoutes registers all route handlers for this module
func (PermissionService) UpdateByPermissionId ¶
func (svc PermissionService) UpdateByPermissionId(ctx context.Context, permissionId string, permissionSpec UpdatePermissionSpec) (*PermissionSpec, error)
type PermissionSpec ¶
type PermissionSpec struct {
PermissionId string `json:"permissionId" validate:"required,valid_object_id"`
Name *string `json:"name"`
Description *string `json:"description"`
CreatedAt time.Time `json:"createdAt"`
}
func (PermissionSpec) ToObjectSpec ¶
func (spec PermissionSpec) ToObjectSpec() *object.ObjectSpec
func (PermissionSpec) ToPermission ¶
func (spec PermissionSpec) ToPermission(objectId int64) *Permission
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) DeleteByPermissionId ¶ added in v0.4.0
func (repo PostgresRepository) DeleteByPermissionId(ctx context.Context, permissionId string) error
func (PostgresRepository) GetByPermissionId ¶ added in v0.4.0
func (PostgresRepository) List ¶ added in v0.4.0
func (repo PostgresRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
func (PostgresRepository) UpdateByPermissionId ¶ 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) DeleteByPermissionId ¶ added in v0.11.0
func (repo SQLiteRepository) DeleteByPermissionId(ctx context.Context, permissionId string) error
func (SQLiteRepository) GetByPermissionId ¶ added in v0.11.0
func (SQLiteRepository) List ¶ added in v0.11.0
func (repo SQLiteRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
func (SQLiteRepository) UpdateByPermissionId ¶ added in v0.11.0
type UpdatePermissionSpec ¶
Click to show internal directories.
Click to hide internal directories.