style: 自动格式化

This commit is contained in:
zetaloop
2026-04-25 04:53:15 +08:00
parent e9bb8fd8e3
commit 111c2f59dd
15 changed files with 333 additions and 337 deletions
+11 -11
View File
@@ -39,17 +39,17 @@ func toAPIOrder(in *orderservice.Orders) types.Order {
_ = json.Unmarshal([]byte(in.GetServiceSnapshot()), &service)
order = types.Order{
Id: in.GetId(),
ConsumerId: in.GetConsumerId(),
PlayerId: playerID,
ShopId: in.GetShopId(),
Service: service,
Status: in.GetStatus(),
TotalPrice: totalPrice,
Note: in.GetNote(),
CreatedAt: formatUnix(in.GetCreatedAt()),
AcceptedAt: formatUnix(in.GetAcceptedAt()),
CompletedAt: formatUnix(in.GetCompletedAt()),
Id: in.GetId(),
ConsumerId: in.GetConsumerId(),
PlayerId: playerID,
ShopId: in.GetShopId(),
Service: service,
Status: in.GetStatus(),
TotalPrice: totalPrice,
Note: in.GetNote(),
CreatedAt: formatUnix(in.GetCreatedAt()),
AcceptedAt: formatUnix(in.GetAcceptedAt()),
CompletedAt: formatUnix(in.GetCompletedAt()),
}
return order
+1 -1
View File
@@ -9,7 +9,7 @@ type Config struct {
zrpc.RpcServerConf
SnowflakeRpcConf zrpc.RpcClientConf
DB struct {
DB struct {
Master string
Slaves string
}
+1 -1
View File
@@ -9,7 +9,7 @@ type Config struct {
zrpc.RpcServerConf
SnowflakeRpcConf zrpc.RpcClientConf
DB struct {
DB struct {
Master string
Slaves string
}
+1 -1
View File
@@ -9,7 +9,7 @@ type Config struct {
zrpc.RpcServerConf
SnowflakeRpcConf zrpc.RpcClientConf
DB struct {
DB struct {
Master string
Slaves string
}
+20 -3
View File
@@ -26,9 +26,26 @@ PASSWORD = "test1234"
def psql(sql: str) -> str:
r = subprocess.run(
["docker", "exec", "-i", CONTAINER, "psql", "-U", DB_USER, "-d", DB_NAME,
"-v", "ON_ERROR_STOP=1", "--no-psqlrc", "-t", "-A"],
input=sql, capture_output=True, text=True, timeout=30,
[
"docker",
"exec",
"-i",
CONTAINER,
"psql",
"-U",
DB_USER,
"-d",
DB_NAME,
"-v",
"ON_ERROR_STOP=1",
"--no-psqlrc",
"-t",
"-A",
],
input=sql,
capture_output=True,
text=True,
timeout=30,
)
if r.returncode != 0:
print(f"psql error:\n{r.stderr}", file=sys.stderr)
+6 -2
View File
@@ -647,7 +647,9 @@ def phase6_player(s: Session, game_id):
return player_id, service_id
def phase7_shop(s_owner: Session, s_invited_player: Session, owner_user_id, invited_player_id):
def phase7_shop(
s_owner: Session, s_invited_player: Session, owner_user_id, invited_player_id
):
print("\n=== Phase 7: Shop ===")
s_owner.post(
@@ -1206,7 +1208,9 @@ def main():
phase2_user(s_user, user_id)
s_consumer.get(f"{GATEWAY}/healthz")
phase1_register(s_consumer, consumer_name, consumer_email, consumer_pass, label="consumer")
phase1_register(
s_consumer, consumer_name, consumer_email, consumer_pass, label="consumer"
)
consumer_login_resp = phase1_login(
s_consumer,
consumer_name,
+57 -63
View File
@@ -1,76 +1,70 @@
syntax = "v1"
import "common.api"
type (
SessionIdReq {
Id int64 `path:"id"`
}
CreateGroupReq {
Name string `json:"name"`
Participants []int64 `json:"participants,optional"`
}
CreateDMReq {
TargetId int64 `json:"targetId"`
}
ChatSession {
Id int64 `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
CreatorId int64 `json:"creatorId"`
Participants []int64 `json:"participants"`
LastMessage string `json:"lastMessage"`
LastMessageAt int64 `json:"lastMessageAt"`
CreatedAt int64 `json:"createdAt"`
}
ChatSessionListResp {
Items []ChatSession `json:"items"`
}
ChatMessage {
Id int64 `json:"id"`
SessionId int64 `json:"sessionId"`
SenderId int64 `json:"senderId"`
Type string `json:"type"`
Content string `json:"content"`
CreatedAt int64 `json:"createdAt"`
}
ChatMessageListResp {
Items []ChatMessage `json:"items"`
}
ListMessageReq {
SessionIdReq
PageReq
}
SessionIdReq {
Id int64 `path:"id"`
}
CreateGroupReq {
Name string `json:"name"`
Participants []int64 `json:"participants,optional"`
}
CreateDMReq {
TargetId int64 `json:"targetId"`
}
ChatSession {
Id int64 `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
CreatorId int64 `json:"creatorId"`
Participants []int64 `json:"participants"`
LastMessage string `json:"lastMessage"`
LastMessageAt int64 `json:"lastMessageAt"`
CreatedAt int64 `json:"createdAt"`
}
ChatSessionListResp {
Items []ChatSession `json:"items"`
}
ChatMessage {
Id int64 `json:"id"`
SessionId int64 `json:"sessionId"`
SenderId int64 `json:"senderId"`
Type string `json:"type"`
Content string `json:"content"`
CreatedAt int64 `json:"createdAt"`
}
ChatMessageListResp {
Items []ChatMessage `json:"items"`
}
ListMessageReq {
SessionIdReq
PageReq
}
)
@server(
prefix: api/v1/chat
group: chat
@server (
prefix: api/v1/chat
group: chat
)
service chat-api {
@doc "create group session"
@handler CreateGroup
post /sessions/group (CreateGroupReq) returns (ChatSession)
@doc "create group session"
@handler CreateGroup
post /sessions/group (CreateGroupReq) returns (ChatSession)
@doc "create dm session"
@handler CreateDM
post /sessions/dm (CreateDMReq) returns (ChatSession)
@doc "create dm session"
@handler CreateDM
post /sessions/dm (CreateDMReq) returns (ChatSession)
@doc "list user sessions"
@handler ListSessions
get /sessions (PageReq) returns (ChatSessionListResp)
@doc "list user sessions"
@handler ListSessions
get /sessions (PageReq) returns (ChatSessionListResp)
@doc "get session detail"
@handler GetSession
get /sessions/:id (SessionIdReq) returns (ChatSession)
@doc "get session detail"
@handler GetSession
get /sessions/:id (SessionIdReq) returns (ChatSession)
@doc "get message history"
@handler ListMessages
get /sessions/:id/messages (ListMessageReq) returns (ChatMessageListResp)
@doc "get message history"
@handler ListMessages
get /sessions/:id/messages (ListMessageReq) returns (ChatMessageListResp)
}
+37 -41
View File
@@ -1,47 +1,43 @@
syntax = "v1"
info(
title: "公共定义"
desc: "Common structures"
author: "Juwan Team"
version: "1.0"
info (
title: "公共定义"
desc: "Common structures"
author: "Juwan Team"
version: "1.0"
)
type (
// 分页请求基础
PageReq {
Offset int64 `form:"offset,default=0"`
Limit int64 `form:"limit,default=20"`
}
// 分页响应元数据
PageMeta {
Total int64 `json:"total"`
Offset int64 `json:"offset"`
Limit int64 `json:"limit"`
}
// 空响应
EmptyResp {}
// 核心用户画像 (被 Auth, Community, Shop 等多个服务引用)
UserProfile {
Id string `json:"id"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Role string `json:"role"` // consumer, player, owner, admin
VerifiedRoles []string `json:"verifiedRoles"`
VerificationStatus map[string]string `json:"verificationStatus"`
Phone string `json:"phone,optional"`
Bio string `json:"bio,optional"`
CreatedAt string `json:"createdAt"`
}
// 简略用户信息 (用于列表、聊天头像等)
SimpleUser {
Id string `json:"id"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
}
// 分页请求基础
PageReq {
Offset int64 `form:"offset,default=0"`
Limit int64 `form:"limit,default=20"`
}
// 分页响应元数据
PageMeta {
Total int64 `json:"total"`
Offset int64 `json:"offset"`
Limit int64 `json:"limit"`
}
// 空响应
EmptyResp {}
// 核心用户画像 (被 Auth, Community, Shop 等多个服务引用)
UserProfile {
Id string `json:"id"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Role string `json:"role"` // consumer, player, owner, admin
VerifiedRoles []string `json:"verifiedRoles"`
VerificationStatus map[string]string `json:"verificationStatus"`
Phone string `json:"phone,optional"`
Bio string `json:"bio,optional"`
CreatedAt string `json:"createdAt"`
}
// 简略用户信息 (用于列表、聊天头像等)
SimpleUser {
Id string `json:"id"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
}
)
+49 -52
View File
@@ -1,65 +1,62 @@
syntax = "v1"
import "common.api"
type (
PathId {
Id int64 `path:"id"`
}
Dispute {
Id int64 `json:"id"`
OrderId int64 `json:"orderId"`
Reason string `json:"reason"`
Status string `json:"status"`
Evidence []string `json:"evidence"`
Result string `json:"result,optional"`
CreatedAt string `json:"createdAt"`
}
DisputeListResp {
Items []Dispute `json:"items"`
Meta PageMeta `json:"meta"`
}
CreateDisputeReq {
PathId
Reason string `json:"reason"`
Evidence []string `json:"evidence"`
}
DisputeResponseReq {
PathId
Reason string `json:"reason"`
Evidence []string `json:"evidence"`
}
AppealReq {
PathId
Reason string `json:"reason"`
}
PathId {
Id int64 `path:"id"`
}
Dispute {
Id int64 `json:"id"`
OrderId int64 `json:"orderId"`
Reason string `json:"reason"`
Status string `json:"status"`
Evidence []string `json:"evidence"`
Result string `json:"result,optional"`
CreatedAt string `json:"createdAt"`
}
DisputeListResp {
Items []Dispute `json:"items"`
Meta PageMeta `json:"meta"`
}
CreateDisputeReq {
PathId
Reason string `json:"reason"`
Evidence []string `json:"evidence"`
}
DisputeResponseReq {
PathId
Reason string `json:"reason"`
Evidence []string `json:"evidence"`
}
AppealReq {
PathId
Reason string `json:"reason"`
}
)
@server(
prefix: api/v1
group: dispute
@server (
prefix: api/v1
group: dispute
)
service dispute-api {
@doc "获取争议列表"
@handler ListDisputes
get /disputes (PageReq) returns (DisputeListResp)
@doc "获取争议列表"
@handler ListDisputes
get /disputes (PageReq) returns (DisputeListResp)
@doc "获取订单争议"
@handler GetOrderDispute
get /orders/:id/dispute (PathId) returns (Dispute)
@doc "获取订单争议"
@handler GetOrderDispute
get /orders/:id/dispute (PathId) returns (Dispute)
@doc "发起争议"
@handler CreateDispute
post /orders/:id/dispute (CreateDisputeReq) returns (EmptyResp)
@doc "发起争议"
@handler CreateDispute
post /orders/:id/dispute (CreateDisputeReq) returns (EmptyResp)
@doc "回应争议"
@handler RespondDispute
post /disputes/:id/response (DisputeResponseReq) returns (EmptyResp)
@doc "回应争议"
@handler RespondDispute
post /disputes/:id/response (DisputeResponseReq) returns (EmptyResp)
@doc "申诉"
@handler AppealDispute
post /disputes/:id/appeal (AppealReq) returns (EmptyResp)
@doc "申诉"
@handler AppealDispute
post /disputes/:id/appeal (AppealReq) returns (EmptyResp)
}
+29 -29
View File
@@ -1,40 +1,40 @@
syntax = "v1"
import "common.api"
type (
PathId {
Id int64 `path:"id"`
}
Notification {
Id int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
Content string `json:"content"`
Read bool `json:"read"`
Link string `json:"link,optional"`
CreatedAt string `json:"createdAt"`
}
NotificationListResp {
Items []Notification `json:"items"`
Meta PageMeta `json:"meta"`
}
PathId {
Id int64 `path:"id"`
}
Notification {
Id int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
Content string `json:"content"`
Read bool `json:"read"`
Link string `json:"link,optional"`
CreatedAt string `json:"createdAt"`
}
NotificationListResp {
Items []Notification `json:"items"`
Meta PageMeta `json:"meta"`
}
)
@server(
prefix: api/v1
group: notification
@server (
prefix: api/v1
group: notification
)
service notifi-api {
@doc "获取通知列表"
@handler ListNotifications
get /notifications (PageReq) returns (NotificationListResp)
@doc "获取通知列表"
@handler ListNotifications
get /notifications (PageReq) returns (NotificationListResp)
@doc "标记已读"
@handler ReadNotification
put /notifications/:id/read (PathId) returns (EmptyResp)
@doc "标记已读"
@handler ReadNotification
put /notifications/:id/read (PathId) returns (EmptyResp)
@doc "全部已读"
@handler ReadAllNotifications
put /notifications/read-all (EmptyResp) returns (EmptyResp)
@doc "全部已读"
@handler ReadAllNotifications
put /notifications/read-all (EmptyResp) returns (EmptyResp)
}
+37 -38
View File
@@ -1,53 +1,52 @@
syntax = "v1"
import "common.api"
type (
Review {
Id int64 `json:"id"`
OrderId int64 `json:"orderId"`
FromUserId int64 `json:"fromUserId"`
FromUserName string `json:"fromUserName"`
Rating int `json:"rating"`
Content string `json:"content"`
Sealed bool `json:"sealed"`
CreatedAt string `json:"createdAt"`
}
ReviewListResp {
Items []Review `json:"items"`
Meta PageMeta `json:"meta"`
}
SubmitReviewReq {
Rating int `json:"rating"`
Content string `json:"content,optional"`
}
Review {
Id int64 `json:"id"`
OrderId int64 `json:"orderId"`
FromUserId int64 `json:"fromUserId"`
FromUserName string `json:"fromUserName"`
Rating int `json:"rating"`
Content string `json:"content"`
Sealed bool `json:"sealed"`
CreatedAt string `json:"createdAt"`
}
ReviewListResp {
Items []Review `json:"items"`
Meta PageMeta `json:"meta"`
}
SubmitReviewReq {
Rating int `json:"rating"`
Content string `json:"content,optional"`
}
)
@server(
prefix: api/v1
group: review
@server (
prefix: api/v1
group: review
)
service review-api {
@doc "提交评价"
@handler SubmitReview
post /orders/:id/review (SubmitReviewReq) returns (EmptyResp)
@doc "提交评价"
@handler SubmitReview
post /orders/:id/review (SubmitReviewReq) returns (EmptyResp)
@doc "获取订单评价"
@handler GetOrderReviews
get /orders/:id/reviews (EmptyResp) returns ([]Review)
@doc "获取订单评价"
@handler GetOrderReviews
get /orders/:id/reviews (EmptyResp) returns ([]Review)
}
@server(
prefix: api/v1
group: review
@server (
prefix: api/v1
group: review
)
service review-api {
@doc "获取公开评价列表"
@handler ListReviews
get /reviews (PageReq) returns (ReviewListResp)
@doc "获取公开评价列表"
@handler ListReviews
get /reviews (PageReq) returns (ReviewListResp)
@doc "获取用户收到的评价"
@handler ListUserReviews
get /users/:id/reviews (PageReq) returns (ReviewListResp)
@doc "获取用户收到的评价"
@handler ListUserReviews
get /users/:id/reviews (PageReq) returns (ReviewListResp)
}
+52 -55
View File
@@ -1,72 +1,69 @@
syntax = "v1"
import "common.api"
type (
PathIDReq {
Id int64 `path:"id"`
}
SearchReq {
PageReq
Q string `form:"q"`
MinPrice float64 `form:"min,optional"`
MaxPrice float64 `form:"max,optional"`
OnlyOnline bool `form:"onlyOnline,optional"`
Sort string `form:"sort,optional"`
}
SearchResp {
Items []interface{} `json:"items"` // Mixed items
Meta PageMeta `json:"meta"`
}
FavoriteReq {
TargetType string `json:"targetType"` // player, shop
TargetId int64 `json:"targetId"`
}
FavoriteCheckReq {
PathIDReq
TargetType string `form:"targetType"`
TargetId int64 `form:"targetId"`
}
FavoriteCheckResp {
Favorited bool `json:"favorited"`
}
PathIDReq {
Id int64 `path:"id"`
}
SearchReq {
PageReq
Q string `form:"q"`
MinPrice float64 `form:"min,optional"`
MaxPrice float64 `form:"max,optional"`
OnlyOnline bool `form:"onlyOnline,optional"`
Sort string `form:"sort,optional"`
}
SearchResp {
Items []interface{} `json:"items"` // Mixed items
Meta PageMeta `json:"meta"`
}
FavoriteReq {
TargetType string `json:"targetType"` // player, shop
TargetId int64 `json:"targetId"`
}
FavoriteCheckReq {
PathIDReq
TargetType string `form:"targetType"`
TargetId int64 `form:"targetId"`
}
FavoriteCheckResp {
Favorited bool `json:"favorited"`
}
)
@server(
prefix: api/v1
group: search
@server (
prefix: api/v1
group: search
)
service search-api {
@doc "统一搜索"
@handler Search
get /search (SearchReq) returns (SearchResp)
@doc "统一搜索"
@handler Search
get /search (SearchReq) returns (SearchResp)
@doc "首页推荐"
@handler Recommendations
get /recommendations/home (PageReq) returns (SearchResp)
@doc "首页推荐"
@handler Recommendations
get /recommendations/home (PageReq) returns (SearchResp)
}
@server(
prefix: api/v1
group: favorites
@server (
prefix: api/v1
group: favorites
)
service search-api {
@doc "获取收藏列表"
@handler ListFavorites
get /favorites (PageReq) returns (SearchResp)
@doc "获取收藏列表"
@handler ListFavorites
get /favorites (PageReq) returns (SearchResp)
@doc "添加收藏"
@handler AddFavorite
post /favorites (FavoriteReq) returns (EmptyResp)
@doc "添加收藏"
@handler AddFavorite
post /favorites (FavoriteReq) returns (EmptyResp)
@doc "取消收藏"
@handler RemoveFavorite
delete /favorites/:id (PathIDReq) returns (EmptyResp)
@doc "取消收藏"
@handler RemoveFavorite
delete /favorites/:id (PathIDReq) returns (EmptyResp)
@doc "检查收藏状态"
@handler CheckFavorite
get /users/:id/favorites/check (FavoriteCheckReq) returns (FavoriteCheckResp)
@doc "检查收藏状态"
@handler CheckFavorite
get /users/:id/favorites/check (FavoriteCheckReq) returns (FavoriteCheckResp)
}
+21 -29
View File
@@ -1,9 +1,9 @@
syntax = "proto3";
option go_package ="./pb";
package pb;
option go_package = "./pb";
// ------------------------------------
// Messages
// ------------------------------------
@@ -39,15 +39,13 @@ message UpdateChatSessionsReq {
optional int64 lastMessageAt = 4; //lastMessageAt
}
message UpdateChatSessionsResp {
}
message UpdateChatSessionsResp {}
message DelChatSessionsReq {
int64 id = 1; //id
}
message DelChatSessionsResp {
}
message DelChatSessionsResp {}
message GetChatSessionsByIdReq {
int64 id = 1; //id
@@ -73,16 +71,14 @@ message AddParticipantReq {
int64 userId = 2; //userId
}
message AddParticipantResp {
}
message AddParticipantResp {}
message RemoveParticipantReq {
int64 sessionId = 1; //sessionId
int64 userId = 2; //userId
}
message RemoveParticipantResp {
}
message RemoveParticipantResp {}
//--------------------------------chatMessages--------------------------------
message ChatMessages {
@@ -109,8 +105,7 @@ message DelChatMessagesReq {
int64 id = 1; //id
}
message DelChatMessagesResp {
}
message DelChatMessagesResp {}
message GetChatMessagesByIdReq {
int64 id = 1; //id
@@ -131,25 +126,22 @@ message SearchChatMessagesResp {
repeated ChatMessages chatMessages = 1; //chatMessages
}
// ------------------------------------
// Rpc Func
// ------------------------------------
service chatService{
//-----------------------chatSessions-----------------------
rpc AddChatSessions(AddChatSessionsReq) returns (AddChatSessionsResp);
rpc UpdateChatSessions(UpdateChatSessionsReq) returns (UpdateChatSessionsResp);
rpc DelChatSessions(DelChatSessionsReq) returns (DelChatSessionsResp);
rpc GetChatSessionsById(GetChatSessionsByIdReq) returns (GetChatSessionsByIdResp);
rpc SearchChatSessions(SearchChatSessionsReq) returns (SearchChatSessionsResp);
rpc AddParticipant(AddParticipantReq) returns (AddParticipantResp);
rpc RemoveParticipant(RemoveParticipantReq) returns (RemoveParticipantResp);
//-----------------------chatMessages-----------------------
rpc AddChatMessages(AddChatMessagesReq) returns (AddChatMessagesResp);
rpc DelChatMessages(DelChatMessagesReq) returns (DelChatMessagesResp);
rpc GetChatMessagesById(GetChatMessagesByIdReq) returns (GetChatMessagesByIdResp);
rpc SearchChatMessages(SearchChatMessagesReq) returns (SearchChatMessagesResp);
service chatService {
//-----------------------chatSessions-----------------------
rpc AddChatSessions(AddChatSessionsReq) returns (AddChatSessionsResp);
rpc UpdateChatSessions(UpdateChatSessionsReq) returns (UpdateChatSessionsResp);
rpc DelChatSessions(DelChatSessionsReq) returns (DelChatSessionsResp);
rpc GetChatSessionsById(GetChatSessionsByIdReq) returns (GetChatSessionsByIdResp);
rpc SearchChatSessions(SearchChatSessionsReq) returns (SearchChatSessionsResp);
rpc AddParticipant(AddParticipantReq) returns (AddParticipantResp);
rpc RemoveParticipant(RemoveParticipantReq) returns (RemoveParticipantResp);
//-----------------------chatMessages-----------------------
rpc AddChatMessages(AddChatMessagesReq) returns (AddChatMessagesResp);
rpc DelChatMessages(DelChatMessagesReq) returns (DelChatMessagesResp);
rpc GetChatMessagesById(GetChatMessagesByIdReq) returns (GetChatMessagesByIdResp);
rpc SearchChatMessages(SearchChatMessagesReq) returns (SearchChatMessagesResp);
}