findanswerlogic.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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/knowledge"
  7. "context"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type FindAnswerLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewFindAnswerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindAnswerLogic {
  16. return &FindAnswerLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // FindAnswer 根据问题查询答案
  23. func (l *FindAnswerLogic) FindAnswer(in *knowledge.FindAnswerReq) (*knowledge.FindAnswerResp, error) {
  24. k := service.KnowledgeService{}
  25. question := k.FindAnswer(in, C.Es.Addr, C.Es.Index, C.Segment)
  26. return &knowledge.FindAnswerResp{
  27. ErrorCode: 0,
  28. ErrorMsg: "请求成功",
  29. Data: question,
  30. }, nil
  31. }