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"` CaptchaId string `json:"captchaId"` Captcha string `json:"captcha"` } // 验证码响应 CaptchaResp { CaptchaId string `json:"captchaId"` CaptchaImg string `json:"captchaImg"` } // 登录响应 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/auth group: auth ) service auth-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) @doc "获取图形验证码" @handler GetCaptcha get /captcha returns (CaptchaResp) } // ========== 需要鉴权的接口 ========== @server ( prefix: /api/auth group: user jwt: Auth ) service auth-api { @doc "获取当前用户信息" @handler GetUserInfo get /info returns (LoginResp) @doc "更新个人信息" @handler UpdateUser post /update (UpdateUserReq) @doc "修改密码" @handler ChangePassword post /changePassword (ChangePasswordReq) @doc "获取位置信息" @handler GetLocation get /location (LocationReq) @doc "获取天气信息" @handler GetWeather get /weather (WeatherReq) }