-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openapi): add openapi auth and version ,echo apis
- Loading branch information
Showing
34 changed files
with
481 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import "openapi/auth.api" | ||
import "openapi/demo.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
syntax = "v1" | ||
|
||
info( | ||
title: "Demo Open API" | ||
desc: "This is a api of Open API in Artisan Cloud" | ||
author: "Matrix-X" | ||
email: "[email protected]" | ||
version: "v1" | ||
) | ||
|
||
@server( | ||
group: openapi/auth | ||
prefix: /openapi/v1/auth | ||
) | ||
|
||
|
||
service PowerX { | ||
@doc "Auth by platform" | ||
@handler AuthPlatform | ||
post / (PlatformAuthRequest) returns (PlatformAuthResponse) | ||
} | ||
|
||
|
||
type ( | ||
PlatformAuthRequest { | ||
AccessKey string `json:"accessKey"` | ||
SecretKey string `json:"secretKey"` | ||
} | ||
|
||
PlatformAuthResponse { | ||
TokenType string `json:"tokenType"` | ||
ExpiresIn string `json:"expiresIn"` | ||
AccessToken string `json:"accessToken"` | ||
RefreshToken string `json:"refreshToken"` | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ syntax = "v1" | |
|
||
info( | ||
title: "Demo Open API" | ||
desc: "This is a demo Open API for testing purposes." | ||
desc: "This is a api of Open API in Artisan Cloud" | ||
author: "Matrix-X" | ||
email: "[email protected]" | ||
version: "v1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package config | ||
|
||
type Database struct { | ||
Driver string | ||
DSN string | ||
SeedCommerceData bool | ||
SeedDepartment bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package config | ||
|
||
type MediaResource struct { | ||
LocalStorage struct { | ||
StoragePath string | ||
} | ||
OSS struct { | ||
Enable bool | ||
Minio struct { | ||
Endpoint string | ||
Credentials struct { | ||
AccessKey string | ||
SecretKey string | ||
} | ||
UseSSL bool | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package config | ||
|
||
import ( | ||
"PowerX/internal/config/openapiplatform" | ||
"PowerX/internal/config/openapiprovider" | ||
) | ||
|
||
type OpenAPI struct { | ||
Platforms struct { | ||
BrainX openapiplatform.BrainX | ||
} | ||
Providers struct { | ||
BrainX openapiprovider.BrainX | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package openapiplatform | ||
|
||
type BrainX struct { | ||
AccessKey string | ||
SecretKey string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package openapiprovider | ||
|
||
type BrainX struct { | ||
BaseUrl string | ||
AccessKey string | ||
SecretKey string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package config | ||
|
||
type RedisBase struct { | ||
Host string | ||
Username string | ||
Password string | ||
DB int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package config | ||
|
||
type WeWork struct { | ||
CropId string | ||
AgentId int | ||
Secret string | ||
Token string | ||
EncodingAESKey string | ||
OAuth struct { | ||
Callback string | ||
Scopes []string | ||
} | ||
HttpDebug bool | ||
Debug bool | ||
} | ||
|
||
type WechatOA struct { | ||
AppId string | ||
Secret string | ||
AESKey string | ||
OAuth struct { | ||
Callback string | ||
Scopes []string | ||
} | ||
HttpDebug bool | ||
Debug bool | ||
} | ||
|
||
type WechatPay struct { | ||
AppId string | ||
MchId string | ||
MchApiV3Key string | ||
Key string | ||
CertPath string | ||
KeyPath string | ||
RSAPublicKeyPath string | ||
SerialNo string | ||
WechatPaySerial string | ||
NotifyUrl string | ||
HttpDebug bool | ||
Debug bool | ||
} | ||
|
||
type WechatMP struct { | ||
AppId string | ||
Secret string | ||
AESKey string | ||
OAuth struct { | ||
Callback string | ||
Scopes []string | ||
} | ||
HttpDebug bool | ||
Debug bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package auth | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/openapi/auth" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
// Auth by platform | ||
func AuthPlatformHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.PlatformAuthRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := auth.NewAuthPlatformLogic(r.Context(), svcCtx) | ||
resp, err := l.AuthPlatform(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
Oops, something went wrong.