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
+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)
}
+38 -42
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"`
}
)
+50 -53
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)
}
+30 -30
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)
}
+38 -39
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)
}
+53 -56
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)
}
+25 -33
View File
@@ -1,12 +1,12 @@
syntax = "proto3";
option go_package ="./pb";
package pb;
// ------------------------------------
option go_package = "./pb";
// ------------------------------------
// Messages
// ------------------------------------
// ------------------------------------
//--------------------------------chatSessions--------------------------------
message ChatSessions {
@@ -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);
}