|
@@ -6,6 +6,7 @@ import (
|
|
|
"GtDataStore/common/xerr"
|
|
|
"context"
|
|
|
"github.com/pkg/errors"
|
|
|
+ "github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
|
@@ -25,14 +26,19 @@ func NewItemHistoryDataFirstLastByTimeLogic(ctx context.Context, svcCtx *svc.Ser
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
+ FirstData, err1 := l.svcCtx.ItemHistoryData.QueryHistoryDataFirstByTime(l.ctx, in)
|
|
|
+ if err1 != nil && err1 != sqlx.ErrNotFound {
|
|
|
+ return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "model QueryHistoryDataFirstByTime get data err:%v", err1)
|
|
|
}
|
|
|
- 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)
|
|
|
+ LastData, err2 := l.svcCtx.ItemHistoryData.QueryHistoryDataLastByTime(l.ctx, in)
|
|
|
+ if err2 != nil && err2 != sqlx.ErrNotFound {
|
|
|
+ return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "model QueryHistoryDataLastByTime get data err:%v", err2)
|
|
|
}
|
|
|
+
|
|
|
+ if err1 == sqlx.ErrNotFound && err2 == sqlx.ErrNotFound {
|
|
|
+ return nil, nil
|
|
|
+ }
|
|
|
+
|
|
|
return &pb.ItemHistoryDataFirstLastResp{
|
|
|
First: FirstData.Val,
|
|
|
Last: LastData.Val,
|