Documentation
¶
Index ¶
- type ModelApproveStatusSetter
- type ModelCreateTimeSetter
- type ModelIDFieldGetter
- type ModelIDGetter
- type ModelIDSetter
- type ModelUpdateTimeSetter
- type Option
- type Options
- type Repository
- func (r *Repository[T, TID]) Count(ctx context.Context, qops ...Option) (count int64, err error)
- func (r *Repository[T, TID]) Create(ctx context.Context, obj *T, message string) (TID, error)
- func (r *Repository[T, TID]) Delete(ctx context.Context, id TID, message string) error
- func (r *Repository[T, TID]) FetchList(ctx context.Context, qops ...Option) (list []*T, err error)
- func (r *Repository[T, TID]) Get(ctx context.Context, id TID, qops ...Option) (*T, error)
- func (r *Repository[T, TID]) Update(ctx context.Context, id TID, obj *T, message string) error
- type RepositoryApproveIface
- type RepositoryApprover
- type RepositoryIface
- type RepositoryIfaceWithApprove
- type Usecase
- func (u *Usecase[T, TID]) Count(ctx context.Context, qops ...Option) (int64, error)
- func (u *Usecase[T, TID]) Create(ctx context.Context, obj *T, message string) (id TID, err error)
- func (u *Usecase[T, TID]) Delete(ctx context.Context, id TID, message string) error
- func (u *Usecase[T, TID]) FetchList(ctx context.Context, qops ...Option) ([]*T, error)
- func (u *Usecase[T, TID]) Get(ctx context.Context, id TID, qops ...Option) (*T, error)
- func (u *Usecase[T, TID]) Update(ctx context.Context, id TID, obj *T, message string) error
- type UsecaseApproveIface
- type UsecaseApprover
- type UsecaseIface
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 ¶
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 ¶
ModelUpdateTimeSetter defines an interface for models that can set their update time
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]) 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
type RepositoryApproveIface ¶
type RepositoryApprover ¶
type RepositoryApprover[T any, TID any] struct { repository.Repository IDName string StatusName string }
RepositoryApprover provides methods to approve or reject entities
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 ¶
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 ¶
Create creates a new entity with ACL permission check. Returns the ID of the created entity if successful.
func (*Usecase[T, TID]) Delete ¶
Delete removes an entity with ACL permission check. Fetches the existing entity first to verify delete permissions.
func (*Usecase[T, TID]) FetchList ¶
FetchList retrieves a list of entities with ACL permission checks. Validates both general list access and individual object access permissions.
type UsecaseApproveIface ¶
type UsecaseApprover ¶
type UsecaseApprover[T any, TID any] struct { Repo RepositoryIfaceWithApprove[T, TID] }
UsecaseApprover provides approve/reject usecase methods
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 }