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