chore(release): snapshot 1.4.2
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"aggios-app/backend/internal/config"
|
||||
"aggios-app/backend/internal/domain"
|
||||
"aggios-app/backend/internal/repository"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -15,14 +16,16 @@ type AgencyService struct {
|
||||
userRepo *repository.UserRepository
|
||||
tenantRepo *repository.TenantRepository
|
||||
cfg *config.Config
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
// NewAgencyService creates a new agency service
|
||||
func NewAgencyService(userRepo *repository.UserRepository, tenantRepo *repository.TenantRepository, cfg *config.Config) *AgencyService {
|
||||
func NewAgencyService(userRepo *repository.UserRepository, tenantRepo *repository.TenantRepository, cfg *config.Config, db *sql.DB) *AgencyService {
|
||||
return &AgencyService{
|
||||
userRepo: userRepo,
|
||||
tenantRepo: tenantRepo,
|
||||
cfg: cfg,
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +183,43 @@ func (s *AgencyService) GetAgencyDetails(id uuid.UUID) (*domain.AgencyDetails, e
|
||||
details.Admin = admin
|
||||
}
|
||||
|
||||
// Buscar subscription e soluções
|
||||
var subscription domain.AgencySubscriptionInfo
|
||||
query := `
|
||||
SELECT
|
||||
s.plan_id,
|
||||
p.name as plan_name,
|
||||
s.status
|
||||
FROM agency_subscriptions s
|
||||
JOIN plans p ON s.plan_id = p.id
|
||||
WHERE s.agency_id = $1
|
||||
LIMIT 1
|
||||
`
|
||||
err = s.db.QueryRow(query, id).Scan(&subscription.PlanID, &subscription.PlanName, &subscription.Status)
|
||||
if err == nil {
|
||||
// Buscar soluções do plano
|
||||
solutionsQuery := `
|
||||
SELECT sol.id, sol.name, sol.slug, sol.icon
|
||||
FROM solutions sol
|
||||
JOIN plan_solutions ps ON sol.id = ps.solution_id
|
||||
WHERE ps.plan_id = $1
|
||||
ORDER BY sol.name
|
||||
`
|
||||
rows, err := s.db.Query(solutionsQuery, subscription.PlanID)
|
||||
if err == nil {
|
||||
defer rows.Close()
|
||||
var solutions []domain.Solution
|
||||
for rows.Next() {
|
||||
var solution domain.Solution
|
||||
if err := rows.Scan(&solution.ID, &solution.Name, &solution.Slug, &solution.Icon); err == nil {
|
||||
solutions = append(solutions, solution)
|
||||
}
|
||||
}
|
||||
subscription.Solutions = solutions
|
||||
details.Subscription = &subscription
|
||||
}
|
||||
}
|
||||
|
||||
return details, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user