feat: add customer list, modify pagination utils
This commit is contained in:
@@ -3,10 +3,13 @@ package customerRepo
|
||||
import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/db"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/filters"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/find"
|
||||
)
|
||||
|
||||
type UICustomerRepo interface {
|
||||
Get(id uint) (*model.Customer, error)
|
||||
Find(langId uint, p find.Paging, filt *filters.FiltersList) (*find.Found[model.Customer], error)
|
||||
}
|
||||
|
||||
type CustomerRepo struct{}
|
||||
@@ -25,3 +28,12 @@ func (repo *CustomerRepo) Get(id uint) (*model.Customer, error) {
|
||||
|
||||
return &customer, err
|
||||
}
|
||||
|
||||
func (repo *CustomerRepo) Find(langId uint, p find.Paging, filt *filters.FiltersList) (*find.Found[model.Customer], error) {
|
||||
found, err := find.Paginate[model.Customer](langId, p, db.DB.
|
||||
Model(&model.Customer{}).
|
||||
Scopes(filt.All()...),
|
||||
)
|
||||
|
||||
return &found, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user