liujiandao
2023-10-17 93714edf943addbded3bccf1c76d1b53f46fc349
model/clientStatus.go
@@ -3,6 +3,7 @@
import (
   "aps_crm/pkg/mysqlx"
   "gorm.io/gorm"
   "sync"
)
type (
@@ -91,3 +92,37 @@
   var db = slf.build()
   return db.Updates(values).Error
}
func (slf *ClientStatusSearch) CreateBatch(records []*ClientStatus) error {
   var db = slf.build()
   return db.Create(records).Error
}
// InitDefaultData 初始化数据
func (slf *ClientStatusSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) {
   var (
      db          = slf.Orm.Table(slf.TableName())
      total int64 = 0
   )
   defer wg.Done()
   if err := db.Count(&total).Error; err != nil {
      errCh <- err
      return
   }
   if total != 0 {
      return
   }
   records := []*ClientStatus{
      {1, "初期沟通"},
      {2, "需求分析"},
      {3, "方案报价"},
      {4, "商务谈判"},
      {5, "成功结案"},
   }
   err := slf.CreateBatch(records)
   if err != nil {
      errCh <- err
      return
   }
}