knowledgeaddlogic.go 1018 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package logic
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. "knowledgeBase/rpc/knowledge/knowledge"
  6. "knowledgeBase/api/knowledge/internal/svc"
  7. "knowledgeBase/api/knowledge/internal/types"
  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. // todo: add your logic here and delete this line
  23. resp, err := l.svcCtx.Knowledge.KnowledgeAdd(l.ctx, &knowledge.AddRequest{
  24. Question: req.Question,
  25. Answer: req.Answer,
  26. Person: req.Person,
  27. TenantId: req.TenanId,
  28. AppId: req.AppId,
  29. })
  30. if err != nil {
  31. return nil, err
  32. }
  33. return &types.CommonRes{
  34. Error_msg: resp.ErrorMsg,
  35. Error_code: int(resp.ErrorCode),
  36. Data: resp.Data,
  37. }, nil
  38. }