i2bill.api 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. syntax = "v1"
  2. info(
  3. title: // TODO: add title
  4. desc: // TODO: add description
  5. author: "double.huang"
  6. email: "2637309949@qq.com"
  7. )
  8. type WXLoginResponse {
  9. OpenID string `json:"openid"`
  10. SessionKey string `json:"session_key"`
  11. UnionID string `json:"unionid"`
  12. ErrCode int `json:"errcode"`
  13. ErrMsg string `json:"errmsg"`
  14. }
  15. type Watermark {
  16. AppID string `json:"appid"`
  17. TimeStamp int64 `json:"timestamp"`
  18. }
  19. type WXUserInfo {
  20. OpenID string `json:"openId,omitempty"`
  21. NickName string `json:"nickName"`
  22. AvatarUrl string `json:"avatarUrl"`
  23. Gender int64 `json:"gender"`
  24. Country string `json:"country"`
  25. Province string `json:"province"`
  26. City string `json:"city"`
  27. UnionID string `json:"unionId,omitempty"`
  28. Language string `json:"language"`
  29. Watermark Watermark `json:"watermark,omitempty"`
  30. }
  31. type ResUserInfo {
  32. UserInfo WXUserInfo `json:"userInfo"`
  33. RawData string `json:"rawData"`
  34. Signature string `json:"signature"`
  35. EncryptedData string `json:"encryptedData"`
  36. IV string `json:"iv"`
  37. }
  38. type authLoginBody {
  39. Code string `json:"code"`
  40. UserInfo ResUserInfo `json:"userInfo"`
  41. }
  42. type AuthUserInfo {
  43. ID int64 `json:"id"`
  44. UserName string `json:"username"`
  45. NickName string `json:"nickname"`
  46. Gender int64 `json:"gender"`
  47. Avatar string `json:"avatar"`
  48. Birthday int64 `json:"birthday"`
  49. }
  50. type authResponse {
  51. Token string `json:"token"`
  52. UserInfo AuthUserInfo `json:"userInfo"`
  53. }
  54. type request {
  55. // TODO: add members here and delete this comment
  56. Id int64 `form:"id"`
  57. }
  58. type response {
  59. // TODO: add members here and delete this comment
  60. Id int64 `json:"id"`
  61. }
  62. service i2bill-api {
  63. @handler LoginByWeixin // TODO
  64. post /api/auth/loginByWeixin(authLoginBody) returns(authResponse)
  65. }
  66. @server(
  67. jwt: JwtAuth
  68. )
  69. service i2bill-api {
  70. @handler GetUser // TODO: set handler name and delete this comment
  71. get /api/users/id/:userId(request) returns(response)
  72. }