go-zero微服务框架 proto 案例
以文章管理为例
syntax = "proto3";
package article;
// protoc-gen-go 版本大于1.4.0, proto文件需要加上go_package,否则无法生成
option go_package = "./article";
message IdRequest {
string id = 1;
}
message getArticleByArticleCodeReq {
string articleCode = 1;
}
// 文章
message addArticleReq {
string title = 1;
int64 sectionId = 2;
int64 columnId = 3;
int64 memberId = 4;
string content = 5;
string picUrl = 6;
int64 isAdvert = 7;
string linkUrl = 8;
int64 createTime = 9;
int64 updateTime = 10;
string articleCode = 11;
}
message articleResp {
int64 code = 1;
string msg = 2;
}
message getArticleListReq {
int64 pageSize = 1;
int64 page = 2;
string title = 3;
int64 memberId = 4;
int64 sectionId = 5;
int64 columnId = 6;
int64 isChecked = 7;
int64 isAdvert = 8;
string column = 9;
string type = 10;
int64 num = 11;
string articleCode = 12;
}
message articleList {
int64 id = 1;
string title = 2;
string keyword = 3;
string description = 4;
int64 createTime = 5;
int64 updateTime = 6;
int64 memberId = 7;
int64 sectionId = 8;
int64 columnId = 9;
int64 commentNum = 10;
int64 likeNum = 11;
int64 viewNum = 12;
int64 collectionNum = 13;
int64 isChecked = 14;
string content = 15;
int64 isAdvert = 16;
string linkUrl = 17;
string picUrl = 18;
int64 weight = 19;
int64 mid = 20;
string memberCode = 21;
string nickName = 22;
string image = 23;
string articleCode =24;
}
message getArticleListResp {
repeated articleList articleList = 1;
int64 code = 2;
string msg = 3;
int64 total = 4;
}
message getArticleDetailResp {
articleList articleList = 1;
int64 code = 2;
string msg = 3;
}
// 评论
message addCommentReq {
int64 articleId = 2;
int64 reviewer = 3;
string content = 4;
int64 appraisee = 5;
int64 isChecked = 6;
int64 likeNum = 7;
int64 createTime = 8;
int64 updateTime = 9;
int64 pid = 10;
}
message commentResp {
int64 code = 1;
string msg = 2;
}
message getCommentListReq {
int64 pageSize = 1;
int64 page = 2;
int64 articleId = 3;
int64 isChecked = 4;
int64 likeNum = 5;
int64 createTime = 6;
int64 pid = 7;
}
message commentList {
int64 id = 1;
int64 articleId = 2;
int64 reviewer = 3;
string content = 4;
int64 appraisee = 5;
int64 isChecked = 6;
int64 likeNum = 7;
int64 pid = 8;
int64 createTime = 9;
int64 updateTime = 10;
}
message getCommentListResp {
repeated commentList commentList = 1;
int64 code = 2;
string msg = 3;
int64 total = 4;
}
service Article {
// 根据文章编号获取文章
rpc getArticleByArticleCode(getArticleByArticleCodeReq) returns(getArticleDetailResp);
// 添加文章
rpc addArticle(addArticleReq) returns(articleResp);
// 更新文章
rpc updateArticle(articleList) returns(articleResp);
// 获取文章列表
rpc getArticleList(getArticleListReq) returns(getArticleListResp);
// 添加评论
rpc addComment(addCommentReq) returns(commentResp);
// 更新评论
rpc updateComment(commentList) returns(commentResp);
// 获取评论列表
rpc getCommentList(getCommentListReq) returns(getCommentListResp);
}
还没有评论,快来发表第一个评论吧