repository

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRepository

type BaseRepository[T any, K comparable, S any] interface {
	// GetDB returns the gorm.DB instance.
	GetDB() *gorm.DB

	// Save saves a single entity.
	// filterContext provides additional context for the operation.
	// item is the entity to be saved.
	// tx is an optional transaction. If nil, the default DB is used.
	Save(tx *gorm.DB, filterContext *S, item *T) (*T, error)

	// SaveMany saves multiple entities.
	// filterContext provides additional context for the operation.
	// item is the list of entities to be saved.
	// tx is an optional transaction. If nil, the default DB is used.
	SaveMany(tx *gorm.DB, filterContext *S, item []*T) ([]*T, error)

	// Update updates a single entity.
	// filterContext provides additional context for the operation.
	// item is the entity to be updated.
	// tx is an optional transaction. If nil, the default DB is used.
	Update(tx *gorm.DB, filterContext *S, item *T) (*T, error)

	// UpdateMany updates multiple entities.
	// filterContext provides additional context for the operation.
	// item is the list of entities to be updated.
	// tx is an optional transaction. If nil, the default DB is used.
	UpdateMany(tx *gorm.DB, filterContext *S, item []*T) ([]*T, error)

	// Delete deletes a single entity by its ID.
	// searchParams provides additional context for the operation.
	// itemId is the ID of the entity to be deleted.
	// tx is an optional transaction. If nil, the default DB is used.
	Delete(tx *gorm.DB, searchParams *S, itemId K) error

	// DeleteByIds deletes multiple entities by their IDs.
	// searchParams provides additional context for the operation.
	// itemIds is the list of IDs of the entities to be deleted.
	// tx is an optional transaction. If nil, the default DB is used.
	DeleteByIds(tx *gorm.DB, searchParams *S, itemIds []K) error

	// FindById finds a single entity by its ID.
	// searchParams provides additional context for the operation.
	// itemId is the ID of the entity to be found.
	// tx is an optional transaction. If nil, the default DB is used.
	FindById(tx *gorm.DB, searchParams *S, itemId K) (*T, error)

	// FindByIds finds multiple entities by their IDs.
	// searchParams provides additional context for the operation.
	// itemIds is the list of IDs of the entities to be found.
	// tx is an optional transaction. If nil, the default DB is used.
	FindByIds(tx *gorm.DB, searchParams *S, itemIds []K) ([]*T, error)

	// FindAll finds all entities with pagination.
	// searchParams provides additional context for the operation.
	// pageSize is the number of entities per page.
	// page is the current page number.
	// tx is an optional transaction. If nil, the default DB is used.
	FindAll(tx *gorm.DB, searchParams *S, pageSize int, page int) ([]*T, error)

	// Search searches for entities based on search parameters.
	// searchParams provides the criteria for the search.
	// tx is an optional transaction. If nil, the default DB is used.
	Search(tx *gorm.DB, searchParams *S) ([]*T, error)

	// Count counts the number of entities based on search parameters.
	// searchParams provides the criteria for the count.
	// tx is an optional transaction. If nil, the default DB is used.
	Count(tx *gorm.DB, searchParams *S) (int64, error)

	// Deleted returns a list of IDs of deleted entities based on search parameters.
	// searchParams provides the criteria for the search.
	// tx is an optional transaction. If nil, the default DB is used.
	Deleted(tx *gorm.DB, searchParams *S) ([]string, error)
}

BaseRepository defines a generic repository interface for CRUD operations. T represents the type of the entity. K represents the type of the entity's ID. S represents the type of the search parameters. Many methods accept an optional *gorm.DB transaction (tx). If tx is nil, the default DB connection is used.

type OrganizationRepository

type OrganizationRepository struct {
	Db *gorm.DB
}

func (*OrganizationRepository) Count

func (e *OrganizationRepository) Count(tx *gorm.DB, searchParams *OrganizationSearch) (int64, error)

func (*OrganizationRepository) Delete

func (e *OrganizationRepository) Delete(tx *gorm.DB, filterContext *OrganizationSearch, itemId uuid.UUID) error

func (*OrganizationRepository) DeleteByIds

func (e *OrganizationRepository) DeleteByIds(tx *gorm.DB, filterContext *OrganizationSearch, itemIds []uuid.UUID) error

func (*OrganizationRepository) Deleted

func (e *OrganizationRepository) Deleted(tx *gorm.DB, searchParams *OrganizationSearch) ([]string, error)

func (*OrganizationRepository) FindAll

func (e *OrganizationRepository) FindAll(tx *gorm.DB, filterContext *OrganizationSearch, pageSize int, page int) ([]*model.Organization, error)

func (*OrganizationRepository) FindById

func (e *OrganizationRepository) FindById(tx *gorm.DB, filterContext *OrganizationSearch, itemId uuid.UUID) (*model.Organization, error)

func (*OrganizationRepository) FindByIds

func (e *OrganizationRepository) FindByIds(tx *gorm.DB, filterContext *OrganizationSearch, itemIds []uuid.UUID) ([]*model.Organization, error)

func (*OrganizationRepository) GetDB

func (e *OrganizationRepository) GetDB() *gorm.DB

func (*OrganizationRepository) Save

func (e *OrganizationRepository) Save(tx *gorm.DB, filterContext *OrganizationSearch, item *model.Organization) (*model.Organization, error)

func (*OrganizationRepository) SaveMany

func (e *OrganizationRepository) SaveMany(tx *gorm.DB, filterContext *OrganizationSearch, item []*model.Organization) ([]*model.Organization, error)

func (*OrganizationRepository) Search

func (e *OrganizationRepository) Search(tx *gorm.DB, searchParams *OrganizationSearch) ([]*model.Organization, error)

func (*OrganizationRepository) Update

func (e *OrganizationRepository) Update(tx *gorm.DB, filterContext *OrganizationSearch, item *model.Organization) (*model.Organization, error)

func (*OrganizationRepository) UpdateMany

func (e *OrganizationRepository) UpdateMany(tx *gorm.DB, filterContext *OrganizationSearch, items []*model.Organization) ([]*model.Organization, error)

type OrganizationSearch

type OrganizationSearch struct {
	OrganizationType string
	PageSize         int
	PageNumber       int
	OrderBy          string
}

type SystemUserOrganizationRepository

type SystemUserOrganizationRepository struct {
	Db *gorm.DB
}

func (*SystemUserOrganizationRepository) Count

func (*SystemUserOrganizationRepository) Delete

func (e *SystemUserOrganizationRepository) Delete(tx *gorm.DB, filterContext *SystemUserOrganizationSearch, itemId uuid.UUID) error

func (*SystemUserOrganizationRepository) DeleteByIds

func (e *SystemUserOrganizationRepository) DeleteByIds(tx *gorm.DB, filterContext *SystemUserOrganizationSearch, itemIds []uuid.UUID) error

func (*SystemUserOrganizationRepository) Deleted

func (*SystemUserOrganizationRepository) FindAll

func (e *SystemUserOrganizationRepository) FindAll(tx *gorm.DB, filterContext *SystemUserOrganizationSearch, pageSize int, page int) ([]*model.SystemUserOrganization, error)

func (*SystemUserOrganizationRepository) FindById

func (*SystemUserOrganizationRepository) FindByIds

func (*SystemUserOrganizationRepository) GetDB

func (*SystemUserOrganizationRepository) Save

func (*SystemUserOrganizationRepository) SaveMany

func (*SystemUserOrganizationRepository) Search

func (*SystemUserOrganizationRepository) Update

func (*SystemUserOrganizationRepository) UpdateMany

type SystemUserOrganizationSearch

type SystemUserOrganizationSearch struct {
	OrganizationId uuid.UUID
	SystemUser     string
	PageSize       int
	PageNumber     int
	OrderBy        string
}

type SystemUserRepo

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

func NewSystemUserRepo

func NewSystemUserRepo(db *gorm.DB) *SystemUserRepo

func (*SystemUserRepo) Delete

func (m *SystemUserRepo) Delete(item *model.SystemUser) error

func (*SystemUserRepo) FindById

func (m *SystemUserRepo) FindById(userId uuid.UUID) (*model.SystemUser, error)

func (*SystemUserRepo) FindByUserName

func (m *SystemUserRepo) FindByUserName(userName string) (*model.SystemUser, error)

func (*SystemUserRepo) Save

func (m *SystemUserRepo) Save(item *model.SystemUser) error

Jump to

Keyboard shortcuts

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