Refactor: Remove deprecated gRPC service files and implement new API structure
- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`. - Added new API server implementations for objectstory, player, and shop services. - Introduced configuration files for new APIs in `etc/*.yaml`. - Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`. - Removed unused user update handler and user API files. - Added utility functions for context management and HTTP header parsing. - Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ type (
|
||||
prefix: api/v1/chat
|
||||
group: chat
|
||||
)
|
||||
service juwan-api {
|
||||
service chat-api {
|
||||
@doc "获取会话列表"
|
||||
@handler ListSessions
|
||||
get /sessions (PageReq) returns (ChatSessionListResp)
|
||||
|
||||
+97
-101
@@ -1,121 +1,117 @@
|
||||
syntax = "v1"
|
||||
|
||||
import "common.api"
|
||||
|
||||
type (
|
||||
PathId {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
Post {
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []string `json:"images"`
|
||||
Tags []string `json:"tags"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
CommentCount int64 `json:"commentCount"`
|
||||
Liked bool `json:"liked"`
|
||||
Author UserProfile `json:"author"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
CreatePostReq {
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []string `json:"images"`
|
||||
Tags []string `json:"tags"`
|
||||
LinkedOrderId string `json:"linkedOrderId,optional"`
|
||||
}
|
||||
|
||||
PostListReq {
|
||||
PageReq
|
||||
Tags string `form:"tags,optional"`
|
||||
SortBy string `form:"sortBy,optional"`
|
||||
}
|
||||
|
||||
PostListResp {
|
||||
Items []Post `json:"items"`
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
|
||||
Comment {
|
||||
Id int64 `json:"id"`
|
||||
Content string `json:"content"`
|
||||
Author UserProfile `json:"author"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
Liked bool `json:"liked"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
CommentListResp {
|
||||
Items []Comment `json:"items"`
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
|
||||
CreateCommentReq {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
ListCommentsReq {
|
||||
PathId
|
||||
PageReq
|
||||
}
|
||||
PathId {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
Post {
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []string `json:"images"`
|
||||
Tags []string `json:"tags"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
CommentCount int64 `json:"commentCount"`
|
||||
Liked bool `json:"liked"`
|
||||
Author UserProfile `json:"author"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
CreatePostReq {
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []string `json:"images"`
|
||||
Tags []string `json:"tags"`
|
||||
LinkedOrderId string `json:"linkedOrderId,optional"`
|
||||
}
|
||||
PostListReq {
|
||||
PageReq
|
||||
Tags string `form:"tags,optional"`
|
||||
SortBy string `form:"sortBy,optional"`
|
||||
}
|
||||
PostListResp {
|
||||
Items []Post `json:"items"`
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
Comment {
|
||||
Id int64 `json:"id"`
|
||||
Content string `json:"content"`
|
||||
Author UserProfile `json:"author"`
|
||||
LikeCount int64 `json:"likeCount"`
|
||||
Liked bool `json:"liked"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
CommentListResp {
|
||||
Items []Comment `json:"items"`
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
CreateCommentReq {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
ListCommentsReq {
|
||||
PathId
|
||||
PageReq
|
||||
}
|
||||
)
|
||||
|
||||
@server(
|
||||
prefix: api/v1
|
||||
group: community
|
||||
@server (
|
||||
prefix: api/v1
|
||||
group: community
|
||||
)
|
||||
service juwan-api {
|
||||
@doc "获取帖子列表"
|
||||
@handler ListPosts
|
||||
get /posts (PostListReq) returns (PostListResp)
|
||||
service community-api {
|
||||
@doc "获取帖子列表"
|
||||
@handler ListPosts
|
||||
get /posts (PostListReq) returns (PostListResp)
|
||||
|
||||
@doc "获取帖子详情"
|
||||
@handler GetPost
|
||||
get /posts/:id (PathId) returns (Post)
|
||||
@doc "获取帖子详情"
|
||||
@handler GetPost
|
||||
get /posts/:id (PathId) returns (Post)
|
||||
|
||||
@doc "获取帖子评论"
|
||||
@handler ListComments
|
||||
get /posts/:id/comments (ListCommentsReq ) returns (CommentListResp)
|
||||
@doc "获取帖子评论"
|
||||
@handler ListComments
|
||||
get /posts/:id/comments (ListCommentsReq) returns (CommentListResp)
|
||||
|
||||
@doc "获取用户帖子"
|
||||
@handler ListUserPosts
|
||||
get /users/:id/posts (ListCommentsReq ) returns (PostListResp)
|
||||
@doc "获取用户帖子"
|
||||
@handler ListUserPosts
|
||||
get /users/:id/posts (ListCommentsReq) returns (PostListResp)
|
||||
}
|
||||
|
||||
@server(
|
||||
prefix: api/v1
|
||||
group: community
|
||||
@server (
|
||||
prefix: api/v1
|
||||
group: community
|
||||
)
|
||||
service juwan-api {
|
||||
@doc "发布帖子"
|
||||
@handler CreatePost
|
||||
post /posts (CreatePostReq) returns (Post)
|
||||
service community-api {
|
||||
@doc "发布帖子"
|
||||
@handler CreatePost
|
||||
post /posts (CreatePostReq) returns (Post)
|
||||
|
||||
@doc "点赞帖子"
|
||||
@handler LikePost
|
||||
post /posts/:id/like (PathId) returns (EmptyResp)
|
||||
@doc "点赞帖子"
|
||||
@handler LikePost
|
||||
post /posts/:id/like (PathId) returns (EmptyResp)
|
||||
|
||||
@doc "取消点赞帖子"
|
||||
@handler UnlikePost
|
||||
delete /posts/:id/like (PathId) returns (EmptyResp)
|
||||
@doc "取消点赞帖子"
|
||||
@handler UnlikePost
|
||||
delete /posts/:id/like (PathId) returns (EmptyResp)
|
||||
|
||||
@doc "置顶帖子"
|
||||
@handler PinPost
|
||||
post /posts/:id/pin (PathId) returns (EmptyResp)
|
||||
@doc "置顶帖子"
|
||||
@handler PinPost
|
||||
post /posts/:id/pin (PathId) returns (EmptyResp)
|
||||
|
||||
@doc "取消置顶"
|
||||
@handler UnpinPost
|
||||
delete /posts/:id/pin (PathId) returns (EmptyResp)
|
||||
@doc "取消置顶"
|
||||
@handler UnpinPost
|
||||
delete /posts/:id/pin (PathId) returns (EmptyResp)
|
||||
|
||||
@doc "发表评论"
|
||||
@handler CreateComment
|
||||
post /posts/:id/comments (CreateCommentReq) returns (Comment)
|
||||
@doc "发表评论"
|
||||
@handler CreateComment
|
||||
post /posts/:id/comments (CreateCommentReq) returns (Comment)
|
||||
|
||||
@doc "点赞评论"
|
||||
@handler LikeComment
|
||||
post /comments/:id/like (PathId) returns (EmptyResp)
|
||||
@doc "点赞评论"
|
||||
@handler LikeComment
|
||||
post /comments/:id/like (PathId) returns (EmptyResp)
|
||||
|
||||
@doc "取消点赞评论"
|
||||
@handler UnlikeComment
|
||||
delete /comments/:id/like (PathId) returns (EmptyResp)
|
||||
}
|
||||
|
||||
@doc "取消点赞评论"
|
||||
@handler UnlikeComment
|
||||
delete /comments/:id/like (PathId) returns (EmptyResp)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ type (
|
||||
prefix: api/v1
|
||||
group: dispute
|
||||
)
|
||||
service juwan-api {
|
||||
service dispute-api {
|
||||
@doc "获取争议列表"
|
||||
@handler ListDisputes
|
||||
get /disputes (PageReq) returns (DisputeListResp)
|
||||
|
||||
@@ -25,7 +25,7 @@ type (
|
||||
prefix: api/v1
|
||||
group: notification
|
||||
)
|
||||
service juwan-api {
|
||||
service notifi-api {
|
||||
@doc "获取通知列表"
|
||||
@handler ListNotifications
|
||||
get /notifications (PageReq) returns (NotificationListResp)
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
syntax = "v1"
|
||||
import "common.api"
|
||||
import "player.api" // 为了使用 PlayerService 定义
|
||||
|
||||
type (
|
||||
PathId {
|
||||
@@ -52,7 +51,7 @@ type (
|
||||
prefix: api/v1/orders
|
||||
group: order
|
||||
)
|
||||
service juwan-api {
|
||||
service order-api {
|
||||
@doc "获取订单列表"
|
||||
@handler ListOrders
|
||||
get / (OrderListReq) returns (OrderListResp)
|
||||
|
||||
+2
-2
@@ -83,7 +83,7 @@ type (
|
||||
prefix: api/v1
|
||||
group: player
|
||||
)
|
||||
service juwan-api {
|
||||
service player-api {
|
||||
@doc "获取打手列表"
|
||||
@handler ListPlayers
|
||||
get /players (PlayerListReq) returns (PlayerListResp)
|
||||
@@ -115,7 +115,7 @@ type (
|
||||
prefix: api/v1
|
||||
group: player
|
||||
)
|
||||
service juwan-api {
|
||||
service player-api {
|
||||
@doc "更新接单状态"
|
||||
@handler UpdatePlayerStatus
|
||||
put /players/me/status (UpdatePlayerStatusReq) returns (EmptyResp)
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ service juwan-api {
|
||||
prefix: api/v1
|
||||
group: review
|
||||
)
|
||||
service juwan-api {
|
||||
service review-api {
|
||||
@doc "获取公开评价列表"
|
||||
@handler ListReviews
|
||||
get /reviews (PageReq) returns (ReviewListResp)
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ service juwan-api {
|
||||
prefix: api/v1
|
||||
group: favorites
|
||||
)
|
||||
service juwan-api {
|
||||
service search-api {
|
||||
@doc "获取收藏列表"
|
||||
@handler ListFavorites
|
||||
get /favorites (PageReq) returns (SearchResp)
|
||||
|
||||
+21
-21
@@ -9,11 +9,11 @@ type (
|
||||
Name string `json:"name"`
|
||||
Banner string `json:"banner,optional"`
|
||||
Description string `json:"description"`
|
||||
Rating float64 `json:"rating"`
|
||||
Rating string `json:"rating"`
|
||||
TotalOrders int64 `json:"totalOrders"`
|
||||
PlayerCount int64 `json:"playerCount"`
|
||||
CommissionType string `json:"commissionType"`
|
||||
CommissionValue float64 `json:"commissionValue"`
|
||||
CommissionValue string `json:"commissionValue"`
|
||||
Announcements []string `json:"announcements"`
|
||||
TemplateConfig interface{} `json:"templateConfig"`
|
||||
}
|
||||
@@ -22,20 +22,20 @@ type (
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
CreateShopReq {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
CommissionType string `json:"commissionType"`
|
||||
CommissionValue float64 `json:"commissionValue"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
CommissionType string `json:"commissionType"`
|
||||
CommissionValue string `json:"commissionValue"`
|
||||
}
|
||||
UpdateShopReq {
|
||||
Id int64 `path:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
Description string `json:"description,optional"`
|
||||
CommissionType string `json:"commissionType,optional"`
|
||||
CommissionValue float64 `json:"commissionValue,optional"`
|
||||
AllowMultiShop bool `json:"allowMultiShop,optional"`
|
||||
AllowIndependentOrders bool `json:"allowIndependentOrders,optional"`
|
||||
DispatchMode string `json:"dispatchMode,optional"`
|
||||
Id int64 `path:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
Description string `json:"description,optional"`
|
||||
CommissionType string `json:"commissionType,optional"`
|
||||
CommissionValue string `json:"commissionValue,optional"`
|
||||
AllowMultiShop bool `json:"allowMultiShop,optional"`
|
||||
AllowIndependentOrders bool `json:"allowIndependentOrders,optional"`
|
||||
DispatchMode string `json:"dispatchMode,optional"`
|
||||
}
|
||||
UpdateTemplateReq {
|
||||
Id int64 `path:"id"`
|
||||
@@ -46,11 +46,11 @@ type (
|
||||
Content string `json:"content"`
|
||||
}
|
||||
IncomeStatsResp {
|
||||
MonthlyIncome float64 `json:"monthlyIncome"`
|
||||
PendingSettlement float64 `json:"pendingSettlement"`
|
||||
TotalWithdrawn float64 `json:"totalWithdrawn"`
|
||||
TotalOrders int64 `json:"totalOrders"`
|
||||
CompletedOrders int64 `json:"completedOrders"`
|
||||
MonthlyIncome string `json:"monthlyIncome"`
|
||||
PendingSettlement string `json:"pendingSettlement"`
|
||||
TotalWithdrawn string `json:"totalWithdrawn"`
|
||||
TotalOrders int64 `json:"totalOrders"`
|
||||
CompletedOrders int64 `json:"completedOrders"`
|
||||
}
|
||||
InvitationReq {
|
||||
Id int64 `path:"id"`
|
||||
@@ -71,7 +71,7 @@ type (
|
||||
prefix: api/v1
|
||||
group: shop
|
||||
)
|
||||
service juwan-api {
|
||||
service shop-api {
|
||||
@doc "获取店铺列表"
|
||||
@handler ListShops
|
||||
get /shops (PageReq) returns (ShopListResp)
|
||||
@@ -99,7 +99,7 @@ type (
|
||||
prefix: api/v1
|
||||
group: shop
|
||||
)
|
||||
service juwan-api {
|
||||
service shop-api {
|
||||
@doc "创建店铺"
|
||||
@handler CreateShop
|
||||
post /shops (CreateShopReq) returns (ShopProfile)
|
||||
|
||||
+5
-5
@@ -70,8 +70,8 @@ type (
|
||||
Role string `json:"role"` // consumer, player, owner, admin
|
||||
VerifiedRoles []string `json:"verifiedRoles"` // e.g. ["consumer", "player"]
|
||||
VerificationStatus map[string]string `json:"verificationStatus"` // e.g. {"player": "approved"}
|
||||
Phone string `json:"phone,omitempty"`
|
||||
Bio string `json:"bio,omitempty"`
|
||||
Phone string `json:"phone,omitempty,optional "`
|
||||
Bio string `json:"bio,omitempty,optional "`
|
||||
CreatedAt string `json:"createdAt"` // ISO 8601
|
||||
}
|
||||
)
|
||||
@@ -81,8 +81,8 @@ type (
|
||||
// =================================================================================
|
||||
type (
|
||||
RegisterReq {
|
||||
Phone string `json:"phone,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Phone string `json:"phone,omitempty,optional"`
|
||||
Email string `json:"email,omitempty,"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Vcode string `json:"vcode,omitempty"` // 验证码
|
||||
@@ -93,7 +93,7 @@ type (
|
||||
User User `json:"user"`
|
||||
}
|
||||
LoginReq {
|
||||
Phone string `json:"phone,omitempty"` // 手机号登录
|
||||
Phone string `json:"phone,omitempty,optional"` // 手机号登录
|
||||
Username string `json:"username,omitempty"` // 或用户名登录
|
||||
Password string `json:"password"`
|
||||
Remember bool `json:"remember,optional"`
|
||||
|
||||
+39
-40
@@ -1,50 +1,49 @@
|
||||
syntax = "v1"
|
||||
|
||||
import "common.api"
|
||||
|
||||
type (
|
||||
WalletBalance {
|
||||
Balance float64 `json:"balance"`
|
||||
FrozenBalance float64 `json:"frozenBalance"`
|
||||
}
|
||||
|
||||
Transaction {
|
||||
Id int64 `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Amount float64 `json:"amount"`
|
||||
Description string `json:"description"`
|
||||
OrderId string `json:"orderId,optional"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
TransactionListResp {
|
||||
Items []Transaction `json:"items"`
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
|
||||
TopupReq {
|
||||
Amount float64 `json:"amount"`
|
||||
Method string `json:"method"`
|
||||
}
|
||||
WalletBalance {
|
||||
Balance string `json:"balance"`
|
||||
FrozenBalance string `json:"frozenBalance"`
|
||||
}
|
||||
Transaction {
|
||||
Id int64 `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Amount string `json:"amount"`
|
||||
Description string `json:"description"`
|
||||
OrderId string `json:"orderId,optional"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
TransactionListResp {
|
||||
Items []Transaction `json:"items"`
|
||||
Meta PageMeta `json:"meta"`
|
||||
}
|
||||
TopupReq {
|
||||
Amount string `json:"amount"`
|
||||
Method string `json:"method"`
|
||||
}
|
||||
)
|
||||
|
||||
@server(
|
||||
prefix: api/v1/wallet
|
||||
group: wallet
|
||||
@server (
|
||||
prefix: api/v1/wallet
|
||||
group: wallet
|
||||
)
|
||||
service juwan-api {
|
||||
@doc "获取余额"
|
||||
@handler GetBalance
|
||||
get /balance (EmptyResp) returns (WalletBalance)
|
||||
service wallet-api {
|
||||
@doc "获取余额"
|
||||
@handler GetBalance
|
||||
get /balance (EmptyResp) returns (WalletBalance)
|
||||
|
||||
@doc "获取流水"
|
||||
@handler ListTransactions
|
||||
get /transactions (PageReq) returns (TransactionListResp)
|
||||
@doc "获取流水"
|
||||
@handler ListTransactions
|
||||
get /transactions (PageReq) returns (TransactionListResp)
|
||||
|
||||
@doc "充值"
|
||||
@handler Topup
|
||||
post /topup (TopupReq) returns (EmptyResp)
|
||||
@doc "充值"
|
||||
@handler Topup
|
||||
post /topup (TopupReq) returns (EmptyResp)
|
||||
|
||||
@doc "提现"
|
||||
@handler Withdraw
|
||||
post /withdraw (TopupReq) returns (EmptyResp)
|
||||
}
|
||||
|
||||
@doc "提现"
|
||||
@handler Withdraw
|
||||
post /withdraw (TopupReq) returns (EmptyResp)
|
||||
}
|
||||
Reference in New Issue
Block a user