zhangqian
2023-11-01 530fed8ec225453572d57b15c200ab062c335457
model/invoiceStatus.go
@@ -6,24 +6,25 @@
   "errors"
   "fmt"
   "gorm.io/gorm"
   "sync"
)
type (
   // InvoiceStatus 发票状态
   InvoiceStatus struct {
      Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
      Name   string    `json:"name" gorm:"column:name"`
      Name string `json:"name" gorm:"column:name"`
   }
   // InvoiceStatusSearch 发票状态搜索条件
   InvoiceStatusSearch struct {
      InvoiceStatus
      Orm *gorm.DB
        QueryClass  constvar.InvoiceStatusQueryClass
        KeywordType constvar.InvoiceStatusKeywordType
        Keyword     string
        PageNum  int
        PageSize int
      Orm         *gorm.DB
      QueryClass  constvar.InvoiceStatusQueryClass
      KeywordType constvar.InvoiceStatusKeywordType
      Keyword     string
      PageNum     int
      PageSize    int
   }
)
@@ -124,17 +125,28 @@
}
// InitDefaultData 初始化数据
func (slf *InvoiceStatusSearch) InitDefaultData() error {
func (slf *InvoiceStatusSearch) 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 := []*InvoiceStatus{}
   return slf.CreateBatch(records)
   records := []*InvoiceStatus{
      {1, "已创建"},
      {2, "已寄送"},
      {3, "自动创建"},
   }
   err := slf.CreateBatch(records)
   if err != nil {
      errCh <- err
      return
   }
}