app-cloudep-tweeting-service/generate/protobuf/tweeting.proto

105 lines
3.1 KiB
Protocol Buffer
Raw Normal View History

2024-08-28 09:09:01 +00:00
syntax = "proto3";
2024-08-28 14:24:47 +00:00
package tweeting;
2024-08-30 02:44:35 +00:00
option go_package = "./tweeting";
2024-08-28 09:09:01 +00:00
2024-08-30 02:44:35 +00:00
// ========== 基本回應 ===========
message OKResp {}
2024-08-28 09:09:01 +00:00
// 空的請求
2024-08-30 02:44:35 +00:00
message NoneReq {}
2024-08-28 09:09:01 +00:00
// 分頁信息
message Pager {
2024-08-30 02:44:35 +00:00
int64 total = 1; // 總數量
int64 size = 2; // 每頁數量
int64 index = 3; // 當前頁碼
2024-08-28 09:09:01 +00:00
}
2024-08-30 02:44:35 +00:00
// ========== 貼文區 ===========
// ------ NewPost 新增貼文--------
2024-08-28 09:09:01 +00:00
message NewPostReq {
2024-08-30 02:44:35 +00:00
string uid = 1; // 發佈貼文的用戶ID
string content = 2; // 貼文內容
repeated string tags = 3; // 貼文相關標籤
repeated Media media = 4; // 這筆文章的所有 Media URL
bool is_ad = 5; // 是否為廣告
}
message Media {
string type = 1;
string url = 2;
2024-08-28 09:09:01 +00:00
}
// 貼文回應
message PostResp {
string post_id = 1; // 創建成功的貼文ID
}
2024-08-30 02:44:35 +00:00
// ------ DeletePost 刪除貼文 ------
2024-08-28 09:09:01 +00:00
// 刪除貼文的請求
message DeletePostsReq {
2024-08-30 02:44:35 +00:00
repeated string post_id = 1; // 貼文ID
2024-08-28 09:09:01 +00:00
}
2024-08-30 02:44:35 +00:00
// ------ UpdatePost 更新貼文 ------
2024-08-28 09:09:01 +00:00
// 更新貼文的請求
message UpdatePostReq {
2024-08-30 02:44:35 +00:00
string post_id = 1; // 貼文ID
repeated string tags = 2; // 新的標籤列表
repeated Media media = 3; // 這筆文章的所有 Media URL
optional string content = 4; // 新的貼文內容
optional int64 like_count = 5; // 喜歡數量
optional int64 dislike_count = 6; // 不喜歡數量
2024-08-28 09:09:01 +00:00
}
2024-08-30 02:44:35 +00:00
// ------ListPosts 查詢貼文 ------
2024-08-28 09:09:01 +00:00
// 查詢貼文的請求
message QueryPostsReq {
2024-08-30 02:44:35 +00:00
repeated string uid = 1; // 可選根據用戶ID篩選貼文
repeated string post_id = 2; // 可選根據貼文ID篩選貼文
optional int32 only_ads = 3; // 可選:是否只顯示廣告 0 不篩選 1 只顯示廣告 2 不顯示廣告
int32 page_index = 4; // 分頁的頁碼
int32 page_size = 5; // 每頁顯示的數量
2024-08-28 09:09:01 +00:00
}
// 貼文詳情
message PostDetailItem {
2024-08-30 02:44:35 +00:00
string post_id = 1; // 貼文ID
string uid = 2; // 發佈用戶ID
string content = 3; // 貼文內容
repeated string tags = 4; // 標籤
repeated Media media = 5; // 圖片URL
bool is_ad = 6; // 是否為廣告
int64 created_at = 7; // 發佈時間
int64 update_at = 8; // 更新時間
int64 like_count = 9; // 讚數
int64 dislike_count = 10; // 不喜歡數量
2024-08-28 09:09:01 +00:00
}
// 貼文列表回應
message ListPostsResp {
repeated PostDetailItem posts = 1; // 貼文列表
Pager page = 2;
}
2024-08-30 02:44:35 +00:00
message ModifyLikeDislikeCountReq {
string post_id = 1; // 貼文的 ID
int64 reaction_type = 2; // 用戶的反應類型,可能是讚或不讚
bool is_increment = 3; // 表示是否增加true 表示增加false 表示減少)
int64 count = 4; // 異動數量
2024-08-28 09:09:01 +00:00
}
2024-08-30 02:44:35 +00:00
// ========== 定義貼文服務(最基本單位,不要把邏輯放進來,也考慮是否要做快取) ==========
2024-08-28 09:09:01 +00:00
service PostService {
2024-08-30 02:44:35 +00:00
// CreatePost 新增貼文
rpc CreatePost(NewPostReq) returns (PostResp);
2024-08-28 09:09:01 +00:00
// DeletePost 刪除貼文
rpc DeletePost(DeletePostsReq) returns (OKResp);
// UpdatePost 更新貼文
rpc UpdatePost(UpdatePostReq) returns (OKResp);
// ListPosts 查詢貼文
rpc ListPosts(QueryPostsReq) returns (ListPostsResp);
}