guesstoasklogic.go 1.1 KB

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