csfetchhistorylistlogic.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package logic
  2. import (
  3. "context"
  4. "ylink/comm/ctxdata"
  5. "ylink/core/cmd/rpc/cmd"
  6. "ylink/bff/cmdbff/api/internal/svc"
  7. "ylink/bff/cmdbff/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type CsFetchHistoryListLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewCsFetchHistoryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CsFetchHistoryListLogic {
  16. return &CsFetchHistoryListLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *CsFetchHistoryListLogic) CsFetchHistoryList(req *types.CsFetchHistoryChatReq) (resp *types.CsFetchHistoryChatResp, err error) {
  23. csId := ctxdata.GetCsIdFromCtx(l.ctx)
  24. cmdResp, err := l.svcCtx.CmdRpc.CsFetchHistoryChat(l.ctx, &cmd.CsFetchHistoryChatReq{
  25. CsId: csId,
  26. Page: req.Page,
  27. Limit: req.Limit,
  28. })
  29. if err != nil {
  30. return nil, err
  31. }
  32. return &types.CsFetchHistoryChatResp{
  33. TotalPage: cmdResp.TotalPage,
  34. CurrentPage: cmdResp.CurrentPage,
  35. List: cmdResp.List.AsSlice(),
  36. }, nil
  37. }