2026-05-25 15:45:57 +08:00

89 lines
3.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package gamemanagement
import gamev1 "hyapp.local/api/proto/game/v1"
type platformDTO struct {
AppCode string `json:"appCode"`
PlatformCode string `json:"platformCode"`
PlatformName string `json:"platformName"`
Status string `json:"status"`
APIBaseURL string `json:"apiBaseUrl"`
// adapterType 决定服务端按哪家厂商协议拼启动 URL 和处理回调。
AdapterType string `json:"adapterType"`
// callbackSecret 是后台配置页可见的厂商 key/AppSecret只对有 game:view 权限的管理员返回。
CallbackSecret string `json:"callbackSecret"`
CallbackSecretSet bool `json:"callbackSecretSet"`
CallbackIPWhitelist []string `json:"callbackIpWhitelist"`
// adapterConfigJson 承载 uid_mode/default_lang/token_ttl_seconds 等可热更新配置。
AdapterConfigJSON string `json:"adapterConfigJson"`
SortOrder int32 `json:"sortOrder"`
CreatedAtMS int64 `json:"createdAtMs"`
UpdatedAtMS int64 `json:"updatedAtMs"`
}
type catalogDTO struct {
AppCode string `json:"appCode"`
GameID string `json:"gameId"`
PlatformCode string `json:"platformCode"`
ProviderGameID string `json:"providerGameId"`
GameName string `json:"gameName"`
Category string `json:"category"`
IconURL string `json:"iconUrl"`
CoverURL string `json:"coverUrl"`
// launchUrl 只在厂商列表预览时返回,正式目录仍由 platform.adapterConfigJson.game_urls 按 providerGameId 解析。
LaunchURL string `json:"launchUrl,omitempty"`
LaunchMode string `json:"launchMode"`
Orientation string `json:"orientation"`
MinCoin int64 `json:"minCoin"`
Status string `json:"status"`
SortOrder int32 `json:"sortOrder"`
Tags []string `json:"tags"`
CreatedAtMS int64 `json:"createdAtMs"`
UpdatedAtMS int64 `json:"updatedAtMs"`
}
func platformFromProto(item *gamev1.GamePlatform) platformDTO {
if item == nil {
return platformDTO{}
}
return platformDTO{
AppCode: item.GetAppCode(),
PlatformCode: item.GetPlatformCode(),
PlatformName: item.GetPlatformName(),
Status: item.GetStatus(),
APIBaseURL: item.GetApiBaseUrl(),
AdapterType: item.GetAdapterType(),
CallbackSecret: item.GetCallbackSecret(),
CallbackSecretSet: item.GetCallbackSecretSet(),
CallbackIPWhitelist: item.GetCallbackIpWhitelist(),
AdapterConfigJSON: item.GetAdapterConfigJson(),
SortOrder: item.GetSortOrder(),
CreatedAtMS: item.GetCreatedAtMs(),
UpdatedAtMS: item.GetUpdatedAtMs(),
}
}
func catalogFromProto(item *gamev1.GameCatalogItem) catalogDTO {
if item == nil {
return catalogDTO{}
}
return catalogDTO{
AppCode: item.GetAppCode(),
GameID: item.GetGameId(),
PlatformCode: item.GetPlatformCode(),
ProviderGameID: item.GetProviderGameId(),
GameName: item.GetGameName(),
Category: item.GetCategory(),
IconURL: item.GetIconUrl(),
CoverURL: item.GetCoverUrl(),
LaunchMode: item.GetLaunchMode(),
Orientation: item.GetOrientation(),
MinCoin: item.GetMinCoin(),
Status: item.GetStatus(),
SortOrder: item.GetSortOrder(),
Tags: item.GetTags(),
CreatedAtMS: item.GetCreatedAtMs(),
UpdatedAtMS: item.GetUpdatedAtMs(),
}
}