fix
wangpengfei
2023-08-18 8546acdc2a1f06253f30e0543fc202ebf5219bd0
model/serviceType.go
@@ -6,6 +6,7 @@
   "errors"
   "fmt"
   "gorm.io/gorm"
   "sync"
)
type (
@@ -119,16 +120,18 @@
}
// InitDefaultData 初始化数据
func (slf *ServiceTypeSearch) InitDefaultData() error {
func (slf *ServiceTypeSearch) 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 {
      return err
      errCh <- err
      return
   }
   if total != 0 {
      return nil
      return
   }
   records := []*ServiceType{
      {1, "电话"},
@@ -137,5 +140,9 @@
      {4, "上门"},
      {5, "其他"},
   }
   return slf.CreateBatch(records)
   err := slf.CreateBatch(records)
   if err != nil {
      errCh <- err
      return
   }
}