Merge pull request #76 from rede5/codex/update-company_id-and-user_id-to-uuid-v7
Adopt UUIDv7 aliases and default user role 'PHARMACY'
This commit is contained in:
commit
bbab9cfbb4
2 changed files with 13 additions and 9 deletions
|
|
@ -6,9 +6,13 @@ import (
|
||||||
"github.com/gofrs/uuid/v5"
|
"github.com/gofrs/uuid/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CompanyID and UserID are UUIDv7 identifiers for performance-friendly indexing.
|
||||||
|
type CompanyID = uuid.UUID
|
||||||
|
type UserID = uuid.UUID
|
||||||
|
|
||||||
// Tenant represents a B2B actor (pharmacy/distributor) in the marketplace.
|
// Tenant represents a B2B actor (pharmacy/distributor) in the marketplace.
|
||||||
type Tenant struct {
|
type Tenant struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID CompanyID `db:"id" json:"id"`
|
||||||
CNPJ string `db:"cnpj" json:"cnpj"`
|
CNPJ string `db:"cnpj" json:"cnpj"`
|
||||||
CorporateName string `db:"corporate_name" json:"corporate_name"`
|
CorporateName string `db:"corporate_name" json:"corporate_name"`
|
||||||
Category string `db:"category" json:"category"` // farmacia, distribuidora
|
Category string `db:"category" json:"category"` // farmacia, distribuidora
|
||||||
|
|
@ -46,8 +50,8 @@ const (
|
||||||
|
|
||||||
// User represents an authenticated actor inside a company.
|
// User represents an authenticated actor inside a company.
|
||||||
type User struct {
|
type User struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID UserID `db:"id" json:"id"`
|
||||||
CompanyID uuid.UUID `db:"company_id" json:"company_id"`
|
CompanyID CompanyID `db:"company_id" json:"company_id"`
|
||||||
Role string `db:"role" json:"role"`
|
Role string `db:"role" json:"role"`
|
||||||
Name string `db:"name" json:"name"`
|
Name string `db:"name" json:"name"`
|
||||||
Username string `db:"username" json:"username"`
|
Username string `db:"username" json:"username"`
|
||||||
|
|
@ -67,7 +71,7 @@ type User struct {
|
||||||
|
|
||||||
// UserFilter captures listing constraints.
|
// UserFilter captures listing constraints.
|
||||||
type UserFilter struct {
|
type UserFilter struct {
|
||||||
CompanyID *uuid.UUID
|
CompanyID *CompanyID
|
||||||
Limit int
|
Limit int
|
||||||
Offset int
|
Offset int
|
||||||
}
|
}
|
||||||
|
|
@ -498,7 +502,7 @@ type Review struct {
|
||||||
|
|
||||||
// CompanyRating exposes the aggregate score for a seller or pharmacy.
|
// CompanyRating exposes the aggregate score for a seller or pharmacy.
|
||||||
type CompanyRating struct {
|
type CompanyRating struct {
|
||||||
CompanyID uuid.UUID `json:"company_id"`
|
CompanyID CompanyID `json:"company_id"`
|
||||||
AverageScore float64 `json:"average_score"`
|
AverageScore float64 `json:"average_score"`
|
||||||
TotalReviews int64 `json:"total_reviews"`
|
TotalReviews int64 `json:"total_reviews"`
|
||||||
}
|
}
|
||||||
|
|
@ -530,7 +534,7 @@ type AdminDashboard struct {
|
||||||
// CompanyDocument represents a KYC/KYB document (CNPJ card, Permit).
|
// CompanyDocument represents a KYC/KYB document (CNPJ card, Permit).
|
||||||
type CompanyDocument struct {
|
type CompanyDocument struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID uuid.UUID `db:"id" json:"id"`
|
||||||
CompanyID uuid.UUID `db:"company_id" json:"company_id"`
|
CompanyID CompanyID `db:"company_id" json:"company_id"`
|
||||||
Type string `db:"type" json:"type"` // CNPJ, PERMIT, IDENTITY
|
Type string `db:"type" json:"type"` // CNPJ, PERMIT, IDENTITY
|
||||||
URL string `db:"url" json:"url"`
|
URL string `db:"url" json:"url"`
|
||||||
Status string `db:"status" json:"status"` // PENDING, APPROVED, REJECTED
|
Status string `db:"status" json:"status"` // PENDING, APPROVED, REJECTED
|
||||||
|
|
@ -542,7 +546,7 @@ type CompanyDocument struct {
|
||||||
// LedgerEntry represents an immutable financial record.
|
// LedgerEntry represents an immutable financial record.
|
||||||
type LedgerEntry struct {
|
type LedgerEntry struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID uuid.UUID `db:"id" json:"id"`
|
||||||
CompanyID uuid.UUID `db:"company_id" json:"company_id"`
|
CompanyID CompanyID `db:"company_id" json:"company_id"`
|
||||||
AmountCents int64 `db:"amount_cents" json:"amount_cents"`
|
AmountCents int64 `db:"amount_cents" json:"amount_cents"`
|
||||||
Type string `db:"type" json:"type"` // SALE, FEE, WITHDRAWAL, REFUND
|
Type string `db:"type" json:"type"` // SALE, FEE, WITHDRAWAL, REFUND
|
||||||
Description string `db:"description" json:"description"`
|
Description string `db:"description" json:"description"`
|
||||||
|
|
@ -553,7 +557,7 @@ type LedgerEntry struct {
|
||||||
// Withdrawal represents a payout request.
|
// Withdrawal represents a payout request.
|
||||||
type Withdrawal struct {
|
type Withdrawal struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID uuid.UUID `db:"id" json:"id"`
|
||||||
CompanyID uuid.UUID `db:"company_id" json:"company_id"`
|
CompanyID CompanyID `db:"company_id" json:"company_id"`
|
||||||
AmountCents int64 `db:"amount_cents" json:"amount_cents"`
|
AmountCents int64 `db:"amount_cents" json:"amount_cents"`
|
||||||
Status string `db:"status" json:"status"` // PENDING, APPROVED, PAID, REJECTED
|
Status string `db:"status" json:"status"` // PENDING, APPROVED, PAID, REJECTED
|
||||||
BankAccountInfo string `db:"bank_account_info" json:"bank_account_info"`
|
BankAccountInfo string `db:"bank_account_info" json:"bank_account_info"`
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS companies (
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
id UUID PRIMARY KEY,
|
id UUID PRIMARY KEY,
|
||||||
company_id UUID NOT NULL REFERENCES companies(id),
|
company_id UUID NOT NULL REFERENCES companies(id),
|
||||||
role TEXT NOT NULL,
|
role TEXT NOT NULL DEFAULT 'PHARMACY',
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
email TEXT NOT NULL UNIQUE,
|
email TEXT NOT NULL UNIQUE,
|
||||||
password_hash TEXT NOT NULL,
|
password_hash TEXT NOT NULL,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue