Browse Source

初始化

zhibo-mj
majun 7 months ago
parent
commit
5705c1c9ac
  1. 15
      api/hello/hello.go
  2. 12
      api/hello/v1/hello.go
  3. 2
      hack/config.yaml
  4. 4
      internal/cmd/cmd.go
  5. 5
      internal/controller/hello/hello.go
  6. 16
      internal/controller/hello/hello_new.go
  7. 13
      internal/controller/hello/hello_v1_hello.go

15
api/hello/hello.go

@ -1,15 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package hello
import (
"context"
"practice_Go/api/hello/v1"
)
type IHelloV1 interface {
Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error)
}

12
api/hello/v1/hello.go

@ -1,12 +0,0 @@
package v1
import (
"github.com/gogf/gf/v2/frame/g"
)
type HelloReq struct {
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"`
}
type HelloRes struct {
g.Meta `mime:"text/html" example:"string"`
}

2
hack/config.yaml

@ -4,7 +4,7 @@
gfcli: gfcli:
gen: gen:
dao: dao:
- link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test"
- link: "mysql:root:123456@tcp(127.0.0.1:3306)/demo"
descriptionTag: true descriptionTag: true
docker: docker:

4
internal/cmd/cmd.go

@ -7,7 +7,7 @@ import (
"github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd" "github.com/gogf/gf/v2/os/gcmd"
"practice_Go/internal/controller/hello"
) )
var ( var (
@ -20,7 +20,7 @@ var (
s.Group("/", func(group *ghttp.RouterGroup) { s.Group("/", func(group *ghttp.RouterGroup) {
group.Middleware(ghttp.MiddlewareHandlerResponse) group.Middleware(ghttp.MiddlewareHandlerResponse)
group.Bind( group.Bind(
hello.NewV1(),
) )
}) })
s.Run() s.Run()

5
internal/controller/hello/hello.go

@ -1,5 +0,0 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package hello

16
internal/controller/hello/hello_new.go

@ -1,16 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package hello
import (
"practice_Go/api/hello"
)
type ControllerV1 struct{}
func NewV1() hello.IHelloV1 {
return &ControllerV1{}
}

13
internal/controller/hello/hello_v1_hello.go

@ -1,13 +0,0 @@
package hello
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"practice_Go/api/hello/v1"
)
func (c *ControllerV1) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) {
g.RequestFromCtx(ctx).Response.Writeln("Hello World!")
return
}
Loading…
Cancel
Save