feat: add support
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
support "lone-services/rpc/support/pb"
|
||||
"lone-services/services/support/internal/ccc"
|
||||
"lone-services/services/support/internal/svc"
|
||||
"lone-services/services/support/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CallLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCallLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CallLogic {
|
||||
return &CallLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CallLogic) Call(in *support.CallReq) (*support.Response, error) {
|
||||
var req validator.CallValidator
|
||||
if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return outResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
endpoint := utils.GetConfigString("ccc.endpoint")
|
||||
body, err := ccc.Call(req.Action, req.Version, req.Request, req.A, req.S, endpoint)
|
||||
if err != nil {
|
||||
l.Errorf("ccc call action=%s version=%s: %v", req.Action, req.Version, err)
|
||||
return outResponse(utils.Fail, err.Error()), nil
|
||||
}
|
||||
return okResponse(body), nil
|
||||
}
|
||||
Reference in New Issue
Block a user