Documentation
¶
Index ¶
- Constants
- func CreateHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
- func DeleteHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
- func GetHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
- func ListHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
- func UpdateHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, role Model) (int64, error)
- func (repo MySQLRepository) DeleteByRoleId(ctx context.Context, roleId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetByRoleId(ctx context.Context, roleId string) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo MySQLRepository) UpdateByRoleId(ctx context.Context, roleId string, model Model) error
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByRoleId(ctx context.Context, roleId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetByRoleId(ctx context.Context, roleId string) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo PostgresRepository) UpdateByRoleId(ctx context.Context, roleId string, model Model) error
- type Role
- func (role Role) GetCreatedAt() time.Time
- func (role Role) GetDeletedAt() *time.Time
- func (role Role) GetDescription() *string
- func (role Role) GetID() int64
- func (role Role) GetName() *string
- func (role Role) GetObjectId() int64
- func (role Role) GetRoleId() string
- func (role Role) GetUpdatedAt() time.Time
- func (role *Role) SetDescription(newDescription *string)
- func (role *Role) SetName(newName *string)
- func (role Role) ToRoleSpec() *RoleSpec
- type RoleListParamParser
- type RoleRepository
- type RoleService
- func (svc RoleService) Create(ctx context.Context, roleSpec RoleSpec) (*RoleSpec, error)
- func (svc RoleService) DeleteByRoleId(ctx context.Context, roleId string) (*wookie.Token, error)
- func (svc RoleService) GetByRoleId(ctx context.Context, roleId string) (*RoleSpec, error)
- func (svc RoleService) List(ctx context.Context, listParams service.ListParams) ([]RoleSpec, error)
- func (svc RoleService) Routes() ([]service.Route, error)
- func (svc RoleService) UpdateByRoleId(ctx context.Context, roleId string, roleSpec UpdateRoleSpec) (*RoleSpec, error)
- type RoleSpec
- type SQLiteRepository
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) DeleteByRoleId(ctx context.Context, roleId string) error
- func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) GetByRoleId(ctx context.Context, roleId string) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo SQLiteRepository) UpdateByRoleId(ctx context.Context, roleId string, model Model) error
- type UpdateRoleSpec
Constants ¶
View Source
const DefaultSortBy = "roleId"
View Source
const ResourceTypeRole = "role"
Variables ¶
This section is empty.
Functions ¶
func CreateHandler ¶ added in v0.11.0
func CreateHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
func DeleteHandler ¶ added in v0.11.0
func DeleteHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
func GetHandler ¶ added in v0.11.0
func GetHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
func ListHandler ¶ added in v0.11.0
func ListHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error
func UpdateHandler ¶ added in v0.11.0
func UpdateHandler(svc RoleService, 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) DeleteByRoleId ¶
func (repo MySQLRepository) DeleteByRoleId(ctx context.Context, roleId string) error
func (MySQLRepository) GetByRoleId ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
func (MySQLRepository) UpdateByRoleId ¶
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) DeleteByRoleId ¶ added in v0.4.0
func (repo PostgresRepository) DeleteByRoleId(ctx context.Context, roleId string) error
func (PostgresRepository) GetByRoleId ¶ 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) UpdateByRoleId ¶ added in v0.4.0
type Role ¶
type Role struct {
ID int64 `mysql:"id" postgres:"id" sqlite:"id"`
ObjectId int64 `mysql:"objectId" postgres:"object_id" sqlite:"objectId"`
RoleId string `mysql:"roleId" postgres:"role_id" sqlite:"roleId"`
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 (Role) GetCreatedAt ¶ added in v0.8.0
func (Role) GetDeletedAt ¶ added in v0.8.0
func (Role) GetDescription ¶ added in v0.8.0
func (Role) GetObjectId ¶ added in v0.8.0
func (Role) GetUpdatedAt ¶ added in v0.8.0
func (*Role) SetDescription ¶ added in v0.8.0
func (Role) ToRoleSpec ¶
type RoleListParamParser ¶
type RoleListParamParser struct{}
func (RoleListParamParser) GetDefaultSortBy ¶
func (parser RoleListParamParser) GetDefaultSortBy() string
func (RoleListParamParser) GetSupportedSortBys ¶
func (parser RoleListParamParser) GetSupportedSortBys() []string
func (RoleListParamParser) ParseValue ¶
func (parser RoleListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type RoleRepository ¶
type RoleRepository interface {
Create(ctx context.Context, role Model) (int64, error)
GetById(ctx context.Context, id int64) (Model, error)
GetByRoleId(ctx context.Context, roleId string) (Model, error)
List(ctx context.Context, listParams service.ListParams) ([]Model, error)
UpdateByRoleId(ctx context.Context, roleId string, role Model) error
DeleteByRoleId(ctx context.Context, roleId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (RoleRepository, error)
type RoleService ¶
type RoleService struct {
service.BaseService
Repository RoleRepository
EventSvc event.Service
ObjectSvc *object.ObjectService
}
func NewService ¶
func NewService(env service.Env, repository RoleRepository, eventSvc event.Service, objectSvc *object.ObjectService) *RoleService
func (RoleService) DeleteByRoleId ¶
func (RoleService) GetByRoleId ¶
func (RoleService) List ¶
func (svc RoleService) List(ctx context.Context, listParams service.ListParams) ([]RoleSpec, error)
func (RoleService) Routes ¶ added in v0.8.0
func (svc RoleService) Routes() ([]service.Route, error)
GetRoutes registers all route handlers for this module
func (RoleService) UpdateByRoleId ¶
func (svc RoleService) UpdateByRoleId(ctx context.Context, roleId string, roleSpec UpdateRoleSpec) (*RoleSpec, error)
type RoleSpec ¶
type RoleSpec struct {
RoleId string `json:"roleId" validate:"required,valid_object_id"`
Name *string `json:"name"`
Description *string `json:"description"`
CreatedAt time.Time `json:"createdAt"`
}
func (RoleSpec) ToObjectSpec ¶
func (spec RoleSpec) ToObjectSpec() *object.ObjectSpec
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) DeleteByRoleId ¶ added in v0.11.0
func (repo SQLiteRepository) DeleteByRoleId(ctx context.Context, roleId string) error
func (SQLiteRepository) GetByRoleId ¶ 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) UpdateByRoleId ¶ added in v0.11.0
type UpdateRoleSpec ¶
Click to show internal directories.
Click to hide internal directories.