chore(release): snapshot 1.4.2
This commit is contained in:
346
backend/internal/repository/crm_repository.go
Normal file
346
backend/internal/repository/crm_repository.go
Normal file
@@ -0,0 +1,346 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"aggios-app/backend/internal/domain"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
type CRMRepository struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewCRMRepository(db *sql.DB) *CRMRepository {
|
||||
return &CRMRepository{db: db}
|
||||
}
|
||||
|
||||
// ==================== CUSTOMERS ====================
|
||||
|
||||
func (r *CRMRepository) CreateCustomer(customer *domain.CRMCustomer) error {
|
||||
query := `
|
||||
INSERT INTO crm_customers (
|
||||
id, tenant_id, name, email, phone, company, position,
|
||||
address, city, state, zip_code, country, notes, tags,
|
||||
is_active, created_by
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
|
||||
RETURNING created_at, updated_at
|
||||
`
|
||||
|
||||
return r.db.QueryRow(
|
||||
query,
|
||||
customer.ID, customer.TenantID, customer.Name, customer.Email, customer.Phone,
|
||||
customer.Company, customer.Position, customer.Address, customer.City, customer.State,
|
||||
customer.ZipCode, customer.Country, customer.Notes, pq.Array(customer.Tags),
|
||||
customer.IsActive, customer.CreatedBy,
|
||||
).Scan(&customer.CreatedAt, &customer.UpdatedAt)
|
||||
}
|
||||
|
||||
func (r *CRMRepository) GetCustomersByTenant(tenantID string) ([]domain.CRMCustomer, error) {
|
||||
query := `
|
||||
SELECT id, tenant_id, name, email, phone, company, position,
|
||||
address, city, state, zip_code, country, notes, tags,
|
||||
is_active, created_by, created_at, updated_at
|
||||
FROM crm_customers
|
||||
WHERE tenant_id = $1 AND is_active = true
|
||||
ORDER BY created_at DESC
|
||||
`
|
||||
|
||||
rows, err := r.db.Query(query, tenantID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var customers []domain.CRMCustomer
|
||||
for rows.Next() {
|
||||
var c domain.CRMCustomer
|
||||
err := rows.Scan(
|
||||
&c.ID, &c.TenantID, &c.Name, &c.Email, &c.Phone, &c.Company, &c.Position,
|
||||
&c.Address, &c.City, &c.State, &c.ZipCode, &c.Country, &c.Notes, pq.Array(&c.Tags),
|
||||
&c.IsActive, &c.CreatedBy, &c.CreatedAt, &c.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
customers = append(customers, c)
|
||||
}
|
||||
|
||||
return customers, nil
|
||||
}
|
||||
|
||||
func (r *CRMRepository) GetCustomerByID(id string, tenantID string) (*domain.CRMCustomer, error) {
|
||||
query := `
|
||||
SELECT id, tenant_id, name, email, phone, company, position,
|
||||
address, city, state, zip_code, country, notes, tags,
|
||||
is_active, created_by, created_at, updated_at
|
||||
FROM crm_customers
|
||||
WHERE id = $1 AND tenant_id = $2
|
||||
`
|
||||
|
||||
var c domain.CRMCustomer
|
||||
err := r.db.QueryRow(query, id, tenantID).Scan(
|
||||
&c.ID, &c.TenantID, &c.Name, &c.Email, &c.Phone, &c.Company, &c.Position,
|
||||
&c.Address, &c.City, &c.State, &c.ZipCode, &c.Country, &c.Notes, pq.Array(&c.Tags),
|
||||
&c.IsActive, &c.CreatedBy, &c.CreatedAt, &c.UpdatedAt,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
func (r *CRMRepository) UpdateCustomer(customer *domain.CRMCustomer) error {
|
||||
query := `
|
||||
UPDATE crm_customers SET
|
||||
name = $1, email = $2, phone = $3, company = $4, position = $5,
|
||||
address = $6, city = $7, state = $8, zip_code = $9, country = $10,
|
||||
notes = $11, tags = $12, is_active = $13
|
||||
WHERE id = $14 AND tenant_id = $15
|
||||
`
|
||||
|
||||
result, err := r.db.Exec(
|
||||
query,
|
||||
customer.Name, customer.Email, customer.Phone, customer.Company, customer.Position,
|
||||
customer.Address, customer.City, customer.State, customer.ZipCode, customer.Country,
|
||||
customer.Notes, pq.Array(customer.Tags), customer.IsActive,
|
||||
customer.ID, customer.TenantID,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rows, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rows == 0 {
|
||||
return fmt.Errorf("customer not found")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *CRMRepository) DeleteCustomer(id string, tenantID string) error {
|
||||
query := `DELETE FROM crm_customers WHERE id = $1 AND tenant_id = $2`
|
||||
|
||||
result, err := r.db.Exec(query, id, tenantID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rows, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rows == 0 {
|
||||
return fmt.Errorf("customer not found")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ==================== LISTS ====================
|
||||
|
||||
func (r *CRMRepository) CreateList(list *domain.CRMList) error {
|
||||
query := `
|
||||
INSERT INTO crm_lists (id, tenant_id, name, description, color, created_by)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
RETURNING created_at, updated_at
|
||||
`
|
||||
|
||||
return r.db.QueryRow(
|
||||
query,
|
||||
list.ID, list.TenantID, list.Name, list.Description, list.Color, list.CreatedBy,
|
||||
).Scan(&list.CreatedAt, &list.UpdatedAt)
|
||||
}
|
||||
|
||||
func (r *CRMRepository) GetListsByTenant(tenantID string) ([]domain.CRMListWithCustomers, error) {
|
||||
query := `
|
||||
SELECT l.id, l.tenant_id, l.name, l.description, l.color, l.created_by,
|
||||
l.created_at, l.updated_at,
|
||||
COUNT(cl.customer_id) as customer_count
|
||||
FROM crm_lists l
|
||||
LEFT JOIN crm_customer_lists cl ON l.id = cl.list_id
|
||||
WHERE l.tenant_id = $1
|
||||
GROUP BY l.id
|
||||
ORDER BY l.created_at DESC
|
||||
`
|
||||
|
||||
rows, err := r.db.Query(query, tenantID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var lists []domain.CRMListWithCustomers
|
||||
for rows.Next() {
|
||||
var l domain.CRMListWithCustomers
|
||||
err := rows.Scan(
|
||||
&l.ID, &l.TenantID, &l.Name, &l.Description, &l.Color, &l.CreatedBy,
|
||||
&l.CreatedAt, &l.UpdatedAt, &l.CustomerCount,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lists = append(lists, l)
|
||||
}
|
||||
|
||||
return lists, nil
|
||||
}
|
||||
|
||||
func (r *CRMRepository) GetListByID(id string, tenantID string) (*domain.CRMList, error) {
|
||||
query := `
|
||||
SELECT id, tenant_id, name, description, color, created_by, created_at, updated_at
|
||||
FROM crm_lists
|
||||
WHERE id = $1 AND tenant_id = $2
|
||||
`
|
||||
|
||||
var l domain.CRMList
|
||||
err := r.db.QueryRow(query, id, tenantID).Scan(
|
||||
&l.ID, &l.TenantID, &l.Name, &l.Description, &l.Color, &l.CreatedBy,
|
||||
&l.CreatedAt, &l.UpdatedAt,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &l, nil
|
||||
}
|
||||
|
||||
func (r *CRMRepository) UpdateList(list *domain.CRMList) error {
|
||||
query := `
|
||||
UPDATE crm_lists SET
|
||||
name = $1, description = $2, color = $3
|
||||
WHERE id = $4 AND tenant_id = $5
|
||||
`
|
||||
|
||||
result, err := r.db.Exec(query, list.Name, list.Description, list.Color, list.ID, list.TenantID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rows, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rows == 0 {
|
||||
return fmt.Errorf("list not found")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *CRMRepository) DeleteList(id string, tenantID string) error {
|
||||
query := `DELETE FROM crm_lists WHERE id = $1 AND tenant_id = $2`
|
||||
|
||||
result, err := r.db.Exec(query, id, tenantID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rows, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rows == 0 {
|
||||
return fmt.Errorf("list not found")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ==================== CUSTOMER <-> LIST ====================
|
||||
|
||||
func (r *CRMRepository) AddCustomerToList(customerID, listID, addedBy string) error {
|
||||
query := `
|
||||
INSERT INTO crm_customer_lists (customer_id, list_id, added_by)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (customer_id, list_id) DO NOTHING
|
||||
`
|
||||
|
||||
_, err := r.db.Exec(query, customerID, listID, addedBy)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *CRMRepository) RemoveCustomerFromList(customerID, listID string) error {
|
||||
query := `DELETE FROM crm_customer_lists WHERE customer_id = $1 AND list_id = $2`
|
||||
|
||||
_, err := r.db.Exec(query, customerID, listID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *CRMRepository) GetCustomerLists(customerID string) ([]domain.CRMList, error) {
|
||||
query := `
|
||||
SELECT l.id, l.tenant_id, l.name, l.description, l.color, l.created_by,
|
||||
l.created_at, l.updated_at
|
||||
FROM crm_lists l
|
||||
INNER JOIN crm_customer_lists cl ON l.id = cl.list_id
|
||||
WHERE cl.customer_id = $1
|
||||
ORDER BY l.name
|
||||
`
|
||||
|
||||
rows, err := r.db.Query(query, customerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var lists []domain.CRMList
|
||||
for rows.Next() {
|
||||
var l domain.CRMList
|
||||
err := rows.Scan(
|
||||
&l.ID, &l.TenantID, &l.Name, &l.Description, &l.Color, &l.CreatedBy,
|
||||
&l.CreatedAt, &l.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lists = append(lists, l)
|
||||
}
|
||||
|
||||
return lists, nil
|
||||
}
|
||||
|
||||
func (r *CRMRepository) GetListCustomers(listID string, tenantID string) ([]domain.CRMCustomer, error) {
|
||||
query := `
|
||||
SELECT c.id, c.tenant_id, c.name, c.email, c.phone, c.company, c.position,
|
||||
c.address, c.city, c.state, c.zip_code, c.country, c.notes, c.tags,
|
||||
c.is_active, c.created_by, c.created_at, c.updated_at
|
||||
FROM crm_customers c
|
||||
INNER JOIN crm_customer_lists cl ON c.id = cl.customer_id
|
||||
WHERE cl.list_id = $1 AND c.tenant_id = $2 AND c.is_active = true
|
||||
ORDER BY c.name
|
||||
`
|
||||
|
||||
rows, err := r.db.Query(query, listID, tenantID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var customers []domain.CRMCustomer
|
||||
for rows.Next() {
|
||||
var c domain.CRMCustomer
|
||||
err := rows.Scan(
|
||||
&c.ID, &c.TenantID, &c.Name, &c.Email, &c.Phone, &c.Company, &c.Position,
|
||||
&c.Address, &c.City, &c.State, &c.ZipCode, &c.Country, &c.Notes, pq.Array(&c.Tags),
|
||||
&c.IsActive, &c.CreatedBy, &c.CreatedAt, &c.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
customers = append(customers, c)
|
||||
}
|
||||
|
||||
return customers, nil
|
||||
}
|
||||
300
backend/internal/repository/solution_repository.go
Normal file
300
backend/internal/repository/solution_repository.go
Normal file
@@ -0,0 +1,300 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"aggios-app/backend/internal/domain"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type SolutionRepository struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewSolutionRepository(db *sql.DB) *SolutionRepository {
|
||||
return &SolutionRepository{db: db}
|
||||
}
|
||||
|
||||
// ==================== SOLUTIONS ====================
|
||||
|
||||
func (r *SolutionRepository) CreateSolution(solution *domain.Solution) error {
|
||||
query := `
|
||||
INSERT INTO solutions (id, name, slug, icon, description, is_active)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
RETURNING created_at, updated_at
|
||||
`
|
||||
|
||||
return r.db.QueryRow(
|
||||
query,
|
||||
solution.ID, solution.Name, solution.Slug, solution.Icon,
|
||||
solution.Description, solution.IsActive,
|
||||
).Scan(&solution.CreatedAt, &solution.UpdatedAt)
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) GetAllSolutions() ([]domain.Solution, error) {
|
||||
query := `
|
||||
SELECT id, name, slug, icon, description, is_active, created_at, updated_at
|
||||
FROM solutions
|
||||
ORDER BY created_at DESC
|
||||
`
|
||||
|
||||
rows, err := r.db.Query(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var solutions []domain.Solution
|
||||
for rows.Next() {
|
||||
var s domain.Solution
|
||||
err := rows.Scan(
|
||||
&s.ID, &s.Name, &s.Slug, &s.Icon, &s.Description,
|
||||
&s.IsActive, &s.CreatedAt, &s.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
solutions = append(solutions, s)
|
||||
}
|
||||
|
||||
return solutions, nil
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) GetActiveSolutions() ([]domain.Solution, error) {
|
||||
query := `
|
||||
SELECT id, name, slug, icon, description, is_active, created_at, updated_at
|
||||
FROM solutions
|
||||
WHERE is_active = true
|
||||
ORDER BY name
|
||||
`
|
||||
|
||||
rows, err := r.db.Query(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var solutions []domain.Solution
|
||||
for rows.Next() {
|
||||
var s domain.Solution
|
||||
err := rows.Scan(
|
||||
&s.ID, &s.Name, &s.Slug, &s.Icon, &s.Description,
|
||||
&s.IsActive, &s.CreatedAt, &s.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
solutions = append(solutions, s)
|
||||
}
|
||||
|
||||
return solutions, nil
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) GetSolutionByID(id string) (*domain.Solution, error) {
|
||||
query := `
|
||||
SELECT id, name, slug, icon, description, is_active, created_at, updated_at
|
||||
FROM solutions
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
var s domain.Solution
|
||||
err := r.db.QueryRow(query, id).Scan(
|
||||
&s.ID, &s.Name, &s.Slug, &s.Icon, &s.Description,
|
||||
&s.IsActive, &s.CreatedAt, &s.UpdatedAt,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) GetSolutionBySlug(slug string) (*domain.Solution, error) {
|
||||
query := `
|
||||
SELECT id, name, slug, icon, description, is_active, created_at, updated_at
|
||||
FROM solutions
|
||||
WHERE slug = $1
|
||||
`
|
||||
|
||||
var s domain.Solution
|
||||
err := r.db.QueryRow(query, slug).Scan(
|
||||
&s.ID, &s.Name, &s.Slug, &s.Icon, &s.Description,
|
||||
&s.IsActive, &s.CreatedAt, &s.UpdatedAt,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) UpdateSolution(solution *domain.Solution) error {
|
||||
query := `
|
||||
UPDATE solutions SET
|
||||
name = $1, slug = $2, icon = $3, description = $4, is_active = $5, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $6
|
||||
`
|
||||
|
||||
result, err := r.db.Exec(
|
||||
query,
|
||||
solution.Name, solution.Slug, solution.Icon, solution.Description,
|
||||
solution.IsActive, solution.ID,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rows, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rows == 0 {
|
||||
return fmt.Errorf("solution not found")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) DeleteSolution(id string) error {
|
||||
query := `DELETE FROM solutions WHERE id = $1`
|
||||
|
||||
result, err := r.db.Exec(query, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rows, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rows == 0 {
|
||||
return fmt.Errorf("solution not found")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ==================== PLAN <-> SOLUTION ====================
|
||||
|
||||
func (r *SolutionRepository) AddSolutionToPlan(planID, solutionID string) error {
|
||||
query := `
|
||||
INSERT INTO plan_solutions (plan_id, solution_id)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT (plan_id, solution_id) DO NOTHING
|
||||
`
|
||||
|
||||
_, err := r.db.Exec(query, planID, solutionID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) RemoveSolutionFromPlan(planID, solutionID string) error {
|
||||
query := `DELETE FROM plan_solutions WHERE plan_id = $1 AND solution_id = $2`
|
||||
|
||||
_, err := r.db.Exec(query, planID, solutionID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) GetPlanSolutions(planID string) ([]domain.Solution, error) {
|
||||
query := `
|
||||
SELECT s.id, s.name, s.slug, s.icon, s.description, s.is_active, s.created_at, s.updated_at
|
||||
FROM solutions s
|
||||
INNER JOIN plan_solutions ps ON s.id = ps.solution_id
|
||||
WHERE ps.plan_id = $1
|
||||
ORDER BY s.name
|
||||
`
|
||||
|
||||
rows, err := r.db.Query(query, planID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var solutions []domain.Solution
|
||||
for rows.Next() {
|
||||
var s domain.Solution
|
||||
err := rows.Scan(
|
||||
&s.ID, &s.Name, &s.Slug, &s.Icon, &s.Description,
|
||||
&s.IsActive, &s.CreatedAt, &s.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
solutions = append(solutions, s)
|
||||
}
|
||||
|
||||
return solutions, nil
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) SetPlanSolutions(planID string, solutionIDs []string) error {
|
||||
// Inicia transação
|
||||
tx, err := r.db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove todas as soluções antigas do plano
|
||||
_, err = tx.Exec(`DELETE FROM plan_solutions WHERE plan_id = $1`, planID)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
// Adiciona as novas soluções
|
||||
stmt, err := tx.Prepare(`INSERT INTO plan_solutions (plan_id, solution_id) VALUES ($1, $2)`)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
for _, solutionID := range solutionIDs {
|
||||
_, err = stmt.Exec(planID, solutionID)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
func (r *SolutionRepository) GetTenantSolutions(tenantID string) ([]domain.Solution, error) {
|
||||
query := `
|
||||
SELECT DISTINCT s.id, s.name, s.slug, s.icon, s.description, s.is_active, s.created_at, s.updated_at
|
||||
FROM solutions s
|
||||
INNER JOIN plan_solutions ps ON s.id = ps.solution_id
|
||||
INNER JOIN agency_subscriptions asub ON ps.plan_id = asub.plan_id
|
||||
WHERE asub.agency_id = $1 AND s.is_active = true AND asub.status = 'active'
|
||||
ORDER BY s.name
|
||||
`
|
||||
|
||||
rows, err := r.db.Query(query, tenantID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var solutions []domain.Solution
|
||||
for rows.Next() {
|
||||
var s domain.Solution
|
||||
err := rows.Scan(
|
||||
&s.ID, &s.Name, &s.Slug, &s.Icon, &s.Description,
|
||||
&s.IsActive, &s.CreatedAt, &s.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
solutions = append(solutions, s)
|
||||
}
|
||||
|
||||
// Se não encontrou via subscription, retorna array vazio
|
||||
if solutions == nil {
|
||||
solutions = []domain.Solution{}
|
||||
}
|
||||
|
||||
return solutions, nil
|
||||
}
|
||||
Reference in New Issue
Block a user