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/timeSpent.go | 39 +++++++++++++++++++++++++++------------
1 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/model/timeSpent.go b/model/timeSpent.go
index de29623..926d4de 100644
--- a/model/timeSpent.go
+++ b/model/timeSpent.go
@@ -6,24 +6,25 @@
"errors"
"fmt"
"gorm.io/gorm"
+ "sync"
)
type (
// TimeSpent 鑺辫垂鏃堕棿
TimeSpent 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;type:varchar(255);not null;default:'';comment:鍚嶇О"`
}
// TimeSpentSearch 鑺辫垂鏃堕棿鎼滅储鏉′欢
TimeSpentSearch struct {
TimeSpent
- Orm *gorm.DB
- QueryClass constvar.TimeSpentQueryClass
- KeywordType constvar.TimeSpentKeywordType
- Keyword string
- PageNum int
- PageSize int
+ Orm *gorm.DB
+ QueryClass constvar.TimeSpentQueryClass
+ KeywordType constvar.TimeSpentKeywordType
+ Keyword string
+ PageNum int
+ PageSize int
}
)
@@ -119,17 +120,31 @@
}
// InitDefaultData 鍒濆鍖栨暟鎹�
-func (slf *TimeSpentSearch) InitDefaultData() error {
+func (slf *TimeSpentSearch) 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 := []*TimeSpent{}
- return slf.CreateBatch(records)
+ records := []*TimeSpent{
+ {1, "1灏忔椂"},
+ {2, "2灏忔椂"},
+ {3, "0.5涓伐浣滄棩"},
+ {4, "1涓伐浣滄棩"},
+ {5, "2涓伐浣滄棩"},
+ {6, "2涓伐浣滄棩浠ヤ笂"},
+ }
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+ }
}
--
Gitblit v1.8.0