perf: add pagination, filters, and fix Django sync pagination

This commit is contained in:
2026-04-30 15:34:25 -03:00
parent 19333cf713
commit badd54b4be
12 changed files with 413 additions and 176 deletions

View File

@@ -122,8 +122,8 @@ func (s *Service) SyncWithCloud() error {
return nil
}
func (s *Service) GetProducts() ([]models.Product, error) {
return s.repo.GetProducts()
func (s *Service) GetProducts(params *repository.PaginationParams) (*repository.PaginatedResponse, error) {
return s.repo.GetProducts(params)
}
func (s *Service) CreateProduct(product *models.Product) error {
@@ -134,20 +134,20 @@ func (s *Service) UpdateProduct(id uint, updates map[string]interface{}) error {
return s.repo.UpdateProductFields(id, updates)
}
func (s *Service) GetMesas() ([]models.Mesa, error) {
return s.repo.GetMesas()
func (s *Service) GetMesas(params *repository.PaginationParams) (*repository.PaginatedResponse, error) {
return s.repo.GetMesas(params)
}
func (s *Service) GetComandas() ([]models.Comanda, error) {
return s.repo.GetComandas()
func (s *Service) GetComandas(params *repository.PaginationParams) (*repository.PaginatedResponse, error) {
return s.repo.GetComandas(params)
}
func (s *Service) GetComandaByID(id uint) (*models.Comanda, error) {
return s.repo.GetComandaByID(id)
}
func (s *Service) GetCategories() ([]models.Category, error) {
return s.repo.GetCategories()
func (s *Service) GetCategories(params *repository.PaginationParams) (*repository.PaginatedResponse, error) {
return s.repo.GetCategories(params)
}
func (s *Service) CreateCategory(cat *models.Category) error {
@@ -158,16 +158,16 @@ func (s *Service) UpdateCategory(id uint, updates map[string]interface{}) error
return s.repo.UpdateCategoryFields(id, updates)
}
func (s *Service) GetTypePayments() ([]models.TypePay, error) {
return s.repo.GetTypePayments()
func (s *Service) GetTypePayments(params *repository.PaginationParams) (*repository.PaginatedResponse, error) {
return s.repo.GetTypePayments(params)
}
func (s *Service) GetClients() ([]models.Client, error) {
return s.repo.GetClients()
func (s *Service) GetClients(params *repository.PaginationParams) (*repository.PaginatedResponse, error) {
return s.repo.GetClients(params)
}
func (s *Service) GetOrders() ([]models.Order, error) {
return s.repo.GetOrders()
func (s *Service) GetOrders(params *repository.PaginationParams) (*repository.PaginatedResponse, error) {
return s.repo.GetOrders(params)
}
func (s *Service) CreateOrder(order *models.Order) error {
@@ -199,8 +199,8 @@ func (s *Service) SetOrderCanceled(id uint) error {
return s.repo.UpdateOrderFields(id, map[string]interface{}{"canceled": &now})
}
func (s *Service) GetPayments() ([]models.Payment, error) {
return s.repo.GetPayments()
func (s *Service) GetPayments(params *repository.PaginationParams) (*repository.PaginatedResponse, error) {
return s.repo.GetPayments(params)
}
func (s *Service) DeleteItem(itemID uint) error {