|
@@ -0,0 +1,42 @@
|
|
|
+package logic
|
|
|
+
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+ "github.com/zeromicro/go-zero/core/logx"
|
|
|
+ "knowledgeBase/rpc/knowledge/knowledgeclient"
|
|
|
+
|
|
|
+ "knowledgeBase/api/knowledge/internal/svc"
|
|
|
+ "knowledgeBase/api/knowledge/internal/types"
|
|
|
+)
|
|
|
+
|
|
|
+type RecommendAnswerLogic struct {
|
|
|
+ logx.Logger
|
|
|
+ ctx context.Context
|
|
|
+ svcCtx *svc.ServiceContext
|
|
|
+}
|
|
|
+
|
|
|
+func NewRecommendAnswerLogic(ctx context.Context, svcCtx *svc.ServiceContext) RecommendAnswerLogic {
|
|
|
+ return RecommendAnswerLogic{
|
|
|
+ Logger: logx.WithContext(ctx),
|
|
|
+ ctx: ctx,
|
|
|
+ svcCtx: svcCtx,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (l *RecommendAnswerLogic) RecommendAnswer(req types.FindAnswerReq) (*types.CommonRes, error) {
|
|
|
+ // todo: add your logic here and delete this line
|
|
|
+ resp, err := l.svcCtx.Knowledge.RecommendAnswer(l.ctx, &knowledgeclient.FindAnswerReq{
|
|
|
+ AppId: req.AppId,
|
|
|
+ Type: req.Type,
|
|
|
+ TenantId: req.TenantId,
|
|
|
+ Question: req.Question,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return &types.CommonRes{
|
|
|
+ Error_code: int(resp.ErrorCode),
|
|
|
+ Error_msg: resp.ErrorMsg,
|
|
|
+ Data: resp.Data,
|
|
|
+ }, nil
|
|
|
+}
|