满足压测处理

This commit is contained in:
李子铭 2025-03-21 16:19:44 +08:00
parent 2cdb04c522
commit 4f71228ff1
2 changed files with 4 additions and 2 deletions

View File

@ -92,7 +92,7 @@ func (p *OrderRepoImpl) GetByOutBizNo(ctx context.Context, t vo.OrderType, outBi
info := &model.Order{} info := &model.Order{}
db := p.DB(ctx) db := p.db.DB(ctx).WithContext(ctx).Model(model.Order{})
tx := db.Where(model.Order{Type: t.GetValue(), OutBizNo: outBizNo}).First(&info) tx := db.Where(model.Order{Type: t.GetValue(), OutBizNo: outBizNo}).First(&info)
if tx.Error != nil { if tx.Error != nil {
@ -122,9 +122,11 @@ func (p *OrderRepoImpl) GetByID(ctx context.Context, id uint64) (*bo.OrderBo, er
tx := p.DB(ctx).Where(model.Order{ID: id}).First(&info) tx := p.DB(ctx).Where(model.Order{ID: id}).First(&info)
if tx.Error != nil { if tx.Error != nil {
if errors.Is(tx.Error, gorm.ErrRecordNotFound) { if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
return nil, err2.ErrorDbNotFound("订单数据不存在") return nil, err2.ErrorDbNotFound("订单数据不存在")
} }
return nil, fmt.Errorf("order db fail %w", tx.Error) return nil, fmt.Errorf("order db fail %w", tx.Error)
} }

View File

@ -85,7 +85,7 @@ func (r *ProductRepoImpl) GetByProductNo(ctx context.Context, productNo string)
func (r *ProductRepoImpl) getByProductNo(ctx context.Context, item *model.Product, productNo string) (*model.Product, error) { func (r *ProductRepoImpl) getByProductNo(ctx context.Context, item *model.Product, productNo string) (*model.Product, error) {
db := r.DB(ctx) db := r.db.DB(ctx).WithContext(ctx).Model(model.Product{})
tx := db.Where(model.Product{ProductNo: productNo}).First(&item) tx := db.Where(model.Product{ProductNo: productNo}).First(&item)
if tx.Error != nil { if tx.Error != nil {