首次提交

This commit is contained in:
2025-10-14 17:18:21 +08:00
commit f0155d1e63
54 changed files with 1956 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,13 @@
package hello
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/ayflying/p2p/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
}

View File

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

View File

@@ -0,0 +1,15 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package p2p
import (
"github.com/ayflying/p2p/api/p2p"
)
type ControllerV1 struct{}
func NewV1() p2p.IP2PV1 {
return &ControllerV1{}
}

View File

@@ -0,0 +1,13 @@
package p2p
import (
"context"
"github.com/ayflying/p2p/api/p2p/v1"
"github.com/ayflying/p2p/internal/service"
)
func (c *ControllerV1) Connect(ctx context.Context, req *v1.ConnectReq) (res *v1.ConnectRes, err error) {
err = service.P2P().DiscoverAndConnect(req.TargetID)
return
}

View File

@@ -0,0 +1,13 @@
package p2p
import (
"context"
"github.com/ayflying/p2p/api/p2p/v1"
"github.com/ayflying/p2p/internal/service"
)
func (c *ControllerV1) Send(ctx context.Context, req *v1.SendReq) (res *v1.SendRes, err error) {
err = service.P2P().SendData(req.TargetID, []byte(req.Data))
return
}