generated from PenaSide/GolangTemplate
feat: model versioning\nfix: pay empty cart 500 -> 406
This commit is contained in:
parent
e3f0e1202c
commit
0d21b76a00
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
||||
#v1.0.0
|
||||
|
||||
INTERNAL:
|
||||
|
||||
- Добавлено версионирование модели данных. На данный момент модель под версией 1
|
||||
|
||||
FIX:
|
||||
|
||||
- При пустой корзине во время оплаты(/cart/pay) больше не будет возвращаться 500, а будет возвращаться 406
|
||||
|
||||
#v1.0.0
|
@ -412,6 +412,12 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
"406":
|
||||
description: корзина пустая
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
|
||||
/wallet:
|
||||
patch:
|
||||
|
@ -135,6 +135,10 @@ func (receiver *CartController) Pay(ctx *fiber.Ctx) error {
|
||||
|
||||
receiver.logger.Info("account for pay", zap.Any("acc", account))
|
||||
|
||||
if len(account.Cart) == 0 {
|
||||
return ctx.Status(fiber.StatusNotAcceptable).SendString("cart is empty")
|
||||
}
|
||||
|
||||
tariffs, err := receiver.hubAdminClient.GetTariffs(ctx.Context(), accessToken, account.Cart)
|
||||
if err != nil {
|
||||
return receiver.middleWare.ErrorOld(ctx, err)
|
||||
|
@ -15,6 +15,7 @@ type Account struct {
|
||||
DeletedAt *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`
|
||||
From string `json:"from" bson:"from"`
|
||||
Partner string `json:"partner" bson:"partner"`
|
||||
Version uint32 `json:"version" bson:"version"`
|
||||
}
|
||||
|
||||
func (receiver *Account) Sanitize() *Account {
|
||||
@ -32,6 +33,7 @@ func (receiver *Account) Sanitize() *Account {
|
||||
//receiver.Partner = ""
|
||||
receiver.DeletedAt = nil
|
||||
receiver.Deleted = false
|
||||
receiver.Version = mongoVersion
|
||||
|
||||
return receiver
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ type ServiceConfiguration struct {
|
||||
PubKey string `env:"PUBLIC_KEY"`
|
||||
PrivKey string `env:"PRIVATE_KEY"`
|
||||
ModuleLogger string `env:"MODULE_LOGGER"`
|
||||
NotificationBotToken string `env:"NOTIFICATION_BOT_TOKEN"`
|
||||
NotificationChannel int64 `env:"NOTIFICATION_CHANNEL"`
|
||||
AdminURL string `env:"ADMIN_FRONT_URL"`
|
||||
NotificationBotToken string `env:"NOTIFICATION_BOT_TOKEN"`
|
||||
NotificationChannel int64 `env:"NOTIFICATION_CHANNEL"`
|
||||
AdminURL string `env:"ADMIN_FRONT_URL"`
|
||||
}
|
||||
|
||||
type KafkaConfiguration struct {
|
||||
@ -131,3 +131,5 @@ type PlainAuth struct {
|
||||
Username string `env:"MAIL_AUTH_USERNAME,required"`
|
||||
Password string `env:"MAIL_AUTH_PASSWORD,required"`
|
||||
}
|
||||
|
||||
const mongoVersion uint32 = 1
|
||||
|
@ -12,6 +12,7 @@ type CurrencyList struct {
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
|
||||
DeletedAt *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`
|
||||
Version uint32 `json:"version" bson:"version"`
|
||||
}
|
||||
|
||||
func (receiver *CurrencyList) Sanitize() *CurrencyList {
|
||||
@ -22,6 +23,7 @@ func (receiver *CurrencyList) Sanitize() *CurrencyList {
|
||||
receiver.UpdatedAt = now
|
||||
receiver.DeletedAt = nil
|
||||
receiver.Deleted = false
|
||||
receiver.Version = mongoVersion
|
||||
|
||||
return receiver
|
||||
}
|
||||
|
@ -7,11 +7,12 @@ type History struct {
|
||||
UserID string `json:"userId" bson:"userId"`
|
||||
Comment string `json:"comment" bson:"comment"`
|
||||
Key string `json:"key" bson:"key"`
|
||||
RawDetails RawDetails `json:"rawDetails" bson:"rawDetails"`
|
||||
RawDetails RawDetails `json:"rawDetails" bson:"rawDetails"`
|
||||
Deleted bool `json:"isDeleted" bson:"isDeleted"`
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
|
||||
DeletedAt *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`
|
||||
Version uint32 `json:"version" bson:"version"`
|
||||
}
|
||||
|
||||
type TariffID struct {
|
||||
@ -33,7 +34,7 @@ type ReportHistory struct {
|
||||
type RawDetails struct {
|
||||
Tariffs []Tariff `json:"tariffs" bson:"tariffs"`
|
||||
Price int64 `json:"price" bson:"price"`
|
||||
Comment string `json:"comment" bson:"comment"`
|
||||
Comment string `json:"comment" bson:"comment"`
|
||||
}
|
||||
|
||||
func (receiver *History) Sanitize() *History {
|
||||
@ -44,6 +45,7 @@ func (receiver *History) Sanitize() *History {
|
||||
receiver.UpdatedAt = now
|
||||
receiver.DeletedAt = nil
|
||||
receiver.Deleted = false
|
||||
receiver.Version = mongoVersion
|
||||
|
||||
return receiver
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package models
|
||||
|
||||
type RespGeneratorService struct {
|
||||
DocNumber string `json:"docnumber"`
|
||||
DocNumber string `json:"docnumber"`
|
||||
Date string `json:"date"`
|
||||
OrgTaxNum string `json:"orgtaxnum"`
|
||||
OrgName string `json:"orgname"`
|
||||
OrgName string `json:"orgname"`
|
||||
Name string `json:"name"`
|
||||
Amount string `json:"amount"`
|
||||
Price string `json:"price"`
|
||||
Sum string `json:"sum"`
|
||||
Unit string `json:"unit"`
|
||||
Price string `json:"price"`
|
||||
Sum string `json:"sum"`
|
||||
Unit string `json:"unit"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user