|
@@ -0,0 +1,40 @@
|
|
|
+package logic
|
|
|
+
|
|
|
+import (
|
|
|
+ "GtDataStore/app/cmd/organization/internal/svc"
|
|
|
+ "GtDataStore/app/cmd/organization/pb"
|
|
|
+ "GtDataStore/common/xerr"
|
|
|
+ "context"
|
|
|
+ "github.com/pkg/errors"
|
|
|
+
|
|
|
+ "github.com/zeromicro/go-zero/core/logx"
|
|
|
+)
|
|
|
+
|
|
|
+type ItemHistoryDataFirstLastByTimeLogic struct {
|
|
|
+ ctx context.Context
|
|
|
+ svcCtx *svc.ServiceContext
|
|
|
+ logx.Logger
|
|
|
+}
|
|
|
+
|
|
|
+func NewItemHistoryDataFirstLastByTimeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemHistoryDataFirstLastByTimeLogic {
|
|
|
+ return &ItemHistoryDataFirstLastByTimeLogic{
|
|
|
+ ctx: ctx,
|
|
|
+ svcCtx: svcCtx,
|
|
|
+ Logger: logx.WithContext(ctx),
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (l *ItemHistoryDataFirstLastByTimeLogic) ItemHistoryDataFirstLastByTime(in *pb.ItemHistoryDataByTimeReq) (*pb.ItemHistoryDataFirstLastResp, error) {
|
|
|
+ FirstData, err := l.svcCtx.ItemHistoryData.QueryHistoryDataFirstByTime(l.ctx, in)
|
|
|
+ if err != nil {
|
|
|
+ return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "model QueryHistoryDataFirstByTime get data err:%v", err)
|
|
|
+ }
|
|
|
+ LastData, err := l.svcCtx.ItemHistoryData.QueryHistoryDataLastByTime(l.ctx, in)
|
|
|
+ if err != nil {
|
|
|
+ return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "model QueryHistoryDataLastByTime get data err:%v", err)
|
|
|
+ }
|
|
|
+ return &pb.ItemHistoryDataFirstLastResp{
|
|
|
+ First: FirstData.Val,
|
|
|
+ Last: LastData.Val,
|
|
|
+ }, nil
|
|
|
+}
|