2024-08-25 07:08:49 +00:00
|
|
|
|
syntax = "v1"
|
|
|
|
|
|
|
|
|
|
info(
|
|
|
|
|
title: "Portal-Api-Gateway (PGW)"
|
|
|
|
|
desc: "digimon web portal api gateway"
|
|
|
|
|
author: "daniel Wang"
|
|
|
|
|
email: "igs170911@gmail.com"
|
|
|
|
|
version: "0.0.1"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Status {
|
|
|
|
|
Code int64 `json:"code"` // 狀態碼
|
|
|
|
|
Message string `json:"message"` // 訊息
|
|
|
|
|
Data interface{} `json:"data,omitempty"` // 可選的數據,當有返回時才出現
|
|
|
|
|
Error interface{} `json:"error,omitempty"` // 可選的錯誤信息
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type BaseResponse {
|
|
|
|
|
Status Status `json:"status"` // 狀態
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------
|
2024-08-26 06:36:58 +00:00
|
|
|
|
|
|
|
|
|
type MemberLoginHeader {
|
|
|
|
|
DeviceID string `header:"device_id"`
|
|
|
|
|
IpAddress string `header:"ip_address"`
|
|
|
|
|
Brewser string `header:"brewser"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-25 07:08:49 +00:00
|
|
|
|
type CreateAccountRequest {
|
|
|
|
|
Account string `json:"account" validate:"required, account"` // 帳號名稱
|
|
|
|
|
Token string `json:"token"` // 密碼或平台token,密碼請 sha256 轉碼
|
|
|
|
|
TokenCheck string `json:"token_check"` // 密碼或平台token,密碼請 sha256 轉碼
|
|
|
|
|
Platform string `json:"platform" validate:"oneof=digimon google twitter"` // 平台名稱 digimon, google, twitter
|
2024-08-26 06:36:58 +00:00
|
|
|
|
AccountType int64 `json:"account_type" validate:"oneof=1 2 3"`// 帳號類型 1 手機 2 信箱 3 自定義帳號
|
|
|
|
|
MemberLoginHeader
|
2024-08-25 07:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-26 06:36:58 +00:00
|
|
|
|
// CreateAccountItem 建立帳號也幫忙登入
|
2024-08-25 07:08:49 +00:00
|
|
|
|
type CreateAccountItem {
|
|
|
|
|
UID string `json:"uid"` // 使用者UID
|
2024-08-26 06:36:58 +00:00
|
|
|
|
AccessToken string `json:"access_token"` // 訪問令牌 預設 5 分鐘過期
|
|
|
|
|
RefreshToken string `json:"refresh_token"` // 刷新令牌 (預設一天過期,只能用一次),當呼叫更新token api 時,會自動把舊的失效,變成新的 refresh_token ,前端要記得過其實協助刷新,刷新不過表示全失效了(重新登入)
|
|
|
|
|
TokenType string `json:"token_type"` // Bearer
|
2024-08-25 07:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CreateAccountResp {
|
|
|
|
|
Status Status `json:"status"` // 狀態
|
|
|
|
|
Data CreateAccountItem `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
// -------------------------------------------
|
|
|
|
|
|
|
|
|
|
type LoginResp {
|
|
|
|
|
Status Status `json:"status"` // 狀態
|
|
|
|
|
Data LoginItem `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type LoginItem {
|
2024-08-26 06:36:58 +00:00
|
|
|
|
UID string `json:"uid"` // Account
|
2024-08-25 07:08:49 +00:00
|
|
|
|
AccessToken string `json:"access_token"` // 訪問令牌 預設 5 分鐘過期
|
|
|
|
|
RefreshToken string `json:"refresh_token"` // 刷新令牌 (預設一天過期,只能用一次),當呼叫更新token api 時,會自動把舊的失效,變成新的 refresh_token ,前端要記得過其實協助刷新,刷新不過表示全失效了(重新登入)
|
|
|
|
|
TokenType string `json:"token_type"` // Bearer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type LoginReq {
|
|
|
|
|
Account string `json:"account" validate:"required, account"` // 帳號名稱
|
|
|
|
|
Token string `json:"token"` // 密碼或平台token,密碼請 sha256 轉碼
|
|
|
|
|
Platform string `json:"platform" validate:"oneof=digimon google twitter"` // 平台名稱 digimon, google, twitter
|
2024-08-26 06:36:58 +00:00
|
|
|
|
AccountType int64 `json:"account_type" validate:"oneof=1 2 3"` // 帳號類型 1 手機 2 信箱 3 自定義帳號
|
|
|
|
|
MemberLoginHeader
|
2024-08-25 07:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
// -------------------------------------------
|
|
|
|
|
|
|
|
|
|
type ForgetPasswordCodeReq {
|
|
|
|
|
Account string `json:"account" validate:"required, account"` // 帳號名稱
|
2024-08-26 06:36:58 +00:00
|
|
|
|
AccountType int32 `json:"account_type" validate:"oneof=1 2 3"` // 帳號類型 1 手機 2 信箱 3 自定義帳號
|
2024-08-25 07:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
// -------------------------------------------
|
|
|
|
|
|
|
|
|
|
type CheckoutVerifyReq {
|
|
|
|
|
Account string `form:"account"m:"account" validate:"required, account"` // 帳號名稱
|
|
|
|
|
VerifyCode string `form:"verify_code" validate:"required,len=6"` // 驗證碼,長度為6
|
|
|
|
|
}
|
|
|
|
|
// -------------------------------------------
|
|
|
|
|
type UpdatePasswordReq {
|
|
|
|
|
Account string `json:"account" validate:"required, account"` // 帳號名稱
|
|
|
|
|
VerifyCode string `json:"verify_code" validate:"required,len=6"` // 驗證碼,長度為6
|
|
|
|
|
Token string `json:"token" validate:"required"` // 密碼或平台token,密碼請 sha256 轉碼
|
|
|
|
|
TokenCheck string `json:"token_check" validate:"required"` // 密碼或平台token,密碼請 sha256 轉碼
|
|
|
|
|
}
|
2024-08-26 06:36:58 +00:00
|
|
|
|
// -------------------------------------------
|
|
|
|
|
type UpdateTokenReq {
|
|
|
|
|
UID string `json:"uid" validate:"required"` // uid
|
|
|
|
|
Token string `json:"token" validate:"required"` // refresh token
|
|
|
|
|
MemberLoginHeader
|
|
|
|
|
}
|
2024-08-25 07:08:49 +00:00
|
|
|
|
|
|
|
|
|
@server(
|
|
|
|
|
group: member
|
|
|
|
|
prefix: /api/v1
|
|
|
|
|
schemes: https
|
|
|
|
|
timeout: 3s
|
|
|
|
|
)
|
|
|
|
|
service gateway {
|
|
|
|
|
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
|
|
|
|
|
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
|
|
|
|
|
@doc(
|
|
|
|
|
summary:"創建新會員"
|
|
|
|
|
description: "創建一個全新的帳號"
|
|
|
|
|
)
|
|
|
|
|
@handler createAccount
|
|
|
|
|
post /member (CreateAccountRequest) returns (CreateAccountResp)
|
|
|
|
|
|
|
|
|
|
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
|
|
|
|
|
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
|
|
|
|
|
@doc(
|
|
|
|
|
summary:"登入"
|
|
|
|
|
description: "會員登入"
|
|
|
|
|
)
|
|
|
|
|
@handler Login
|
|
|
|
|
post /member/login (LoginReq) returns (LoginResp)
|
|
|
|
|
|
|
|
|
|
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
|
|
|
|
|
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
|
|
|
|
|
@doc(
|
|
|
|
|
summary:"發送忘記密碼驗證"
|
|
|
|
|
description: "發送忘記密碼驗證(三分鐘內只能發一次信)"
|
|
|
|
|
)
|
2024-08-26 06:36:58 +00:00
|
|
|
|
@handler ForgetPasswordCode
|
2024-08-25 07:08:49 +00:00
|
|
|
|
post /member/forget-password-code (ForgetPasswordCodeReq) returns (BaseResponse)
|
|
|
|
|
|
|
|
|
|
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
|
|
|
|
|
/* @respdoc-403 (BaseResponse) // 無效的驗證碼 */
|
|
|
|
|
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
|
|
|
|
|
@doc(
|
|
|
|
|
summary:"確認驗證碼是否有效"
|
|
|
|
|
description: "確認驗證碼是否有效"
|
|
|
|
|
)
|
|
|
|
|
@handler CheckVerifyCode
|
|
|
|
|
get /member/check-verify-code (CheckoutVerifyReq) returns (BaseResponse)
|
|
|
|
|
|
|
|
|
|
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
|
|
|
|
|
/* @respdoc-403 (BaseResponse) // 無效的驗證碼 */
|
|
|
|
|
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
|
|
|
|
|
@doc(
|
|
|
|
|
summary:"更新密碼"
|
|
|
|
|
description: "更新密碼"
|
|
|
|
|
)
|
|
|
|
|
@handler UpadtePassword
|
|
|
|
|
put /member/update-password (UpdatePasswordReq) returns (BaseResponse)
|
2024-08-26 06:36:58 +00:00
|
|
|
|
|
|
|
|
|
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
|
|
|
|
|
/* @respdoc-403 (BaseResponse) // 無效的驗證碼 */
|
|
|
|
|
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
|
|
|
|
|
@doc(
|
|
|
|
|
summary:"更新Token"
|
|
|
|
|
description: "用 RefreshToken 換取 AccessToken"
|
|
|
|
|
)
|
|
|
|
|
@handler RefreshAccessToken
|
|
|
|
|
put /member/refresh_access_token (UpdateTokenReq) returns (LoginResp)
|
|
|
|
|
|
2024-08-25 07:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Header {
|
|
|
|
|
Uid string `header:"uid"`
|
|
|
|
|
Token string `header:"token"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 07:40:00 +00:00
|
|
|
|
type GetMemberHeader {
|
|
|
|
|
Token string `header:"token"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-25 07:08:49 +00:00
|
|
|
|
type UserInfoResp {
|
|
|
|
|
Status Status `json:"status"` // 狀態
|
|
|
|
|
Data UserInfo `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 07:40:00 +00:00
|
|
|
|
type UserInfo {
|
|
|
|
|
UID string `json:"uid"`
|
|
|
|
|
VerifyType string `json:"verify_type"`
|
|
|
|
|
AlarmType string `json:"alarm_type"`
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
Language string `json:"language"`
|
|
|
|
|
Currency string `json:"currency"`
|
|
|
|
|
Avatar string `json:"avatar"`
|
|
|
|
|
CreateTime string `json:"curreate_time"`
|
|
|
|
|
UpdateTime string `json:"update_time"`
|
|
|
|
|
NickName *string `json:"nick_name,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-25 07:08:49 +00:00
|
|
|
|
|
|
|
|
|
@server(
|
|
|
|
|
group: member
|
|
|
|
|
prefix: /api/v1
|
|
|
|
|
schemes: https
|
|
|
|
|
timeout: 3s
|
|
|
|
|
middleware: AuthMiddleware
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
service gateway {
|
|
|
|
|
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
|
|
|
|
|
/* @respdoc-403 (BaseResponse) // 無效的Token */
|
|
|
|
|
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
|
|
|
|
|
@doc(
|
|
|
|
|
summary: "會員登出"
|
|
|
|
|
)
|
|
|
|
|
@handler Logout
|
2024-08-27 07:40:00 +00:00
|
|
|
|
get /member/logout (GetMemberHeader) returns (BaseResponse)
|
2024-08-25 07:08:49 +00:00
|
|
|
|
|
|
|
|
|
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
|
|
|
|
|
/* @respdoc-403 (BaseResponse) // 無效的Token */
|
|
|
|
|
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
|
|
|
|
|
@doc(
|
|
|
|
|
summary: "取得會員資訊"
|
|
|
|
|
)
|
|
|
|
|
@handler Info
|
2024-08-27 07:40:00 +00:00
|
|
|
|
get /member/info (GetMemberHeader) returns (UserInfoResp)
|
2024-08-25 07:08:49 +00:00
|
|
|
|
}
|