0xc3 hace 1 mes
padre
commit
8cbbf76b5a
Se han modificado 2 ficheros con 13 adiciones y 7 borrados
  1. 1 0
      migrations/00001_clients_table.sql
  2. 12 7
      src/server/db/repo/client.go

+ 1 - 0
migrations/00001_clients_table.sql

@@ -10,6 +10,7 @@ CREATE TABLE clients (
   legal_address TEXT,
   physical_address TEXT,
   note TEXT,
+  reg_date TEXT,
   income_amount DECIMAL(19, 4),
   income_currency CHAR(3)
 );

+ 12 - 7
src/server/db/repo/client.go

@@ -3,6 +3,7 @@ package repo
 import (
 	"database/sql"
 	"math/rand"
+	"time"
 
 	"github.com/google/uuid"
 )
@@ -31,12 +32,13 @@ type ClientInfo struct {
 	LegalAddress    string `db:"legal_address" json:"legal_address"`
 	PhysicalAddress string `db:"physical_address" json:"physical_address"`
 	Note            string `db:"note" json:"note"`
+	RegDate         string `db:"reg_date" json:"reg_date"`
 
 	Income Money `json:"income"`
 
-	Tags     []string          `json:"tags"`
-	Phones   []string          `json:"phones"`
-	Metadata map[string]string `json:"metadata"`
+	Tags     []string            `json:"tags"`
+	Phones   []string            `json:"phones"`
+	Metadata []map[string]string `json:"metadata"`
 }
 
 // ClientTag представляет запись из таблицы client_tags
@@ -84,10 +86,11 @@ func (r *ClientRepo) FetchExampleClients(limit int, offset int) []ClientInfo {
 			Email:           "ivanov@example.com",
 			PhysicalAddress: "г. Москва, ул. Тверская, д. 1, кв. 42",
 			Note:            "Постоянный клиент",
+			RegDate:         time.Now().Format("02.01.2006 15:04"),
 			Income:          Money{19999, "RUB"},
 			Phones:          []string{"+79001234567", "+74951234567"},
 			Tags:            []string{"vip", "active"},
-			Metadata:        map[string]string{"source": "website", "referral": "google"},
+			Metadata:        []map[string]string{{"source": "website", "referral": "google"}},
 		},
 		{
 			ID:           uuid.New().String(),
@@ -97,10 +100,11 @@ func (r *ClientRepo) FetchExampleClients(limit int, offset int) []ClientInfo {
 			Email:        "office@technoservice.ru",
 			LegalAddress: "125009, г. Москва, ул. Тверская, д. 7",
 			Note:         "Основной контрагент",
+			RegDate:      time.Now().Format("02.01.2006 15:04"),
 			Income:       Money{10090, "RUB"},
 			Phones:       []string{"+74959876543"},
 			Tags:         []string{"partner", "reliable"},
-			Metadata:     map[string]string{"industry": "it", "employees": "50+"},
+			Metadata:     []map[string]string{{"industry": "it", "employees": "50+"}},
 		},
 		{
 			ID:           uuid.New().String(),
@@ -110,10 +114,11 @@ func (r *ClientRepo) FetchExampleClients(limit int, offset int) []ClientInfo {
 			Email:        "supply@globalsupply.ru",
 			LegalAddress: "190000, г. Санкт-Петербург, Невский пр., д. 28",
 			Note:         "Основной поставщик оборудования",
-			Income:       Money{15000, "EUR"},
+			RegDate:      time.Now().Format("02.01.2006 15:04"),
+			Income:       Money{15000000, "EUR"},
 			Phones:       []string{"+74951112233", "+78123334455"},
 			Tags:         []string{"supplier", "international"},
-			Metadata:     map[string]string{"currency": "EUR", "delivery_time": "2 weeks"},
+			Metadata:     []map[string]string{{"currency": "EUR", "delivery_time": "2 weeks"}},
 		},
 	}