zhangqian
2023-11-21 3bdc6225a61aaf20583642ea5a1319109c22072e
service/test/supplier.go
@@ -11,42 +11,42 @@
}
// CreateSupplier 创建Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) CreateSupplier(s *test.Supplier) (err error) {
   err = global.GVA_DB.Create(s).Error
   return err
}
// DeleteSupplier 删除Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) DeleteSupplier(s test.Supplier) (err error) {
   err = global.GVA_DB.Delete(&s).Error
   return err
}
// DeleteSupplierByIds 批量删除Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) DeleteSupplierByIds(ids request.IdsReq) (err error) {
   err = global.GVA_DB.Delete(&[]test.Supplier{}, "id in ?", ids.Ids).Error
   return err
}
// UpdateSupplier 更新Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) UpdateSupplier(s test.Supplier) (err error) {
   err = global.GVA_DB.Updates(&s).Error
   return err
}
// GetSupplier 根据id获取Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) GetSupplier(id uint) (s test.Supplier, err error) {
   err = global.GVA_DB.Where("id = ?", id).First(&s).Error
   return
}
// GetSupplierByNumber 根据编码获取Supplier记录
func (sService *SupplierService) GetSupplierByNumber(number string) (s test.Supplier, err error) {
   err = global.GVA_DB.Where("number = ?", number).First(&s).Error
   return
}
// GetSupplierInfoList 分页获取Supplier记录
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) GetSupplierInfoList(info testReq.SupplierSearch) (list []test.Supplier, total int64, err error) {
   limit := info.PageSize
   offset := info.PageSize * (info.Page - 1)
@@ -64,7 +64,7 @@
      db = db.Where("number LIKE ?", "%"+info.Number+"%")
   }
   if info.SupplierType != "" {
      db = db.Where("supplier_type LIKE ?", "%"+info.SupplierType+"%")
      db = db.Where("srm_supplier_type LIKE ?", "%"+info.SupplierType+"%")
   }
   if info.Industry != "" {
      db = db.Where("industry LIKE ?", "%"+info.Industry+"%")
@@ -83,7 +83,7 @@
      return
   }
   err = db.Debug().Limit(limit).Offset(offset).Preload("Contract").Find(&ss).Error
   err = db.Debug().Limit(limit).Offset(offset).Order("created_at desc").Preload("Contract").Find(&ss).Error
   return ss, total, err
}