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/serviceType.go | 54 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/model/serviceType.go b/model/serviceType.go
index 7e6f686..b3e6348 100644
--- a/model/serviceType.go
+++ b/model/serviceType.go
@@ -6,24 +6,25 @@
"errors"
"fmt"
"gorm.io/gorm"
+ "sync"
)
type (
- // ServiceType 鏈嶅姟绫诲瀷
+ // ServiceType 鏈嶅姟鏂瑰紡
ServiceType 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:''"`
}
- // ServiceTypeSearch 鏈嶅姟绫诲瀷鎼滅储鏉′欢
+ // ServiceTypeSearch 鏈嶅姟鏂瑰紡鎼滅储鏉′欢
ServiceTypeSearch struct {
ServiceType
- Orm *gorm.DB
- QueryClass constvar.ServiceTypeQueryClass
- KeywordType constvar.ServiceTypeKeywordType
- Keyword string
- PageNum int
- PageSize int
+ Orm *gorm.DB
+ QueryClass constvar.ServiceTypeQueryClass
+ KeywordType constvar.ServiceTypeKeywordType
+ Keyword string
+ PageNum int
+ PageSize int
}
)
@@ -49,6 +50,11 @@
func (slf *ServiceTypeSearch) Create(record *ServiceType) error {
var db = slf.build()
return db.Create(record).Error
+}
+
+func (slf *ServiceTypeSearch) CreateBatch(records []*ServiceType) error {
+ var db = slf.build()
+ return db.Create(records).Error
}
func (slf *ServiceTypeSearch) Delete() error {
@@ -111,4 +117,32 @@
err := db.Find(&records).Error
return records, total, err
-}
\ No newline at end of file
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *ServiceTypeSearch) 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 {
+ errCh <- err
+ return
+ }
+ if total != 0 {
+ return
+ }
+ records := []*ServiceType{
+ {1, "鐢佃瘽"},
+ {2, "杩滅▼"},
+ {3, "閫佷慨"},
+ {4, "涓婇棬"},
+ {5, "鍏朵粬"},
+ }
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+ }
+}
--
Gitblit v1.8.0