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)
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package ="./pb";
|
||||
|
||||
package pb;
|
||||
|
||||
// ------------------------------------
|
||||
// Messages
|
||||
// ------------------------------------
|
||||
|
||||
//--------------------------------commentLikes--------------------------------
|
||||
message CommentLikes {
|
||||
int64 commentId = 1; //commentId
|
||||
int64 userId = 2; //userId
|
||||
int64 createdAt = 3; //createdAt
|
||||
}
|
||||
|
||||
message AddCommentLikesReq {
|
||||
int64 commentId = 1; //commentId
|
||||
int64 userId = 2; //userId
|
||||
int64 createdAt = 3; //createdAt
|
||||
}
|
||||
|
||||
message AddCommentLikesResp {
|
||||
}
|
||||
|
||||
message UpdateCommentLikesReq {
|
||||
int64 commentId = 1; //commentId
|
||||
int64 userId = 2; //userId
|
||||
int64 createdAt = 3; //createdAt
|
||||
}
|
||||
|
||||
message UpdateCommentLikesResp {
|
||||
}
|
||||
|
||||
message DelCommentLikesReq {
|
||||
int64 id = 1; //id
|
||||
optional int64 userId = 2; //userId
|
||||
}
|
||||
|
||||
message DelCommentLikesResp {
|
||||
}
|
||||
|
||||
message GetCommentLikesByIdReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message GetCommentLikesByIdResp {
|
||||
CommentLikes commentLikes = 1; //commentLikes
|
||||
}
|
||||
|
||||
message SearchCommentLikesReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
int64 commentId = 3; //commentId
|
||||
int64 userId = 4; //userId
|
||||
int64 createdAt = 5; //createdAt
|
||||
}
|
||||
|
||||
message SearchCommentLikesResp {
|
||||
repeated CommentLikes commentLikes = 1; //commentLikes
|
||||
}
|
||||
|
||||
//--------------------------------comments--------------------------------
|
||||
message Comments {
|
||||
int64 id = 1; //id
|
||||
int64 postId = 2; //postId
|
||||
int64 authorId = 3; //authorId
|
||||
string content = 4; //content
|
||||
int64 likeCount = 5; //likeCount
|
||||
int64 createdAt = 6; //createdAt
|
||||
int64 deletedAt = 7; //deletedAt
|
||||
}
|
||||
|
||||
message AddCommentsReq {
|
||||
int64 postId = 1; //postId
|
||||
int64 authorId = 2; //authorId
|
||||
string content = 3; //content
|
||||
int64 likeCount = 4; //likeCount
|
||||
int64 createdAt = 5; //createdAt
|
||||
int64 deletedAt = 6; //deletedAt
|
||||
}
|
||||
|
||||
message AddCommentsResp {
|
||||
}
|
||||
|
||||
message UpdateCommentsReq {
|
||||
int64 id = 1; //id
|
||||
int64 postId = 2; //postId
|
||||
int64 authorId = 3; //authorId
|
||||
string content = 4; //content
|
||||
int64 likeCount = 5; //likeCount
|
||||
int64 createdAt = 6; //createdAt
|
||||
int64 deletedAt = 7; //deletedAt
|
||||
}
|
||||
|
||||
message UpdateCommentsResp {
|
||||
}
|
||||
|
||||
message DelCommentsReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message DelCommentsResp {
|
||||
}
|
||||
|
||||
message GetCommentsByIdReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message GetCommentsByIdResp {
|
||||
Comments comments = 1; //comments
|
||||
}
|
||||
|
||||
message SearchCommentsReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
int64 id = 3; //id
|
||||
int64 postId = 4; //postId
|
||||
int64 authorId = 5; //authorId
|
||||
optional string content = 6; //content
|
||||
optional int64 likeCount = 7; //likeCount
|
||||
int64 createdAt = 8; //createdAt
|
||||
int64 deletedAt = 9; //deletedAt
|
||||
}
|
||||
|
||||
message SearchCommentsResp {
|
||||
repeated Comments comments = 1; //comments
|
||||
}
|
||||
|
||||
//--------------------------------postLikes--------------------------------
|
||||
message PostLikes {
|
||||
int64 postId = 1; //postId
|
||||
int64 userId = 2; //userId
|
||||
int64 createdAt = 3; //createdAt
|
||||
}
|
||||
|
||||
message AddPostLikesReq {
|
||||
int64 postId = 1; //postId
|
||||
int64 userId = 2; //userId
|
||||
int64 createdAt = 3; //createdAt
|
||||
}
|
||||
|
||||
message AddPostLikesResp {
|
||||
}
|
||||
|
||||
message UpdatePostLikesReq {
|
||||
optional int64 postId = 1; //postId
|
||||
optional int64 userId = 2; //userId
|
||||
int64 createdAt = 3; //createdAt
|
||||
}
|
||||
|
||||
message UpdatePostLikesResp {
|
||||
}
|
||||
|
||||
message DelPostLikesReq {
|
||||
int64 id = 1; //id
|
||||
optional int64 userId = 2; //userId
|
||||
}
|
||||
|
||||
message DelPostLikesResp {
|
||||
}
|
||||
|
||||
message GetPostLikesByIdReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message GetPostLikesByIdResp {
|
||||
PostLikes postLikes = 1; //postLikes
|
||||
}
|
||||
|
||||
message SearchPostLikesReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
optional int64 postId = 3; //postId
|
||||
optional int64 userId = 4; //userId
|
||||
int64 createdAt = 5; //createdAt
|
||||
}
|
||||
|
||||
message SearchPostLikesResp {
|
||||
repeated PostLikes postLikes = 1; //postLikes
|
||||
}
|
||||
|
||||
//--------------------------------posts--------------------------------
|
||||
message Posts {
|
||||
int64 id = 1; //id
|
||||
int64 authorId = 2; //authorId
|
||||
string authorRole = 3; //authorRole
|
||||
string title = 4; //title
|
||||
string content = 5; //content
|
||||
repeated string images = 6; //images
|
||||
repeated string tags = 7; //tags
|
||||
int64 linkedOrderId = 8; //linkedOrderId
|
||||
int64 quotedPostId = 9; //quotedPostId
|
||||
int64 likeCount = 10; //likeCount
|
||||
int64 commentCount = 11; //commentCount
|
||||
bool pinned = 12; //pinned
|
||||
string searchText = 13; //searchText
|
||||
int64 createdAt = 14; //createdAt
|
||||
int64 updatedAt = 15; //updatedAt
|
||||
int64 deletedAt = 16; //deletedAt
|
||||
}
|
||||
|
||||
message AddPostsReq {
|
||||
int64 authorId = 1; //authorId
|
||||
string authorRole = 2; //authorRole
|
||||
string title = 3; //title
|
||||
string content = 4; //content
|
||||
repeated string images = 5; //images
|
||||
repeated string tags = 6; //tags
|
||||
int64 linkedOrderId = 7; //linkedOrderId
|
||||
int64 quotedPostId = 8; //quotedPostId
|
||||
int64 likeCount = 9; //likeCount
|
||||
int64 commentCount = 10; //commentCount
|
||||
bool pinned = 11; //pinned
|
||||
string searchText = 12; //searchText
|
||||
int64 createdAt = 13; //createdAt
|
||||
int64 updatedAt = 14; //updatedAt
|
||||
int64 deletedAt = 15; //deletedAt
|
||||
}
|
||||
|
||||
message AddPostsResp {
|
||||
}
|
||||
|
||||
message UpdatePostsReq {
|
||||
int64 id = 1; //id
|
||||
optional int64 authorId = 2; //authorId
|
||||
optional string authorRole = 3; //authorRole
|
||||
optional string title = 4; //title
|
||||
optional string content = 5; //content
|
||||
repeated string images = 6; //images
|
||||
repeated string tags = 7; //tags
|
||||
optional int64 linkedOrderId = 8; //linkedOrderId
|
||||
optional int64 quotedPostId = 9; //quotedPostId
|
||||
optional int64 likeCount = 10; //likeCount
|
||||
optional int64 commentCount = 11; //commentCount
|
||||
optional bool pinned = 12; //pinned
|
||||
optional string searchText = 13; //searchText
|
||||
optional int64 createdAt = 14; //createdAt
|
||||
optional int64 updatedAt = 15; //updatedAt
|
||||
optional int64 deletedAt = 16; //deletedAt
|
||||
}
|
||||
|
||||
message UpdatePostsResp {
|
||||
}
|
||||
|
||||
message DelPostsReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message DelPostsResp {
|
||||
}
|
||||
|
||||
message GetPostsByIdReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message GetPostsByIdResp {
|
||||
Posts posts = 1; //posts
|
||||
}
|
||||
|
||||
message SearchPostsReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
int64 id = 3; //id
|
||||
optional int64 authorId = 4; //authorId
|
||||
optional string authorRole = 5; //authorRole
|
||||
optional string title = 6; //title
|
||||
optional string content = 7; //content
|
||||
repeated string images = 8; //images
|
||||
repeated string tags = 9; //tags
|
||||
optional int64 linkedOrderId = 10; //linkedOrderId
|
||||
optional int64 quotedPostId = 11; //quotedPostId
|
||||
optional int64 likeCount = 12; //likeCount
|
||||
optional int64 commentCount = 13; //commentCount
|
||||
optional bool pinned = 14; //pinned
|
||||
optional string searchText = 15; //searchText
|
||||
optional int64 createdAt = 16; //createdAt
|
||||
optional int64 updatedAt = 17; //updatedAt
|
||||
optional int64 deletedAt = 18; //deletedAt
|
||||
}
|
||||
|
||||
message SearchPostsResp {
|
||||
repeated Posts posts = 1; //posts
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// Rpc Func
|
||||
// ------------------------------------
|
||||
|
||||
service communityService{
|
||||
|
||||
//-----------------------commentLikes-----------------------
|
||||
rpc AddCommentLikes(AddCommentLikesReq) returns (AddCommentLikesResp);
|
||||
rpc UpdateCommentLikes(UpdateCommentLikesReq) returns (UpdateCommentLikesResp);
|
||||
rpc DelCommentLikes(DelCommentLikesReq) returns (DelCommentLikesResp);
|
||||
rpc GetCommentLikesById(GetCommentLikesByIdReq) returns (GetCommentLikesByIdResp);
|
||||
rpc SearchCommentLikes(SearchCommentLikesReq) returns (SearchCommentLikesResp);
|
||||
//-----------------------comments-----------------------
|
||||
rpc AddComments(AddCommentsReq) returns (AddCommentsResp);
|
||||
rpc UpdateComments(UpdateCommentsReq) returns (UpdateCommentsResp);
|
||||
rpc DelComments(DelCommentsReq) returns (DelCommentsResp);
|
||||
rpc GetCommentsById(GetCommentsByIdReq) returns (GetCommentsByIdResp);
|
||||
rpc SearchComments(SearchCommentsReq) returns (SearchCommentsResp);
|
||||
//-----------------------postLikes-----------------------
|
||||
rpc AddPostLikes(AddPostLikesReq) returns (AddPostLikesResp);
|
||||
rpc UpdatePostLikes(UpdatePostLikesReq) returns (UpdatePostLikesResp);
|
||||
rpc DelPostLikes(DelPostLikesReq) returns (DelPostLikesResp);
|
||||
rpc GetPostLikesById(GetPostLikesByIdReq) returns (GetPostLikesByIdResp);
|
||||
rpc SearchPostLikes(SearchPostLikesReq) returns (SearchPostLikesResp);
|
||||
//-----------------------posts-----------------------
|
||||
rpc AddPosts(AddPostsReq) returns (AddPostsResp);
|
||||
rpc UpdatePosts(UpdatePostsReq) returns (UpdatePostsResp);
|
||||
rpc DelPosts(DelPostsReq) returns (DelPostsResp);
|
||||
rpc GetPostsById(GetPostsByIdReq) returns (GetPostsByIdResp);
|
||||
rpc SearchPosts(SearchPostsReq) returns (SearchPostsResp);
|
||||
|
||||
}
|
||||
+8
-8
@@ -66,13 +66,13 @@ message SearchGamesReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
int64 id = 3; //id
|
||||
string name = 4; //name
|
||||
string icon = 5; //icon
|
||||
string category = 6; //category
|
||||
int64 sortOrder = 7; //sortOrder
|
||||
bool isActive = 8; //isActive
|
||||
int64 createdAt = 9; //createdAt
|
||||
int64 updatedAt = 10; //updatedAt
|
||||
optional string name = 4; //name
|
||||
optional string icon = 5; //icon
|
||||
optional string category = 6; //category
|
||||
optional int64 sortOrder = 7; //sortOrder
|
||||
optional bool isActive = 8; //isActive
|
||||
optional int64 createdAt = 9; //createdAt
|
||||
optional int64 updatedAt = 10; //updatedAt
|
||||
}
|
||||
|
||||
message SearchGamesResp {
|
||||
@@ -85,7 +85,7 @@ message SearchGamesResp {
|
||||
// Rpc Func
|
||||
// ------------------------------------
|
||||
|
||||
service public{
|
||||
service GameService {
|
||||
|
||||
//-----------------------games-----------------------
|
||||
rpc AddGames(AddGamesReq) returns (AddGamesResp);
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package ="./pb";
|
||||
|
||||
package pb;
|
||||
|
||||
// ------------------------------------
|
||||
// Messages
|
||||
// ------------------------------------
|
||||
|
||||
//--------------------------------orders--------------------------------
|
||||
message Orders {
|
||||
int64 id = 1; //id
|
||||
int64 consumerId = 2; //consumerId
|
||||
string consumerName = 3; //consumerName
|
||||
int64 playerId = 4; //playerId
|
||||
string playerName = 5; //playerName
|
||||
optional int64 shopId = 6; //shopId
|
||||
optional string shopName = 7; //shopName
|
||||
string serviceSnapshot = 8; //serviceSnapshot
|
||||
string status = 9; //status
|
||||
string totalPrice = 10; //totalPrice
|
||||
optional string note = 11; //note
|
||||
int64 version = 12; //version
|
||||
optional string timeoutJobId = 13; //timeoutJobId
|
||||
string searchText = 14; //searchText
|
||||
int64 createdAt = 15; //createdAt
|
||||
optional int64 acceptedAt = 16; //acceptedAt
|
||||
optional int64 closedAt = 17; //closedAt
|
||||
optional int64 completedAt = 18; //completedAt
|
||||
optional int64 cancelledAt = 19; //cancelledAt
|
||||
int64 updatedAt = 20; //updatedAt
|
||||
}
|
||||
|
||||
message AddOrdersReq {
|
||||
int64 id = 1; //id
|
||||
int64 consumerId = 2; //consumerId
|
||||
string consumerName = 3; //consumerName
|
||||
int64 playerId = 4; //playerId
|
||||
string playerName = 5; //playerName
|
||||
optional int64 shopId = 6; //shopId
|
||||
optional string shopName = 7; //shopName
|
||||
string serviceSnapshot = 8; //serviceSnapshot
|
||||
optional string status = 9; //status
|
||||
string totalPrice = 10; //totalPrice
|
||||
optional string note = 11; //note
|
||||
optional int64 version = 12; //version
|
||||
optional string timeoutJobId = 13; //timeoutJobId
|
||||
optional string searchText = 14; //searchText
|
||||
optional int64 createdAt = 15; //createdAt
|
||||
optional int64 acceptedAt = 16; //acceptedAt
|
||||
optional int64 closedAt = 17; //closedAt
|
||||
optional int64 completedAt = 18; //completedAt
|
||||
optional int64 cancelledAt = 19; //cancelledAt
|
||||
optional int64 updatedAt = 20; //updatedAt
|
||||
}
|
||||
|
||||
message AddOrdersResp {
|
||||
}
|
||||
|
||||
message UpdateOrdersReq {
|
||||
int64 id = 1; //id
|
||||
optional int64 consumerId = 2; //consumerId
|
||||
optional string consumerName = 3; //consumerName
|
||||
optional int64 playerId = 4; //playerId
|
||||
optional string playerName = 5; //playerName
|
||||
optional int64 shopId = 6; //shopId
|
||||
optional string shopName = 7; //shopName
|
||||
optional string serviceSnapshot = 8; //serviceSnapshot
|
||||
optional string status = 9; //status
|
||||
optional string totalPrice = 10; //totalPrice
|
||||
optional string note = 11; //note
|
||||
optional int64 version = 12; //version
|
||||
optional string timeoutJobId = 13; //timeoutJobId
|
||||
optional string searchText = 14; //searchText
|
||||
optional int64 createdAt = 15; //createdAt
|
||||
optional int64 acceptedAt = 16; //acceptedAt
|
||||
optional int64 closedAt = 17; //closedAt
|
||||
optional int64 completedAt = 18; //completedAt
|
||||
optional int64 cancelledAt = 19; //cancelledAt
|
||||
optional int64 updatedAt = 20; //updatedAt
|
||||
}
|
||||
|
||||
message UpdateOrdersResp {
|
||||
}
|
||||
|
||||
message DelOrdersReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message DelOrdersResp {
|
||||
}
|
||||
|
||||
message GetOrdersByIdReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message GetOrdersByIdResp {
|
||||
Orders orders = 1; //orders
|
||||
}
|
||||
|
||||
message SearchOrdersReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
optional int64 id = 3; //id
|
||||
optional int64 consumerId = 4; //consumerId
|
||||
optional string consumerName = 5; //consumerName
|
||||
optional int64 playerId = 6; //playerId
|
||||
optional string playerName = 7; //playerName
|
||||
optional int64 shopId = 8; //shopId
|
||||
optional string shopName = 9; //shopName
|
||||
optional string serviceSnapshot = 10; //serviceSnapshot
|
||||
optional string status = 11; //status
|
||||
optional string totalPrice = 12; //totalPrice
|
||||
optional string note = 13; //note
|
||||
optional int64 version = 14; //version
|
||||
optional string timeoutJobId = 15; //timeoutJobId
|
||||
optional string searchText = 16; //searchText
|
||||
optional int64 createdAt = 17; //createdAt
|
||||
optional int64 acceptedAt = 18; //acceptedAt
|
||||
optional int64 closedAt = 19; //closedAt
|
||||
optional int64 completedAt = 20; //completedAt
|
||||
optional int64 cancelledAt = 21; //cancelledAt
|
||||
optional int64 updatedAt = 22; //updatedAt
|
||||
}
|
||||
|
||||
message SearchOrdersResp {
|
||||
repeated Orders orders = 1; //orders
|
||||
}
|
||||
|
||||
//--------------------------------orderStateLogs--------------------------------
|
||||
message OrderStateLogs {
|
||||
int64 id = 1; //id
|
||||
int64 orderId = 2; //orderId
|
||||
optional string fromStatus = 3; //fromStatus
|
||||
string toStatus = 4; //toStatus
|
||||
string action = 5; //action
|
||||
int64 actorId = 6; //actorId
|
||||
string actorRole = 7; //actorRole
|
||||
optional string metadata = 8; //metadata
|
||||
int64 createdAt = 9; //createdAt
|
||||
}
|
||||
|
||||
message AddOrderStateLogsReq {
|
||||
int64 id = 1; //id
|
||||
int64 orderId = 2; //orderId
|
||||
optional string fromStatus = 3; //fromStatus
|
||||
string toStatus = 4; //toStatus
|
||||
string action = 5; //action
|
||||
int64 actorId = 6; //actorId
|
||||
string actorRole = 7; //actorRole
|
||||
optional string metadata = 8; //metadata
|
||||
optional int64 createdAt = 9; //createdAt
|
||||
}
|
||||
|
||||
message AddOrderStateLogsResp {
|
||||
}
|
||||
|
||||
message UpdateOrderStateLogsReq {
|
||||
int64 id = 1; //id
|
||||
optional int64 orderId = 2; //orderId
|
||||
optional string fromStatus = 3; //fromStatus
|
||||
optional string toStatus = 4; //toStatus
|
||||
optional string action = 5; //action
|
||||
optional int64 actorId = 6; //actorId
|
||||
optional string actorRole = 7; //actorRole
|
||||
optional string metadata = 8; //metadata
|
||||
optional int64 createdAt = 9; //createdAt
|
||||
}
|
||||
|
||||
message UpdateOrderStateLogsResp {
|
||||
}
|
||||
|
||||
message DelOrderStateLogsReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message DelOrderStateLogsResp {
|
||||
}
|
||||
|
||||
message GetOrderStateLogsByIdReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message GetOrderStateLogsByIdResp {
|
||||
OrderStateLogs orderStateLogs = 1; //orderStateLogs
|
||||
}
|
||||
|
||||
message SearchOrderStateLogsReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
optional int64 id = 3; //id
|
||||
optional int64 orderId = 4; //orderId
|
||||
optional string fromStatus = 5; //fromStatus
|
||||
optional string toStatus = 6; //toStatus
|
||||
optional string action = 7; //action
|
||||
optional int64 actorId = 8; //actorId
|
||||
optional string actorRole = 9; //actorRole
|
||||
optional string metadata = 10; //metadata
|
||||
optional int64 createdAt = 11; //createdAt
|
||||
}
|
||||
|
||||
message SearchOrderStateLogsResp {
|
||||
repeated OrderStateLogs orderStateLogs = 1; //orderStateLogs
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
// Rpc Func
|
||||
// ------------------------------------
|
||||
|
||||
service orderService {
|
||||
//-----------------------orders-----------------------
|
||||
rpc AddOrders(AddOrdersReq) returns (AddOrdersResp);
|
||||
rpc UpdateOrders(UpdateOrdersReq) returns (UpdateOrdersResp);
|
||||
rpc DelOrders(DelOrdersReq) returns (DelOrdersResp);
|
||||
rpc GetOrdersById(GetOrdersByIdReq) returns (GetOrdersByIdResp);
|
||||
rpc SearchOrders(SearchOrdersReq) returns (SearchOrdersResp);
|
||||
|
||||
//-----------------------orderStateLogs-----------------------
|
||||
rpc AddOrderStateLogs(AddOrderStateLogsReq) returns (AddOrderStateLogsResp);
|
||||
rpc UpdateOrderStateLogs(UpdateOrderStateLogsReq) returns (UpdateOrderStateLogsResp);
|
||||
rpc DelOrderStateLogs(DelOrderStateLogsReq) returns (DelOrderStateLogsResp);
|
||||
rpc GetOrderStateLogsById(GetOrderStateLogsByIdReq) returns (GetOrderStateLogsByIdResp);
|
||||
rpc SearchOrderStateLogs(SearchOrderStateLogsReq) returns (SearchOrderStateLogsResp);
|
||||
}
|
||||
+9
-8
@@ -42,6 +42,7 @@ message UpdateShopInvitationsReq {
|
||||
}
|
||||
|
||||
message UpdateShopInvitationsResp {
|
||||
ShopInvitations shopInvitations = 1;
|
||||
}
|
||||
|
||||
message DelShopInvitationsReq {
|
||||
@@ -142,11 +143,11 @@ message Shops {
|
||||
string name = 3; //name
|
||||
string banner = 4; //banner
|
||||
string description = 5; //description
|
||||
double rating = 6; //rating
|
||||
string rating = 6; //rating
|
||||
int64 totalOrders = 7; //totalOrders
|
||||
int64 playerCount = 8; //playerCount
|
||||
string commissionType = 9; //commissionType
|
||||
double commissionValue = 10; //commissionValue
|
||||
string commissionValue = 10; //commissionValue
|
||||
bool allowMultiShop = 11; //allowMultiShop
|
||||
bool allowIndependentOrders = 12; //allowIndependentOrders
|
||||
string dispatchMode = 13; //dispatchMode
|
||||
@@ -161,11 +162,11 @@ message AddShopsReq {
|
||||
string name = 2; //name
|
||||
string banner = 3; //banner
|
||||
string description = 4; //description
|
||||
double rating = 5; //rating
|
||||
string rating = 5; //rating
|
||||
int64 totalOrders = 6; //totalOrders
|
||||
int64 playerCount = 7; //playerCount
|
||||
string commissionType = 8; //commissionType
|
||||
double commissionValue = 9; //commissionValue
|
||||
string commissionValue = 9; //commissionValue
|
||||
bool allowMultiShop = 10; //allowMultiShop
|
||||
bool allowIndependentOrders = 11; //allowIndependentOrders
|
||||
string dispatchMode = 12; //dispatchMode
|
||||
@@ -184,11 +185,11 @@ message UpdateShopsReq {
|
||||
string name = 3; //name
|
||||
string banner = 4; //banner
|
||||
string description = 5; //description
|
||||
double rating = 6; //rating
|
||||
string rating = 6; //rating
|
||||
int64 totalOrders = 7; //totalOrders
|
||||
int64 playerCount = 8; //playerCount
|
||||
string commissionType = 9; //commissionType
|
||||
double commissionValue = 10; //commissionValue
|
||||
string commissionValue = 10; //commissionValue
|
||||
bool allowMultiShop = 11; //allowMultiShop
|
||||
bool allowIndependentOrders = 12; //allowIndependentOrders
|
||||
string dispatchMode = 13; //dispatchMode
|
||||
@@ -224,11 +225,11 @@ message SearchShopsReq {
|
||||
string name = 5; //name
|
||||
string banner = 6; //banner
|
||||
string description = 7; //description
|
||||
double rating = 8; //rating
|
||||
string rating = 8; //rating
|
||||
int64 totalOrders = 9; //totalOrders
|
||||
int64 playerCount = 10; //playerCount
|
||||
string commissionType = 11; //commissionType
|
||||
double commissionValue = 12; //commissionValue
|
||||
string commissionValue = 12; //commissionValue
|
||||
bool allowMultiShop = 13; //allowMultiShop
|
||||
bool allowIndependentOrders = 14; //allowIndependentOrders
|
||||
string dispatchMode = 15; //dispatchMode
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package ="./pb";
|
||||
|
||||
package pb;
|
||||
|
||||
// ------------------------------------
|
||||
// Messages
|
||||
// ------------------------------------
|
||||
|
||||
//--------------------------------walletTransactions--------------------------------
|
||||
message WalletTransactions {
|
||||
int64 id = 1; //id
|
||||
int64 userId = 2; //userId
|
||||
string type = 3; //type
|
||||
string amount = 4; //amount
|
||||
string balanceAfter = 5; //balanceAfter
|
||||
string description = 6; //description
|
||||
int64 orderId = 7; //orderId
|
||||
int64 createdAt = 8; //createdAt
|
||||
string searchText = 9; //searchText
|
||||
}
|
||||
|
||||
message AddWalletTransactionsReq {
|
||||
int64 userId = 1; //userId
|
||||
string type = 2; //type
|
||||
string amount = 3; //amount
|
||||
string balanceAfter = 4; //balanceAfter
|
||||
string description = 5; //description
|
||||
int64 orderId = 6; //orderId
|
||||
int64 createdAt = 7; //createdAt
|
||||
string searchText = 8; //searchText
|
||||
}
|
||||
|
||||
message AddWalletTransactionsResp {
|
||||
}
|
||||
|
||||
message UpdateWalletTransactionsReq {
|
||||
int64 id = 1; //id
|
||||
optional int64 userId = 2; //userId
|
||||
optional string type = 3; //type
|
||||
optional string amount = 4; //amount
|
||||
optional string balanceAfter = 5; //balanceAfter
|
||||
optional string description = 6; //description
|
||||
optional int64 orderId = 7; //orderId
|
||||
optional int64 createdAt = 8; //createdAt
|
||||
optional string searchText = 9; //searchText
|
||||
}
|
||||
|
||||
message UpdateWalletTransactionsResp {
|
||||
}
|
||||
|
||||
message DelWalletTransactionsReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message DelWalletTransactionsResp {
|
||||
}
|
||||
|
||||
message GetWalletTransactionsByIdReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message GetWalletTransactionsByIdResp {
|
||||
WalletTransactions walletTransactions = 1; //walletTransactions
|
||||
}
|
||||
|
||||
message SearchWalletTransactionsReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
int64 id = 3; //id
|
||||
optional int64 userId = 4; //userId
|
||||
optional string type = 5; //type
|
||||
optional string amount = 6; //amount
|
||||
optional string balanceAfter = 7; //balanceAfter
|
||||
optional string description = 8; //description
|
||||
optional int64 orderId = 9; //orderId
|
||||
optional int64 createdAt = 10; //createdAt
|
||||
optional string searchText = 11; //searchText
|
||||
}
|
||||
|
||||
message SearchWalletTransactionsResp {
|
||||
repeated WalletTransactions walletTransactions = 1; //walletTransactions
|
||||
}
|
||||
|
||||
//--------------------------------wallets--------------------------------
|
||||
message Wallets {
|
||||
int64 userId = 1; //userId
|
||||
string balance = 2; //balance
|
||||
string frozenBalance = 3; //frozenBalance
|
||||
int64 updatedAt = 4; //updatedAt
|
||||
int64 version = 5; //version
|
||||
}
|
||||
|
||||
message AddWalletsReq {
|
||||
int64 userId = 1; //userId
|
||||
string balance = 2; //balance
|
||||
string frozenBalance = 3; //frozenBalance
|
||||
int64 updatedAt = 4; //updatedAt
|
||||
}
|
||||
|
||||
message AddWalletsResp {
|
||||
}
|
||||
|
||||
message UpdateWalletsReq {
|
||||
int64 userId = 1; //userId
|
||||
optional string balance = 2; //balance
|
||||
optional string frozenBalance = 3; //frozenBalance
|
||||
optional int64 updatedAt = 4; //updatedAt
|
||||
optional int64 version = 5; //version
|
||||
}
|
||||
|
||||
message UpdateWalletsResp {
|
||||
}
|
||||
|
||||
message DelWalletsReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message DelWalletsResp {
|
||||
}
|
||||
|
||||
message GetWalletsByIdReq {
|
||||
int64 id = 1; //id
|
||||
}
|
||||
|
||||
message GetWalletsByIdResp {
|
||||
Wallets wallets = 1; //wallets
|
||||
}
|
||||
|
||||
message SearchWalletsReq {
|
||||
int64 page = 1; //page
|
||||
int64 limit = 2; //limit
|
||||
int64 userId = 3; //userId
|
||||
optional string balance = 4; //balance
|
||||
optional string frozenBalance = 5; //frozenBalance
|
||||
optional int64 updatedAt = 6; //updatedAt
|
||||
}
|
||||
|
||||
message SearchWalletsResp {
|
||||
repeated Wallets wallets = 1; //wallets
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// Rpc Func
|
||||
// ------------------------------------
|
||||
|
||||
service walletService{
|
||||
|
||||
//-----------------------walletTransactions-----------------------
|
||||
rpc AddWalletTransactions(AddWalletTransactionsReq) returns (AddWalletTransactionsResp);
|
||||
rpc UpdateWalletTransactions(UpdateWalletTransactionsReq) returns (UpdateWalletTransactionsResp);
|
||||
rpc DelWalletTransactions(DelWalletTransactionsReq) returns (DelWalletTransactionsResp);
|
||||
rpc GetWalletTransactionsById(GetWalletTransactionsByIdReq) returns (GetWalletTransactionsByIdResp);
|
||||
rpc SearchWalletTransactions(SearchWalletTransactionsReq) returns (SearchWalletTransactionsResp);
|
||||
//-----------------------wallets-----------------------
|
||||
rpc AddWallets(AddWalletsReq) returns (AddWalletsResp);
|
||||
rpc UpdateWallets(UpdateWalletsReq) returns (UpdateWalletsResp);
|
||||
rpc DelWallets(DelWalletsReq) returns (DelWalletsResp);
|
||||
rpc GetWalletsById(GetWalletsByIdReq) returns (GetWalletsByIdResp);
|
||||
rpc SearchWallets(SearchWalletsReq) returns (SearchWalletsResp);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
CREATE TABLE comment_likes (
|
||||
comment_id BIGINT NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
CREATE TABLE comment_likes
|
||||
(
|
||||
comment_id BIGINT NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
PRIMARY KEY (comment_id, user_id)
|
||||
PRIMARY KEY (comment_id, user_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_comment_likes_lookup ON comment_likes(user_id, comment_id);
|
||||
CREATE INDEX idx_comment_likes_lookup ON comment_likes (user_id, comment_id);
|
||||
@@ -1,21 +1,22 @@
|
||||
CREATE TABLE comments (
|
||||
id BIGINT PRIMARY KEY,
|
||||
post_id BIGINT NOT NULL REFERENCES posts(id),
|
||||
author_id BIGINT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
like_count INT DEFAULT 0,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMPTZ
|
||||
CREATE TABLE comments
|
||||
(
|
||||
id BIGINT PRIMARY KEY,
|
||||
post_id BIGINT NOT NULL REFERENCES posts (id),
|
||||
author_id BIGINT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
like_count INT DEFAULT 0,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMPTZ
|
||||
);
|
||||
|
||||
-- 基础索引
|
||||
CREATE INDEX idx_comments_post ON comments(post_id, created_at) WHERE deleted_at IS NULL;
|
||||
CREATE INDEX idx_comments_author ON comments(author_id, created_at DESC) WHERE deleted_at IS NULL;
|
||||
CREATE INDEX idx_comments_post ON comments (post_id, created_at) WHERE deleted_at IS NULL;
|
||||
CREATE INDEX idx_comments_author ON comments (author_id, created_at DESC) WHERE deleted_at IS NULL;
|
||||
|
||||
-- 三元组索引用于评论内容搜索
|
||||
CREATE INDEX idx_comments_content_trgm ON comments USING gin(content gin_trgm_ops)
|
||||
CREATE INDEX idx_comments_content_trgm ON comments USING gin (content gin_trgm_ops)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
-- 热门评论索引
|
||||
CREATE INDEX idx_comments_post_likes ON comments(post_id, like_count DESC, created_at)
|
||||
CREATE INDEX idx_comments_post_likes ON comments (post_id, like_count DESC, created_at)
|
||||
WHERE deleted_at IS NULL;
|
||||
@@ -1,14 +1,15 @@
|
||||
CREATE TABLE post_likes (
|
||||
post_id BIGINT NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
CREATE TABLE post_likes
|
||||
(
|
||||
post_id BIGINT NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
-- 复合主键,防止重复点赞
|
||||
PRIMARY KEY (post_id, user_id)
|
||||
PRIMARY KEY (post_id, user_id)
|
||||
);
|
||||
|
||||
-- [核心索引] 优化 "feed流中判断我是否已赞" (user_id = ? AND post_id IN (...))
|
||||
CREATE INDEX idx_post_likes_lookup ON post_likes(user_id, post_id);
|
||||
CREATE INDEX idx_post_likes_lookup ON post_likes (user_id, post_id);
|
||||
|
||||
-- [核心索引] 优化 "我赞过的帖子" 列表
|
||||
CREATE INDEX idx_post_likes_user_timeline ON post_likes(user_id, created_at DESC);
|
||||
CREATE INDEX idx_post_likes_user_timeline ON post_likes (user_id, created_at DESC);
|
||||
@@ -1,17 +1,16 @@
|
||||
CREATE TABLE dispute_timeline (
|
||||
id BIGINT PRIMARY KEY,
|
||||
dispute_id BIGINT NOT NULL REFERENCES disputes(id),
|
||||
event_type VARCHAR(30) NOT NULL,
|
||||
actor_id BIGINT,
|
||||
actor_name VARCHAR(100),
|
||||
details JSONB,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
CREATE TABLE dispute_timeline
|
||||
(
|
||||
id BIGINT PRIMARY KEY,
|
||||
dispute_id BIGINT NOT NULL REFERENCES disputes (id),
|
||||
event_type VARCHAR(30) NOT NULL,
|
||||
actor_id BIGINT,
|
||||
actor_name VARCHAR(100),
|
||||
details JSONB,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT chk_event_type CHECK (event_type IN (
|
||||
'created', 'response', 'reviewing', 'resolved', 'appealed'
|
||||
))
|
||||
CONSTRAINT chk_event_type CHECK (event_type IN ('created', 'response', 'reviewing', 'resolved', 'appealed'))
|
||||
);
|
||||
|
||||
CREATE INDEX idx_timeline_dispute ON dispute_timeline(dispute_id, created_at);
|
||||
CREATE INDEX idx_timeline_dispute_created ON dispute_timeline(dispute_id, created_at);
|
||||
CREATE INDEX idx_timeline_dispute ON dispute_timeline (dispute_id, created_at);
|
||||
CREATE INDEX idx_timeline_dispute_created ON dispute_timeline (dispute_id, created_at);
|
||||
CREATE INDEX idx_timeline_details ON dispute_timeline USING gin(details);
|
||||
@@ -1,49 +1,51 @@
|
||||
CREATE TABLE disputes (
|
||||
id BIGINT PRIMARY KEY,
|
||||
order_id BIGINT NOT NULL UNIQUE,
|
||||
initiator_id BIGINT NOT NULL,
|
||||
initiator_name VARCHAR(100) NOT NULL,
|
||||
respondent_id BIGINT NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
evidence TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'open',
|
||||
result VARCHAR(30),
|
||||
respondent_reason TEXT,
|
||||
respondent_evidence TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
appeal_reason TEXT,
|
||||
appealed_at TIMESTAMPTZ,
|
||||
resolved_by BIGINT,
|
||||
resolved_at TIMESTAMPTZ,
|
||||
search_text TEXT GENERATED ALWAYS AS (
|
||||
initiator_name || ' ' || reason || ' ' || coalesce(respondent_reason, '') || ' ' || coalesce(appeal_reason, '')
|
||||
) STORED,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
CREATE TABLE disputes
|
||||
(
|
||||
id BIGINT PRIMARY KEY,
|
||||
order_id BIGINT NOT NULL UNIQUE,
|
||||
initiator_id BIGINT NOT NULL,
|
||||
initiator_name VARCHAR(100) NOT NULL,
|
||||
respondent_id BIGINT NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
evidence TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'open',
|
||||
result VARCHAR(30),
|
||||
respondent_reason TEXT,
|
||||
respondent_evidence TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
appeal_reason TEXT,
|
||||
appealed_at TIMESTAMPTZ,
|
||||
resolved_by BIGINT,
|
||||
resolved_at TIMESTAMPTZ,
|
||||
search_text TEXT GENERATED ALWAYS AS (initiator_name || ' ' || reason || ' ' ||
|
||||
coalesce(respondent_reason, '') || ' ' ||
|
||||
coalesce(appeal_reason, '')) STORED,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT chk_dispute_status CHECK (status IN ('open', 'reviewing', 'resolved', 'appealed')),
|
||||
CONSTRAINT chk_dispute_result CHECK (result IS NULL OR result IN ('full_refund', 'full_payment', 'partial_refund'))
|
||||
CONSTRAINT chk_dispute_status CHECK (status IN ('open', 'reviewing', 'resolved', 'appealed')),
|
||||
CONSTRAINT chk_dispute_result CHECK (result IS NULL OR result IN ('full_refund', 'full_payment', 'partial_refund'))
|
||||
);
|
||||
|
||||
-- 基础索引
|
||||
CREATE INDEX idx_disputes_order ON disputes(order_id);
|
||||
CREATE INDEX idx_disputes_status ON disputes(status, created_at DESC);
|
||||
CREATE INDEX idx_disputes_initiator ON disputes(initiator_id);
|
||||
CREATE INDEX idx_disputes_order ON disputes (order_id);
|
||||
CREATE INDEX idx_disputes_status ON disputes (status, created_at DESC);
|
||||
CREATE INDEX idx_disputes_initiator ON disputes (initiator_id);
|
||||
|
||||
-- 三元组索引用于争议内容搜索
|
||||
CREATE INDEX idx_disputes_search_trgm ON disputes USING gin(search_text gin_trgm_ops);
|
||||
|
||||
-- 复合索引优化状态查询
|
||||
CREATE INDEX idx_disputes_status_created ON disputes(status, created_at DESC);
|
||||
CREATE INDEX idx_disputes_status_created ON disputes (status, created_at DESC);
|
||||
|
||||
-- 参与者索引
|
||||
CREATE INDEX idx_disputes_initiator_status ON disputes(initiator_id, status, created_at DESC);
|
||||
CREATE INDEX idx_disputes_respondent_status ON disputes(respondent_id, status, created_at DESC);
|
||||
CREATE INDEX idx_disputes_initiator_status ON disputes (initiator_id, status, created_at DESC);
|
||||
CREATE INDEX idx_disputes_respondent_status ON disputes (respondent_id, status, created_at DESC);
|
||||
|
||||
-- 数组索引优化证据查询
|
||||
CREATE INDEX idx_disputes_evidence ON disputes USING gin(evidence);
|
||||
CREATE INDEX idx_disputes_respondent_evidence ON disputes USING gin(respondent_evidence);
|
||||
|
||||
CREATE TRIGGER trigger_disputes_updated_at
|
||||
BEFORE UPDATE ON disputes
|
||||
BEFORE UPDATE
|
||||
ON disputes
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION update_updated_at_column();
|
||||
+24
-24
@@ -1,37 +1,37 @@
|
||||
CREATE TABLE reviews (
|
||||
id BIGINT PRIMARY KEY,
|
||||
order_id BIGINT NOT NULL,
|
||||
from_user_id BIGINT NOT NULL,
|
||||
from_user_name VARCHAR(100) NOT NULL,
|
||||
from_user_avatar TEXT,
|
||||
to_user_id BIGINT NOT NULL,
|
||||
rating SMALLINT NOT NULL,
|
||||
content TEXT,
|
||||
sealed BOOLEAN DEFAULT TRUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
unsealed_at TIMESTAMPTZ,
|
||||
|
||||
CONSTRAINT chk_rating_range CHECK (rating >= 1 AND rating <= 5),
|
||||
UNIQUE(order_id, from_user_id)
|
||||
CREATE TABLE reviews
|
||||
(
|
||||
id BIGINT PRIMARY KEY,
|
||||
order_id BIGINT NOT NULL,
|
||||
from_user_id BIGINT NOT NULL,
|
||||
from_user_name VARCHAR(100) NOT NULL,
|
||||
from_user_avatar TEXT,
|
||||
to_user_id BIGINT NOT NULL,
|
||||
rating SMALLINT NOT NULL,
|
||||
content TEXT,
|
||||
sealed BOOLEAN DEFAULT TRUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
unsealed_at TIMESTAMPTZ,
|
||||
CONSTRAINT chk_rating_range CHECK (rating >= 1 AND rating <= 5),
|
||||
UNIQUE (order_id, from_user_id)
|
||||
);
|
||||
|
||||
-- 基础索引
|
||||
CREATE INDEX idx_reviews_order ON reviews(order_id);
|
||||
CREATE INDEX idx_reviews_to_user ON reviews(to_user_id, created_at
|
||||
|
||||
CREATE INDEX idx_reviews_to_user ON reviews(to_user_id, created_at DESC) WHERE sealed = FALSE;
|
||||
CREATE INDEX idx_reviews_from_user ON reviews(from_user_id);
|
||||
CREATE INDEX idx_reviews_order ON reviews (order_id);
|
||||
CREATE INDEX idx_reviews_to_user ON reviews (to_user_id, created_at
|
||||
CREATE INDEX idx_reviews_to_user ON reviews(to_user_id, created_at DESC)
|
||||
WHERE sealed = FALSE;
|
||||
CREATE INDEX idx_reviews_from_user ON reviews (from_user_id);
|
||||
|
||||
-- 三元组索引用于评价内容搜索
|
||||
CREATE INDEX idx_reviews_content_trgm ON reviews USING gin(content gin_trgm_ops)
|
||||
CREATE INDEX idx_reviews_content_trgm ON reviews USING gin (content gin_trgm_ops)
|
||||
WHERE sealed = FALSE AND content IS NOT NULL;
|
||||
|
||||
-- 复合索引优化用户评价列表
|
||||
CREATE INDEX idx_reviews_to_user_rating ON reviews(to_user_id, rating DESC, created_at DESC)
|
||||
CREATE INDEX idx_reviews_to_user_rating ON reviews (to_user_id, rating DESC, created_at DESC)
|
||||
WHERE sealed = FALSE;
|
||||
|
||||
-- 复合索引优化订单评价查询
|
||||
CREATE INDEX idx_reviews_order_sealed ON reviews(order_id, sealed);
|
||||
CREATE INDEX idx_reviews_order_sealed ON reviews (order_id, sealed);
|
||||
|
||||
-- 评分统计索引
|
||||
CREATE INDEX idx_reviews_rating_created ON reviews(rating, created_at DESC) WHERE sealed = FALSE;
|
||||
CREATE INDEX idx_reviews_rating_created ON reviews (rating, created_at DESC) WHERE sealed = FALSE;
|
||||
@@ -1,33 +1,33 @@
|
||||
CREATE TABLE wallet_transactions (
|
||||
id BIGINT PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
type VARCHAR(20) NOT NULL,
|
||||
amount DECIMAL(12,2) NOT NULL,
|
||||
balance_after DECIMAL(12,2) NOT NULL,
|
||||
description VARCHAR(500) NOT NULL,
|
||||
order_id BIGINT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
search_text TEXT GENERATED ALWAYS AS (
|
||||
type || ' ' || description
|
||||
) STORED,
|
||||
CREATE TABLE wallet_transactions
|
||||
(
|
||||
id BIGINT PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
type VARCHAR(20) NOT NULL,
|
||||
amount DECIMAL(12, 2) NOT NULL,
|
||||
balance_after DECIMAL(12, 2) NOT NULL,
|
||||
description VARCHAR(500) NOT NULL,
|
||||
order_id BIGINT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
search_text TEXT GENERATED ALWAYS AS (
|
||||
type || ' ' || description
|
||||
) STORED,
|
||||
|
||||
CONSTRAINT chk_transaction_type CHECK (type IN ('topup', 'payment', 'income', 'withdrawal', 'refund'))
|
||||
CONSTRAINT chk_transaction_type CHECK (type IN ('topup', 'payment', 'income', 'withdrawal', 'refund'))
|
||||
);
|
||||
|
||||
-- 基础索引
|
||||
CREATE INDEX idx_transactions_user ON wallet_transactions(user_id, created_at DESC);
|
||||
CREATE INDEX idx_transactions_order ON wallet_transactions(order_id) WHERE order_id IS NOT NULL;
|
||||
CREATE INDEX idx_transactions_type ON wallet_transactions(user_id, type, created_at DESC);
|
||||
CREATE INDEX idx_transactions_user ON wallet_transactions (user_id, created_at DESC);
|
||||
CREATE INDEX idx_transactions_order ON wallet_transactions (order_id) WHERE order_id IS NOT NULL;
|
||||
CREATE INDEX idx_transactions_type ON wallet_transactions (user_id, type, created_at DESC);
|
||||
|
||||
-- 三元组索引用于交易描述搜索
|
||||
CREATE INDEX idx_transactions_search_trgm ON wallet_transactions USING gin(search_text gin_trgm_ops);
|
||||
|
||||
-- 复合索引优化用户交易查询
|
||||
CREATE INDEX idx_transactions_user_type_created ON wallet_transactions(user_id, type, created_at DESC);
|
||||
CREATE INDEX idx_transactions_user_type_created ON wallet_transactions (user_id, type, created_at DESC);
|
||||
|
||||
-- 时间范围索引 (用于统计)
|
||||
CREATE INDEX idx_transactions_created_amount ON wallet_transactions(created_at DESC, amount);
|
||||
CREATE INDEX idx_transactions_created_amount ON wallet_transactions (created_at DESC, amount);
|
||||
|
||||
-- 订单关联索引
|
||||
CREATE INDEX idx_transactions_order_type ON wallet_transactions(order_id, type)
|
||||
WHERE order_id IS NOT NULL;
|
||||
CREATE INDEX idx_transactions_order_type ON wallet_transactions (order_id, type) WHERE order_id IS NOT NULL;
|
||||
+12
-10
@@ -1,17 +1,19 @@
|
||||
CREATE TABLE wallets (
|
||||
user_id BIGINT PRIMARY KEY,
|
||||
balance DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
frozen_balance DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
version INT NOT NULL DEFAULT 1, -- 必须使用乐观锁
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
CREATE TABLE wallets
|
||||
(
|
||||
user_id BIGINT PRIMARY KEY,
|
||||
balance DECIMAL(12, 2) NOT NULL DEFAULT 0.00,
|
||||
frozen_balance DECIMAL(12, 2) NOT NULL DEFAULT 0.00,
|
||||
version INT NOT NULL DEFAULT 1, -- 必须使用乐观锁
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT chk_balance_non_negative CHECK (balance >= 0),
|
||||
CONSTRAINT chk_frozen_non_negative CHECK (frozen_balance >= 0)
|
||||
CONSTRAINT chk_balance_non_negative CHECK (balance >= 0),
|
||||
CONSTRAINT chk_frozen_non_negative CHECK (frozen_balance >= 0)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_wallets_updated ON wallets(updated_at DESC);
|
||||
CREATE INDEX idx_wallets_updated ON wallets (updated_at DESC);
|
||||
|
||||
CREATE TRIGGER trigger_wallets_updated_at
|
||||
BEFORE UPDATE ON wallets
|
||||
BEFORE UPDATE
|
||||
ON wallets
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION update_updated_at_column();
|
||||
Reference in New Issue
Block a user