chore: refacto
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package models
|
||||
|
||||
import "github.com/golang-jwt/jwt/v5"
|
||||
|
||||
type ClientClaims struct {
|
||||
ClientID int `json:"client_id"`
|
||||
Username string `json:"username"`
|
||||
Role string `json:"role"`
|
||||
SessionID string `json:"session_id"`
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
type AdminClaims struct {
|
||||
UserID int `json:"user_id"`
|
||||
Username string `json:"username"`
|
||||
Role string `json:"role"`
|
||||
SessionID string `json:"session_id"`
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// STRUCTURES REQUÊTE / RÉPONSE
|
||||
// ============================================
|
||||
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
|
||||
type RegisterClientRequest struct {
|
||||
Username string `json:"username" binding:"required,min=3,max=50"`
|
||||
Password string `json:"password" binding:"required,min=8"`
|
||||
Nom string `json:"nom" binding:"required,min=2,max=100"`
|
||||
Prenom string `json:"prenom" binding:"required,min=2,max=100"`
|
||||
Telephone string `json:"telephone" binding:"required"`
|
||||
}
|
||||
|
||||
type RegisterAdminRequest struct {
|
||||
Username string `json:"username" binding:"required,min=3,max=50"`
|
||||
Password string `json:"password" binding:"required,min=8"`
|
||||
Role string `json:"role" binding:"required,oneof=admin cabine livreur"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
TokenType string `json:"token_type"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
User any `json:"user"`
|
||||
}
|
||||
|
||||
type ProfileResponse struct {
|
||||
Username string `json:"username"`
|
||||
Role string `json:"role"`
|
||||
}
|
||||
@@ -10,10 +10,8 @@ type Client struct {
|
||||
Nom string `json:"nom"`
|
||||
Prenom string `json:"prenom"`
|
||||
Telephone string `json:"telephone"`
|
||||
Command int `json:"command"`
|
||||
Point int `json:"point"`
|
||||
PointZipette int `json:"points_zipette"`
|
||||
PointsExtra map[string]int `json:"points_extra"` // pools[2+]
|
||||
Command int `json:"command"`
|
||||
PointsExtra map[string]int `json:"points_extra"`
|
||||
Amende float64 `json:"amende"`
|
||||
CancellationsCount int `json:"cancellations_count"`
|
||||
LastPenaltyReason string `json:"last_penalty_reason"`
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package models
|
||||
|
||||
type PostalZone struct {
|
||||
Name string `json:"name"`
|
||||
MinAmount float64 `json:"min_amount"`
|
||||
Codes []string `json:"codes"`
|
||||
}
|
||||
|
||||
// PointsTier représente un palier du barème de points
|
||||
// Si Max == 0, il n'y a pas de borne supérieure (illimité)
|
||||
type PointsTier struct {
|
||||
Min float64 `json:"min"`
|
||||
Max float64 `json:"max"` // 0 = illimité
|
||||
Points int `json:"points"`
|
||||
}
|
||||
|
||||
// DaySchedule représente les horaires de livraison pour un jour de la semaine
|
||||
type DaySchedule struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
OpenTime string `json:"open_time"` // ex: "09:00"
|
||||
CloseTime string `json:"close_time"` // ex: "20:00"
|
||||
}
|
||||
|
||||
// DeliverySchedule représente les horaires de livraison pour chaque jour
|
||||
type DeliverySchedule struct {
|
||||
Monday DaySchedule `json:"monday"`
|
||||
Tuesday DaySchedule `json:"tuesday"`
|
||||
Wednesday DaySchedule `json:"wednesday"`
|
||||
Thursday DaySchedule `json:"thursday"`
|
||||
Friday DaySchedule `json:"friday"`
|
||||
Saturday DaySchedule `json:"saturday"`
|
||||
Sunday DaySchedule `json:"sunday"`
|
||||
}
|
||||
|
||||
type PointsPool struct {
|
||||
Key string `json:"key"` // identifiant interne (ex: "pool_0")
|
||||
Name string `json:"name"` // nom affiché (ex: "Cannabis", "Accessoires")
|
||||
Categories []string `json:"categories"` // catégories de produits assignées à ce pool
|
||||
Tiers []PointsTier `json:"tiers"` // barème de points
|
||||
}
|
||||
|
||||
// PenaltyTier représente un palier d'amende : à partir de MinCancel annulations, Amount est appliqué
|
||||
type PenaltyTier struct {
|
||||
MinCancel int `json:"min_cancel"` // nombre d'annulations à partir duquel ce palier s'applique
|
||||
Amount int `json:"amount"` // montant de l'amende
|
||||
}
|
||||
|
||||
// CategoryRoute associe un livreur à une ou plusieurs catégories de produits
|
||||
type CategoryRoute struct {
|
||||
DeliverymanUsername string `json:"deliveryman_username"`
|
||||
Categories []string `json:"categories"`
|
||||
}
|
||||
|
||||
// DeliveryModeConfig configure le mode d'assignation des livreurs
|
||||
// Mode "single" → un seul livreur, toutes catégories confondues
|
||||
// Mode "category_based" → chaque livreur gère ses catégories dédiées
|
||||
type DeliveryModeConfig struct {
|
||||
Mode string `json:"mode"` // "single" | "category_based"
|
||||
CategoryRoutes []CategoryRoute `json:"category_routes"` // utilisé uniquement en mode category_based
|
||||
}
|
||||
|
||||
// AppSettings contient les paramètres globaux de l'application
|
||||
type AppSettings struct {
|
||||
PenaltiesEnabled bool `json:"penalties_enabled"`
|
||||
ShowAmendeScore bool `json:"show_amende_score"` // afficher le score d'amendes aux clients/cabine
|
||||
PenaltyTiers []PenaltyTier `json:"penalty_tiers"` // barème des amendes (liste configurable)
|
||||
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
|
||||
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
|
||||
NowPaymentsIPNSecret string `json:"nowpayments_ipn_secret"` // secret IPN NowPayments
|
||||
NowPaymentsCurrencies []string `json:"nowpayments_currencies"` // cryptos acceptées (ex: ["btc","eth","ltc"])
|
||||
DeliverySchedule DeliverySchedule `json:"delivery_schedule"` // horaires de livraison par jour
|
||||
PostalZones []PostalZone `json:"postal_zones"` // zones de livraison avec minimum de commande
|
||||
TelegramBotToken string `json:"telegram_bot_token"` // token du bot Telegram (BotFather)
|
||||
TelegramBotUsername string `json:"telegram_bot_username"` // username du bot (sans @)
|
||||
DeliveryMode DeliveryModeConfig `json:"delivery_mode"` // mode d'assignation des livreurs
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package models
|
||||
|
||||
type TgUpdate struct {
|
||||
UpdateID int `json:"update_id"`
|
||||
Message *TgMessage `json:"message"`
|
||||
}
|
||||
|
||||
type TgMessage struct {
|
||||
MessageID int `json:"message_id"`
|
||||
Chat TgChat `json:"chat"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type TgChat struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type TelegramLinkData struct {
|
||||
Username string `json:"username"`
|
||||
Role string `json:"role"` // "client" | "livreur" | "admin" | "cabine"
|
||||
}
|
||||
@@ -20,8 +20,6 @@ type AdminUpdateClientRequest struct {
|
||||
Nom string `json:"nom,omitempty"`
|
||||
Prenom string `json:"prenom,omitempty"`
|
||||
Telephone string `json:"telephone,omitempty"`
|
||||
Command *int `json:"command,omitempty"`
|
||||
Point *int `json:"point,omitempty"`
|
||||
PointsZipette *int `json:"points_zipette,omitempty"`
|
||||
Amende *float64 `json:"amende,omitempty"`
|
||||
Command *int `json:"command,omitempty"`
|
||||
Amende *float64 `json:"amende,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user