2024-08-28 09:09:01 +00:00
|
|
|
|
syntax = "proto3";
|
2024-08-28 14:24:47 +00:00
|
|
|
|
package tweeting;
|
|
|
|
|
option go_package="./tweeting";
|
2024-08-28 09:09:01 +00:00
|
|
|
|
|
|
|
|
|
// 基本回應
|
|
|
|
|
message OKResp {}
|
|
|
|
|
|
|
|
|
|
// 空的請求
|
|
|
|
|
message NoneReq {}
|
|
|
|
|
|
|
|
|
|
// 分頁信息
|
|
|
|
|
message Pager {
|
|
|
|
|
int64 total =1; // 總數量
|
|
|
|
|
int64 size=2; // 每頁數量
|
|
|
|
|
int64 index=3; // 當前頁碼
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 新增貼文的請求
|
|
|
|
|
message NewPostReq {
|
|
|
|
|
int64 user_id = 1; // 發佈貼文的用戶ID
|
|
|
|
|
string content = 2; // 貼文內容
|
|
|
|
|
repeated string tags = 3; // 貼文相關標籤
|
|
|
|
|
repeated string media_url = 4; // 這筆文章的所有 Media URL
|
|
|
|
|
bool is_ad = 5; // 是否為廣告
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 貼文回應
|
|
|
|
|
message PostResp {
|
|
|
|
|
string post_id = 1; // 創建成功的貼文ID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 刪除貼文的請求
|
|
|
|
|
message DeletePostsReq {
|
|
|
|
|
repeated string post_id = 1; // 貼文ID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新貼文的請求
|
|
|
|
|
message UpdatePostReq {
|
|
|
|
|
string post_id = 1; // 貼文ID
|
|
|
|
|
repeated string tags = 2; // 新的標籤列表
|
|
|
|
|
repeated string media_url = 3; // 這筆文章的所有 Media URL
|
|
|
|
|
optional string content = 4; // 新的貼文內容
|
|
|
|
|
optional int64 like_count = 5; // 喜歡數量
|
|
|
|
|
optional int64 dislike_count = 6; // 不喜歡數量
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查詢貼文的請求
|
|
|
|
|
message QueryPostsReq {
|
|
|
|
|
repeated int64 user_id = 1; // 可選:根據用戶ID篩選貼文
|
|
|
|
|
repeated int64 id = 2; // 可選:根據貼文ID篩選貼文
|
|
|
|
|
repeated string tags = 3; // 可選:根據標籤篩選貼文
|
|
|
|
|
optional bool only_ads = 4; // 可選:是否只顯示廣告
|
|
|
|
|
int32 page_index = 5; // 分頁的頁碼
|
|
|
|
|
int32 page_size = 6; // 每頁顯示的數量
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 貼文詳情
|
|
|
|
|
message PostDetailItem {
|
|
|
|
|
string post_id = 1; // 貼文ID
|
|
|
|
|
int64 user_id = 2; // 發佈用戶ID
|
|
|
|
|
string content = 3; // 貼文內容
|
|
|
|
|
repeated string tags = 4; // 標籤
|
|
|
|
|
repeated string media_url = 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 LikeReq {
|
|
|
|
|
string target_id = 1; // 目標ID(可以是貼文ID或評論ID)
|
|
|
|
|
int64 user_id = 2; // 點讚的用戶ID
|
|
|
|
|
int64 like_type = 3; // 讚或爛的類型
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 讚/不讚項目
|
|
|
|
|
message LikeItem {
|
|
|
|
|
string target_id = 1; // 目標ID(可以是貼文ID或評論ID)
|
|
|
|
|
int64 user_id = 2; // 點讚的用戶ID
|
|
|
|
|
int64 like_type = 3; // 讚或爛的類型
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 讚/不讚列表請求
|
|
|
|
|
message LikeListReq {
|
|
|
|
|
string target_id = 1; // 目標ID(可以是貼文ID或評論ID)
|
|
|
|
|
int64 like_type = 2; // 讚或爛的類型
|
|
|
|
|
int32 page_index = 3; // 當前頁碼
|
|
|
|
|
int32 page_size = 4; // 每頁顯示數量
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 讚/不讚列表回應
|
|
|
|
|
message LikeListResp {
|
|
|
|
|
repeated LikeItem list = 1; // 讚/不讚列表
|
|
|
|
|
Pager page = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 讚/不讚數量請求
|
|
|
|
|
message LikeCountReq {
|
|
|
|
|
string target_id = 1; // 目標ID(可以是貼文ID或評論ID)
|
|
|
|
|
int64 like_type = 2; // 讚或爛的類型
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 讚/不讚數量回應
|
|
|
|
|
message LikeCountResp {
|
|
|
|
|
string count = 1; // 總共按讚數量
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 評論貼文的請求
|
|
|
|
|
message CommentPostReq {
|
|
|
|
|
string post_id = 1; // 貼文ID
|
|
|
|
|
int64 user_id = 2; // 評論者ID
|
|
|
|
|
string content = 3; // 評論內容
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查詢評論的請求
|
|
|
|
|
message GetCommentsReq {
|
|
|
|
|
string post_id = 1; // 貼文ID
|
|
|
|
|
int32 page_index = 2; // 分頁頁碼
|
|
|
|
|
int32 page_size = 3; // 每頁顯示數量
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 評論詳情
|
|
|
|
|
message CommentDetail {
|
|
|
|
|
string comment_id = 1; // 評論ID
|
|
|
|
|
int64 user_id = 2; // 評論者ID
|
|
|
|
|
string content = 3; // 評論內容
|
|
|
|
|
int64 created_at = 4; // 創建時間
|
|
|
|
|
int64 like_count = 5; // 讚數
|
|
|
|
|
int64 dislike_count = 6; // 不喜歡數量
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 評論列表回應
|
|
|
|
|
message GetCommentsResp {
|
|
|
|
|
repeated CommentDetail comments = 1; // 評論列表
|
|
|
|
|
Pager page = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 刪除評論請求
|
|
|
|
|
message DeleteCommentReq {
|
|
|
|
|
string comment_id = 1; // 評論ID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新評論請求
|
|
|
|
|
message UpdateCommentReq {
|
|
|
|
|
string comment_id = 1; // 評論ID
|
|
|
|
|
string content = 2; // 更新後的評論內容
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 定義貼文服務
|
|
|
|
|
service PostService {
|
|
|
|
|
// NewPost 新增貼文
|
|
|
|
|
rpc NewPost(NewPostReq) returns(PostResp);
|
|
|
|
|
// DeletePost 刪除貼文
|
|
|
|
|
rpc DeletePost(DeletePostsReq) returns (OKResp);
|
|
|
|
|
// UpdatePost 更新貼文
|
|
|
|
|
rpc UpdatePost(UpdatePostReq) returns (OKResp);
|
|
|
|
|
// ListPosts 查詢貼文
|
|
|
|
|
rpc ListPosts(QueryPostsReq) returns (ListPostsResp);
|
|
|
|
|
|
|
|
|
|
// Like 點讚/取消讚 貼文
|
|
|
|
|
rpc Like(LikeReq) returns (OKResp);
|
|
|
|
|
// GetLikeStatus 取得讚/不讚狀態
|
|
|
|
|
rpc GetLikeStatus(LikeReq) returns (OKResp);
|
|
|
|
|
// LikeList 取得讚/不讚列表
|
|
|
|
|
rpc LikeList(LikeListReq) returns (LikeListResp);
|
|
|
|
|
// CountLike 取得讚/不讚數量
|
|
|
|
|
rpc CountLike(LikeCountReq) returns (LikeCountResp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 定義評論服務
|
|
|
|
|
service CommentService {
|
|
|
|
|
// NewComment 發表評論
|
|
|
|
|
rpc NewComment(CommentPostReq) returns (OKResp);
|
|
|
|
|
// GetComments 查詢評論
|
|
|
|
|
rpc GetComments(GetCommentsReq) returns (GetCommentsResp);
|
|
|
|
|
// DeleteComment 刪除評論
|
|
|
|
|
rpc DeleteComment(DeleteCommentReq) returns (OKResp);
|
|
|
|
|
// UpdateComment 更新評論
|
|
|
|
|
rpc UpdateComment(UpdateCommentReq) returns (OKResp);
|
|
|
|
|
|
|
|
|
|
// LikeComment 點讚/取消讚 評論
|
|
|
|
|
rpc LikeComment(LikeReq) returns (OKResp);
|
|
|
|
|
// GetLikeStatus 取得讚/不讚評論狀態
|
|
|
|
|
rpc GetLikeStatus(LikeReq) returns (OKResp);
|
|
|
|
|
// LikeList 取得讚/不讚評論列表
|
|
|
|
|
rpc LikeList(LikeListReq) returns (LikeListResp);
|
|
|
|
|
// CountLike 取得讚/不讚評論數量
|
|
|
|
|
rpc CountLike(LikeCountReq) returns (LikeCountResp);
|
|
|
|
|
}
|