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