zhangqian
2023-11-01 530fed8ec225453572d57b15c200ab062c335457
model/serviceOrderStatus.go
@@ -6,24 +6,25 @@
   "errors"
   "fmt"
   "gorm.io/gorm"
   "sync"
)
type (
   // ServiceOrderStatus 服务单状态
   ServiceOrderStatus struct {
      Id   int    `json:"id" gorm:"column:id;type:int;primary_key;AUTO_INCREMENT"`
       Name string `json:"name" gorm:"column:name;type:varchar(255);not null;default:'';comment:名称"`
      Name string `json:"name" gorm:"column:name;type:varchar(255);not null;default:'';comment:名称"`
   }
   // ServiceOrderStatusSearch 服务单状态搜索条件
   ServiceOrderStatusSearch struct {
      ServiceOrderStatus
      Orm *gorm.DB
        QueryClass  constvar.ServiceOrderStatusQueryClass
        KeywordType constvar.ServiceOrderStatusKeywordType
        Keyword     string
        PageNum  int
        PageSize int
      Orm         *gorm.DB
      QueryClass  constvar.ServiceOrderStatusQueryClass
      KeywordType constvar.ServiceOrderStatusKeywordType
      Keyword     string
      PageNum     int
      PageSize    int
   }
)
@@ -129,17 +130,29 @@
}
// InitDefaultData 初始化数据
func (slf *ServiceOrderStatusSearch) InitDefaultData() error {
func (slf *ServiceOrderStatusSearch) 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 := []*ServiceOrderStatus{}
   return slf.CreateBatch(records)
   records := []*ServiceOrderStatus{
      {1, "未处理"},
      {2, "处理中"},
      {3, "等待回应"},
      {4, "成功关闭"},
   }
   err := slf.CreateBatch(records)
   if err != nil {
      errCh <- err
      return
   }
}