Add Filter and Total Tempat WIsata
This commit is contained in:
@@ -4,14 +4,17 @@ import (
|
||||
"context"
|
||||
"furtuna-be/internal/common/logger"
|
||||
"furtuna-be/internal/common/mycontext"
|
||||
"furtuna-be/internal/constants/role"
|
||||
"furtuna-be/internal/entity"
|
||||
"furtuna-be/internal/repository"
|
||||
"furtuna-be/internal/repository/users"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type SiteService struct {
|
||||
repo repository.SiteRepository
|
||||
user users.UserRepository
|
||||
}
|
||||
|
||||
func NewSiteService(repo repository.SiteRepository) *SiteService {
|
||||
@@ -89,6 +92,17 @@ func (s *SiteService) Delete(ctx mycontext.Context, id int64) error {
|
||||
}
|
||||
|
||||
func (s *SiteService) Count(ctx mycontext.Context, req entity.SiteSearch) (*entity.SiteCount, error) {
|
||||
if req.SiteID != nil {
|
||||
total, err := s.user.CountUsersByRoleAndSiteOrPartner(ctx, int(role.Casheer), req.SiteID)
|
||||
if err != nil {
|
||||
logger.ContextLogger(ctx).Error("error when getting count user", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
return &entity.SiteCount{
|
||||
Count: total,
|
||||
}, nil
|
||||
}
|
||||
|
||||
count, err := s.repo.Count(ctx, req)
|
||||
if err != nil {
|
||||
logger.ContextLogger(ctx).Error("error when getting all sites", zap.Error(err))
|
||||
@@ -96,4 +110,4 @@ func (s *SiteService) Count(ctx mycontext.Context, req entity.SiteSearch) (*enti
|
||||
}
|
||||
|
||||
return count.ToSiteCount(), nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user