knowledgeaddlogic.go 1.1 KB

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