knowledgelistlogic.go 990 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package logic
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. "knowledgeBase/rpc/knowledge/knowledgeclient"
  6. "knowledgeBase/api/knowledge/internal/svc"
  7. "knowledgeBase/api/knowledge/internal/types"
  8. )
  9. type KnowledgeListLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewKnowledgeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) KnowledgeListLogic {
  15. return KnowledgeListLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *KnowledgeListLogic) KnowledgeList(req types.ListReq) (*types.CommonRes, error) {
  22. // todo: add your logic here and delete this line
  23. resp, err := l.svcCtx.Knowledge.KnowledgeList(l.ctx, &knowledgeclient.ListRequest{
  24. TenantId: req.TenantId,
  25. PageIndex: req.PageIndex,
  26. PageSize: req.PageSize,
  27. })
  28. if err != nil {
  29. return nil, err
  30. }
  31. return &types.CommonRes{
  32. Error_code: int(resp.ErrorCode),
  33. Error_msg: resp.ErrorMsg,
  34. Data: resp.Data,
  35. }, nil
  36. }