permissionstore

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

README

permissionstore

Documentation

Index

Constants

View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_ENTITY_ID = "entity_id"
View Source
const COLUMN_ENTITY_TYPE = "entity_type"
View Source
const COLUMN_HANDLE = "handle"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_MEMO = "memo"
View Source
const COLUMN_METAS = "metas"
View Source
const COLUMN_PERMISSION = "permission"
View Source
const COLUMN_PERMISSION_ID = "permission_id"
View Source
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_STATUS = "status"
View Source
const COLUMN_TITLE = "title"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const ERROR_EMPTY_ARRAY = "array cannot be empty"
View Source
const ERROR_EMPTY_STRING = "string cannot be empty"
View Source
const ERROR_NEGATIVE_NUMBER = "number cannot be negative"
View Source
const PERMISSION_STATUS_ACTIVE = "active"
View Source
const PERMISSION_STATUS_DELETED = "deleted"
View Source
const PERMISSION_STATUS_INACTIVE = "inactive"

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityPermissionInterface

type EntityPermissionInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	IsSoftDeleted() bool

	CreatedAt() string
	CreatedAtCarbon() carbon.Carbon
	SetCreatedAt(createdAt string) EntityPermissionInterface

	EntityType() string
	SetEntityType(entityType string) EntityPermissionInterface

	EntityID() string
	SetEntityID(entityID string) EntityPermissionInterface

	ID() string
	SetID(id string) EntityPermissionInterface

	Memo() string
	SetMemo(memo string) EntityPermissionInterface

	Meta(name string) string
	SetMeta(name string, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error

	PermissionID() string
	SetPermissionID(permissionID string) EntityPermissionInterface

	SoftDeletedAt() string
	SoftDeletedAtCarbon() carbon.Carbon
	SetSoftDeletedAt(softDeletedAt string) EntityPermissionInterface

	UpdatedAt() string
	UpdatedAtCarbon() carbon.Carbon
	SetUpdatedAt(updatedAt string) EntityPermissionInterface
}

func NewEntityPermission

func NewEntityPermission() EntityPermissionInterface

func NewEntityPermissionFromExistingData

func NewEntityPermissionFromExistingData(data map[string]string) EntityPermissionInterface

type EntityPermissionQueryInterface

type EntityPermissionQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) EntityPermissionQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) EntityPermissionQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) EntityPermissionQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) EntityPermissionQueryInterface

	HasEntityID() bool
	EntityID() string
	SetEntityID(entityID string) EntityPermissionQueryInterface

	HasEntityType() bool
	EntityType() string
	SetEntityType(entityType string) EntityPermissionQueryInterface

	HasID() bool
	ID() string
	SetID(id string) EntityPermissionQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) EntityPermissionQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) EntityPermissionQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) EntityPermissionQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) EntityPermissionQueryInterface

	HasPermissionID() bool
	PermissionID() string
	SetPermissionID(permissionID string) EntityPermissionQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) EntityPermissionQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) EntityPermissionQueryInterface
	// contains filtered or unexported methods
}

func NewEntityPermissionQuery

func NewEntityPermissionQuery() EntityPermissionQueryInterface

type NewStoreOptions

type NewStoreOptions struct {
	// PermissionTableName is the name of the permission table
	PermissionTableName string

	// EntityPermissionTableName is the name of the entity to permission relation table
	EntityPermissionTableName string

	// DB is the underlying database connection
	DB *sql.DB

	// DbDriverName is the database driver name/type
	DbDriverName string

	// AutomigrateEnabled indicates whether to automatically migrate the database
	AutomigrateEnabled bool

	// DebugEnabled enables or disables the debug mode
	DebugEnabled bool

	// SqlLogger is the sql statement logger when debug mode is enabled, defaults to the default logger
	SqlLogger *slog.Logger
}

NewStoreOptions define the options for creating a new block store

type PermissionInterface

type PermissionInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	IsActive() bool
	IsInactive() bool
	IsSoftDeleted() bool

	CreatedAt() string
	CreatedAtCarbon() carbon.Carbon
	SetCreatedAt(createdAt string) PermissionInterface

	Handle() string
	SetHandle(handle string) PermissionInterface

	ID() string
	SetID(id string) PermissionInterface

	Memo() string
	SetMemo(memo string) PermissionInterface

	Meta(name string) string
	SetMeta(name string, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error

	Status() string
	SetStatus(status string) PermissionInterface

	SoftDeletedAt() string
	SoftDeletedAtCarbon() carbon.Carbon
	SetSoftDeletedAt(softDeletedAt string) PermissionInterface

	Title() string
	SetTitle(title string) PermissionInterface

	UpdatedAt() string
	UpdatedAtCarbon() carbon.Carbon
	SetUpdatedAt(updatedAt string) PermissionInterface
}

func NewPermission

func NewPermission() PermissionInterface

func NewPermissionFromExistingData

func NewPermissionFromExistingData(data map[string]string) PermissionInterface

type PermissionQueryInterface

type PermissionQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) PermissionQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) PermissionQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) PermissionQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) PermissionQueryInterface

	HasHandle() bool
	Handle() string
	SetHandle(handle string) PermissionQueryInterface

	HasID() bool
	ID() string
	SetID(id string) PermissionQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) PermissionQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) PermissionQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) PermissionQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) PermissionQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) PermissionQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) PermissionQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) PermissionQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) PermissionQueryInterface

	HasTitleLike() bool
	TitleLike() string
	SetTitleLike(titleLike string) PermissionQueryInterface
	// contains filtered or unexported methods
}

func NewPermissionQuery

func NewPermissionQuery() PermissionQueryInterface

type StoreInterface

type StoreInterface interface {
	// AutoMigrate auto migrates the database schema
	AutoMigrate() error

	// EnableDebug enables or disables the debug mode
	EnableDebug(debug bool)

	// DB returns the underlying database connection
	DB() *sql.DB

	// PermissionCount returns the number of permissions based on the given query options
	PermissionCount(ctx context.Context, options PermissionQueryInterface) (int64, error)

	// PermissionCreate creates a new permission
	PermissionCreate(ctx context.Context, permission PermissionInterface) error

	// PermissionDelete deletes a permission
	PermissionDelete(ctx context.Context, permission PermissionInterface) error

	// PermissionDeleteByID deletes a permission by its ID
	PermissionDeleteByID(ctx context.Context, id string) error

	// PermissionFindByHandle returns a permission by its handle
	PermissionFindByHandle(ctx context.Context, handle string) (PermissionInterface, error)

	// PermissionFindByID returns a permission by its ID
	PermissionFindByID(ctx context.Context, id string) (PermissionInterface, error)

	// PermissionList returns a list of permissions based on the given query options
	PermissionList(ctx context.Context, query PermissionQueryInterface) ([]PermissionInterface, error)

	// PermissionSoftDelete soft deletes a permission
	PermissionSoftDelete(ctx context.Context, permission PermissionInterface) error

	// PermissionSoftDeleteByID soft deletes a permission by its ID
	PermissionSoftDeleteByID(ctx context.Context, id string) error

	// PermissionUpdate updates a permission
	PermissionUpdate(ctx context.Context, permission PermissionInterface) error

	// EntityPermissionCount returns the number of permission entities mappings based on the given query options
	EntityPermissionCount(ctx context.Context, options EntityPermissionQueryInterface) (int64, error)

	// EntityPermissionCreate creates a new permission entity mapping
	EntityPermissionCreate(ctx context.Context, entityPermission EntityPermissionInterface) error

	// EntityPermissionDelete deletes a permission entity mapping
	EntityPermissionDelete(ctx context.Context, entityPermission EntityPermissionInterface) error

	// EntityPermissionDeleteByID deletes a permission entity mapping by its ID
	EntityPermissionDeleteByID(ctx context.Context, id string) error

	// EntityPermissionFindByEntityAndPermission returns a permission entity mapping by its entity type, entity ID and permission ID
	EntityPermissionFindByEntityAndPermission(ctx context.Context, entityType string, entityID string, permissionID string) (EntityPermissionInterface, error)

	// EntityPermissionFindByID returns a permission entity mapping by its ID
	EntityPermissionFindByID(ctx context.Context, id string) (EntityPermissionInterface, error)

	// EntityPermissionList returns a list of permission entity mappings based on the given query options
	EntityPermissionList(ctx context.Context, query EntityPermissionQueryInterface) ([]EntityPermissionInterface, error)

	// EntityPermissionSoftDelete soft deletes a permission entity mapping
	EntityPermissionSoftDelete(ctx context.Context, entityPermission EntityPermissionInterface) error

	// EntityPermissionSoftDeleteByID soft deletes a permission entity mapping by its ID
	EntityPermissionSoftDeleteByID(ctx context.Context, id string) error

	// EntityPermissionUpdate updates a permission entity mapping
	EntityPermissionUpdate(ctx context.Context, entityPermission EntityPermissionInterface) error
}

func NewStore

func NewStore(opts NewStoreOptions) (StoreInterface, error)

NewStore creates a new block store

type UserInterface

type UserInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()
	Get(columnName string) string
	Set(columnName string, value string)

	IsActive() bool
	IsInactive() bool
	IsSoftDeleted() bool
	IsUnverified() bool

	IsAdministrator() bool
	IsManager() bool
	IsSuperuser() bool

	IsRegistrationCompleted() bool

	BusinessName() string
	SetBusinessName(businessName string) UserInterface

	Country() string
	SetCountry(country string) UserInterface

	CreatedAt() string
	CreatedAtCarbon() carbon.Carbon
	SetCreatedAt(createdAt string) UserInterface

	Email() string
	SetEmail(email string) UserInterface

	ID() string
	SetID(id string) UserInterface

	FirstName() string
	SetFirstName(firstName string) UserInterface

	LastName() string
	SetLastName(lastName string) UserInterface

	Memo() string
	SetMemo(memo string) UserInterface

	Meta(name string) string
	SetMeta(name string, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error
	UpsertMetas(metas map[string]string) error

	MiddleNames() string
	SetMiddleNames(middleNames string) UserInterface

	Password() string
	SetPassword(password string) UserInterface

	Phone() string
	SetPhone(phone string) UserInterface

	ProfileImageUrl() string
	SetProfileImageUrl(profileImageUrl string) UserInterface

	Permission() string
	SetPermission(permission string) UserInterface

	SoftDeletedAt() string
	SoftDeletedAtCarbon() carbon.Carbon
	SetSoftDeletedAt(deletedAt string) UserInterface

	Timezone() string
	SetTimezone(timezone string) UserInterface

	Status() string
	SetStatus(status string) UserInterface

	PasswordCompare(password string) bool

	UpdatedAt() string
	UpdatedAtCarbon() carbon.Carbon
	SetUpdatedAt(updatedAt string) UserInterface
}

Jump to

Keyboard shortcuts

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