- Add auth handlers (signup, login, logout, account management) with bcrypt - Add client, customer, service, scheduling, payment, question, answer handlers - Add dashboard, monthly report, and lead pipeline pages - Add UTF-8 middleware to force charset on HTML responses - Add config package with env-based overrides for DB path, secrets, endpoints - Add parser package for WhatsApp message ingestion - Add clean-arch layers: pkg/domain, pkg/repo, pkg/usecase for leads - Add cmd/migrate utility for DB migrations - Add Makefile, README, run-tests.sh, and dev scripts - Update docker-compose.yml with memory limits - Update .air.toml to exclude DB files and stop on errors - Update whatsapp-sync dependencies and add src/index.js entrypoint - Add whatsme standalone WhatsApp reader app (source only) - Untrack .opencode-sandbox/data/go-crm.db from git history - Expand root .gitignore: ngrok, tmp dirs, sandbox DBs, compiled binaries
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package handlers
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
|
|
"go-crm/internal/whatsapp"
|
|
"go-crm/pkg/usecase"
|
|
)
|
|
|
|
// App holds the application dependencies injected at startup.
|
|
// All handler methods live on *App, eliminating package-level global state.
|
|
type App struct {
|
|
DB *sql.DB
|
|
LeadService *usecase.LeadService
|
|
WAConnector whatsapp.Connector
|
|
}
|
|
|
|
// NewApp constructs an App with the given database, lead service, and WhatsApp connector.
|
|
func NewApp(db *sql.DB, leadSvc *usecase.LeadService, wa whatsapp.Connector) *App {
|
|
return &App{DB: db, LeadService: leadSvc, WAConnector: wa}
|
|
}
|
|
|
|
// WAConnector is a package-level global kept for backward-compat with existing tests.
|
|
// New code should use App.WAConnector via NewApp.
|
|
var WAConnector whatsapp.Connector
|
|
|
|
// SetupHandlers is kept for backward compatibility with existing tests.
|
|
// New code should use NewApp directly.
|
|
func SetupHandlers(db *sql.DB, wa whatsapp.Connector) {
|
|
DB = db
|
|
WAConnector = wa
|
|
}
|
|
|
|
func getCurrentTimestamp() int64 {
|
|
return time.Now().Unix()
|
|
}
|