knowledgeaddlogic.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package logic
  2. import (
  3. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/internal/service"
  4. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/internal/svc"
  5. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/knowledgeclient"
  6. "context"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type KnowledgeAddLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewKnowledgeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *KnowledgeAddLogic {
  15. return &KnowledgeAddLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. type Question struct {
  22. Question string `json:"question"`
  23. KeyWords string `json:"keyWords"`
  24. }
  25. // KnowledgeAdd 知识新增
  26. func (l *KnowledgeAddLogic) KnowledgeAdd(in *knowledgeclient.AddRequest) (*knowledgeclient.AddResponse, error) {
  27. result := &knowledgeclient.AddResponse{}
  28. k := service.KnowledgeService{}
  29. ok, msg, err := k.KnowledgeAdd(in)
  30. if !ok && err != nil {
  31. result.ErrorCode = -1
  32. result.ErrorMsg = msg
  33. } else {
  34. result.ErrorCode = 0
  35. result.ErrorMsg = msg
  36. }
  37. return result, nil
  38. }