chore: refacto
This commit is contained in:
@@ -4,20 +4,23 @@ package models
|
||||
import "time"
|
||||
|
||||
type Client struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Username string `gorm:"column:username" json:"username"`
|
||||
Password string `gorm:"column:password" json:"-"`
|
||||
Nom string `gorm:"column:nom" json:"nom"`
|
||||
Prenom string `gorm:"column:prenom" json:"prenom"`
|
||||
Telephone string `gorm:"column:telephone" json:"telephone"`
|
||||
Command int `gorm:"column:command" json:"command"`
|
||||
PointsExtra map[string]int `gorm:"-" json:"points_extra"`
|
||||
Amende float64 `gorm:"column:amende" json:"amende"`
|
||||
CancellationsCount int `gorm:"column:cancellations_count" json:"cancellations_count"`
|
||||
LastPenaltyReason string `gorm:"column:last_penalty_reason" json:"last_penalty_reason"`
|
||||
MustChangePassword bool `gorm:"column:must_change_password" json:"must_change_password"`
|
||||
ReferralBalance float64 `gorm:"column:referral_balance" json:"referral_balance"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Username string `gorm:"column:username;not null" json:"username"`
|
||||
Password string `gorm:"column:password" json:"-"`
|
||||
Nom string `gorm:"column:nom" json:"nom"`
|
||||
Prenom string `gorm:"column:prenom" json:"prenom"`
|
||||
Telephone string `gorm:"column:telephone;not null" json:"telephone"`
|
||||
Command int `gorm:"column:command;default:0" json:"command"`
|
||||
CancelCommande int `gorm:"column:cancel_commande;default:0" json:"cancel_commande"`
|
||||
Amende float64 `gorm:"column:amende;default:0" json:"amende"`
|
||||
CancellationsCount int `gorm:"column:cancellations_count;not null;default:0" json:"cancellations_count"`
|
||||
LastPenaltyReason string `gorm:"column:last_penalty_reason" json:"last_penalty_reason"`
|
||||
MustChangePassword bool `gorm:"column:must_change_password;default:false" json:"must_change_password"`
|
||||
ReferralBalance float64 `gorm:"column:referral_balance;default:0" json:"referral_balance"`
|
||||
// points_extra est un JSONB géré manuellement (type non supporté nativement par GORM)
|
||||
PointsExtra map[string]int `gorm:"-" json:"points_extra"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (Client) TableName() string { return "clients" }
|
||||
|
||||
@@ -3,28 +3,43 @@ package models
|
||||
import "time"
|
||||
|
||||
type Command struct {
|
||||
ID int `json:"id"`
|
||||
UserID int `json:"user_id"`
|
||||
Username string `json:"username"`
|
||||
Status string `json:"status"` // "pending", "assigned", "livre", "approved", "cancelled", "disabled"
|
||||
Total float64 `json:"total"`
|
||||
DeliveryAddress string `json:"delivery_address"` // Adresse de livraison pour cette commande
|
||||
LivreurAssign string `json:"livreur_assign,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
ClientOrderID int `gorm:"column:client_order_id" json:"client_order_id"`
|
||||
UserID int `gorm:"column:user_id" json:"user_id"`
|
||||
Username string `gorm:"column:username" json:"username"`
|
||||
Status string `gorm:"column:status" json:"status"`
|
||||
Total float64 `gorm:"column:total_prix" json:"total"`
|
||||
DeliveryAddress string `gorm:"column:adresse" json:"delivery_address"`
|
||||
LivreurAssign string `gorm:"column:livreur_assign" json:"livreur_assign,omitempty"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (Command) TableName() string { return "commandes" }
|
||||
|
||||
// CommandItem représente un produit dans une commande
|
||||
type CommandItem struct {
|
||||
ID int `json:"id"`
|
||||
CommandID int `json:"command_id"`
|
||||
ProductID int `json:"product_id"`
|
||||
Quantity int `json:"quantity"`
|
||||
Price float64 `json:"price"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
CommandID int `gorm:"column:command_id" json:"command_id"`
|
||||
Produit string `gorm:"column:produit" json:"produit"`
|
||||
ProductID int `gorm:"column:product_id" json:"product_id"`
|
||||
Quantity float64 `gorm:"column:quantite" json:"quantity"`
|
||||
Price float64 `gorm:"column:prix" json:"price"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
type CommandLog struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
CommandID int `gorm:"column:command_id" json:"command_id"`
|
||||
Status string `gorm:"column:status" json:"status"`
|
||||
Message string `gorm:"column:message" json:"message"`
|
||||
Author string `gorm:"column:author" json:"author"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
}
|
||||
|
||||
func (CommandLog) TableName() string { return "command_logs" }
|
||||
|
||||
type CommandPriority struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
|
||||
@@ -6,7 +6,7 @@ import "time"
|
||||
type CryptoPayment struct {
|
||||
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
CommandID int `json:"command_id" gorm:"column:command_id;index"`
|
||||
NowPaymentID string `json:"nowpayment_id" gorm:"column:nowpayment_id;uniqueIndex"`
|
||||
NowPaymentID string `json:"nowpayment_id" gorm:"column:nowpayment_id;not null"`
|
||||
Status string `json:"status" gorm:"column:status"`
|
||||
PriceAmount float64 `json:"price_amount" gorm:"column:price_amount"`
|
||||
PriceCurrency string `json:"price_currency" gorm:"column:price_currency"`
|
||||
|
||||
@@ -67,6 +67,7 @@ type AppSettings struct {
|
||||
PointsEnabled bool `json:"points_enabled"` // afficher/activer le système de points
|
||||
PointsPools []PointsPool `json:"points_pools"` // types de points personnalisés
|
||||
ReferralEnabled bool `json:"referral_enabled"` // activer/désactiver le système de parrainage
|
||||
ReferralAmount float64 `json:"referral_amount"` // montant crédité par parrainage
|
||||
CryptoPaymentEnabled bool `json:"crypto_payment_enabled"` // activer/désactiver le paiement crypto
|
||||
CryptoOnly bool `json:"crypto_only"` // forcer le paiement crypto uniquement (pas d'espèces)
|
||||
NowPaymentsAPIKey string `json:"nowpayments_api_key"` // clé API NowPayments
|
||||
|
||||
@@ -3,12 +3,14 @@ package models
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Username string `json:"username" gorm:"column:username;uniqueIndex"`
|
||||
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Username string `json:"username" gorm:"column:username;not null"`
|
||||
Password string `json:"password,omitempty" gorm:"column:password"`
|
||||
Role string `json:"role" gorm:"column:role"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
Role string `json:"role" gorm:"column:role"`
|
||||
Total float64 `json:"total" gorm:"column:total;default:0"`
|
||||
Livraison float64 `json:"livraison" gorm:"column:livraison;default:0"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
}
|
||||
|
||||
func (User) TableName() string { return "users" }
|
||||
|
||||
Reference in New Issue
Block a user