From de4bcd1dead50b05f716bc5718be5540bdb96783 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期日, 28 四月 2024 17:23:29 +0800
Subject: [PATCH] fix
---
service/test/supplier.go | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/service/test/supplier.go b/service/test/supplier.go
index 27f4a39..0405acc 100644
--- a/service/test/supplier.go
+++ b/service/test/supplier.go
@@ -54,6 +54,10 @@
db := global.GVA_DB.Model(&test.Supplier{})
var ss []test.Supplier
// 濡傛灉鏈夋潯浠舵悳绱� 涓嬫柟浼氳嚜鍔ㄥ垱寤烘悳绱㈣鍙�
+ if info.Keyword != "" {
+ keyword := "%" + info.Keyword + "%"
+ db = db.Where("name LIKE ? or number LIKE ?", keyword, keyword)
+ }
if info.StartCreatedAt != nil && info.EndCreatedAt != nil {
db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt)
}
@@ -101,3 +105,24 @@
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)
+ }
+ if info.Number != "" {
+ db = db.Where("number = ?", info.Number)
+ }
+ 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