generated

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModelApproveStatusSetter

type ModelApproveStatusSetter interface {
	SetApproveStatus(status model.ApproveStatus)
}

ModelApproveStatusSetter defines an interface for models that can set their approval status

type ModelCreateTimeSetter

type ModelCreateTimeSetter interface {
	SetCreatedAt(time.Time)
}

ModelCreateTimeSetter defines an interface for models that can set their creation time

type ModelIDFieldGetter

type ModelIDFieldGetter interface {
	GetIDField() string
}

ModelIDFieldGetter defines an interface for models that can return their ID field name

type ModelIDGetter

type ModelIDGetter[TID any] interface {
	GetID() TID
}

ModelIDGetter defines an interface for models that can return their ID

type ModelIDSetter

type ModelIDSetter[TID any] interface {
	SetID(id TID)
}

ModelIDSetter defines an interface for models that can set their ID

type ModelUpdateTimeSetter

type ModelUpdateTimeSetter interface {
	SetUpdatedAt(time.Time)
}

ModelUpdateTimeSetter defines an interface for models that can set their update time

type Option

type Option = repository.QOption

List select options

type Options

type Options = repository.ListOptions

List select options

type Repository

type Repository[T any, TID any] struct {
	repository.Repository
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository[T any, TID any]() *Repository[T, TID]

NewRepository creates a new repository instance

func (*Repository[T, TID]) Count

func (r *Repository[T, TID]) Count(ctx context.Context, qops ...Option) (count int64, err error)

Count returns the number of campaigns

func (*Repository[T, TID]) Create

func (r *Repository[T, TID]) Create(ctx context.Context, obj *T, message string) (TID, error)

Create creates a new campaign

func (*Repository[T, TID]) Delete

func (r *Repository[T, TID]) Delete(ctx context.Context, id TID, message string) error

Delete deletes a campaign by ID

func (*Repository[T, TID]) FetchList

func (r *Repository[T, TID]) FetchList(ctx context.Context, qops ...Option) (list []*T, err error)

FetchList returns a list of campaigns

func (*Repository[T, TID]) Get

func (r *Repository[T, TID]) Get(ctx context.Context, id TID, qops ...Option) (*T, error)

Get returns a campaign by ID

func (*Repository[T, TID]) Update

func (r *Repository[T, TID]) Update(ctx context.Context, id TID, obj *T, message string) error

Update updates an existing campaign

type RepositoryApproveIface

type RepositoryApproveIface[TID any] interface {
	Approve(ctx context.Context, id TID, message string) error
	Reject(ctx context.Context, id TID, message string) error
}

type RepositoryApprover

type RepositoryApprover[T any, TID any] struct {
	repository.Repository
	IDName     string
	StatusName string
}

RepositoryApprover provides methods to approve or reject entities

func (*RepositoryApprover[T, TID]) Approve

func (r *RepositoryApprover[T, TID]) Approve(ctx context.Context, id TID, message string) error

Approve approves an entity by ID

func (*RepositoryApprover[T, TID]) Reject

func (r *RepositoryApprover[T, TID]) Reject(ctx context.Context, id TID, message string) error

Reject rejects an entity by ID

type RepositoryIface

type RepositoryIface[T any, TID any] interface {
	Get(ctx context.Context, id TID, qops ...Option) (*T, error)
	FetchList(ctx context.Context, qops ...Option) ([]*T, error)
	Count(ctx context.Context, qops ...Option) (int64, error)
	Create(ctx context.Context, obj *T, message string) (TID, error)
	Update(ctx context.Context, id TID, obj *T, message string) error
	Delete(ctx context.Context, id TID, message string) error
}

type RepositoryIfaceWithApprove

type RepositoryIfaceWithApprove[T any, TID any] interface {
	RepositoryIface[T, TID]
	RepositoryApproveIface[TID]
}

type Usecase

type Usecase[T any, TID any] struct {
	Repo RepositoryIface[T, TID] // Repository interface for data access operations
}

Usecase provides a generic business logic layer with ACL (Access Control List) support for CRUD operations on entities of type T with ID type TID.

func (*Usecase[T, TID]) Count

func (u *Usecase[T, TID]) Count(ctx context.Context, qops ...Option) (int64, error)

Count returns the total number of entities with ACL permission check. Only counts entities the user has permission to list.

func (*Usecase[T, TID]) Create

func (u *Usecase[T, TID]) Create(ctx context.Context, obj *T, message string) (id TID, err error)

Create creates a new entity with ACL permission check. Returns the ID of the created entity if successful.

func (*Usecase[T, TID]) Delete

func (u *Usecase[T, TID]) Delete(ctx context.Context, id TID, message string) error

Delete removes an entity with ACL permission check. Fetches the existing entity first to verify delete permissions.

func (*Usecase[T, TID]) FetchList

func (u *Usecase[T, TID]) FetchList(ctx context.Context, qops ...Option) ([]*T, error)

FetchList retrieves a list of entities with ACL permission checks. Validates both general list access and individual object access permissions.

func (*Usecase[T, TID]) Get

func (u *Usecase[T, TID]) Get(ctx context.Context, id TID, qops ...Option) (*T, error)

Get retrieves a single entity by ID with ACL permission check. Returns the entity if found and user has read permissions, otherwise returns an error.

func (*Usecase[T, TID]) Update

func (u *Usecase[T, TID]) Update(ctx context.Context, id TID, obj *T, message string) error

Update modifies an existing entity with ACL permission check. Fetches the existing entity first to verify update permissions.

type UsecaseApproveIface

type UsecaseApproveIface[TID any] interface {
	Approve(ctx context.Context, id TID, message string) error
	Reject(ctx context.Context, id TID, message string) error
}

type UsecaseApprover

type UsecaseApprover[T any, TID any] struct {
	Repo RepositoryIfaceWithApprove[T, TID]
}

UsecaseApprover provides approve/reject usecase methods

func (*UsecaseApprover[T, TID]) Approve

func (u *UsecaseApprover[T, TID]) Approve(ctx context.Context, id TID, message string) error

Approve approves an entity by ID with ACL permission check

func (*UsecaseApprover[T, TID]) Reject

func (u *UsecaseApprover[T, TID]) Reject(ctx context.Context, id TID, message string) error

Reject rejects an entity by ID with ACL permission check

type UsecaseIface

type UsecaseIface[T any, TID any] interface {
	Get(ctx context.Context, id TID, qops ...Option) (*T, error)
	FetchList(ctx context.Context, qops ...Option) ([]*T, error)
	Count(ctx context.Context, qops ...Option) (int64, error)
	Create(ctx context.Context, obj *T, message string) (TID, error)
	Update(ctx context.Context, id TID, obj *T, message string) error
	Delete(ctx context.Context, id TID, message string) error
}

Jump to

Keyboard shortcuts

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