81 lines
1.6 KiB
Plaintext
Raw Normal View History

2021-01-01 20:30:52 +08:00
info(
title: "type title here"
desc: "type desc here"
author: "type author here"
email: "type email here"
version: "type version here"
)
2021-01-20 22:38:54 +08:00
2021-01-01 20:30:52 +08:00
type (
//注册请求结构
2021-01-01 20:30:52 +08:00
RegisterReq {
Username string `json:"username"`
Password string `json:"password"`
Mobile string `json:"mobile"`
}
2021-01-20 22:38:54 +08:00
2021-01-01 20:30:52 +08:00
LoginReq {
2021-04-01 23:19:31 +08:00
Username string `json:"username"` //测试
Password string `json:"password"`//测试2
2021-01-20 22:38:54 +08:00
}
2021-01-01 20:30:52 +08:00
UserInfoReq {
2021-01-20 22:38:54 +08:00
Id string `path:"id"`
2021-01-01 20:30:52 +08:00
}
UserInfoReply {
Name string `json:"name"`
Age int `json:"age"`
Birthday string `json:"birthday"`
Description string `json:"description"`
Tag []string `json:"tag"`
Tags [][]string `json:"tags"`
2021-01-01 20:30:52 +08:00
}
UserSearchReq {
2021-04-01 23:19:31 +08:00
KeyWord string `form:"keyWord"` // 关键词
2021-01-01 20:30:52 +08:00
}
ErrorResponse {
Code string `json:"code"`
Message string `json:"message"`
}
2021-01-01 20:30:52 +08:00
)
@server(
prefix: /api
)
2021-01-01 20:30:52 +08:00
service user-api {
@doc(
2021-04-01 23:19:31 +08:00
summary: 注册
2021-01-01 20:30:52 +08:00
)
@handler register
post /user/register (RegisterReq)
2021-01-01 20:30:52 +08:00
@doc(
2021-04-01 23:19:31 +08:00
summary: 登录
2021-01-01 20:30:52 +08:00
)
@handler login
post /user/login (LoginReq)
2021-01-01 20:30:52 +08:00
@doc(
2021-04-01 23:19:31 +08:00
summary: 获取用户信息
2021-01-01 20:30:52 +08:00
)
@handler getUserInfo
/*
@respdoc-400 (
100101: out of authority
100102: user not exist
) // Error code list
*/
/* @respdoc-500 (ErrorResponse) // Server Error */
get /user/:id (UserInfoReq) returns (UserInfoReply)
2021-01-01 20:30:52 +08:00
@doc(
2021-04-01 23:19:31 +08:00
summary: 用户搜索
2021-01-01 20:30:52 +08:00
)
@handler searchUser
get /user/search (UserSearchReq) returns (UserInfoReply)
2021-01-03 16:10:42 +08:00
}