Documentation
¶
Index ¶
- Variables
- type CreateInput
- type Permission
- type PostgresStore
- func (s *PostgresStore) AttachedPermissionIDs(ctx context.Context, roleID string) ([]string, error)
- func (s *PostgresStore) Create(ctx context.Context, input CreateInput) (*Role, error)
- func (s *PostgresStore) Get(ctx context.Context, id string) (*Role, error)
- func (s *PostgresStore) GetByName(ctx context.Context, name string) (*Role, error)
- func (s *PostgresStore) HasUsers(ctx context.Context, roleID string) (bool, error)
- func (s *PostgresStore) List(ctx context.Context, includeDeleted bool) ([]*Role, error)
- func (s *PostgresStore) ListPermissions(ctx context.Context) ([]Permission, error)
- func (s *PostgresStore) ReplacePermissions(ctx context.Context, roleID string, permIDs []string) error
- func (s *PostgresStore) SoftDelete(ctx context.Context, id string) error
- func (s *PostgresStore) Update(ctx context.Context, id string, input UpdateInput) (*Role, error)
- type Role
- type Service
- type Store
- type UpdateInput
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSystemRoleProtected = errors.New("system role is protected") ErrRoleInUse = errors.New("role is in use") )
View Source
var ( ErrNotFound = errors.New("role not found") ErrAlreadyExists = errors.New("role already exists") )
Functions ¶
This section is empty.
Types ¶
type CreateInput ¶
type Permission ¶
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
func (*PostgresStore) AttachedPermissionIDs ¶
func (*PostgresStore) Create ¶
func (s *PostgresStore) Create(ctx context.Context, input CreateInput) (*Role, error)
func (*PostgresStore) ListPermissions ¶
func (s *PostgresStore) ListPermissions(ctx context.Context) ([]Permission, error)
func (*PostgresStore) ReplacePermissions ¶
func (*PostgresStore) SoftDelete ¶
func (s *PostgresStore) SoftDelete(ctx context.Context, id string) error
func (*PostgresStore) Update ¶
func (s *PostgresStore) Update(ctx context.Context, id string, input UpdateInput) (*Role, error)
type Role ¶
type Role struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
IsSystem bool `json:"is_system"`
UserCount int `json:"user_count,omitempty"`
Permissions []Permission `json:"permissions,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
} // @name Role
type Service ¶
type Service interface {
List(ctx context.Context) ([]*Role, error)
Get(ctx context.Context, id string) (*Role, error)
Create(ctx context.Context, input CreateInput) (*Role, error)
Update(ctx context.Context, id string, input UpdateInput) (*Role, error)
Delete(ctx context.Context, id string) error
ReplacePermissions(ctx context.Context, roleID string, permIDs []string) error
ListPermissions(ctx context.Context) ([]Permission, error)
}
func NewService ¶
type Store ¶
type Store interface {
List(ctx context.Context, includeDeleted bool) ([]*Role, error)
Get(ctx context.Context, id string) (*Role, error)
GetByName(ctx context.Context, name string) (*Role, error)
Create(ctx context.Context, input CreateInput) (*Role, error)
Update(ctx context.Context, id string, input UpdateInput) (*Role, error)
SoftDelete(ctx context.Context, id string) error
AttachedPermissionIDs(ctx context.Context, roleID string) ([]string, error)
ReplacePermissions(ctx context.Context, roleID string, permIDs []string) error
HasUsers(ctx context.Context, roleID string) (bool, error)
ListPermissions(ctx context.Context) ([]Permission, error)
}
func NewPostgresStore ¶
type UpdateInput ¶
Click to show internal directories.
Click to hide internal directories.