protoc-gen-slc/tpl/logic.go

53 lines
844 B
Go

package tpl
var LogicFile = `package {methodName}
import (
"context"
{import}
"git.apinb.com/bsm-sdk/core/service"
)
{comment}
func {func}(ctx context.Context, in *pb.{input}) (reply *pb.{output},err error) {
// parse authorization meta.
_, err = service.ParseMetaCtx(ctx, nil)
if err != nil {
return nil, err
}
{valid}
// TODO: add your logic code & delete this line.
{return}
}
`
var CreateCode = `
`
var ValidCode = `
// valildate request id,identity.
if in.Id == 0 && in.Identity == "" {
return nil, errcode.ErrInvalidArgument
}
`
var FetchValidCode = `
// valildate request page_no,page_size.
if in.GetPageNo() < 1 {
in.PageNo = 1
}
if in.GetPageSize() < 10 {
in.PageSize = 50
}
`
var StatusReplyCode = `
return &pb.StatusReply{
Code: 0,
Message: "OK",
Timeseq: time.Now().UnixNano(),
}, nil
`