fix: some api bug

This commit is contained in:
wwweww
2026-03-31 22:12:06 +08:00
parent c5ff4f0216
commit e7970ac25f
219 changed files with 16195 additions and 2126 deletions
+8 -7
View File
@@ -5,6 +5,7 @@ package models
import (
"encoding/json"
"fmt"
"juwan-backend/app/shop/rpc/internal/models/schema"
"juwan-backend/app/shop/rpc/internal/models/shops"
"strings"
"time"
@@ -44,7 +45,7 @@ type Shops struct {
// DispatchMode holds the value of the "dispatch_mode" field.
DispatchMode string `json:"dispatch_mode,omitempty"`
// Announcements holds the value of the "announcements" field.
Announcements []string `json:"announcements,omitempty"`
Announcements schema.TextArray `json:"announcements,omitempty"`
// TemplateConfig holds the value of the "template_config" field.
TemplateConfig map[string]interface{} `json:"template_config,omitempty"`
// CreatedAt holds the value of the "created_at" field.
@@ -59,10 +60,12 @@ func (*Shops) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case shops.FieldAnnouncements, shops.FieldTemplateConfig:
case shops.FieldTemplateConfig:
values[i] = new([]byte)
case shops.FieldRating, shops.FieldCommissionValue:
values[i] = new(decimal.Decimal)
case shops.FieldAnnouncements:
values[i] = new(schema.TextArray)
case shops.FieldAllowMultiShop, shops.FieldAllowIndependentOrders:
values[i] = new(sql.NullBool)
case shops.FieldID, shops.FieldOwnerID, shops.FieldTotalOrders, shops.FieldPlayerCount:
@@ -167,12 +170,10 @@ func (_m *Shops) assignValues(columns []string, values []any) error {
_m.DispatchMode = value.String
}
case shops.FieldAnnouncements:
if value, ok := values[i].(*[]byte); !ok {
if value, ok := values[i].(*schema.TextArray); !ok {
return fmt.Errorf("unexpected type %T for field announcements", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Announcements); err != nil {
return fmt.Errorf("unmarshal field announcements: %w", err)
}
} else if value != nil {
_m.Announcements = *value
}
case shops.FieldTemplateConfig:
if value, ok := values[i].(*[]byte); !ok {