Compare commits
1 Commits
main
...
codex/gola
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e4fab34af |
@ -202,6 +202,7 @@ func (s *BaishunService) SaveAdminGame(ctx context.Context, req SaveAdminBaishun
|
||||
tx.Rollback()
|
||||
return nil, err
|
||||
}
|
||||
showcase := resolveAdminShowcase(req.Showcase, cfg.Showcase, cfg.ID == 0)
|
||||
|
||||
cfgValues := map[string]any{
|
||||
"sys_origin": sysOrigin,
|
||||
@ -212,7 +213,7 @@ func (s *BaishunService) SaveAdminGame(ctx context.Context, req SaveAdminBaishun
|
||||
"game_code": gameCode,
|
||||
"cover": cover,
|
||||
"amounts": strings.TrimSpace(req.Amounts),
|
||||
"is_showcase": req.Showcase,
|
||||
"is_showcase": showcase,
|
||||
"sort": req.Sort,
|
||||
"height": req.Height,
|
||||
"width": req.Width,
|
||||
@ -238,7 +239,7 @@ func (s *BaishunService) SaveAdminGame(ctx context.Context, req SaveAdminBaishun
|
||||
GameCode: gameCode,
|
||||
Cover: cover,
|
||||
Amounts: strings.TrimSpace(req.Amounts),
|
||||
Showcase: req.Showcase,
|
||||
Showcase: showcase,
|
||||
Sort: req.Sort,
|
||||
Height: req.Height,
|
||||
Width: req.Width,
|
||||
@ -585,7 +586,7 @@ func (s *BaishunService) importCatalogGamesTx(tx *gorm.DB, sysOrigin string, fil
|
||||
Category: "OTHER",
|
||||
GameCode: vendorGameID,
|
||||
Cover: defaultIfBlank(catalog.Cover, catalog.PreviewURL),
|
||||
Showcase: false,
|
||||
Showcase: true,
|
||||
Sort: int64(catalog.VendorGameID),
|
||||
FullScreen: true,
|
||||
ClientOrigin: "COMMON",
|
||||
@ -687,6 +688,16 @@ func normalizePageLimit(limit int) int {
|
||||
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 {
|
||||
if strings.TrimSpace(catalogGSP) != "" {
|
||||
return strings.TrimSpace(catalogGSP)
|
||||
|
||||
24
internal/service/baishun/admin_test.go
Normal file
24
internal/service/baishun/admin_test.go
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -239,7 +239,7 @@ type SaveAdminBaishunGameRequest struct {
|
||||
GameCode string `json:"gameCode"`
|
||||
Cover string `json:"cover"`
|
||||
Amounts string `json:"amounts"`
|
||||
Showcase bool `json:"showcase"`
|
||||
Showcase *bool `json:"showcase"`
|
||||
Sort int64 `json:"sort"`
|
||||
Height float64 `json:"height"`
|
||||
Width float64 `json:"width"`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user