From dd07a07290bf66fde945dbbebc23ae048205775d Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期五, 22 九月 2023 10:19:46 +0800 Subject: [PATCH] 分页查询product列表搜索条件合并 --- service/test/product.go | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/service/test/product.go b/service/test/product.go index 7bc0813..1079d11 100644 --- a/service/test/product.go +++ b/service/test/product.go @@ -54,6 +54,10 @@ db := global.GVA_DB.Model(&test.Product{}) var ps []test.Product // 濡傛灉鏈夋潯浠舵悳绱� 涓嬫柟浼氳嚜鍔ㄥ垱寤烘悳绱㈣鍙� + //鎼滅储妗嗗悎涓�娣诲姞鏌ヨ鏉′欢 + if info.Keyword != "" { + db = db.Where("Product.name LIKE ?", "%"+info.Keyword+"%").Joins("Supplier").Or("Supplier.name LIKE ?", "%"+info.Keyword+"%") + } if info.StartCreatedAt != nil && info.EndCreatedAt != nil { db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt) } -- Gitblit v1.8.0