From c0f8f8d3a74dbdab4f6ab4926fc664d818fb50f2 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期四, 25 四月 2024 16:59:22 +0800 Subject: [PATCH] 获取供应商产品 --- service/test/supplier.go | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/service/test/supplier.go b/service/test/supplier.go index 27f4a39..b4a792a 100644 --- a/service/test/supplier.go +++ b/service/test/supplier.go @@ -101,3 +101,21 @@ err := global.GVA_DB.Model(&test.Supplier{}).Count(&total).Error return int(total), err } + +func (sService *SupplierService) GetSupplierProduct(info testReq.SupplierProduct) ([]test.SupplierMaterial, int64, error) { + limit := info.PageSize + offset := info.PageSize * (info.Page - 1) + // 鍒涘缓db + db := global.GVA_DB.Model(&test.SupplierMaterial{}) + var ps []test.SupplierMaterial + var total int64 + if info.SupplierId > 0 { + db = db.Where("supplier_id = ?", info.SupplierId) + } + err := db.Count(&total).Error + if err != nil { + return ps, total, err + } + err = db.Limit(limit).Offset(offset).Order("id desc").Preload("Supplier").Find(&ps).Error + return ps, total, err +} -- Gitblit v1.8.0