爱凌峰,你的分享学习平台!

  • 首页
  • 分享板块
  • 热门工具
  • chatGpt聊天
  • 思维导图
  • 在线Excel
  • 留言建议
请登录| 注册博主
  • 分享板块
  • 留言建议

  • go-zero微服务框架 proto 案例EnjoyMount
    Go-zero

    go-zero微服务框架 proto 案例

    go-zero微服务框架 proto 案例EnjoyMount
    Go-zero
    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); }

    查看详情
    点赞
    评论
    收藏
    浏览89
    2023-02-27 18:20:54
  • go-zero微服务框架 api 案例EnjoyMount
    Go-zero

    go-zero微服务框架 api 案例

    go-zero微服务框架 api 案例EnjoyMount
    Go-zero

    最外层可以引入://=====================================> blog api v1 <================================= import ( "api/role.api" "api/menu.api" "api/user.api" "api/upload.api" "api/member.api" "api/article.api" )user.apiinfo( author: "lxl" date: "2022-12-20" desc: "user-api" email: "1123736022@qq.com" version: "v1" ) type ( // 一个用户 UserList { Id int64 `json:"id"` //ID UserName string `json:"userName"` //用户名 Password string `json:"password"` //密码 NickName string `json:"nickName"` //昵称 Email string `json:"email"` //邮箱 Image string `json:"image"` //头像 CreateTime int64 `json:"createTime"` UpdateTime int64 `json:"updateTime"` } // 用户列表请求 UserListReq { Page int64 `json:"page"` PageSize int64 `json:"pageSize"` NickName string `json:"nickName"` Email string `json:"email"` } // 用户列表响应 UserListResp { List []UserList `json:"list"` Code int64 `json:"code"` Msg string `json:"msg"` Total int64 `json:"total"` } // 用户新增请求 AddUserReq { UserName string `json:"userName"` //用户名 Password string `json:"password"` //密码 NickName string `json:"nickName"` //昵称 Email string `json:"email"` //邮箱 Image string `json:"image"` //头像 } // 删除用户请求 delUserReq { Id int64 `json:"id"` } // 批量删除用户请求 batchDelUserReq { Ids string `json:"ids"` } // 获取用户信息响应 UserInfoReply { // UserInfo UserList `json:"user_info"` Id string `json:"id"` Name string `json:"name"` } // 用户登录请求 UserLoginReq { UserName string `json:"userName"` //用户名 Password string `json:"password"` //密码 } // 用户登录响应 UserLoginResp { Code int64 `json:"code"` Msg string `json:"msg"` } // 用户响应 UserResp { Code int64 `json:"code"` Msg string `json:"msg"` Token string `json:"token"` UserInfo GetUserResponse `json:"userInfo"` } // 获取用户信息请求 GetUserRequest { Id int64 `json:"id"` } GetUserResponse { Id int64 `json:"id"` //ID UserName string `json:"userName"` //用户名 NickName string `json:"nickName"` //昵称 Email string `json:"email"` //邮箱 Image string `json:"image"` //头像 CreateTime int64 `json:"createTime"` UpdateTime int64 `json:"updateTime"` } JwtTokenRequest { } JwtTokenResponse { AccessToken string `json:"access_token"` AccessExpire int64 `json:"access_expire"` RefreshAfter int64 `json:"refresh_after"` // 建议客户端刷新token的绝对时间 } ) @server( prefix: api group: user jwt: JwtAuth ) service blog { // 获取用户列表 @handler getUserList post /user/getUserList (UserListReq) returns (UserListResp) // 添加用户 @handler addUser post /user/addUser (AddUserReq) returns (UserResp) // 更新用户 @handler updateUser post /user/updateUser (UserList) returns (UserResp) // 删除用户用户 @handler delUser post /user/delUser (delUserReq) returns (UserResp) // 批量删除用户用户 @handler batchDelUser post /user/batchDelUser (batchDelUserReq) returns (UserResp) // 获取用户信息 @handler getUserInfo post /user/info (GetUserRequest) returns (GetUserResponse) } @server( prefix: api group: user ) service blog { @handler userLogin post /user/login (UserLoginReq) returns (UserLoginResp) @handler JwtHandler post /user/token (JwtTokenRequest) returns (JwtTokenResponse) }

    查看详情
    点赞
    评论
    收藏
    浏览51
    2023-02-27 18:57:46
上一页首页1尾页下一页共 1 页 2条

创作内容

开启你的爱凌峰创作之旅

发布首篇内容,开通创作中心
快来成为爱凌峰创作者吧~

  • 
    分享板块
  • 
    热门工具
  • 
    科技资讯
  • 
    留言建议
写文章

内容板块

  • HTML(1)
  • JavaScript(16)
  • CSS(3)
  • Vue(4)
  • TypeScript(1)
  • Vite
  • React
  • C++
  • Golang(11)
  • Java(3)
  • Python(1)
  • PHP(8)
  • Git(1)
  • Linux(9)
  • SEO
  • SEM
  • Laravel(7)
  • Docker(8)
  • Kubernetes
  • Gin(12)
  • Go-zero(2)
  • 工具推荐(3)
  • 人工智能(3)
  • Shell(5)
  • 网络咨询
  • 销售
  • 测试
  • UI设计
  • 平面设计
  • 原画
  • 视频剪辑
  • 产品
  • 运营(1)
  • 摄影
  • 音乐
  • 文学(7)
  • 运动
  • 游戏
  • 电竞
  • 健康
  • 娱乐
  • 心理
  • 情感(1)
  • 科技(39)
  • 数码(1)
  • 财经
  • 故事
  • 体育
  • 校园
  • 汽车
  • 时尚
  • 职场(2)
  • 亲子
  • 影视
  • 美食
  • 旅行
  • 法律
  • 动漫
  • 时事(6)
  • 家居
  • 国际
  • 宠物
  • AI绘图(1)
  • 生活
关注我们
友情链接:
爱凌峰
Copyright © 2023 爱凌峰 版权所有 保留一切权利 备案号: 蜀ICP备2023011400号-1

Copyright © 2023 爱凌峰
版权所有 保留一切权利

备案号: 蜀ICP备2023011400号-1

 首页
 资讯
 热门工具
登录