Skip to content

Commit

Permalink
feat(openapi): add brainx provider hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Sep 23, 2024
1 parent bf87847 commit 5ec7969
Show file tree
Hide file tree
Showing 17 changed files with 455 additions and 97 deletions.
1 change: 1 addition & 0 deletions api/custom.api
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Custom APis
5 changes: 4 additions & 1 deletion api/openapi.api
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import "openapi/auth.api"
import "openapi/demo.api"
import "openapi/demo.api"

// provider
import "openapi/provider/brainx/demo.api"
27 changes: 27 additions & 0 deletions api/openapi/provider/brainx/demo.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "v1"

info(
title: "Provider Demo Open API of BrainX"
desc: "This is a api of Open API in Artisan Cloud"
author: "Matrix-X"
email: "[email protected]"
version: "v1"
)

@server(
group: openapi/provider/brainx
prefix: /openapi/v1/provider/brainx
)

service PowerX {
@doc "hello world api for provider demo"
@handler HelloWorld
get /hello-world returns (HelloWorldResponse)
}


type (
HelloWorldResponse {
Message string `json:"message"`
}
)
1 change: 0 additions & 1 deletion api/powerx.api
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import "admin.wechat.offiaccount.api"
import "mp.api"
import "web.api"
import "openapi.api"

import "pro.api"
import "custom.api"
import "plugin.api"
Expand Down
1 change: 1 addition & 0 deletions api/pro.api
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Pro APis
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ module PowerX

go 1.23

//replace github.com/ArtisanCloud/PowerLibs/v3 => ../../../PowerWechat/PowerLibs

//replace github.com/ArtisanCloud/PowerWeChat/v3 => ../../../PowerWechat/PowerWeChat

require (
github.com/ArtisanCloud/PowerLibs/v3 v3.2.6
github.com/ArtisanCloud/PowerSocialite/v3 v3.0.7
github.com/ArtisanCloud/PowerWeChat/v3 v3.2.42
github.com/ArtisanCloud/PowerWeChat/v3 v3.2.45
github.com/Blank-Xu/sql-adapter v0.0.0-20210714092925-0bdd0d548758
github.com/brianvoe/gofakeit/v6 v6.21.0
github.com/casbin/casbin/v2 v2.60.0
Expand All @@ -25,7 +27,7 @@ require (
github.com/zeromicro/go-zero v1.7.2
github.com/zeromicro/go-zero/tools/goctl v1.7.2
github.com/zeromicro/zero-contrib/router/gin v0.0.0-20230708101417-16e73a5d116c
golang.org/x/crypto v0.26.0
golang.org/x/crypto v0.27.0
golang.org/x/oauth2 v0.22.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/datatypes v1.1.1
Expand Down Expand Up @@ -114,8 +116,8 @@ require (
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.66.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ github.com/ArtisanCloud/PowerLibs/v3 v3.2.6 h1:xNDXBJ1VNYAEgs4UG/lSygzU66/XG3mTA
github.com/ArtisanCloud/PowerLibs/v3 v3.2.6/go.mod h1:xFGsskCnzAu+6rFEJbGVAlwhrwZPXAny6m7j71S/B5k=
github.com/ArtisanCloud/PowerSocialite/v3 v3.0.7 h1:P+erNlErr+X2v7Et+yTWaTfIRhw+HfpAPdvNIEwk9Gw=
github.com/ArtisanCloud/PowerSocialite/v3 v3.0.7/go.mod h1:VZQNCvcK/rldF3QaExiSl1gJEAkyc5/I8RLOd3WFZq4=
github.com/ArtisanCloud/PowerWeChat/v3 v3.2.42 h1:fU+/xJPGTAsSCyoeCn036VLBLUNjDnVrH0bls9HS9hg=
github.com/ArtisanCloud/PowerWeChat/v3 v3.2.42/go.mod h1:8GMw0a41XWr5EWpV/uXOluLCdOSMShgDLReH5FgxKZ8=
github.com/ArtisanCloud/PowerWeChat/v3 v3.2.45 h1:Wi8+OTRowLI82kBZfTg9DMyiZKWuUalU7B2BkshsQHE=
github.com/ArtisanCloud/PowerWeChat/v3 v3.2.45/go.mod h1:HgdxYE6yV9OAMKIvHNRHUShq6auhFK0T2sIpUd1dG5o=
github.com/Blank-Xu/sql-adapter v0.0.0-20210714092925-0bdd0d548758 h1:L4iwZiJYTNirz4Er7Bw2+AVzW8VCpCGYc8luHc3y5lU=
github.com/Blank-Xu/sql-adapter v0.0.0-20210714092925-0bdd0d548758/go.mod h1:GlBcPpgzETyqz83HIUFEMobVY38h1fOFXgwpy7T64xE=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down Expand Up @@ -1094,8 +1094,8 @@ golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -1357,8 +1357,8 @@ golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand All @@ -1385,8 +1385,8 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
7 changes: 4 additions & 3 deletions internal/config/openapiprovider/brainx.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package openapiprovider

type BrainX struct {
BaseUrl string
AccessKey string
SecretKey string
BaseUrl string
AccessKey string
SecretKey string
ProviderName string
}
22 changes: 22 additions & 0 deletions internal/handler/openapi/provider/brainx/helloworldhandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package brainx

import (
"net/http"

"PowerX/internal/logic/openapi/provider/brainx"
"PowerX/internal/svc"
"github.com/zeromicro/go-zero/rest/httpx"
)

// hello world api for provider demo
func HelloWorldHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := brainx.NewHelloWorldLogic(r.Context(), svcCtx)
resp, err := l.HelloWorld()
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
Loading

0 comments on commit 5ec7969

Please sign in to comment.