knowledgeaddlogic.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package logic
  2. import (
  3. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/api/knowledge/internal/svc"
  4. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/api/knowledge/internal/types"
  5. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/knowledge"
  6. "context"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type KnowledgeAddLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewKnowledgeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) KnowledgeAddLogic {
  15. return KnowledgeAddLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *KnowledgeAddLogic) KnowledgeAdd(req types.AddKnowledgeReq) (*types.CommonRes, error) {
  22. resp, err := l.svcCtx.Knowledge.KnowledgeAdd(l.ctx, &knowledge.AddRequest{
  23. Question: req.Question,
  24. Answer: req.Answer,
  25. EntUserId: req.EntUserId,
  26. EntId: req.EntId,
  27. AppId: req.AppId,
  28. })
  29. if err != nil {
  30. return nil, err
  31. }
  32. return &types.CommonRes{
  33. Error_msg: resp.ErrorMsg,
  34. Error_code: int(resp.ErrorCode),
  35. Data: resp.Data,
  36. }, nil
  37. }