推进活动列表第一刀与联调回归
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -109,6 +109,8 @@ func NewRouter(
|
||||
mux.HandleFunc("GET /dev/client-logs", devHandler.ListClientLogs)
|
||||
mux.HandleFunc("DELETE /dev/client-logs", devHandler.ClearClientLogs)
|
||||
mux.HandleFunc("GET /dev/manifest-summary", devHandler.ManifestSummary)
|
||||
mux.HandleFunc("GET /dev/demo-assets/presentations/{demoKey}", devHandler.DemoPresentationSchema)
|
||||
mux.HandleFunc("GET /dev/demo-assets/content-manifests/{demoKey}", devHandler.DemoContentManifest)
|
||||
mux.HandleFunc("GET /dev/config/local-files", configHandler.ListLocalFiles)
|
||||
mux.HandleFunc("POST /dev/events/{eventPublicID}/config-sources/import-local", configHandler.ImportLocal)
|
||||
mux.HandleFunc("POST /dev/config-builds/preview", configHandler.BuildPreview)
|
||||
|
||||
@@ -129,7 +129,7 @@ func (s *EventPlayService) GetEventPlay(ctx context.Context, input EventPlayInpu
|
||||
}
|
||||
}
|
||||
|
||||
canLaunch := event.Status == "active" && event.CurrentReleaseID != nil && event.ManifestURL != nil
|
||||
canLaunch, launchReason := evaluateEventLaunchReadiness(event)
|
||||
result.Play.CanLaunch = canLaunch
|
||||
if canLaunch {
|
||||
result.Play.LaunchSource = LaunchSourceEventCurrentRelease
|
||||
@@ -141,13 +141,13 @@ func (s *EventPlayService) GetEventPlay(ctx context.Context, input EventPlayInpu
|
||||
result.Play.Reason = "user has an ongoing session for this event"
|
||||
case canLaunch:
|
||||
result.Play.PrimaryAction = "start"
|
||||
result.Play.Reason = "event is active and launchable"
|
||||
result.Play.Reason = launchReason
|
||||
case result.Play.RecentSession != nil:
|
||||
result.Play.PrimaryAction = "review_last_result"
|
||||
result.Play.Reason = "event is not launchable, but user has previous session history"
|
||||
result.Play.Reason = launchReason + ", but user has previous session history"
|
||||
default:
|
||||
result.Play.PrimaryAction = "unavailable"
|
||||
result.Play.Reason = "event is not launchable"
|
||||
result.Play.Reason = launchReason
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -152,11 +152,8 @@ func (s *EventService) LaunchEvent(ctx context.Context, input LaunchEventInput)
|
||||
if event == nil {
|
||||
return nil, apperr.New(http.StatusNotFound, "event_not_found", "event not found")
|
||||
}
|
||||
if event.Status != "active" {
|
||||
return nil, apperr.New(http.StatusConflict, "event_not_launchable", "event is not active")
|
||||
}
|
||||
if event.CurrentReleaseID == nil || event.CurrentReleasePubID == nil || event.ConfigLabel == nil || event.ManifestURL == nil {
|
||||
return nil, apperr.New(http.StatusConflict, "event_release_missing", "event does not have a published release")
|
||||
if canLaunch, reason := evaluateEventLaunchReadiness(event); !canLaunch {
|
||||
return nil, launchReadinessError(reason)
|
||||
}
|
||||
if input.ReleaseID != "" && input.ReleaseID != *event.CurrentReleasePubID {
|
||||
return nil, apperr.New(http.StatusConflict, "release_not_launchable", "requested release is not the current published release")
|
||||
|
||||
@@ -24,17 +24,27 @@ type ListCardsInput struct {
|
||||
}
|
||||
|
||||
type CardResult struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Subtitle *string `json:"subtitle,omitempty"`
|
||||
CoverURL *string `json:"coverUrl,omitempty"`
|
||||
DisplaySlot string `json:"displaySlot"`
|
||||
DisplayPriority int `json:"displayPriority"`
|
||||
Event *struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Subtitle *string `json:"subtitle,omitempty"`
|
||||
Summary *string `json:"summary,omitempty"`
|
||||
CoverURL *string `json:"coverUrl,omitempty"`
|
||||
DisplaySlot string `json:"displaySlot"`
|
||||
DisplayPriority int `json:"displayPriority"`
|
||||
Status string `json:"status"`
|
||||
StatusCode string `json:"statusCode"`
|
||||
TimeWindow string `json:"timeWindow"`
|
||||
CTAText string `json:"ctaText"`
|
||||
IsDefaultExperience bool `json:"isDefaultExperience"`
|
||||
EventType *string `json:"eventType,omitempty"`
|
||||
CurrentPresentation *PresentationSummaryView `json:"currentPresentation,omitempty"`
|
||||
CurrentContentBundle *ContentBundleSummaryView `json:"currentContentBundle,omitempty"`
|
||||
Event *struct {
|
||||
ID string `json:"id"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Summary *string `json:"summary,omitempty"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
} `json:"event,omitempty"`
|
||||
HTMLURL *string `json:"htmlUrl,omitempty"`
|
||||
}
|
||||
@@ -128,23 +138,35 @@ func normalizeSlot(slot string) string {
|
||||
func mapCards(cards []postgres.Card) []CardResult {
|
||||
results := make([]CardResult, 0, len(cards))
|
||||
for _, card := range cards {
|
||||
statusCode, statusText := deriveCardStatus(card)
|
||||
item := CardResult{
|
||||
ID: card.PublicID,
|
||||
Type: card.CardType,
|
||||
Title: card.Title,
|
||||
Subtitle: card.Subtitle,
|
||||
CoverURL: card.CoverURL,
|
||||
DisplaySlot: card.DisplaySlot,
|
||||
DisplayPriority: card.DisplayPriority,
|
||||
HTMLURL: card.HTMLURL,
|
||||
ID: card.PublicID,
|
||||
Type: card.CardType,
|
||||
Title: fallbackCardTitle(card.Title),
|
||||
Subtitle: card.Subtitle,
|
||||
Summary: fallbackCardSummary(card.EventSummary),
|
||||
CoverURL: card.CoverURL,
|
||||
DisplaySlot: card.DisplaySlot,
|
||||
DisplayPriority: card.DisplayPriority,
|
||||
Status: statusText,
|
||||
StatusCode: statusCode,
|
||||
TimeWindow: deriveCardTimeWindow(card),
|
||||
CTAText: deriveCardCTAText(card, statusCode),
|
||||
IsDefaultExperience: card.IsDefaultExperience,
|
||||
EventType: deriveCardEventType(card),
|
||||
CurrentPresentation: buildCardPresentationSummary(card),
|
||||
CurrentContentBundle: buildCardContentBundleSummary(card),
|
||||
HTMLURL: card.HTMLURL,
|
||||
}
|
||||
if card.EventPublicID != nil || card.EventDisplayName != nil {
|
||||
item.Event = &struct {
|
||||
ID string `json:"id"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Summary *string `json:"summary,omitempty"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
}{
|
||||
Summary: card.EventSummary,
|
||||
Status: card.EventStatus,
|
||||
}
|
||||
if card.EventPublicID != nil {
|
||||
item.Event.ID = *card.EventPublicID
|
||||
@@ -157,3 +179,134 @@ func mapCards(cards []postgres.Card) []CardResult {
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
func fallbackCardTitle(title string) string {
|
||||
title = strings.TrimSpace(title)
|
||||
if title == "" {
|
||||
return "未命名活动"
|
||||
}
|
||||
return title
|
||||
}
|
||||
|
||||
func fallbackCardSummary(summary *string) *string {
|
||||
if summary != nil && strings.TrimSpace(*summary) != "" {
|
||||
return summary
|
||||
}
|
||||
text := "当前暂无活动摘要"
|
||||
return &text
|
||||
}
|
||||
|
||||
func deriveCardStatus(card postgres.Card) (string, string) {
|
||||
if card.EventStatus == nil {
|
||||
return "pending", "状态待确认"
|
||||
}
|
||||
switch strings.TrimSpace(*card.EventStatus) {
|
||||
case "active":
|
||||
if card.EventCurrentReleasePubID == nil {
|
||||
return "upcoming", "即将开始"
|
||||
}
|
||||
if card.EventRuntimeBindingID == nil || card.EventPresentationID == nil || card.EventContentBundleID == nil {
|
||||
return "upcoming", "即将开始"
|
||||
}
|
||||
return "running", "进行中"
|
||||
case "archived", "disabled", "inactive":
|
||||
return "ended", "已结束"
|
||||
default:
|
||||
return "pending", "状态待确认"
|
||||
}
|
||||
}
|
||||
|
||||
func deriveCardTimeWindow(card postgres.Card) string {
|
||||
if card.StartsAt == nil && card.EndsAt == nil {
|
||||
return "时间待公布"
|
||||
}
|
||||
const layout = "01-02 15:04"
|
||||
switch {
|
||||
case card.StartsAt != nil && card.EndsAt != nil:
|
||||
return card.StartsAt.Local().Format(layout) + " - " + card.EndsAt.Local().Format(layout)
|
||||
case card.StartsAt != nil:
|
||||
return "开始于 " + card.StartsAt.Local().Format(layout)
|
||||
default:
|
||||
return "截止至 " + card.EndsAt.Local().Format(layout)
|
||||
}
|
||||
}
|
||||
|
||||
func deriveCardCTAText(card postgres.Card, statusCode string) string {
|
||||
if card.IsDefaultExperience {
|
||||
return "进入体验"
|
||||
}
|
||||
switch statusCode {
|
||||
case "running":
|
||||
return "进入活动"
|
||||
case "ended":
|
||||
return "查看回顾"
|
||||
default:
|
||||
return "查看详情"
|
||||
}
|
||||
}
|
||||
|
||||
func deriveCardEventType(card postgres.Card) *string {
|
||||
if card.EventReleasePayloadJSON != nil {
|
||||
payload, err := decodeJSONObject(*card.EventReleasePayloadJSON)
|
||||
if err == nil {
|
||||
if game, ok := payload["game"].(map[string]any); ok {
|
||||
if rawMode, ok := game["mode"].(string); ok {
|
||||
switch strings.TrimSpace(rawMode) {
|
||||
case "classic-sequential":
|
||||
text := "顺序赛"
|
||||
return &text
|
||||
case "score-o":
|
||||
text := "积分赛"
|
||||
return &text
|
||||
}
|
||||
}
|
||||
}
|
||||
if plan := resolveVariantPlan(card.EventReleasePayloadJSON); plan.AssignmentMode != nil && *plan.AssignmentMode == AssignmentModeManual {
|
||||
text := "多赛道"
|
||||
return &text
|
||||
}
|
||||
}
|
||||
}
|
||||
if card.IsDefaultExperience {
|
||||
text := "体验活动"
|
||||
return &text
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildCardPresentationSummary(card postgres.Card) *PresentationSummaryView {
|
||||
if card.EventPresentationID == nil {
|
||||
return nil
|
||||
}
|
||||
summary := &PresentationSummaryView{
|
||||
PresentationID: *card.EventPresentationID,
|
||||
Name: card.EventPresentationName,
|
||||
PresentationType: card.EventPresentationType,
|
||||
}
|
||||
if card.EventPresentationSchemaJSON != nil && strings.TrimSpace(*card.EventPresentationSchemaJSON) != "" {
|
||||
if schema, err := decodeJSONObject(*card.EventPresentationSchemaJSON); err == nil {
|
||||
summary.TemplateKey = readStringField(schema, "templateKey")
|
||||
summary.Version = readStringField(schema, "version")
|
||||
}
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func buildCardContentBundleSummary(card postgres.Card) *ContentBundleSummaryView {
|
||||
if card.EventContentBundleID == nil {
|
||||
return nil
|
||||
}
|
||||
summary := &ContentBundleSummaryView{
|
||||
ContentBundleID: *card.EventContentBundleID,
|
||||
Name: card.EventContentBundleName,
|
||||
EntryURL: card.EventContentEntryURL,
|
||||
AssetRootURL: card.EventContentAssetRootURL,
|
||||
}
|
||||
if card.EventContentMetadataJSON != nil && strings.TrimSpace(*card.EventContentMetadataJSON) != "" {
|
||||
if metadata, err := decodeJSONObject(*card.EventContentMetadataJSON); err == nil {
|
||||
summary.BundleType = readStringField(metadata, "bundleType")
|
||||
summary.Version = readStringField(metadata, "version")
|
||||
}
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
56
backend/internal/service/launch_rules.go
Normal file
56
backend/internal/service/launch_rules.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"cmr-backend/internal/apperr"
|
||||
"cmr-backend/internal/store/postgres"
|
||||
)
|
||||
|
||||
const (
|
||||
launchReadyReasonOK = "event is active and launchable"
|
||||
launchReadyReasonNotActive = "event is not active"
|
||||
launchReadyReasonReleaseMissing = "event does not have a published release"
|
||||
launchReadyReasonRuntimeMissing = "current published release is missing runtime binding"
|
||||
launchReadyReasonPresentationMissing = "current published release is missing presentation binding"
|
||||
launchReadyReasonContentMissing = "current published release is missing content bundle binding"
|
||||
)
|
||||
|
||||
func evaluateEventLaunchReadiness(event *postgres.Event) (bool, string) {
|
||||
if event == nil {
|
||||
return false, launchReadyReasonReleaseMissing
|
||||
}
|
||||
if event.Status != "active" {
|
||||
return false, launchReadyReasonNotActive
|
||||
}
|
||||
if event.CurrentReleaseID == nil || event.CurrentReleasePubID == nil || event.ConfigLabel == nil || event.ManifestURL == nil {
|
||||
return false, launchReadyReasonReleaseMissing
|
||||
}
|
||||
if buildRuntimeSummaryFromEvent(event) == nil {
|
||||
return false, launchReadyReasonRuntimeMissing
|
||||
}
|
||||
if buildPresentationSummaryFromEvent(event) == nil {
|
||||
return false, launchReadyReasonPresentationMissing
|
||||
}
|
||||
if buildContentBundleSummaryFromEvent(event) == nil {
|
||||
return false, launchReadyReasonContentMissing
|
||||
}
|
||||
return true, launchReadyReasonOK
|
||||
}
|
||||
|
||||
func launchReadinessError(reason string) error {
|
||||
switch reason {
|
||||
case launchReadyReasonNotActive:
|
||||
return apperr.New(http.StatusConflict, "event_not_launchable", reason)
|
||||
case launchReadyReasonReleaseMissing:
|
||||
return apperr.New(http.StatusConflict, "event_release_missing", reason)
|
||||
case launchReadyReasonRuntimeMissing:
|
||||
return apperr.New(http.StatusConflict, "event_release_runtime_missing", reason)
|
||||
case launchReadyReasonPresentationMissing:
|
||||
return apperr.New(http.StatusConflict, "event_release_presentation_missing", reason)
|
||||
case launchReadyReasonContentMissing:
|
||||
return apperr.New(http.StatusConflict, "event_release_content_bundle_missing", reason)
|
||||
default:
|
||||
return apperr.New(http.StatusConflict, "event_not_launchable", reason)
|
||||
}
|
||||
}
|
||||
@@ -7,19 +7,37 @@ import (
|
||||
)
|
||||
|
||||
type Card struct {
|
||||
ID string
|
||||
PublicID string
|
||||
CardType string
|
||||
Title string
|
||||
Subtitle *string
|
||||
CoverURL *string
|
||||
DisplaySlot string
|
||||
DisplayPriority int
|
||||
EntryChannelID *string
|
||||
EventPublicID *string
|
||||
EventDisplayName *string
|
||||
EventSummary *string
|
||||
HTMLURL *string
|
||||
ID string
|
||||
PublicID string
|
||||
CardType string
|
||||
Title string
|
||||
Subtitle *string
|
||||
CoverURL *string
|
||||
DisplaySlot string
|
||||
DisplayPriority int
|
||||
IsDefaultExperience bool
|
||||
StartsAt *time.Time
|
||||
EndsAt *time.Time
|
||||
EntryChannelID *string
|
||||
EventPublicID *string
|
||||
EventDisplayName *string
|
||||
EventSummary *string
|
||||
EventStatus *string
|
||||
EventCurrentReleasePubID *string
|
||||
EventConfigLabel *string
|
||||
EventRouteCode *string
|
||||
EventReleasePayloadJSON *string
|
||||
EventRuntimeBindingID *string
|
||||
EventPresentationID *string
|
||||
EventPresentationName *string
|
||||
EventPresentationType *string
|
||||
EventPresentationSchemaJSON *string
|
||||
EventContentBundleID *string
|
||||
EventContentBundleName *string
|
||||
EventContentEntryURL *string
|
||||
EventContentAssetRootURL *string
|
||||
EventContentMetadataJSON *string
|
||||
HTMLURL *string
|
||||
}
|
||||
|
||||
func (s *Store) ListCardsForEntry(ctx context.Context, tenantID string, entryChannelID *string, slot string, now time.Time, limit int) ([]Card, error) {
|
||||
@@ -40,13 +58,35 @@ func (s *Store) ListCardsForEntry(ctx context.Context, tenantID string, entryCha
|
||||
c.cover_url,
|
||||
c.display_slot,
|
||||
c.display_priority,
|
||||
c.is_default_experience,
|
||||
c.starts_at,
|
||||
c.ends_at,
|
||||
c.entry_channel_id,
|
||||
e.event_public_id,
|
||||
e.display_name,
|
||||
e.summary,
|
||||
e.status,
|
||||
er.release_public_id,
|
||||
er.config_label,
|
||||
er.route_code,
|
||||
er.payload_jsonb::text,
|
||||
mrb.runtime_binding_public_id,
|
||||
ep.presentation_public_id,
|
||||
ep.name,
|
||||
ep.presentation_type,
|
||||
ep.schema_jsonb::text,
|
||||
cb.content_bundle_public_id,
|
||||
cb.name,
|
||||
cb.entry_url,
|
||||
cb.asset_root_url,
|
||||
cb.metadata_jsonb::text,
|
||||
c.html_url
|
||||
FROM cards c
|
||||
LEFT JOIN events e ON e.id = c.event_id
|
||||
LEFT JOIN event_releases er ON er.id = e.current_release_id
|
||||
LEFT JOIN map_runtime_bindings mrb ON mrb.id = er.runtime_binding_id
|
||||
LEFT JOIN event_presentations ep ON ep.id = er.presentation_id
|
||||
LEFT JOIN content_bundles cb ON cb.id = er.content_bundle_id
|
||||
WHERE c.tenant_id = $1
|
||||
AND ($2::uuid IS NULL OR c.entry_channel_id = $2 OR c.entry_channel_id IS NULL)
|
||||
AND c.display_slot = $3
|
||||
@@ -76,10 +116,28 @@ func (s *Store) ListCardsForEntry(ctx context.Context, tenantID string, entryCha
|
||||
&card.CoverURL,
|
||||
&card.DisplaySlot,
|
||||
&card.DisplayPriority,
|
||||
&card.IsDefaultExperience,
|
||||
&card.StartsAt,
|
||||
&card.EndsAt,
|
||||
&card.EntryChannelID,
|
||||
&card.EventPublicID,
|
||||
&card.EventDisplayName,
|
||||
&card.EventSummary,
|
||||
&card.EventStatus,
|
||||
&card.EventCurrentReleasePubID,
|
||||
&card.EventConfigLabel,
|
||||
&card.EventRouteCode,
|
||||
&card.EventReleasePayloadJSON,
|
||||
&card.EventRuntimeBindingID,
|
||||
&card.EventPresentationID,
|
||||
&card.EventPresentationName,
|
||||
&card.EventPresentationType,
|
||||
&card.EventPresentationSchemaJSON,
|
||||
&card.EventContentBundleID,
|
||||
&card.EventContentBundleName,
|
||||
&card.EventContentEntryURL,
|
||||
&card.EventContentAssetRootURL,
|
||||
&card.EventContentMetadataJSON,
|
||||
&card.HTMLURL,
|
||||
); err != nil {
|
||||
return nil, fmt.Errorf("scan card: %w", err)
|
||||
|
||||
@@ -31,6 +31,11 @@ type DemoBootstrapSummary struct {
|
||||
VariantManualEventID string `json:"variantManualEventId"`
|
||||
VariantManualRelease string `json:"variantManualReleaseId"`
|
||||
VariantManualCardID string `json:"variantManualCardId"`
|
||||
VariantManualSourceID string `json:"variantManualSourceId"`
|
||||
VariantManualBuildID string `json:"variantManualBuildId"`
|
||||
VariantManualCourseSet string `json:"variantManualCourseSetId"`
|
||||
VariantManualVariantID string `json:"variantManualCourseVariantId"`
|
||||
VariantManualRuntimeID string `json:"variantManualRuntimeBindingId"`
|
||||
CleanedSessionCount int64 `json:"cleanedSessionCount"`
|
||||
}
|
||||
|
||||
@@ -44,7 +49,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
var tenantID string
|
||||
if err := tx.QueryRow(ctx, `
|
||||
INSERT INTO tenants (tenant_code, name, status)
|
||||
VALUES ('tenant_demo', 'Demo Tenant', 'active')
|
||||
VALUES ('tenant_demo', '联调租户', 'active')
|
||||
ON CONFLICT (tenant_code) DO UPDATE SET
|
||||
name = EXCLUDED.name,
|
||||
status = EXCLUDED.status
|
||||
@@ -58,7 +63,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
INSERT INTO entry_channels (
|
||||
tenant_id, channel_code, channel_type, platform_app_id, display_name, status, is_default
|
||||
)
|
||||
VALUES ($1, 'mini-demo', 'wechat_mini', 'wx-demo-appid', 'Demo Mini Channel', 'active', true)
|
||||
VALUES ($1, 'mini-demo', 'wechat_mini', 'wx-demo-appid', '小程序联调入口', 'active', true)
|
||||
ON CONFLICT (tenant_id, channel_code) DO UPDATE SET
|
||||
channel_type = EXCLUDED.channel_type,
|
||||
platform_app_id = EXCLUDED.platform_app_id,
|
||||
@@ -75,7 +80,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
INSERT INTO events (
|
||||
tenant_id, event_public_id, slug, display_name, summary, status
|
||||
)
|
||||
VALUES ($1, 'evt_demo_001', 'demo-city-run', 'Demo City Run', 'Launch flow demo event', 'active')
|
||||
VALUES ($1, 'evt_demo_001', 'city-park-classic', '领秀城公园顺序赛', '顺序赛联调样例活动', 'active')
|
||||
ON CONFLICT (event_public_id) DO UPDATE SET
|
||||
tenant_id = EXCLUDED.tenant_id,
|
||||
slug = EXCLUDED.slug,
|
||||
@@ -106,7 +111,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
'rel_demo_001',
|
||||
$1,
|
||||
1,
|
||||
'Demo Config v1',
|
||||
'顺序赛联调配置 v1',
|
||||
'https://oss-mbh5.colormaprun.com/gotomars/event/releases/evt_demo_001/rel_e7dd953743c5c0d2/manifest.json',
|
||||
'demo-checksum-001',
|
||||
'route-demo-001',
|
||||
@@ -132,7 +137,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
return nil, fmt.Errorf("attach demo release: %w", err)
|
||||
}
|
||||
|
||||
sourceNotes := "demo source config imported from local event sample"
|
||||
sourceNotes := "顺序赛联调 source 配置"
|
||||
source, err := s.UpsertEventConfigSource(ctx, tx, UpsertEventConfigSourceParams{
|
||||
EventID: eventID,
|
||||
SourceVersionNo: 1,
|
||||
@@ -144,7 +149,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
Source: map[string]any{
|
||||
"app": map[string]any{
|
||||
"id": "sample-classic-001",
|
||||
"title": "顺序赛示例",
|
||||
"title": "领秀城公园顺序赛",
|
||||
},
|
||||
"branding": map[string]any{
|
||||
"tenantCode": "tenant_demo",
|
||||
@@ -173,7 +178,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
return nil, fmt.Errorf("ensure demo event config source: %w", err)
|
||||
}
|
||||
|
||||
buildLog := "demo build generated from sample classic-sequential.json"
|
||||
buildLog := "顺序赛联调 build 产物"
|
||||
build, err := s.UpsertEventConfigBuild(ctx, tx, UpsertEventConfigBuildParams{
|
||||
EventID: eventID,
|
||||
SourceID: source.ID,
|
||||
@@ -186,7 +191,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
"version": "2026.04.01",
|
||||
"app": map[string]any{
|
||||
"id": "sample-classic-001",
|
||||
"title": "顺序赛示例",
|
||||
"title": "领秀城公园顺序赛",
|
||||
},
|
||||
"map": map[string]any{
|
||||
"tiles": "https://oss-mbh5.colormaprun.com/gotomars/map/lxcb-001/tiles/",
|
||||
@@ -296,20 +301,26 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
event_id,
|
||||
display_slot,
|
||||
display_priority,
|
||||
status
|
||||
status,
|
||||
is_default_experience,
|
||||
starts_at,
|
||||
ends_at
|
||||
)
|
||||
VALUES (
|
||||
'card_demo_001',
|
||||
$1,
|
||||
$2,
|
||||
'event',
|
||||
'Demo City Run',
|
||||
'今日推荐路线',
|
||||
'领秀城公园顺序赛',
|
||||
'顺序赛推荐入口',
|
||||
'https://oss-mbh5.colormaprun.com/gotomars/assets/demo-cover.jpg',
|
||||
$3,
|
||||
'home_primary',
|
||||
100,
|
||||
'active'
|
||||
'active',
|
||||
true,
|
||||
NOW() - INTERVAL '1 day',
|
||||
NOW() + INTERVAL '30 day'
|
||||
)
|
||||
ON CONFLICT (card_public_id) DO UPDATE SET
|
||||
tenant_id = EXCLUDED.tenant_id,
|
||||
@@ -321,7 +332,10 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
event_id = EXCLUDED.event_id,
|
||||
display_slot = EXCLUDED.display_slot,
|
||||
display_priority = EXCLUDED.display_priority,
|
||||
status = EXCLUDED.status
|
||||
status = EXCLUDED.status,
|
||||
is_default_experience = EXCLUDED.is_default_experience,
|
||||
starts_at = EXCLUDED.starts_at,
|
||||
ends_at = EXCLUDED.ends_at
|
||||
RETURNING card_public_id
|
||||
`, tenantID, channelID, eventID).Scan(&cardPublicID); err != nil {
|
||||
return nil, fmt.Errorf("ensure demo card: %w", err)
|
||||
@@ -333,7 +347,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
place_public_id, code, name, region, status
|
||||
)
|
||||
VALUES (
|
||||
'place_demo_001', 'place-demo-001', 'Demo Park', 'Shanghai', 'active'
|
||||
'place_demo_001', 'place-demo-001', '领秀城公园', 'Shanghai', 'active'
|
||||
)
|
||||
ON CONFLICT (code) DO UPDATE SET
|
||||
name = EXCLUDED.name,
|
||||
@@ -350,7 +364,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
map_asset_public_id, place_id, code, name, map_type, status
|
||||
)
|
||||
VALUES (
|
||||
'mapasset_demo_001', $1, 'mapasset-demo-001', 'Demo Asset Map', 'standard', 'active'
|
||||
'mapasset_demo_001', $1, 'mapasset-demo-001', '领秀城公园基础底图', 'standard', 'active'
|
||||
)
|
||||
ON CONFLICT (code) DO UPDATE SET
|
||||
place_id = EXCLUDED.place_id,
|
||||
@@ -429,7 +443,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
course_set_public_id, place_id, map_asset_id, code, mode, name, status
|
||||
)
|
||||
VALUES (
|
||||
'cset_demo_001', $1, $2, 'cset-demo-001', 'classic-sequential', 'Demo Course Set', 'active'
|
||||
'cset_demo_001', $1, $2, 'cset-demo-001', 'classic-sequential', '顺序赛标准赛道', 'active'
|
||||
)
|
||||
ON CONFLICT (code) DO UPDATE SET
|
||||
place_id = EXCLUDED.place_id,
|
||||
@@ -448,7 +462,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
course_variant_public_id, course_set_id, source_id, name, route_code, mode, control_count, status, is_default
|
||||
)
|
||||
VALUES (
|
||||
'cvariant_demo_001', $1, $2, 'Demo Variant A', 'route-demo-a', 'classic-sequential', 8, 'active', true
|
||||
'cvariant_demo_001', $1, $2, '顺序赛 A 线', 'route-demo-a', 'classic-sequential', 8, 'active', true
|
||||
)
|
||||
ON CONFLICT (course_variant_public_id) DO UPDATE SET
|
||||
course_set_id = EXCLUDED.course_set_id,
|
||||
@@ -470,7 +484,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
course_variant_public_id, course_set_id, source_id, name, route_code, mode, control_count, status, is_default
|
||||
)
|
||||
VALUES (
|
||||
'cvariant_demo_002', $1, $2, 'Demo Variant B', 'route-demo-b', 'classic-sequential', 10, 'active', false
|
||||
'cvariant_demo_002', $1, $2, '顺序赛 B 线', 'route-demo-b', 'classic-sequential', 10, 'active', false
|
||||
)
|
||||
ON CONFLICT (course_variant_public_id) DO UPDATE SET
|
||||
course_set_id = EXCLUDED.course_set_id,
|
||||
@@ -500,7 +514,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
runtime_binding_public_id, event_id, place_id, map_asset_id, tile_release_id, course_set_id, course_variant_id, status, notes
|
||||
)
|
||||
VALUES (
|
||||
'runtime_demo_001', $1, $2, $3, $4, $5, $6, 'active', 'demo runtime binding'
|
||||
'runtime_demo_001', $1, $2, $3, $4, $5, $6, 'active', '顺序赛联调运行绑定'
|
||||
)
|
||||
ON CONFLICT (runtime_binding_public_id) DO UPDATE SET
|
||||
event_id = EXCLUDED.event_id,
|
||||
@@ -521,7 +535,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
INSERT INTO events (
|
||||
tenant_id, event_public_id, slug, display_name, summary, status
|
||||
)
|
||||
VALUES ($1, 'evt_demo_variant_manual_001', 'demo-variant-manual-run', 'Demo Variant Manual Run', 'Manual 多赛道联调活动', 'active')
|
||||
VALUES ($1, 'evt_demo_variant_manual_001', 'city-park-manual-variant', '领秀城公园多赛道挑战', '手动多赛道联调样例活动', 'active')
|
||||
ON CONFLICT (event_public_id) DO UPDATE SET
|
||||
tenant_id = EXCLUDED.tenant_id,
|
||||
slug = EXCLUDED.slug,
|
||||
@@ -553,7 +567,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
'rel_demo_variant_manual_001',
|
||||
$1,
|
||||
1,
|
||||
'Demo Variant Manual Config v1',
|
||||
'多赛道联调配置 v1',
|
||||
'https://oss-mbh5.colormaprun.com/gotomars/event/releases/evt_demo_001/rel_e7dd953743c5c0d2/manifest.json',
|
||||
'demo-variant-checksum-001',
|
||||
'route-variant-a',
|
||||
@@ -614,20 +628,26 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
event_id,
|
||||
display_slot,
|
||||
display_priority,
|
||||
status
|
||||
status,
|
||||
is_default_experience,
|
||||
starts_at,
|
||||
ends_at
|
||||
)
|
||||
VALUES (
|
||||
'card_demo_variant_manual_001',
|
||||
$1,
|
||||
$2,
|
||||
'event',
|
||||
'Demo Variant Manual Run',
|
||||
'多赛道手动选择联调',
|
||||
'领秀城公园多赛道挑战',
|
||||
'手动选择赛道入口',
|
||||
'https://oss-mbh5.colormaprun.com/gotomars/assets/demo-cover.jpg',
|
||||
$3,
|
||||
'home_primary',
|
||||
95,
|
||||
'active'
|
||||
'active',
|
||||
false,
|
||||
NOW() - INTERVAL '1 day',
|
||||
NOW() + INTERVAL '30 day'
|
||||
)
|
||||
ON CONFLICT (card_public_id) DO UPDATE SET
|
||||
tenant_id = EXCLUDED.tenant_id,
|
||||
@@ -639,18 +659,242 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
event_id = EXCLUDED.event_id,
|
||||
display_slot = EXCLUDED.display_slot,
|
||||
display_priority = EXCLUDED.display_priority,
|
||||
status = EXCLUDED.status
|
||||
status = EXCLUDED.status,
|
||||
is_default_experience = EXCLUDED.is_default_experience,
|
||||
starts_at = EXCLUDED.starts_at,
|
||||
ends_at = EXCLUDED.ends_at
|
||||
RETURNING card_public_id
|
||||
`, tenantID, channelID, manualEventID).Scan(&manualCardPublicID); err != nil {
|
||||
return nil, fmt.Errorf("ensure variant manual demo card: %w", err)
|
||||
}
|
||||
|
||||
manualSourceNotes := "多赛道联调 source 配置"
|
||||
manualSource, err := s.UpsertEventConfigSource(ctx, tx, UpsertEventConfigSourceParams{
|
||||
EventID: manualEventID,
|
||||
SourceVersionNo: 1,
|
||||
SourceKind: "event_bundle",
|
||||
SchemaID: "event-source",
|
||||
SchemaVersion: "1",
|
||||
Status: "active",
|
||||
Notes: &manualSourceNotes,
|
||||
Source: map[string]any{
|
||||
"schemaVersion": "1",
|
||||
"app": map[string]any{
|
||||
"id": "sample-variant-manual-001",
|
||||
"title": "领秀城公园多赛道挑战",
|
||||
},
|
||||
"branding": map[string]any{
|
||||
"tenantCode": "tenant_demo",
|
||||
"entryChannel": "mini-demo",
|
||||
},
|
||||
"map": map[string]any{
|
||||
"tiles": "../map/lxcb-001/tiles/",
|
||||
"mapmeta": "../map/lxcb-001/tiles/meta.json",
|
||||
},
|
||||
"playfield": map[string]any{
|
||||
"kind": "course",
|
||||
"source": map[string]any{
|
||||
"type": "kml",
|
||||
"url": "../kml/lxcb-001/10/c01.kml",
|
||||
},
|
||||
},
|
||||
"game": map[string]any{
|
||||
"mode": "classic-sequential",
|
||||
},
|
||||
"play": map[string]any{
|
||||
"assignmentMode": "manual",
|
||||
"courseVariants": []map[string]any{
|
||||
{
|
||||
"id": "variant_a",
|
||||
"name": "A 线",
|
||||
"description": "短线体验版(c01.kml)",
|
||||
"routeCode": "route-variant-a",
|
||||
"selectable": true,
|
||||
},
|
||||
{
|
||||
"id": "variant_b",
|
||||
"name": "B 线",
|
||||
"description": "长线挑战版(c02.kml)",
|
||||
"routeCode": "route-variant-b",
|
||||
"selectable": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
"content": map[string]any{
|
||||
"h5Template": "content-h5-test-template.html",
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ensure variant manual demo event config source: %w", err)
|
||||
}
|
||||
|
||||
manualBuildLog := "多赛道联调 build 产物"
|
||||
manualBuild, err := s.UpsertEventConfigBuild(ctx, tx, UpsertEventConfigBuildParams{
|
||||
EventID: manualEventID,
|
||||
SourceID: manualSource.ID,
|
||||
BuildNo: 1,
|
||||
BuildStatus: "success",
|
||||
BuildLog: &manualBuildLog,
|
||||
Manifest: map[string]any{
|
||||
"schemaVersion": "1",
|
||||
"releaseId": "rel_demo_variant_manual_001",
|
||||
"version": "2026.04.01",
|
||||
"app": map[string]any{
|
||||
"id": "sample-variant-manual-001",
|
||||
"title": "领秀城公园多赛道挑战",
|
||||
},
|
||||
"map": map[string]any{
|
||||
"tiles": "https://oss-mbh5.colormaprun.com/gotomars/map/lxcb-001/tiles/",
|
||||
"mapmeta": "https://oss-mbh5.colormaprun.com/gotomars/map/lxcb-001/tiles/meta.json",
|
||||
},
|
||||
"playfield": map[string]any{
|
||||
"kind": "course",
|
||||
"source": map[string]any{
|
||||
"type": "kml",
|
||||
"url": "https://oss-mbh5.colormaprun.com/gotomars/kml/lxcb-001/10/c01.kml",
|
||||
},
|
||||
},
|
||||
"game": map[string]any{
|
||||
"mode": "classic-sequential",
|
||||
},
|
||||
"play": map[string]any{
|
||||
"assignmentMode": "manual",
|
||||
"courseVariants": []map[string]any{
|
||||
{
|
||||
"id": "variant_a",
|
||||
"name": "A 线",
|
||||
"description": "短线体验版(c01.kml)",
|
||||
"routeCode": "route-variant-a",
|
||||
"selectable": true,
|
||||
},
|
||||
{
|
||||
"id": "variant_b",
|
||||
"name": "B 线",
|
||||
"description": "长线挑战版(c02.kml)",
|
||||
"routeCode": "route-variant-b",
|
||||
"selectable": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
"assets": map[string]any{
|
||||
"contentHtml": "https://oss-mbh5.colormaprun.com/gotomars/event/content-h5-test-template.html",
|
||||
},
|
||||
},
|
||||
AssetIndex: []map[string]any{
|
||||
{"assetType": "manifest", "assetKey": "manifest"},
|
||||
{"assetType": "mapmeta", "assetKey": "mapmeta"},
|
||||
{"assetType": "playfield", "assetKey": "playfield-kml"},
|
||||
{"assetType": "content_html", "assetKey": "content-html"},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ensure variant manual demo event config build: %w", err)
|
||||
}
|
||||
|
||||
if err := s.AttachBuildToRelease(ctx, tx, manualReleaseRow.ID, manualBuild.ID); err != nil {
|
||||
return nil, fmt.Errorf("attach variant manual demo build to release: %w", err)
|
||||
}
|
||||
|
||||
var manualCourseSetID, manualCourseSetPublicID string
|
||||
if err := tx.QueryRow(ctx, `
|
||||
INSERT INTO course_sets (
|
||||
course_set_public_id, place_id, map_asset_id, code, mode, name, status
|
||||
)
|
||||
VALUES (
|
||||
'cset_demo_variant_manual_001', $1, $2, 'cset-demo-variant-manual-001', 'classic-sequential', '多赛道挑战赛道集', 'active'
|
||||
)
|
||||
ON CONFLICT (code) DO UPDATE SET
|
||||
place_id = EXCLUDED.place_id,
|
||||
map_asset_id = EXCLUDED.map_asset_id,
|
||||
mode = EXCLUDED.mode,
|
||||
name = EXCLUDED.name,
|
||||
status = EXCLUDED.status
|
||||
RETURNING id, course_set_public_id
|
||||
`, placeID, mapAssetID).Scan(&manualCourseSetID, &manualCourseSetPublicID); err != nil {
|
||||
return nil, fmt.Errorf("ensure variant manual demo course set: %w", err)
|
||||
}
|
||||
|
||||
var manualVariantAID string
|
||||
if err := tx.QueryRow(ctx, `
|
||||
INSERT INTO course_variants (
|
||||
course_variant_public_id, course_set_id, source_id, name, route_code, mode, control_count, status, is_default
|
||||
)
|
||||
VALUES (
|
||||
'cvariant_demo_variant_manual_a', $1, $2, '多赛道 A 线', 'route-variant-a', 'classic-sequential', 8, 'active', false
|
||||
)
|
||||
ON CONFLICT (course_variant_public_id) DO UPDATE SET
|
||||
course_set_id = EXCLUDED.course_set_id,
|
||||
source_id = EXCLUDED.source_id,
|
||||
name = EXCLUDED.name,
|
||||
route_code = EXCLUDED.route_code,
|
||||
mode = EXCLUDED.mode,
|
||||
control_count = EXCLUDED.control_count,
|
||||
status = EXCLUDED.status,
|
||||
is_default = EXCLUDED.is_default
|
||||
RETURNING id
|
||||
`, manualCourseSetID, courseSourceID).Scan(&manualVariantAID); err != nil {
|
||||
return nil, fmt.Errorf("ensure variant manual demo variant a: %w", err)
|
||||
}
|
||||
|
||||
var manualVariantBID, manualVariantBPublicID string
|
||||
if err := tx.QueryRow(ctx, `
|
||||
INSERT INTO course_variants (
|
||||
course_variant_public_id, course_set_id, source_id, name, route_code, mode, control_count, status, is_default
|
||||
)
|
||||
VALUES (
|
||||
'cvariant_demo_variant_manual_b', $1, $2, '多赛道 B 线', 'route-variant-b', 'classic-sequential', 10, 'active', true
|
||||
)
|
||||
ON CONFLICT (course_variant_public_id) DO UPDATE SET
|
||||
course_set_id = EXCLUDED.course_set_id,
|
||||
source_id = EXCLUDED.source_id,
|
||||
name = EXCLUDED.name,
|
||||
route_code = EXCLUDED.route_code,
|
||||
mode = EXCLUDED.mode,
|
||||
control_count = EXCLUDED.control_count,
|
||||
status = EXCLUDED.status,
|
||||
is_default = EXCLUDED.is_default
|
||||
RETURNING id, course_variant_public_id
|
||||
`, manualCourseSetID, courseSourceVariantBID).Scan(&manualVariantBID, &manualVariantBPublicID); err != nil {
|
||||
return nil, fmt.Errorf("ensure variant manual demo variant b: %w", err)
|
||||
}
|
||||
|
||||
if _, err := tx.Exec(ctx, `
|
||||
UPDATE course_sets
|
||||
SET current_variant_id = $2
|
||||
WHERE id = $1
|
||||
`, manualCourseSetID, manualVariantBID); err != nil {
|
||||
return nil, fmt.Errorf("attach variant manual demo course variant: %w", err)
|
||||
}
|
||||
|
||||
var manualRuntimeBindingID, manualRuntimeBindingPublicID string
|
||||
if err := tx.QueryRow(ctx, `
|
||||
INSERT INTO map_runtime_bindings (
|
||||
runtime_binding_public_id, event_id, place_id, map_asset_id, tile_release_id, course_set_id, course_variant_id, status, notes
|
||||
)
|
||||
VALUES (
|
||||
'runtime_demo_variant_manual_001', $1, $2, $3, $4, $5, $6, 'active', '多赛道联调运行绑定'
|
||||
)
|
||||
ON CONFLICT (runtime_binding_public_id) DO UPDATE SET
|
||||
event_id = EXCLUDED.event_id,
|
||||
place_id = EXCLUDED.place_id,
|
||||
map_asset_id = EXCLUDED.map_asset_id,
|
||||
tile_release_id = EXCLUDED.tile_release_id,
|
||||
course_set_id = EXCLUDED.course_set_id,
|
||||
course_variant_id = EXCLUDED.course_variant_id,
|
||||
status = EXCLUDED.status,
|
||||
notes = EXCLUDED.notes
|
||||
RETURNING id, runtime_binding_public_id
|
||||
`, manualEventID, placeID, mapAssetID, tileReleaseID, manualCourseSetID, manualVariantBID).Scan(&manualRuntimeBindingID, &manualRuntimeBindingPublicID); err != nil {
|
||||
return nil, fmt.Errorf("ensure variant manual demo runtime binding: %w", err)
|
||||
}
|
||||
|
||||
var scoreOEventID string
|
||||
if err := tx.QueryRow(ctx, `
|
||||
INSERT INTO events (
|
||||
tenant_id, event_public_id, slug, display_name, summary, status
|
||||
)
|
||||
VALUES ($1, 'evt_demo_score_o_001', 'demo-score-o-run', 'Demo Score-O Run', '积分赛联调活动', 'active')
|
||||
VALUES ($1, 'evt_demo_score_o_001', 'city-park-score-o', '领秀城公园积分赛', '积分赛联调样例活动', 'active')
|
||||
ON CONFLICT (event_public_id) DO UPDATE SET
|
||||
tenant_id = EXCLUDED.tenant_id,
|
||||
slug = EXCLUDED.slug,
|
||||
@@ -681,7 +925,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
'rel_demo_score_o_001',
|
||||
$1,
|
||||
1,
|
||||
'Demo Score-O Config v1',
|
||||
'积分赛联调配置 v1',
|
||||
'https://oss-mbh5.colormaprun.com/gotomars/event/score-o.json',
|
||||
'demo-score-o-checksum-001',
|
||||
'route-score-o-001',
|
||||
@@ -707,7 +951,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
return nil, fmt.Errorf("attach score-o demo release: %w", err)
|
||||
}
|
||||
|
||||
scoreOSourceNotes := "demo source config imported from local event sample score-o"
|
||||
scoreOSourceNotes := "积分赛联调 source 配置"
|
||||
scoreOSource, err := s.UpsertEventConfigSource(ctx, tx, UpsertEventConfigSourceParams{
|
||||
EventID: scoreOEventID,
|
||||
SourceVersionNo: 1,
|
||||
@@ -720,7 +964,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
"schemaVersion": "1",
|
||||
"app": map[string]any{
|
||||
"id": "sample-score-o-001",
|
||||
"title": "积分赛示例",
|
||||
"title": "领秀城公园积分赛",
|
||||
},
|
||||
"branding": map[string]any{
|
||||
"tenantCode": "tenant_demo",
|
||||
@@ -749,7 +993,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
return nil, fmt.Errorf("ensure score-o demo event config source: %w", err)
|
||||
}
|
||||
|
||||
scoreOBuildLog := "demo build generated from sample score-o.json"
|
||||
scoreOBuildLog := "积分赛联调 build 产物"
|
||||
scoreOBuild, err := s.UpsertEventConfigBuild(ctx, tx, UpsertEventConfigBuildParams{
|
||||
EventID: scoreOEventID,
|
||||
SourceID: scoreOSource.ID,
|
||||
@@ -762,7 +1006,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
"version": "2026.04.01",
|
||||
"app": map[string]any{
|
||||
"id": "sample-score-o-001",
|
||||
"title": "积分赛示例",
|
||||
"title": "领秀城公园积分赛",
|
||||
},
|
||||
"map": map[string]any{
|
||||
"tiles": "https://oss-mbh5.colormaprun.com/gotomars/map/lxcb-001/tiles/",
|
||||
@@ -810,20 +1054,26 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
event_id,
|
||||
display_slot,
|
||||
display_priority,
|
||||
status
|
||||
status,
|
||||
is_default_experience,
|
||||
starts_at,
|
||||
ends_at
|
||||
)
|
||||
VALUES (
|
||||
'card_demo_score_o_001',
|
||||
$1,
|
||||
$2,
|
||||
'event',
|
||||
'Demo Score-O Run',
|
||||
'积分赛联调入口',
|
||||
'领秀城公园积分赛',
|
||||
'积分赛推荐入口',
|
||||
'https://oss-mbh5.colormaprun.com/gotomars/assets/demo-cover.jpg',
|
||||
$3,
|
||||
'home_primary',
|
||||
98,
|
||||
'active'
|
||||
'active',
|
||||
false,
|
||||
NOW() - INTERVAL '1 day',
|
||||
NOW() + INTERVAL '30 day'
|
||||
)
|
||||
ON CONFLICT (card_public_id) DO UPDATE SET
|
||||
tenant_id = EXCLUDED.tenant_id,
|
||||
@@ -835,7 +1085,10 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
event_id = EXCLUDED.event_id,
|
||||
display_slot = EXCLUDED.display_slot,
|
||||
display_priority = EXCLUDED.display_priority,
|
||||
status = EXCLUDED.status
|
||||
status = EXCLUDED.status,
|
||||
is_default_experience = EXCLUDED.is_default_experience,
|
||||
starts_at = EXCLUDED.starts_at,
|
||||
ends_at = EXCLUDED.ends_at
|
||||
RETURNING card_public_id
|
||||
`, tenantID, channelID, scoreOEventID).Scan(&scoreOCardPublicID); err != nil {
|
||||
return nil, fmt.Errorf("ensure score-o demo card: %w", err)
|
||||
@@ -847,7 +1100,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
course_set_public_id, place_id, map_asset_id, code, mode, name, status
|
||||
)
|
||||
VALUES (
|
||||
'cset_demo_score_o_001', $1, $2, 'cset-demo-score-o-001', 'score-o', 'Demo Score-O Course Set', 'active'
|
||||
'cset_demo_score_o_001', $1, $2, 'cset-demo-score-o-001', 'score-o', '积分赛标准赛道', 'active'
|
||||
)
|
||||
ON CONFLICT (code) DO UPDATE SET
|
||||
place_id = EXCLUDED.place_id,
|
||||
@@ -866,7 +1119,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
course_variant_public_id, course_set_id, source_id, name, route_code, mode, control_count, status, is_default
|
||||
)
|
||||
VALUES (
|
||||
'cvariant_demo_score_o_001', $1, $2, 'Demo Score-O Variant', 'route-score-o-001', 'score-o', 10, 'active', true
|
||||
'cvariant_demo_score_o_001', $1, $2, '积分赛主赛道', 'route-score-o-001', 'score-o', 10, 'active', true
|
||||
)
|
||||
ON CONFLICT (course_variant_public_id) DO UPDATE SET
|
||||
course_set_id = EXCLUDED.course_set_id,
|
||||
@@ -896,7 +1149,7 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
runtime_binding_public_id, event_id, place_id, map_asset_id, tile_release_id, course_set_id, course_variant_id, status, notes
|
||||
)
|
||||
VALUES (
|
||||
'runtime_demo_score_o_001', $1, $2, $3, $4, $5, $6, 'active', 'demo score-o runtime binding'
|
||||
'runtime_demo_score_o_001', $1, $2, $3, $4, $5, $6, 'active', '积分赛联调运行绑定'
|
||||
)
|
||||
ON CONFLICT (runtime_binding_public_id) DO UPDATE SET
|
||||
event_id = EXCLUDED.event_id,
|
||||
@@ -959,6 +1212,11 @@ func (s *Store) EnsureDemoData(ctx context.Context) (*DemoBootstrapSummary, erro
|
||||
VariantManualEventID: "evt_demo_variant_manual_001",
|
||||
VariantManualRelease: manualReleaseRow.PublicID,
|
||||
VariantManualCardID: manualCardPublicID,
|
||||
VariantManualSourceID: manualSource.ID,
|
||||
VariantManualBuildID: manualBuild.ID,
|
||||
VariantManualCourseSet: manualCourseSetPublicID,
|
||||
VariantManualVariantID: manualVariantBPublicID,
|
||||
VariantManualRuntimeID: manualRuntimeBindingPublicID,
|
||||
CleanedSessionCount: cleanedSessionCount,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user