Documentation
¶
Overview ¶
Package repository provides data access implementations.
Package repository provides data access implementations.
Package repository provides data access implementations.
Package repository provides data access implementations.
Package repository provides data access implementations.
Index ¶
- Variables
- func Count(ctx context.Context, db *gorm.DB, model any, filters map[string]any, ...) (int64, error)
- func IsExists(ctx context.Context, db *gorm.DB, model any, filters map[string]any, ...) (bool, error)
- func NewDepartmentRepository(data *Data) usecase.DepartmentRepository
- func NewRoleRepository(data *Data) usecase.RoleRepository
- func NewTransaction(d *Data) usecase.Transaction
- func NewUserRepository(data *Data) usecase.UserRepository
- type Data
- type DepartmentRepository
- func (r *DepartmentRepository) Count(ctx context.Context, filters map[string]any, notFilters map[string]any) (int64, error)
- func (r *DepartmentRepository) Create(ctx context.Context, department *model.Department) error
- func (r *DepartmentRepository) Delete(ctx context.Context, id uint) error
- func (r *DepartmentRepository) FindByID(ctx context.Context, id uint) (*model.Department, error)
- func (r *DepartmentRepository) IsExists(ctx context.Context, filters map[string]any, notFilters map[string]any) (bool, error)
- func (r *DepartmentRepository) List(ctx context.Context, filters map[string]any, limit, offset int, ...) ([]*model.Department, int, error)
- func (r *DepartmentRepository) Update(ctx context.Context, department *model.Department, params map[string]any) error
- type RoleRepository
- func (r *RoleRepository) Count(ctx context.Context, filters map[string]any, notFilters map[string]any) (int64, error)
- func (r *RoleRepository) Create(ctx context.Context, role *model.Role) error
- func (r *RoleRepository) Delete(ctx context.Context, id uint) error
- func (r *RoleRepository) FindByID(ctx context.Context, id uint) (*model.Role, error)
- func (r *RoleRepository) IsExists(ctx context.Context, filters map[string]any, notFilters map[string]any) (bool, error)
- func (r *RoleRepository) List(ctx context.Context, filters map[string]any, limit, offset int, ...) ([]*model.Role, int, error)
- func (r *RoleRepository) Update(ctx context.Context, role *model.Role, params map[string]any) error
- type UserRepository
- func (r *UserRepository) Count(ctx context.Context, filters map[string]any, notFilters map[string]any) (int64, error)
- func (r *UserRepository) Create(ctx context.Context, user *model.User) error
- func (r *UserRepository) Delete(ctx context.Context, id uint) error
- func (r *UserRepository) DeleteRSAPrivateKey(ctx context.Context, cacheKey string) error
- func (r *UserRepository) FindByID(ctx context.Context, id uint) (*model.User, error)
- func (r *UserRepository) FindByUsername(ctx context.Context, username string) (*model.User, error)
- func (r *UserRepository) GetRSAPrivateKey(ctx context.Context, cacheKey string) ([]byte, error)
- func (r *UserRepository) IsExists(ctx context.Context, filters map[string]any, notFilters map[string]any) (bool, error)
- func (r *UserRepository) List(ctx context.Context, filters map[string]any, limit, offset int, ...) ([]*model.User, int, error)
- func (r *UserRepository) SetRSAPrivateKey(ctx context.Context, cacheKey string, privateKey []byte) error
- func (r *UserRepository) Update(ctx context.Context, user *model.User, params map[string]any) error
Constants ¶
This section is empty.
Variables ¶
var ProviderSet = wire.NewSet( NewData, NewTransaction, NewDepartmentRepository, NewRoleRepository, NewUserRepository, )
ProviderSet provides all repository layer dependencies.
Functions ¶
func Count ¶
func Count(ctx context.Context, db *gorm.DB, model any, filters map[string]any, notFilters map[string]any) (int64, error)
Count is a generic function to count the number of records in the database.
func IsExists ¶
func IsExists(ctx context.Context, db *gorm.DB, model any, filters map[string]any, notFilters map[string]any) (bool, error)
IsExists is a generic function to check if a record exists in the database.
func NewDepartmentRepository ¶
func NewDepartmentRepository(data *Data) usecase.DepartmentRepository
NewDepartmentRepository creates a new instance of department repository.
func NewRoleRepository ¶
func NewRoleRepository(data *Data) usecase.RoleRepository
NewRoleRepository creates a new instance of role repository.
func NewTransaction ¶
func NewTransaction(d *Data) usecase.Transaction
func NewUserRepository ¶
func NewUserRepository(data *Data) usecase.UserRepository
NewUserRepository creates a new instance of user repository.
Types ¶
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data manages data access resources and their lifecycle.
func NewData ¶
func NewData(cfgPG *config.PG, cfgRedis *config.Redis, cfgRabbitMQ *config.RabbitMQ, logger *zap.Logger) (*Data, func(), error)
NewData creates a new Data instance with database, redis, and optional RabbitMQ connections. Returns Data instance and a cleanup function.
func (*Data) Transaction ¶
Transaction executes a function within a database transaction. It automatically commits the transaction if the function returns without error, and automatically rolls back the transaction otherwise.
type DepartmentRepository ¶
type DepartmentRepository struct {
// contains filtered or unexported fields
}
DepartmentRepository is an implementation of the department repository.
func (*DepartmentRepository) Count ¶
func (r *DepartmentRepository) Count(ctx context.Context, filters map[string]any, notFilters map[string]any) (int64, error)
Count counts the number of departments.
func (*DepartmentRepository) Create ¶
func (r *DepartmentRepository) Create(ctx context.Context, department *model.Department) error
Create adds a new department to the database.
func (*DepartmentRepository) Delete ¶
func (r *DepartmentRepository) Delete(ctx context.Context, id uint) error
Delete removes a department by ID.
func (*DepartmentRepository) FindByID ¶
func (r *DepartmentRepository) FindByID(ctx context.Context, id uint) (*model.Department, error)
FindByID retrieves a department by ID.
func (*DepartmentRepository) IsExists ¶
func (r *DepartmentRepository) IsExists(ctx context.Context, filters map[string]any, notFilters map[string]any) (bool, error)
IsExists checks if a department exists in the database.
func (*DepartmentRepository) List ¶
func (r *DepartmentRepository) List(ctx context.Context, filters map[string]any, limit, offset int, sortClause string) ([]*model.Department, int, error)
List retrieves departments with pagination and filtering.
func (*DepartmentRepository) Update ¶
func (r *DepartmentRepository) Update(ctx context.Context, department *model.Department, params map[string]any) error
Update updates a department.
type RoleRepository ¶
type RoleRepository struct {
// contains filtered or unexported fields
}
RoleRepository is an implementation of the role repository.
func (*RoleRepository) Count ¶
func (r *RoleRepository) Count(ctx context.Context, filters map[string]any, notFilters map[string]any) (int64, error)
Count counts the number of roles.
func (*RoleRepository) Delete ¶
func (r *RoleRepository) Delete(ctx context.Context, id uint) error
Delete removes a role by ID.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository is an implementation of the user repository.
func (*UserRepository) Delete ¶
func (r *UserRepository) Delete(ctx context.Context, id uint) error
Delete removes a user by ID.
func (*UserRepository) DeleteRSAPrivateKey ¶
func (r *UserRepository) DeleteRSAPrivateKey(ctx context.Context, cacheKey string) error
DeleteRSAPrivateKey removes the RSA private key from the cache.
func (*UserRepository) FindByUsername ¶
FindByUsername retrieves a user by username.
func (*UserRepository) GetRSAPrivateKey ¶
func (*UserRepository) List ¶
func (r *UserRepository) List(ctx context.Context, filters map[string]any, limit, offset int, sortClause string) ([]*model.User, int, error)
List retrieves users with pagination and filtering.
func (*UserRepository) SetRSAPrivateKey ¶
func (r *UserRepository) SetRSAPrivateKey(ctx context.Context, cacheKey string, privateKey []byte) error
SetRSAPrivateKey sets the RSA private key in the cache.