mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 18:00:24 +08:00
555c4ecd1a
* chore: fix typo * fix: quickstart in dir with go.mod * fix: runner failed * chore: refine code * chore: simplify quickstart mono
37 lines
650 B
Smarty
37 lines
650 B
Smarty
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
"{{.svcPkg}}"
|
|
"{{.typesPkg}}"{{if .callRPC}}
|
|
"{{.rpcClientPkg}}"{{end}}
|
|
)
|
|
|
|
type PingLogic struct {
|
|
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,
|
|
}
|
|
}
|
|
|
|
func (l *PingLogic) Ping() (resp *types.Resp, err error) {
|
|
{{if .callRPC}}if _, err = l.svcCtx.GreetRpc.Ping(l.ctx, new(greet.Placeholder)); err != nil {
|
|
return
|
|
}
|
|
|
|
{{end}}resp = new(types.Resp)
|
|
resp.Msg = "pong"
|
|
|
|
return
|
|
}
|