Update Filter

This commit is contained in:
aditya.siregar
2024-07-30 19:38:23 +07:00
parent 065cfc4df6
commit c7495b8bff
7 changed files with 32 additions and 11 deletions
+4
View File
@@ -93,6 +93,10 @@ func (b *PartnerRepository) GetAll(ctx context.Context, req entity.PartnerSearch
query = query.Where("p.name ILIKE ?", "%"+req.Name+"%")
}
if req.PartnerID != nil {
query = query.Where("p.id = ?", req.PartnerID)
}
if req.Limit > 0 {
query = query.Limit(req.Limit)
}
+4
View File
@@ -101,6 +101,10 @@ func (b *UserRepository) GetAllUsers(ctx context.Context, req entity.UserSearch)
query = query.Where("ur.partner_id = ? ", req.PartnerID)
}
if req.SiteID > 0 {
query = query.Where("ur.site_id = ? ", req.SiteID)
}
// Get the total count without applying the limit and offset.
if err := query.Model(&entity.UserDB{}).Count(&total).Error; err != nil {
logger.ContextLogger(ctx).Error("error when count users", zap.Error(err))