Compare commits

...

1 Commits

Author SHA1 Message Date
hy001
7e4fab34af feat: update baishun admin game types 2026-04-22 20:12:59 +08:00
3 changed files with 39 additions and 4 deletions

View File

@ -202,6 +202,7 @@ func (s *BaishunService) SaveAdminGame(ctx context.Context, req SaveAdminBaishun
tx.Rollback() tx.Rollback()
return nil, err return nil, err
} }
showcase := resolveAdminShowcase(req.Showcase, cfg.Showcase, cfg.ID == 0)
cfgValues := map[string]any{ cfgValues := map[string]any{
"sys_origin": sysOrigin, "sys_origin": sysOrigin,
@ -212,7 +213,7 @@ func (s *BaishunService) SaveAdminGame(ctx context.Context, req SaveAdminBaishun
"game_code": gameCode, "game_code": gameCode,
"cover": cover, "cover": cover,
"amounts": strings.TrimSpace(req.Amounts), "amounts": strings.TrimSpace(req.Amounts),
"is_showcase": req.Showcase, "is_showcase": showcase,
"sort": req.Sort, "sort": req.Sort,
"height": req.Height, "height": req.Height,
"width": req.Width, "width": req.Width,
@ -238,7 +239,7 @@ func (s *BaishunService) SaveAdminGame(ctx context.Context, req SaveAdminBaishun
GameCode: gameCode, GameCode: gameCode,
Cover: cover, Cover: cover,
Amounts: strings.TrimSpace(req.Amounts), Amounts: strings.TrimSpace(req.Amounts),
Showcase: req.Showcase, Showcase: showcase,
Sort: req.Sort, Sort: req.Sort,
Height: req.Height, Height: req.Height,
Width: req.Width, Width: req.Width,
@ -585,7 +586,7 @@ func (s *BaishunService) importCatalogGamesTx(tx *gorm.DB, sysOrigin string, fil
Category: "OTHER", Category: "OTHER",
GameCode: vendorGameID, GameCode: vendorGameID,
Cover: defaultIfBlank(catalog.Cover, catalog.PreviewURL), Cover: defaultIfBlank(catalog.Cover, catalog.PreviewURL),
Showcase: false, Showcase: true,
Sort: int64(catalog.VendorGameID), Sort: int64(catalog.VendorGameID),
FullScreen: true, FullScreen: true,
ClientOrigin: "COMMON", ClientOrigin: "COMMON",
@ -687,6 +688,16 @@ func normalizePageLimit(limit int) int {
return limit return limit
} }
func resolveAdminShowcase(showcase *bool, current bool, isCreate bool) bool {
if showcase != nil {
return *showcase
}
if isCreate {
return true
}
return current
}
func defaultAdminGSP(catalogGSP string, fallback int) string { func defaultAdminGSP(catalogGSP string, fallback int) string {
if strings.TrimSpace(catalogGSP) != "" { if strings.TrimSpace(catalogGSP) != "" {
return strings.TrimSpace(catalogGSP) return strings.TrimSpace(catalogGSP)

View File

@ -0,0 +1,24 @@
package baishun
import "testing"
func TestResolveAdminShowcase(t *testing.T) {
t.Run("create defaults to enabled", func(t *testing.T) {
if got := resolveAdminShowcase(nil, false, true); !got {
t.Fatalf("resolveAdminShowcase(nil, false, true) = %v, want true", got)
}
})
t.Run("update keeps current when omitted", func(t *testing.T) {
if got := resolveAdminShowcase(nil, false, false); got {
t.Fatalf("resolveAdminShowcase(nil, false, false) = %v, want false", got)
}
})
t.Run("explicit false remains false", func(t *testing.T) {
showcase := false
if got := resolveAdminShowcase(&showcase, true, true); got {
t.Fatalf("resolveAdminShowcase(false, true, true) = %v, want false", got)
}
})
}

View File

@ -239,7 +239,7 @@ type SaveAdminBaishunGameRequest struct {
GameCode string `json:"gameCode"` GameCode string `json:"gameCode"`
Cover string `json:"cover"` Cover string `json:"cover"`
Amounts string `json:"amounts"` Amounts string `json:"amounts"`
Showcase bool `json:"showcase"` Showcase *bool `json:"showcase"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
Height float64 `json:"height"` Height float64 `json:"height"`
Width float64 `json:"width"` Width float64 `json:"width"`