1
0

apilogic.tpl 650 B

123456789101112131415161718192021222324252627282930313233343536
  1. package logic
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. "{{.svcPkg}}"
  6. "{{.typesPkg}}"{{if .callRPC}}
  7. "{{.rpcClientPkg}}"{{end}}
  8. )
  9. type PingLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
  15. return &PingLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *PingLogic) Ping() (resp *types.Resp, err error) {
  22. {{if .callRPC}}if _, err = l.svcCtx.GreetRpc.Ping(l.ctx, new(greet.Placeholder)); err != nil {
  23. return
  24. }
  25. {{end}}resp = new(types.Resp)
  26. resp.Msg = "pong"
  27. return
  28. }