| | |
| | | // UpdateSupplier 更新Supplier记录 |
| | | // Author [piexlmax](https://github.com/piexlmax) |
| | | func (sService *SupplierService) UpdateSupplier(s test.Supplier) (err error) { |
| | | err = global.GVA_DB.Save(&s).Error |
| | | err = global.GVA_DB.Updates(&s).Error |
| | | return err |
| | | } |
| | | |
| | |
| | | if info.Name != "" { |
| | | db = db.Where("name LIKE ?", "%"+info.Name+"%") |
| | | } |
| | | if info.Number != "" { |
| | | db = db.Where("number LIKE ?", "%"+info.Number+"%") |
| | | } |
| | | if info.SupplierType != "" { |
| | | db = db.Where("srm_supplier_type LIKE ?", "%"+info.SupplierType+"%") |
| | | } |
| | | if info.Industry != "" { |
| | | db = db.Where("industry LIKE ?", "%"+info.Industry+"%") |
| | | } |
| | | if info.Contact != "" { |
| | | db = db.Where("contact LIKE ?", "%"+info.Contact+"%") |
| | | } |
| | | if info.Phone != "" { |
| | | db = db.Where("phone LIKE ?", "%"+info.Phone+"%") |
| | | } |
| | | if info.CreatedAt != nil { |
| | | db = db.Where("created_at = ?", info.CreatedAt) |
| | | } |
| | | err = db.Count(&total).Error |
| | | if err != nil { |
| | | return |
| | | } |
| | | |
| | | err = db.Limit(limit).Offset(offset).Find(&ss).Error |
| | | err = db.Debug().Limit(limit).Offset(offset).Order("created_at desc").Preload("Contract").Find(&ss).Error |
| | | return ss, total, err |
| | | } |
| | | |