init: init refactor
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
syntax = "v1"
|
||||
|
||||
info (
|
||||
title: "用户服务API"
|
||||
desc: "用户登录、信息管理等HTTP接口"
|
||||
author: "sundynix"
|
||||
version: "v1.0.0"
|
||||
)
|
||||
|
||||
type (
|
||||
// 微信小程序登录
|
||||
MiniLoginReq {
|
||||
Code string `json:"code"`
|
||||
ClientId string `json:"clientId"`
|
||||
}
|
||||
// 手机号登录
|
||||
LoginByPhoneReq {
|
||||
Code string `json:"code"`
|
||||
OpenId string `json:"openId"`
|
||||
ClientId string `json:"clientId"`
|
||||
}
|
||||
// 账号密码登录
|
||||
LoginReq {
|
||||
Account string `json:"account"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
// 登录响应
|
||||
LoginResp {
|
||||
Token string `json:"token"`
|
||||
UserInfo interface{} `json:"userInfo"`
|
||||
}
|
||||
// 更新用户
|
||||
UpdateUserReq {
|
||||
Name string `json:"name,optional"`
|
||||
Account string `json:"account,optional"`
|
||||
Phone string `json:"phone,optional"`
|
||||
AvatarId string `json:"avatarId,optional"`
|
||||
NickName string `json:"nickName,optional"`
|
||||
}
|
||||
// 修改密码
|
||||
ChangePasswordReq {
|
||||
OldPassword string `json:"oldPassword"`
|
||||
NewPassword string `json:"newPassword"`
|
||||
}
|
||||
// 用户列表查询
|
||||
UserListReq {
|
||||
Current int `json:"current,optional"`
|
||||
PageSize int `json:"pageSize,optional"`
|
||||
Account string `json:"account,optional"`
|
||||
Phone string `json:"phone,optional"`
|
||||
}
|
||||
// 通用ID请求
|
||||
IdReq {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
// 批量ID请求
|
||||
IdsReq {
|
||||
Ids []string `json:"ids"`
|
||||
}
|
||||
// 获取位置
|
||||
LocationReq {
|
||||
Longitude string `form:"longitude"`
|
||||
Latitude string `form:"latitude"`
|
||||
}
|
||||
// 获取天气
|
||||
WeatherReq {
|
||||
Adcode string `form:"adcode"`
|
||||
}
|
||||
)
|
||||
|
||||
// ========== 无需鉴权的接口 ==========
|
||||
@server (
|
||||
prefix: /api/user
|
||||
group: auth
|
||||
)
|
||||
service user-api {
|
||||
@doc "微信小程序登录"
|
||||
@handler MiniLogin
|
||||
post /miniLogin (MiniLoginReq) returns (LoginResp)
|
||||
|
||||
@doc "手机号登录"
|
||||
@handler LoginByPhone
|
||||
post /loginByPhone (LoginByPhoneReq) returns (LoginResp)
|
||||
|
||||
@doc "账号密码登录"
|
||||
@handler Login
|
||||
post /login (LoginReq) returns (LoginResp)
|
||||
}
|
||||
|
||||
// ========== 需要鉴权的接口 ==========
|
||||
@server (
|
||||
prefix: /api/user
|
||||
group: user
|
||||
jwt: Auth
|
||||
)
|
||||
service user-api {
|
||||
@doc "获取当前用户信息"
|
||||
@handler GetUserInfo
|
||||
get /info returns (LoginResp)
|
||||
|
||||
@doc "更新用户信息"
|
||||
@handler UpdateUser
|
||||
put /update (UpdateUserReq)
|
||||
|
||||
@doc "修改密码"
|
||||
@handler ChangePassword
|
||||
put /changePassword (ChangePasswordReq)
|
||||
|
||||
@doc "用户列表"
|
||||
@handler GetUserList
|
||||
post /list (UserListReq)
|
||||
|
||||
@doc "删除用户"
|
||||
@handler DeleteUser
|
||||
delete /delete (IdsReq)
|
||||
|
||||
@doc "获取位置信息"
|
||||
@handler GetLocation
|
||||
get /location (LocationReq)
|
||||
|
||||
@doc "获取天气信息"
|
||||
@handler GetWeather
|
||||
get /weather (WeatherReq)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user