recommendanswerlogic.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package logic
  2. import (
  3. . "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/init"
  4. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/internal/service"
  5. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/internal/svc"
  6. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/knowledgeclient"
  7. "context"
  8. "fmt"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type RecommendAnswerLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewRecommendAnswerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RecommendAnswerLogic {
  17. return &RecommendAnswerLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. // RecommendAnswer 根据问题推荐3个答案
  24. func (l *RecommendAnswerLogic) RecommendAnswer(in *knowledgeclient.FindAnswerReq) (*knowledgeclient.RecommendAnswerResp, error) {
  25. var result = &knowledgeclient.RecommendAnswerResp{}
  26. k := service.KnowledgeService{}
  27. answers := k.RecommendAnswer(in, C.Segment)
  28. fmt.Println("推荐答案2", answers)
  29. result.ErrorCode = 0
  30. result.ErrorMsg = "请求成功"
  31. result.Data = answers
  32. return result, nil
  33. }