fix
wangpengfei
2023-08-30 82c058c91daed212fd9b3807dca9ca80217ce738
service/test/supplier.go
@@ -1,10 +1,10 @@
package test
import (
   "github.com/flipped-aurora/gin-vue-admin/server/global"
   "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
   "github.com/flipped-aurora/gin-vue-admin/server/model/test"
   testReq "github.com/flipped-aurora/gin-vue-admin/server/model/test/request"
   "srm/global"
   "srm/model/common/request"
   "srm/model/test"
   testReq "srm/model/test/request"
)
type SupplierService struct {
@@ -34,7 +34,7 @@
// 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
}
@@ -60,11 +60,35 @@
   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("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).Preload("Contract").Find(&ss).Error
   return ss, total, err
}
// ChangeStatus Change supplier status
func (sService *SupplierService) ChangeStatus(id uint, status int) (err error) {
   err = global.GVA_DB.Model(&test.Supplier{}).Where("id = ?", id).Update("status", status).Error
   return err
}