roles

package
v0.0.0-...-5106b98 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound               = xerror.NotFound(xerror.Role)
	ErrSlugAlreadyExists      = xerror.AlreadyExists(xerror.Role)
	ErrCannotDeleteSystemRole = xerror.CannotDeleteDefault(xerror.Role)
	ErrUserNotMember          = xerror.NotFound(xerror.UserMember)
)

Functions

This section is empty.

Types

type CreateParams

type CreateParams struct {
	OrgSlug   slug.Slug
	Slug      slug.Slug
	Name      string
	IsDefault bool
}

type DeleteParams

type DeleteParams struct {
	OrgSlug slug.Slug
	Slug    slug.Slug
}

type Repository

type Repository interface {
	Create(ctx context.Context, tx postgres.DBTX, params *CreateParams) (*Role, error)
	EnsureDefault(ctx context.Context, tx postgres.DBTX, params *CreateParams) (*Role, error)
	FindBySlug(ctx context.Context, tx postgres.DBTX, orgSlug, roleSlug slug.Slug) (*Role, error)
	ListByOrganization(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug slug.Slug,
		req model.ListRequest,
		includeDeleted bool,
		onlyDeleted bool,
	) ([]*Role, error)
	GetUserPermissionsInOrg(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, userSlug slug.Slug,
	) ([]*UserPermission, error)
	Update(ctx context.Context, tx postgres.DBTX, params *UpdateParams) error
	Delete(ctx context.Context, tx postgres.DBTX, params *DeleteParams) error
	Restore(ctx context.Context, tx postgres.DBTX, params *RestoreParams) error
}

func NewRepository

func NewRepository() Repository

func NewRepositoryWithLogging

func NewRepositoryWithLogging(base Repository, logger *slog.Logger) Repository

NewRepositoryWithLogging wraps base with method completion logging.

type RepositoryWithLogging

type RepositoryWithLogging struct {
	// contains filtered or unexported fields
}

RepositoryWithLogging implements Repository with method completion logging.

func (RepositoryWithLogging) Create

func (_d RepositoryWithLogging) Create(ctx context.Context, tx postgres.DBTX, params *CreateParams) (rp1 *Role, err error)

Create implements Repository.

func (RepositoryWithLogging) Delete

func (_d RepositoryWithLogging) Delete(ctx context.Context, tx postgres.DBTX, params *DeleteParams) (err error)

Delete implements Repository.

func (RepositoryWithLogging) EnsureDefault

func (_d RepositoryWithLogging) EnsureDefault(ctx context.Context, tx postgres.DBTX, params *CreateParams) (rp1 *Role, err error)

EnsureDefault implements Repository.

func (RepositoryWithLogging) FindBySlug

func (_d RepositoryWithLogging) FindBySlug(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, roleSlug slug.Slug) (rp1 *Role, err error)

FindBySlug implements Repository.

func (RepositoryWithLogging) GetUserPermissionsInOrg

func (_d RepositoryWithLogging) GetUserPermissionsInOrg(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, userSlug slug.Slug) (upa1 []*UserPermission, err error)

GetUserPermissionsInOrg implements Repository.

func (RepositoryWithLogging) ListByOrganization

func (_d RepositoryWithLogging) ListByOrganization(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, req model.ListRequest, includeDeleted bool, onlyDeleted bool) (rpa1 []*Role, err error)

ListByOrganization implements Repository.

func (RepositoryWithLogging) Restore

func (_d RepositoryWithLogging) Restore(ctx context.Context, tx postgres.DBTX, params *RestoreParams) (err error)

Restore implements Repository.

func (RepositoryWithLogging) Update

func (_d RepositoryWithLogging) Update(ctx context.Context, tx postgres.DBTX, params *UpdateParams) (err error)

Update implements Repository.

type RestoreParams

type RestoreParams struct {
	OrgSlug slug.Slug
	Slug    slug.Slug
}

type Role

type Role struct {
	Slug      slug.Slug
	Name      string
	IsDefault bool
	DeletedAt *time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
}

type UpdateParams

type UpdateParams struct {
	OrgSlug slug.Slug
	Slug    slug.Slug
	Name    string
}

type UserPermission

type UserPermission struct {
	Resource string
	Action   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL