Add logos to social BI app catalog
This commit is contained in:
parent
1e7c3115d6
commit
24ebf737ae
@ -345,7 +345,7 @@ func main() {
|
||||
appRegistryService,
|
||||
userclient.NewGRPC(userConn),
|
||||
databimodule.WithFinanceRechargeOverviewSource(paymentHandler),
|
||||
databimodule.WithLegacyApps(databiLegacyApps(cfg.DashboardExternalSources)...),
|
||||
databimodule.WithLegacyApps(databiLegacyApps(cfg.DashboardExternalSources, cfg.MoneyRegionSources)...),
|
||||
databimodule.WithLegacyRegionCatalogs(databiLegacyRegionCatalogs(moneyRegionSources)...),
|
||||
)
|
||||
luckyGiftHandler := luckygiftmodule.New(luckygiftadmin.NewGRPC(luckyGiftConn), cfg.LuckyGiftService.RequestTimeout, auditHandler)
|
||||
@ -636,10 +636,17 @@ func wireLegacyGooglePaidSync(sources []paymentmodule.RechargeBillSource, config
|
||||
}
|
||||
|
||||
// databiLegacyApps 把 dashboard 外部源配置映射成社交 BI 的外接 App 目录;
|
||||
// 同一 App 配多个源(如 cdc MySQL + Mongo 补充)时只取一次。
|
||||
func databiLegacyApps(configs []config.DashboardExternalSourceConfig) []databimodule.LegacyAppDescriptor {
|
||||
// Logo 复用财务范围的 legacy App 目录,避免 dashboard、账单和 Social BI 各自维护同一份品牌元数据。
|
||||
func databiLegacyApps(configs []config.DashboardExternalSourceConfig, regionConfigs []config.MoneyRegionSourceConfig) []databimodule.LegacyAppDescriptor {
|
||||
out := []databimodule.LegacyAppDescriptor{}
|
||||
seen := map[string]struct{}{}
|
||||
logoByAppCode := map[string]string{}
|
||||
for _, regionConfig := range regionConfigs {
|
||||
appCode := strings.ToLower(strings.TrimSpace(regionConfig.AppCode))
|
||||
if appCode != "" {
|
||||
logoByAppCode[appCode] = strings.TrimSpace(regionConfig.LogoURL)
|
||||
}
|
||||
}
|
||||
for _, sourceConfig := range configs {
|
||||
if !sourceConfig.Enabled {
|
||||
continue
|
||||
@ -652,7 +659,11 @@ func databiLegacyApps(configs []config.DashboardExternalSourceConfig) []databimo
|
||||
continue
|
||||
}
|
||||
seen[appCode] = struct{}{}
|
||||
out = append(out, databimodule.LegacyAppDescriptor{AppCode: appCode, AppName: strings.TrimSpace(sourceConfig.AppName)})
|
||||
out = append(out, databimodule.LegacyAppDescriptor{
|
||||
AppCode: appCode,
|
||||
AppName: strings.TrimSpace(sourceConfig.AppName),
|
||||
LogoURL: logoByAppCode[appCode],
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ type LegacyRegionCatalogSource interface {
|
||||
type LegacyAppDescriptor struct {
|
||||
AppCode string
|
||||
AppName string
|
||||
LogoURL string
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
@ -152,6 +153,7 @@ func NewService(store *repository.Store, dashboards *dashboard.DashboardService,
|
||||
type AppInfo struct {
|
||||
AppCode string `json:"app_code"`
|
||||
AppName string `json:"app_name"`
|
||||
LogoURL string `json:"logo_url"`
|
||||
Kind string `json:"kind"`
|
||||
}
|
||||
|
||||
@ -1172,6 +1174,7 @@ func (s *Service) listApps(ctx context.Context) ([]AppInfo, error) {
|
||||
out = append(out, AppInfo{
|
||||
AppCode: appCode,
|
||||
AppName: firstNonEmptyString(app.AppName, appCode),
|
||||
LogoURL: strings.TrimSpace(app.LogoURL),
|
||||
Kind: appKindHyapp,
|
||||
})
|
||||
}
|
||||
@ -1184,6 +1187,7 @@ func (s *Service) listApps(ctx context.Context) ([]AppInfo, error) {
|
||||
out = append(out, AppInfo{
|
||||
AppCode: app.AppCode,
|
||||
AppName: firstNonEmptyString(app.AppName, app.AppCode),
|
||||
LogoURL: strings.TrimSpace(app.LogoURL),
|
||||
Kind: appKindLegacy,
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package databi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -8,6 +9,22 @@ import (
|
||||
"hyapp-admin-server/internal/repository"
|
||||
)
|
||||
|
||||
func TestListAppsPreservesLegacyLogoURL(t *testing.T) {
|
||||
service := NewService(nil, nil, nil, nil, WithLegacyApps(LegacyAppDescriptor{
|
||||
AppCode: "Aslan",
|
||||
AppName: "Aslan",
|
||||
LogoURL: "https://media.example.com/aslan.png",
|
||||
}))
|
||||
|
||||
apps, err := service.listApps(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("list apps failed: %v", err)
|
||||
}
|
||||
if len(apps) != 1 || apps[0].AppCode != "aslan" || apps[0].LogoURL != "https://media.example.com/aslan.png" {
|
||||
t.Fatalf("legacy app logo mismatch: %+v", apps)
|
||||
}
|
||||
}
|
||||
|
||||
func testAccess() repository.MoneyAccess {
|
||||
return repository.MoneyAccess{
|
||||
UserID: 7,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user