From 5f0170df9787c6f3ff17cc168b3f2e3f511453f6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 31 十月 2023 20:04:16 +0800
Subject: [PATCH] 支持职级降级的情况
---
model/invoiceType.go | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/model/invoiceType.go b/model/invoiceType.go
index 55eced6..8c2057b 100644
--- a/model/invoiceType.go
+++ b/model/invoiceType.go
@@ -6,24 +6,25 @@
"errors"
"fmt"
"gorm.io/gorm"
+ "sync"
)
type (
// InvoiceType 鍙戠エ绫诲瀷
InvoiceType 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"`
}
// InvoiceTypeSearch 鍙戠エ绫诲瀷鎼滅储鏉′欢
InvoiceTypeSearch struct {
InvoiceType
- Orm *gorm.DB
- QueryClass constvar.InvoiceTypeQueryClass
- KeywordType constvar.InvoiceTypeKeywordType
- Keyword string
- PageNum int
- PageSize int
+ Orm *gorm.DB
+ QueryClass constvar.InvoiceTypeQueryClass
+ KeywordType constvar.InvoiceTypeKeywordType
+ Keyword string
+ PageNum int
+ PageSize int
}
)
@@ -124,17 +125,28 @@
}
// InitDefaultData 鍒濆鍖栨暟鎹�
-func (slf *InvoiceTypeSearch) InitDefaultData() error {
+func (slf *InvoiceTypeSearch) 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 := []*InvoiceType{}
- return slf.CreateBatch(records)
+ records := []*InvoiceType{
+ {1, "澧炵エ6%"},
+ {2, "澧炵エ16%"},
+ {3, "澧炵エ17%"},
+ }
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+
+ }
}
--
Gitblit v1.8.0