mirror of
https://github.com/cubixle/tuugen.git
synced 2026-04-24 23:04:45 +01:00
wip
This commit is contained in:
26
templates/service.go.tmpl
Normal file
26
templates/service.go.tmpl
Normal file
@@ -0,0 +1,26 @@
|
||||
package service
|
||||
|
||||
import ({{ range .Imports }}
|
||||
"{{ . }}"{{ end }}
|
||||
)
|
||||
|
||||
func New() *Service {
|
||||
return &Service{}
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
interactor *interactors.Interactor
|
||||
}
|
||||
{{ range .Funcs }}
|
||||
func (s *Service) {{ .Name }}({{.ArgsToStr}}) {{ if gt (len .Returns) 0 }}({{.ListToStr .Returns}}){{end}} {
|
||||
res, err := s.interactor.{{.Name}}(ctx, req)
|
||||
if err != nil {
|
||||
return nil, errorToGRPCError(err)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
func errorToGRPCError(err error) error {
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user