208 lines
7.5 KiB
Go
208 lines
7.5 KiB
Go
package activitytemplate
|
||
|
||
const (
|
||
// ActivityTypeGiftChallenge 是当前原型对应的礼物挑战赛;类型字段保留,后续模板类型可复用同一生命周期框架。
|
||
ActivityTypeGiftChallenge = "gift_challenge"
|
||
|
||
StatusDraft = "draft"
|
||
StatusPublished = "published"
|
||
StatusDisabled = "disabled"
|
||
StatusArchived = "archived"
|
||
|
||
LifecycleDraft = "draft"
|
||
LifecycleScheduled = "scheduled"
|
||
LifecycleOngoing = "ongoing"
|
||
LifecycleEnded = "ended"
|
||
LifecycleDisabled = "disabled"
|
||
LifecycleArchived = "archived"
|
||
|
||
TaskTypeDailyVisit = "daily_visit"
|
||
TaskTypeGiftCount = "gift_count"
|
||
TaskTypeGiftCoinAmount = "gift_coin_amount"
|
||
|
||
BoardTypeDaily = "daily"
|
||
BoardTypeTotal = "total"
|
||
|
||
SharedAssetLocale = "*"
|
||
)
|
||
|
||
// Locale 是活动页的单语言文案。运行侧先匹配用户语言,再回退到英语,避免把后台内部名称暴露给客户端。
|
||
type Locale struct {
|
||
Locale string `json:"locale"`
|
||
Title string `json:"title"`
|
||
Rules string `json:"rules"`
|
||
}
|
||
|
||
// Gift 是参与任务和排行榜计分的礼物引用;礼物价格和上下架状态仍由礼物 owner 服务维护。
|
||
type Gift struct {
|
||
GiftID string `json:"gift_id"`
|
||
SortOrder int32 `json:"sort_order"`
|
||
Name string `json:"name"`
|
||
IconURL string `json:"icon_url"`
|
||
CoinPrice int64 `json:"coin_price"`
|
||
PriceVersion string `json:"price_version"`
|
||
}
|
||
|
||
// RewardItem is the safe client-facing projection copied from a wallet-owned pinned resource-group
|
||
// snapshot. It intentionally excludes grant strategies, admin IDs and mutable catalog metadata.
|
||
type RewardItem struct {
|
||
ItemType string `json:"item_type"`
|
||
ResourceID int64 `json:"resource_id"`
|
||
ResourceType string `json:"resource_type"`
|
||
Name string `json:"name"`
|
||
IconURL string `json:"icon_url"`
|
||
Quantity int64 `json:"quantity"`
|
||
DurationMS int64 `json:"duration_ms"`
|
||
WalletAssetType string `json:"wallet_asset_type"`
|
||
WalletAssetAmount int64 `json:"wallet_asset_amount"`
|
||
SortOrder int32 `json:"sort_order"`
|
||
}
|
||
|
||
type RewardSnapshot struct {
|
||
SourceGroupID int64 `json:"source_group_id"`
|
||
SnapshotID string `json:"snapshot_id"`
|
||
VersionNo int64 `json:"version_no"`
|
||
SnapshotHash string `json:"snapshot_hash"`
|
||
Name string `json:"name"`
|
||
Items []RewardItem `json:"items"`
|
||
}
|
||
|
||
// Task 是活动实例内的每日任务档位。奖励引用资源组,使复杂资产组合仍由 wallet-service 原子发放。
|
||
type Task struct {
|
||
TaskKey string `json:"task_key"`
|
||
TaskType string `json:"task_type"`
|
||
TargetValue int64 `json:"target_value"`
|
||
RewardResourceGroupID int64 `json:"reward_resource_group_id"`
|
||
SortOrder int32 `json:"sort_order"`
|
||
RewardSnapshot RewardSnapshot `json:"reward_snapshot"`
|
||
}
|
||
|
||
// RankReward 是一个不重叠的名次区间。区间使用闭区间,活动周期本身仍使用 [start_ms,end_ms)。
|
||
type RankReward struct {
|
||
BoardType string `json:"board_type"`
|
||
RankFrom int32 `json:"rank_from"`
|
||
RankTo int32 `json:"rank_to"`
|
||
ResourceGroupID int64 `json:"resource_group_id"`
|
||
SortOrder int32 `json:"sort_order"`
|
||
RewardSnapshot RewardSnapshot `json:"reward_snapshot"`
|
||
}
|
||
|
||
// Asset 是活动页素材清单;Locale="*" 是共享素材,具体语言素材覆盖共享项。
|
||
type Asset struct {
|
||
AssetKey string `json:"asset_key"`
|
||
Locale string `json:"locale"`
|
||
URL string `json:"url"`
|
||
MediaType string `json:"media_type"`
|
||
SortOrder int32 `json:"sort_order"`
|
||
}
|
||
|
||
// Template 是运营后台称作“活动模版”的可排期活动实例。
|
||
// Revision 用于后台乐观锁,PublishedVersion 指向最近一次发布形成的不可变完整快照,两者不能混用。
|
||
type Template struct {
|
||
AppCode string `json:"app_code"`
|
||
TemplateID string `json:"template_id"`
|
||
TemplateCode string `json:"template_code"`
|
||
Name string `json:"name"`
|
||
ActivityType string `json:"activity_type"`
|
||
Status string `json:"status"`
|
||
LifecycleStatus string `json:"lifecycle_status"`
|
||
StartMS int64 `json:"start_ms"`
|
||
EndMS int64 `json:"end_ms"`
|
||
AllRegions bool `json:"all_regions"`
|
||
RegionIDs []int64 `json:"region_ids"`
|
||
Locales []Locale `json:"locales"`
|
||
Gifts []Gift `json:"gifts"`
|
||
Tasks []Task `json:"tasks"`
|
||
DailyLeaderboardSize int32 `json:"daily_leaderboard_size"`
|
||
TotalLeaderboardSize int32 `json:"total_leaderboard_size"`
|
||
RankRewards []RankReward `json:"rank_rewards"`
|
||
Assets []Asset `json:"assets"`
|
||
DisplayConfigJSON string `json:"display_config_json"`
|
||
Revision int64 `json:"revision"`
|
||
PublishedVersion int64 `json:"published_version"`
|
||
CreatedByAdminID int64 `json:"created_by_admin_id"`
|
||
UpdatedByAdminID int64 `json:"updated_by_admin_id"`
|
||
PublishedByAdminID int64 `json:"published_by_admin_id"`
|
||
CreatedAtMS int64 `json:"created_at_ms"`
|
||
UpdatedAtMS int64 `json:"updated_at_ms"`
|
||
PublishedAtMS int64 `json:"published_at_ms"`
|
||
ArchivedAtMS int64 `json:"archived_at_ms"`
|
||
}
|
||
|
||
// Summary 是列表专用轻量投影,只附带区域范围,不加载规则、任务、榜单奖励和素材大字段。
|
||
type Summary struct {
|
||
AppCode string
|
||
TemplateID string
|
||
TemplateCode string
|
||
Name string
|
||
ActivityType string
|
||
Status string
|
||
LifecycleStatus string
|
||
StartMS int64
|
||
EndMS int64
|
||
AllRegions bool
|
||
RegionIDs []int64
|
||
Revision int64
|
||
PublishedVersion int64
|
||
CreatedByAdminID int64
|
||
UpdatedByAdminID int64
|
||
CreatedAtMS int64
|
||
UpdatedAtMS int64
|
||
}
|
||
|
||
// ListQuery 是后台列表筛选。Status 同时接受持久状态和 scheduled/ongoing/ended 生命周期状态。
|
||
type ListQuery struct {
|
||
Keyword string
|
||
Status string
|
||
RegionID *int64
|
||
AllRegions *bool
|
||
StartMS int64
|
||
EndMS int64
|
||
Page int32
|
||
PageSize int32
|
||
NowMS int64
|
||
}
|
||
|
||
// UpdateCommand 承载整份配置替换;子配置必须和主表在一个事务里提交,避免读到半份模板。
|
||
type UpdateCommand struct {
|
||
Template Template
|
||
ExpectedRevision int64
|
||
OperatorAdminID int64
|
||
}
|
||
|
||
// StatusCommand 是发布、停用和软归档的乐观锁命令。
|
||
type StatusCommand struct {
|
||
TemplateID string
|
||
Status string
|
||
ExpectedRevision int64
|
||
OperatorAdminID int64
|
||
RewardSnapshots map[int64]RewardSnapshot
|
||
}
|
||
|
||
// Version 是一次发布的不可变快照。Snapshot 让后台可以审阅历史版本,运行侧也能按版本稳定读取配置。
|
||
type Version struct {
|
||
TemplateID string
|
||
VersionNo int64
|
||
Snapshot Template
|
||
PublishedByAdminID int64
|
||
PublishedAtMS int64
|
||
RuntimeFromMS int64
|
||
RuntimeToMS int64
|
||
}
|
||
|
||
// CloneCommand 明确复制源版本和目标业务编码;源版本为 0 时复制当前编辑态配置。
|
||
type CloneCommand struct {
|
||
SourceTemplateID string
|
||
SourceVersion int64
|
||
TemplateCode string
|
||
Name string
|
||
OperatorAdminID int64
|
||
}
|
||
|
||
// ValidationIssue 是可绑定到表单字段的稳定校验结果;Code 给前端做国际化,Message 便于后台直接展示。
|
||
type ValidationIssue struct {
|
||
Field string
|
||
Code string
|
||
Message string
|
||
}
|