From 3ac5a2604899876826189fec13be1647b24f484e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Mon, 24 Mar 2025 17:50:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=88=B8=EF=BC=8C=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E5=8F=91=E5=88=B8=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/data/repoimpl/order_notify.go | 4 ++++ internal/data/repoimpl/product.go | 1 + internal/data/repoimpl/wechat_notify_register_tag.go | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/internal/data/repoimpl/order_notify.go b/internal/data/repoimpl/order_notify.go index 7877434..34be51d 100644 --- a/internal/data/repoimpl/order_notify.go +++ b/internal/data/repoimpl/order_notify.go @@ -2,6 +2,7 @@ package repoimpl import ( "context" + "errors" "gorm.io/gorm" "time" "unicode/utf8" @@ -34,6 +35,9 @@ func (p *OrderNotifyRepoImpl) GetByID(ctx context.Context, id uint64) (*bo.Order tx := p.DB(ctx).Where(model.OrderNotify{ID: id}).First(&info) if tx.Error != nil { + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { + return nil, err2.ErrorDbNotFound("orderNotify数据不存在") + } return nil, tx.Error } diff --git a/internal/data/repoimpl/product.go b/internal/data/repoimpl/product.go index 2b6b0bf..b29858d 100644 --- a/internal/data/repoimpl/product.go +++ b/internal/data/repoimpl/product.go @@ -92,6 +92,7 @@ func (r *ProductRepoImpl) getByProductNo(ctx context.Context, item *model.Produc if errors.Is(tx.Error, gorm.ErrRecordNotFound) { return nil, err2.ErrorDbNotFound("商品数据不存在") } + sqlDB, _ := db.DB() log.Warnf("product当前打开连接数:%d,空闲连接数:%d", sqlDB.Stats().OpenConnections, sqlDB.Stats().Idle) diff --git a/internal/data/repoimpl/wechat_notify_register_tag.go b/internal/data/repoimpl/wechat_notify_register_tag.go index b6a5018..6816a7b 100644 --- a/internal/data/repoimpl/wechat_notify_register_tag.go +++ b/internal/data/repoimpl/wechat_notify_register_tag.go @@ -2,6 +2,7 @@ package repoimpl import ( "context" + "errors" "gorm.io/gorm" "time" "unicode/utf8" @@ -34,6 +35,9 @@ func (p *WechatNotifyRegisterTagRepoImpl) GetByStockIdAndMchId(ctx context.Conte tx := p.DB(ctx).Where(model.WechatNotifyRegisterTag{StockCreatorMchID: stockCreatorMchID, StockID: stockId}).First(&info) if tx.Error != nil { + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { + return nil, err2.ErrorDbNotFound("notifyTag数据不存在") + } return nil, tx.Error }