Version: 0.9.78.dev.260506
This commit is contained in:
145
backend/shared/contracts/taskclassforum/types.go
Normal file
145
backend/shared/contracts/taskclassforum/types.go
Normal file
@@ -0,0 +1,145 @@
|
||||
package taskclassforum
|
||||
|
||||
// PageResult 是计划广场分页响应的跨层契约。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 只描述分页元数据,不负责查询和排序逻辑;
|
||||
// 2. Items 由具体接口决定,避免为了 P0 引入复杂泛型到 RPC 边界;
|
||||
// 3. HTTP 层和 RPC 层需要保持字段语义一致。
|
||||
type PageResult struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
Total int `json:"total"`
|
||||
HasMore bool `json:"has_more"`
|
||||
}
|
||||
|
||||
// UserBrief 是计划广场前端展示作者和评论人的最小用户信息。
|
||||
type UserBrief struct {
|
||||
UserID uint64 `json:"user_id"`
|
||||
Nickname string `json:"nickname"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
// TemplateSummary 是列表卡片里的模板摘要。
|
||||
type TemplateSummary struct {
|
||||
TaskCount int `json:"task_count"`
|
||||
Mode string `json:"mode"`
|
||||
StartDate string `json:"start_date"`
|
||||
EndDate string `json:"end_date"`
|
||||
StrategyLabels []string `json:"strategy_labels"`
|
||||
}
|
||||
|
||||
// ForumPostCounters 是帖子计数字段快照。
|
||||
type ForumPostCounters struct {
|
||||
LikeCount int64 `json:"like_count"`
|
||||
CommentCount int64 `json:"comment_count"`
|
||||
ImportCount int64 `json:"import_count"`
|
||||
}
|
||||
|
||||
// ForumPostViewerState 是当前登录用户相对该帖子的状态。
|
||||
type ForumPostViewerState struct {
|
||||
Liked bool `json:"liked"`
|
||||
ImportedOnce bool `json:"imported_once"`
|
||||
}
|
||||
|
||||
// ForumTagItem 是计划广场标签筛选区的最小展示单元。
|
||||
type ForumTagItem struct {
|
||||
Tag string `json:"tag"`
|
||||
PostCount int `json:"post_count"`
|
||||
}
|
||||
|
||||
// ForumPostBrief 是计划列表和详情头部共用的帖子摘要。
|
||||
type ForumPostBrief struct {
|
||||
PostID uint64 `json:"post_id"`
|
||||
Title string `json:"title"`
|
||||
Summary string `json:"summary"`
|
||||
Tags []string `json:"tags"`
|
||||
Author UserBrief `json:"author"`
|
||||
TemplateSummary TemplateSummary `json:"template_summary"`
|
||||
Counters ForumPostCounters `json:"counters"`
|
||||
ViewerState ForumPostViewerState `json:"viewer_state"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// TemplateItemPreview 是详情页展示的任务条目快照。
|
||||
type TemplateItemPreview struct {
|
||||
ItemID uint64 `json:"item_id"`
|
||||
Order int `json:"order"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// TemplateDetail 是论坛模板快照的前端展示结构。
|
||||
type TemplateDetail struct {
|
||||
Mode string `json:"mode"`
|
||||
StartDate string `json:"start_date"`
|
||||
EndDate string `json:"end_date"`
|
||||
StrategyLabels []string `json:"strategy_labels"`
|
||||
TaskCount int `json:"task_count"`
|
||||
ItemsPreview []TemplateItemPreview `json:"items_preview"`
|
||||
}
|
||||
|
||||
// ForumPostDetail 是计划详情接口响应主体。
|
||||
type ForumPostDetail struct {
|
||||
Post ForumPostBrief `json:"post"`
|
||||
Template TemplateDetail `json:"template"`
|
||||
}
|
||||
|
||||
// ForumCommentNode 是服务层组装后的多层评论树节点。
|
||||
type ForumCommentNode struct {
|
||||
CommentID uint64 `json:"comment_id"`
|
||||
PostID uint64 `json:"post_id"`
|
||||
ParentCommentID *uint64 `json:"parent_comment_id"`
|
||||
Content string `json:"content"`
|
||||
Status string `json:"status"`
|
||||
Author UserBrief `json:"author"`
|
||||
CanDelete bool `json:"can_delete"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
DeletedAt *string `json:"deleted_at"`
|
||||
Children []ForumCommentNode `json:"children"`
|
||||
}
|
||||
|
||||
// CreateForumPostRequest 是发布计划请求契约。
|
||||
type CreateForumPostRequest struct {
|
||||
ActorUserID uint64 `json:"actor_user_id"`
|
||||
TaskClassID uint64 `json:"task_class_id"`
|
||||
Title string `json:"title"`
|
||||
Summary string `json:"summary"`
|
||||
Tags []string `json:"tags"`
|
||||
IdempotencyKey string `json:"idempotency_key"`
|
||||
}
|
||||
|
||||
// CreateForumCommentRequest 是发表评论或回复请求契约。
|
||||
type CreateForumCommentRequest struct {
|
||||
ActorUserID uint64 `json:"actor_user_id"`
|
||||
PostID uint64 `json:"post_id"`
|
||||
Content string `json:"content"`
|
||||
ParentCommentID *uint64 `json:"parent_comment_id"`
|
||||
IdempotencyKey string `json:"idempotency_key"`
|
||||
}
|
||||
|
||||
// ImportForumPostRequest 是一键导入请求契约。
|
||||
type ImportForumPostRequest struct {
|
||||
ActorUserID uint64 `json:"actor_user_id"`
|
||||
PostID uint64 `json:"post_id"`
|
||||
TargetTitle string `json:"target_title"`
|
||||
IdempotencyKey string `json:"idempotency_key"`
|
||||
}
|
||||
|
||||
// DeleteForumCommentResult 是删除评论后的状态回执。
|
||||
type DeleteForumCommentResult struct {
|
||||
CommentID uint64 `json:"comment_id"`
|
||||
Status string `json:"status"`
|
||||
Content string `json:"content"`
|
||||
DeletedAt *string `json:"deleted_at"`
|
||||
}
|
||||
|
||||
// ImportForumPostResult 是一键导入后的回执。
|
||||
type ImportForumPostResult struct {
|
||||
ImportID uint64 `json:"import_id"`
|
||||
PostID uint64 `json:"post_id"`
|
||||
NewTaskClassID uint64 `json:"new_task_class_id"`
|
||||
TaskClassTitle string `json:"task_class_title"`
|
||||
ImportCount int64 `json:"import_count"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
125
backend/shared/contracts/tokenstore/types.go
Normal file
125
backend/shared/contracts/tokenstore/types.go
Normal file
@@ -0,0 +1,125 @@
|
||||
package tokenstore
|
||||
|
||||
// PageResult 是 token-store 分页响应的跨层契约。
|
||||
type PageResult struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
Total int `json:"total"`
|
||||
HasMore bool `json:"has_more"`
|
||||
}
|
||||
|
||||
// TokenSummary 是 Token 商店概览响应。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. P0 展示 token-store 已记录的获取事实;
|
||||
// 2. 不承诺这些 Token 已经同步到 user/auth 权威额度;
|
||||
// 3. 后续接入 user/auth 后可把 QuotaSyncStatus 调整为 synced。
|
||||
type TokenSummary struct {
|
||||
RecordedTokenTotal int64 `json:"recorded_token_total"`
|
||||
AppliedTokenTotal int64 `json:"applied_token_total"`
|
||||
PendingApplyTokenTotal int64 `json:"pending_apply_token_total"`
|
||||
QuotaSyncStatus string `json:"quota_sync_status"`
|
||||
Tip string `json:"tip"`
|
||||
}
|
||||
|
||||
// TokenProductView 是商品卡片展示结构。
|
||||
type TokenProductView struct {
|
||||
ProductID uint64 `json:"product_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
TokenAmount int64 `json:"token_amount"`
|
||||
PriceCent int64 `json:"price_cent"`
|
||||
PriceText string `json:"price_text"`
|
||||
Currency string `json:"currency"`
|
||||
Badge string `json:"badge"`
|
||||
Status string `json:"status"`
|
||||
SortOrder int `json:"sort_order"`
|
||||
}
|
||||
|
||||
// TokenGrantView 是 Token 获取记录展示结构。
|
||||
type TokenGrantView struct {
|
||||
GrantID uint64 `json:"grant_id"`
|
||||
EventID string `json:"event_id"`
|
||||
Source string `json:"source"`
|
||||
SourceLabel string `json:"source_label"`
|
||||
Amount int64 `json:"amount"`
|
||||
Status string `json:"status"`
|
||||
QuotaApplied bool `json:"quota_applied"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// TokenOrderView 是订单展示结构。
|
||||
type TokenOrderView struct {
|
||||
OrderID uint64 `json:"order_id"`
|
||||
OrderNo string `json:"order_no"`
|
||||
Status string `json:"status"`
|
||||
ProductSnapshot string `json:"product_snapshot"`
|
||||
ProductName string `json:"product_name"`
|
||||
Quantity int `json:"quantity"`
|
||||
TokenAmount int64 `json:"token_amount"`
|
||||
AmountCent int64 `json:"amount_cent"`
|
||||
PriceText string `json:"price_text"`
|
||||
Currency string `json:"currency"`
|
||||
PaymentMode string `json:"payment_mode"`
|
||||
Grant *TokenGrantView `json:"grant"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
PaidAt *string `json:"paid_at"`
|
||||
GrantedAt *string `json:"granted_at"`
|
||||
}
|
||||
|
||||
// CreateTokenOrderRequest 是创建订单请求契约。
|
||||
type CreateTokenOrderRequest struct {
|
||||
ActorUserID uint64 `json:"actor_user_id"`
|
||||
ProductID uint64 `json:"product_id"`
|
||||
Quantity int `json:"quantity"`
|
||||
IdempotencyKey string `json:"idempotency_key"`
|
||||
}
|
||||
|
||||
// ListTokenOrdersRequest 是订单列表查询契约。
|
||||
type ListTokenOrdersRequest struct {
|
||||
ActorUserID uint64 `json:"actor_user_id"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// MockPaidOrderRequest 是 P0 mock paid 请求契约。
|
||||
type MockPaidOrderRequest struct {
|
||||
ActorUserID uint64 `json:"actor_user_id"`
|
||||
OrderID uint64 `json:"order_id"`
|
||||
MockChannel string `json:"mock_channel"`
|
||||
IdempotencyKey string `json:"idempotency_key"`
|
||||
}
|
||||
|
||||
// ListTokenGrantsRequest 是 Token 获取记录列表查询契约。
|
||||
type ListTokenGrantsRequest struct {
|
||||
ActorUserID uint64 `json:"actor_user_id"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
// RecordForumRewardGrantRequest 是论坛奖励入账的内部 RPC 契约。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 只描述一条待记录到 token_grants 的论坛奖励事实;
|
||||
// 2. 不携带最终奖励金额,金额由 token-store 按 source 和配置解析;
|
||||
// 3. source_ref_id 使用字符串承接 post_id / import_id,服务层再按当前库表结构落成整数。
|
||||
type RecordForumRewardGrantRequest struct {
|
||||
EventID string `json:"event_id"`
|
||||
ReceiverUserID uint64 `json:"receiver_user_id"`
|
||||
Source string `json:"source"`
|
||||
SourceRefID string `json:"source_ref_id"`
|
||||
}
|
||||
|
||||
// TokenGrantRecord 是 token-store 内部发放出口使用的获取事实。
|
||||
type TokenGrantRecord struct {
|
||||
EventID string `json:"event_id"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
Source string `json:"source"`
|
||||
SourceRefID uint64 `json:"source_ref_id"`
|
||||
OrderID uint64 `json:"order_id"`
|
||||
Amount int64 `json:"amount"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
Reference in New Issue
Block a user