| | |
| | | DeliveryTime: p.DeliveryTime, |
| | | ShippingDuration: p.ShippingDuration, |
| | | Specifications: p.Specifications, |
| | | CategoryName: p.CategoryName, |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | return |
| | | } |
| | | |
| | | // GetMaterials 获取物料 |
| | | func (pService *ProductService) GetMaterials(info testReq.ProductSearch) (list []test.Material, total int64, err error) { |
| | | limit := info.PageSize |
| | | offset := info.PageSize * (info.Page - 1) |
| | | // 创建db |
| | | db := global.GVA_DB.Model(&test.Material{}) |
| | | var ps []test.Material |
| | | if info.Keyword != "" { |
| | | db = db.Where("name LIKE ? or number LIKE ?", "%"+info.Name+"%", "%"+info.Number+"%") |
| | | } |
| | | |
| | | db = db.Where("purchase_type = ?", test.PurchaseTypeOutSource) |
| | | |
| | | err = db.Count(&total).Error |
| | | if err != nil { |
| | | return |
| | | } |
| | | |
| | | err = db.Limit(limit).Offset(offset).Find(&ps).Error |
| | | return ps, total, err |
| | | } |