Chever John 1f4ccfb54e feat: multi-tenant CRM with PostgreSQL graph, tenant isolation, and Casbin RBAC
- JWT claims extended with tenantId; login enforces strict tenant verification
- AuthorityMiddleware: tenant scope check + Casbin path permission + anti-spoofing
- CRM relation API (upstream/downstream one-hop, create/update/history, full graph)
- CrmRepo backed by PostgreSQL with $N placeholders
- gRPC tenant propagation via UnaryClientInterceptor (x-tenant-id metadata)
- All legacy tables (12) gain tenant_id column with indexes
- All model queries inject WHERE tenant_id filter
- Casbin gorm-adapter downgraded to v3.28.0 for v2 compatibility
- GraphSyncWorker (Kafka -> Neo4j) with idempotent MERGE
- Full graph API restricted to admin role only
- Database migrations for MySQL (CRM tables + tenant columns) and PostgreSQL (CRM init)
- Docker Compose: added postgres service to main stack, graph stack with Kafka/Debezium/Neo4j

Made-with: Cursor
2026-03-30 02:53:55 +00:00

33 lines
582 B
Go

package relation
import (
"database/sql"
"strings"
"time"
)
const timeLayout = "2006-01-02 15:04:05"
func parseTimeOrNow(raw string) time.Time {
if strings.TrimSpace(raw) == "" {
return time.Now()
}
t, err := time.ParseInLocation(timeLayout, raw, time.Local)
if err != nil {
return time.Now()
}
return t
}
func parseNullTime(raw string) sql.NullTime {
if strings.TrimSpace(raw) == "" {
return sql.NullTime{}
}
t, err := time.ParseInLocation(timeLayout, raw, time.Local)
if err != nil {
return sql.NullTime{}
}
return sql.NullTime{Time: t, Valid: true}
}