修复后台
This commit is contained in:
parent
4219117721
commit
e086a518bc
@ -228,7 +228,8 @@ func (r gameRow) name() string {
|
||||
}
|
||||
|
||||
func (r gameRow) cover() string {
|
||||
return defaultIfBlank(r.Cover, defaultIfBlank(r.CatalogCover, r.previewURL()))
|
||||
// 热游的 preview_url 是带用户占位符的 H5 启动地址,不是图片资源;封面为空时直接返回空值,避免客户端把启动页当图片加载。
|
||||
return defaultIfBlank(r.Cover, r.CatalogCover)
|
||||
}
|
||||
|
||||
func (r gameRow) previewURL() string {
|
||||
|
||||
@ -307,14 +307,15 @@ func (s *Service) importCatalogGamesTx(tx *gorm.DB, sysOrigin, profile string, f
|
||||
return nil, idErr
|
||||
}
|
||||
cfg := model.SysGameListConfig{
|
||||
ID: nextCfgID,
|
||||
SysOrigin: sysOrigin,
|
||||
GameOrigin: vendorType,
|
||||
GameID: defaultIfBlank(catalog.InternalGameID, vendorGameID),
|
||||
Name: catalog.Name,
|
||||
Category: roomCategory,
|
||||
GameCode: vendorGameID,
|
||||
Cover: defaultIfBlank(catalog.Cover, catalog.PreviewURL),
|
||||
ID: nextCfgID,
|
||||
SysOrigin: sysOrigin,
|
||||
GameOrigin: vendorType,
|
||||
GameID: defaultIfBlank(catalog.InternalGameID, vendorGameID),
|
||||
Name: catalog.Name,
|
||||
Category: roomCategory,
|
||||
GameCode: vendorGameID,
|
||||
// 热游启动地址包含 uid/token/lang 占位符且整体很长,不能在缺少封面时回填到 cover;封面为空时交给客户端展示默认占位,真正启动地址只放在扩展表里。
|
||||
Cover: hotgameCatalogCover(catalog),
|
||||
Showcase: defaultShowcase,
|
||||
Sort: parseSort(vendorGameID),
|
||||
FullScreen: fullScreen,
|
||||
@ -359,8 +360,9 @@ func (s *Service) refreshExistingGame(tx *gorm.DB, configID int64, catalog model
|
||||
if err := tx.Model(&model.SysGameListConfig{}).
|
||||
Where("id = ? AND game_origin = ?", configID, vendorType).
|
||||
Updates(map[string]any{
|
||||
"name": catalog.Name,
|
||||
"cover": defaultIfBlank(catalog.Cover, catalog.PreviewURL),
|
||||
"name": catalog.Name,
|
||||
// 这里和新导入保持一致,只刷新真实封面,避免把 H5 启动链接写入封面列导致 MySQL 长度错误。
|
||||
"cover": hotgameCatalogCover(catalog),
|
||||
"full_screen": fullScreen,
|
||||
}).Error; err != nil {
|
||||
return err
|
||||
@ -383,6 +385,10 @@ func hotgameLaunchURLForProfile(game defaultCatalogGame, profile string) string
|
||||
return strings.TrimSpace(game.ProdURL)
|
||||
}
|
||||
|
||||
func hotgameCatalogCover(catalog model.HotgameGameCatalog) string {
|
||||
return strings.TrimSpace(catalog.Cover)
|
||||
}
|
||||
|
||||
func resolveImportDefaultShowcase(values ...bool) bool {
|
||||
if len(values) == 0 {
|
||||
return true
|
||||
|
||||
@ -38,6 +38,22 @@ func TestSyncImportAndListRoomGames(t *testing.T) {
|
||||
t.Fatalf("ImportCatalogGames() imported = %d, want 1", importResp.Imported)
|
||||
}
|
||||
|
||||
var cfg model.SysGameListConfig
|
||||
if err := db.Where("game_origin = ? AND game_id = ?", vendorType, "hg_1").First(&cfg).Error; err != nil {
|
||||
t.Fatalf("load imported game config: %v", err)
|
||||
}
|
||||
if cfg.Cover != "" {
|
||||
t.Fatalf("imported cover = %q, want blank because launch url must stay out of cover", cfg.Cover)
|
||||
}
|
||||
|
||||
var ext model.SysGameListVendorExt
|
||||
if err := db.Where("game_list_config_id = ? AND vendor_type = ?", cfg.ID, vendorType).First(&ext).Error; err != nil {
|
||||
t.Fatalf("load imported vendor ext: %v", err)
|
||||
}
|
||||
if !strings.Contains(ext.PreviewURL, "uid={uid}") || !strings.Contains(ext.PackageURL, "token={token}") {
|
||||
t.Fatalf("vendor ext lost launch url placeholders: preview=%q package=%q", ext.PreviewURL, ext.PackageURL)
|
||||
}
|
||||
|
||||
provider := NewAppProvider(service)
|
||||
list, err := provider.ListRoomGames(context.Background(), gameprovider.AuthUser{UserID: 1234567, SysOrigin: "LIKEI"}, "room-1", "")
|
||||
if err != nil {
|
||||
@ -50,6 +66,9 @@ func TestSyncImportAndListRoomGames(t *testing.T) {
|
||||
if item.Provider != vendorType || item.ProviderGameID != "1" || item.GameID != "hg_1" {
|
||||
t.Fatalf("ListRoomGames() item = %+v", item)
|
||||
}
|
||||
if item.Cover != "" {
|
||||
t.Fatalf("ListRoomGames() cover = %q, want blank because hotgame preview url is not an image", item.Cover)
|
||||
}
|
||||
if item.LaunchParams["screenMode"] != "seven" {
|
||||
t.Fatalf("ListRoomGames() screenMode = %v, want seven", item.LaunchParams["screenMode"])
|
||||
}
|
||||
|
||||
17
migrations/053_sys_game_list_cover_length.sql
Normal file
17
migrations/053_sys_game_list_cover_length.sql
Normal file
@ -0,0 +1,17 @@
|
||||
SET @current_schema := DATABASE();
|
||||
|
||||
SET @modify_sys_game_list_cover_sql := IF(
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = @current_schema
|
||||
AND table_name = 'sys_game_list_config'
|
||||
AND column_name = 'cover'
|
||||
),
|
||||
'ALTER TABLE `sys_game_list_config` MODIFY COLUMN `cover` VARCHAR(1024) DEFAULT NULL COMMENT ''封面图''',
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE modify_sys_game_list_cover_stmt FROM @modify_sys_game_list_cover_sql;
|
||||
EXECUTE modify_sys_game_list_cover_stmt;
|
||||
DEALLOCATE PREPARE modify_sys_game_list_cover_stmt;
|
||||
Loading…
x
Reference in New Issue
Block a user