itemHistoryDataInfoLogic.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package datacenter
  2. import (
  3. "GtDataStore/app/cmd/organization/pb"
  4. "context"
  5. "github.com/jinzhu/copier"
  6. "GtDataStore/app/cmd/api/internal/svc"
  7. "GtDataStore/app/cmd/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type ItemHistoryDataInfoLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewItemHistoryDataInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemHistoryDataInfoLogic {
  16. return &ItemHistoryDataInfoLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *ItemHistoryDataInfoLogic) ItemHistoryDataInfo(req *types.ItemHistoryDataByTimeResq) (resp *types.MultiAddItemHistoryDataReq, err error) {
  23. respList := make([]*types.ItemHistoryData, 0)
  24. dataList, err := l.svcCtx.OrganizationRpc.ItemHistoryDataByTime(l.ctx, &pb.ItemHistoryDataByTimeReq{
  25. ProjectId: req.ProjectId,
  26. ItemName: req.ItemName,
  27. Stime: req.STime,
  28. Etime: req.ETime,
  29. })
  30. if err != nil {
  31. return nil, err
  32. }
  33. for _, line := range dataList.List {
  34. tmp := &types.ItemHistoryData{}
  35. _ = copier.Copy(tmp, line)
  36. respList = append(respList, tmp)
  37. }
  38. return &types.MultiAddItemHistoryDataReq{List: respList}, nil
  39. }