findanswerlogic.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package logic
  2. import (
  3. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/knowledge"
  4. "context"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/api/knowledge/internal/svc"
  7. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/api/knowledge/internal/types"
  8. )
  9. type FindAnswerLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewFindAnswerLogic(ctx context.Context, svcCtx *svc.ServiceContext) FindAnswerLogic {
  15. return FindAnswerLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *FindAnswerLogic) FindAnswer(req types.FindAnswerReq) (*types.CommonRes, error) {
  22. // todo: add your logic here and delete this line
  23. resp, err := l.svcCtx.Knowledge.FindAnswer(l.ctx, &knowledge.FindAnswerReq{
  24. Type: req.Type,
  25. RobotEntId: req.RobotEntId,
  26. Question: req.Question,
  27. })
  28. if err != nil {
  29. return nil, err
  30. }
  31. return &types.CommonRes{
  32. Error_code: int(resp.ErrorCode),
  33. Error_msg: resp.ErrorMsg,
  34. Data: resp.Data,
  35. }, nil
  36. }