liujiandao
2023-09-22 dd07a07290bf66fde945dbbebc23ae048205775d
分页查询product列表搜索条件合并
1个文件已修改
4 ■■■■ 已修改文件
service/test/product.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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)
    }