| | |
| | | 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 |
| | | } |