knowledgeeditlogic.go 1.1 KB

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