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

105 lines
3.1 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
package tweeting;
option go_package = "./tweeting";
// ========== 基本回應 ===========
message OKResp {}
// 空的請求
message NoneReq {}
// 分頁信息
message Pager {
int64 total = 1; // 總數量
int64 size = 2; // 每頁數量
int64 index = 3; // 當前頁碼
}
// ========== 貼文區 ===========
// ------ NewPost 新增貼文--------
message NewPostReq {
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;
}
// 貼文回應
message PostResp {
string post_id = 1; // 創建成功的貼文ID
}
// ------ DeletePost 刪除貼文 ------
// 刪除貼文的請求
message DeletePostsReq {
repeated string post_id = 1; // 貼文ID
}
// ------ UpdatePost 更新貼文 ------
// 更新貼文的請求
message UpdatePostReq {
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; // 不喜歡數量
}
// ------ListPosts 查詢貼文 ------
// 查詢貼文的請求
message QueryPostsReq {
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; // 每頁顯示的數量
}
// 貼文詳情
message PostDetailItem {
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; // 不喜歡數量
}
// 貼文列表回應
message ListPostsResp {
repeated PostDetailItem posts = 1; // 貼文列表
Pager page = 2;
}
message ModifyLikeDislikeCountReq {
string post_id = 1; // 貼文的 ID
int64 reaction_type = 2; // 用戶的反應類型,可能是讚或不讚
bool is_increment = 3; // 表示是否增加true 表示增加false 表示減少)
int64 count = 4; // 異動數量
}
// ========== 定義貼文服務(最基本單位,不要把邏輯放進來,也考慮是否要做快取) ==========
service PostService {
// CreatePost 新增貼文
rpc CreatePost(NewPostReq) returns (PostResp);
// DeletePost 刪除貼文
rpc DeletePost(DeletePostsReq) returns (OKResp);
// UpdatePost 更新貼文
rpc UpdatePost(UpdatePostReq) returns (OKResp);
// ListPosts 查詢貼文
rpc ListPosts(QueryPostsReq) returns (ListPostsResp);
}