From 250cbfa1ddcb3cf38e0d0505c1c7e282b940d25b Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 13 十月 2023 10:30:05 +0800
Subject: [PATCH] admin user id 转crm user id
---
model/courierCompany.go | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/model/courierCompany.go b/model/courierCompany.go
index e78f481..da1e65d 100644
--- a/model/courierCompany.go
+++ b/model/courierCompany.go
@@ -6,24 +6,25 @@
"errors"
"fmt"
"gorm.io/gorm"
+ "sync"
)
type (
// CourierCompany 鐗╂祦鍏徃
CourierCompany 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"`
}
// CourierCompanySearch 鐗╂祦鍏徃鎼滅储鏉′欢
CourierCompanySearch struct {
CourierCompany
- Orm *gorm.DB
- QueryClass constvar.CourierCompanyQueryClass
- KeywordType constvar.CourierCompanyKeywordType
- Keyword string
- PageNum int
- PageSize int
+ Orm *gorm.DB
+ QueryClass constvar.CourierCompanyQueryClass
+ KeywordType constvar.CourierCompanyKeywordType
+ Keyword string
+ PageNum int
+ PageSize int
}
)
@@ -124,17 +125,28 @@
}
// InitDefaultData 鍒濆鍖栨暟鎹�
-func (slf *CourierCompanySearch) InitDefaultData() error {
+func (slf *CourierCompanySearch) 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 := []*CourierCompany{}
- return slf.CreateBatch(records)
+ records := []*CourierCompany{
+ {1, "椤轰赴"},
+ {2, "寰烽偊"},
+ {3, "涓繙娴疯繍"},
+ }
+
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+ }
}
--
Gitblit v1.8.0