|
@@ -1,35 +1,35 @@
|
|
|
package logic
|
|
|
|
|
|
import (
|
|
|
- "context"
|
|
|
+ "context"
|
|
|
|
|
|
- "github.com/zeromicro/go-zero/core/logx"
|
|
|
- "greet/api/internal/svc"
|
|
|
- "greet/api/internal/types"
|
|
|
- {{if .callRPC}}"greet/rpc/greet"
|
|
|
-{{end}}
|
|
|
+ "github.com/zeromicro/go-zero/core/logx"
|
|
|
+ "greet/api/internal/svc"
|
|
|
+ "greet/api/internal/types"{{if .callRPC}}
|
|
|
+ "greet/rpc/greet"{{end}}
|
|
|
)
|
|
|
|
|
|
type PingLogic struct {
|
|
|
- logx.Logger
|
|
|
- ctx context.Context
|
|
|
- svcCtx *svc.ServiceContext
|
|
|
+ logx.Logger
|
|
|
+ ctx context.Context
|
|
|
+ svcCtx *svc.ServiceContext
|
|
|
}
|
|
|
|
|
|
func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
|
|
|
- return &PingLogic{
|
|
|
- Logger: logx.WithContext(ctx),
|
|
|
- ctx: ctx,
|
|
|
- svcCtx: svcCtx,
|
|
|
- }
|
|
|
+ return &PingLogic{
|
|
|
+ Logger: logx.WithContext(ctx),
|
|
|
+ ctx: ctx,
|
|
|
+ svcCtx: svcCtx,
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func (l *PingLogic) Ping() (resp *types.Resp, err error) {
|
|
|
- {{if .callRPC}}if _, err = l.svcCtx.GreetRpc.Ping(l.ctx, &greet.Placeholder{});err !=nil {
|
|
|
- return
|
|
|
- }{{end}}
|
|
|
- resp = new(types.Resp)
|
|
|
- resp.Msg = "pong"
|
|
|
+ {{if .callRPC}}if _, err = l.svcCtx.GreetRpc.Ping(l.ctx, new(greet.Placeholder)); err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- return
|
|
|
+ {{end}}resp = new(types.Resp)
|
|
|
+ resp.Msg = "pong"
|
|
|
+
|
|
|
+ return
|
|
|
}
|