From c0305be973254bd1b5a351064f8639d490564b30 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 18 八月 2023 10:13:09 +0800
Subject: [PATCH] 增加一些表的数据初始化

---
 model/timelyRate.go            |   34 ++++++++
 model/satisfaction.go          |   32 ++++++++
 model/serviceContractStatus.go |   27 ++++++
 model/index.go                 |    7 +
 model/isVisit.go               |   26 ++++++
 model/serviceOrderStatus.go    |    7 +
 model/solveRate.go             |   34 ++++++++
 model/serviceContractType.go   |   32 +++++++
 model/serviceType.go           |    2 
 9 files changed, 192 insertions(+), 9 deletions(-)

diff --git a/model/index.go b/model/index.go
index abb5a56..af21862 100644
--- a/model/index.go
+++ b/model/index.go
@@ -106,6 +106,13 @@
 		NewInvoiceTypeSearch(),
 		NewInvoiceStatusSearch(),
 		NewCourierCompanySearch(),
+		NewServiceContractStatusSearch(),
+		NewServiceContractTypeSearch(),
+		NewServiceOrderStatusSearch(),
+		NewSatisfactionSearch(),
+		NewSolveRateSearch(),
+		NewIsVisitSearch(),
+		NewTimelyRateSearch(),
 	}
 	for _, model := range models {
 		if id, ok := model.(InitDefaultData); ok {
diff --git a/model/isVisit.go b/model/isVisit.go
index f6c4af9..ec04ee3 100644
--- a/model/isVisit.go
+++ b/model/isVisit.go
@@ -11,7 +11,7 @@
 		Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
 		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
 	}
-   
+
 	IsVisitSearch struct {
 		IsVisit
 		Orm *gorm.DB
@@ -83,3 +83,27 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *IsVisitSearch) CreateBatch(records []*IsVisit) error {
+	var db = slf.build()
+	return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *IsVisitSearch) InitDefaultData() error {
+	var (
+		db          = slf.Orm.Table(slf.TableName())
+		total int64 = 0
+	)
+	if err := db.Count(&total).Error; err != nil {
+		return err
+	}
+	if total != 0 {
+		return nil
+	}
+	records := []*IsVisit{
+		{1, "鏄�"},
+		{2, "鍚�"},
+	}
+	return slf.CreateBatch(records)
+}
diff --git a/model/satisfaction.go b/model/satisfaction.go
index 11690e6..e8c3e14 100644
--- a/model/satisfaction.go
+++ b/model/satisfaction.go
@@ -77,3 +77,35 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *SatisfactionSearch) CreateBatch(records []*Satisfaction) error {
+	var db = slf.build()
+	return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *SatisfactionSearch) InitDefaultData() error {
+	var (
+		db          = slf.Orm.Table(slf.TableName())
+		total int64 = 0
+	)
+	if err := db.Count(&total).Error; err != nil {
+		return err
+	}
+	if total != 0 {
+		return nil
+	}
+	records := []*Satisfaction{
+		{1, "100%"},
+		{2, "90%"},
+		{3, "80%"},
+		{4, "70%"},
+		{5, "60%"},
+		{6, "50%"},
+		{7, "40%"},
+		{8, "30%"},
+		{9, "20%"},
+		{10, "10%"},
+	}
+	return slf.CreateBatch(records)
+}
diff --git a/model/serviceContractStatus.go b/model/serviceContractStatus.go
index f3631c4..6b4d6e3 100644
--- a/model/serviceContractStatus.go
+++ b/model/serviceContractStatus.go
@@ -11,7 +11,7 @@
 		Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
 		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
 	}
-   
+
 	ServiceContractStatusSearch struct {
 		ServiceContractStatus
 		Orm *gorm.DB
@@ -83,3 +83,28 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *ServiceContractStatusSearch) CreateBatch(records []*ServiceContractStatus) error {
+	var db = slf.build()
+	return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *ServiceContractStatusSearch) InitDefaultData() error {
+	var (
+		db          = slf.Orm.Table(slf.TableName())
+		total int64 = 0
+	)
+	if err := db.Count(&total).Error; err != nil {
+		return err
+	}
+	if total != 0 {
+		return nil
+	}
+	records := []*ServiceContractStatus{
+		{1, "宸插垱寤�"},
+		{2, "宸插鎵�"},
+		{3, "宸蹭綔搴�"},
+	}
+	return slf.CreateBatch(records)
+}
diff --git a/model/serviceContractType.go b/model/serviceContractType.go
index 086ca06..3524737 100644
--- a/model/serviceContractType.go
+++ b/model/serviceContractType.go
@@ -6,12 +6,12 @@
 )
 
 type (
-	// ServiceContractType 鍟嗘満闃舵
+	// ServiceContractType 鏈嶅姟鍚堝悓绫诲瀷
 	ServiceContractType struct {
 		Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
+		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鏈嶅姟鍚堝悓绫诲瀷鍚嶇О"`
 	}
-   
+
 	ServiceContractTypeSearch struct {
 		ServiceContractType
 		Orm *gorm.DB
@@ -83,3 +83,29 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *ServiceContractTypeSearch) CreateBatch(records []*ServiceContractType) error {
+	var db = slf.build()
+	return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *ServiceContractTypeSearch) InitDefaultData() error {
+	var (
+		db          = slf.Orm.Table(slf.TableName())
+		total int64 = 0
+	)
+	if err := db.Count(&total).Error; err != nil {
+		return err
+	}
+	if total != 0 {
+		return nil
+	}
+	records := []*ServiceContractType{
+		{1, "鎸夊勾"},
+		{2, "鎸夋"},
+		{3, "鍏朵粬"},
+		{4, "铏氭嫙鍚堝悓"},
+	}
+	return slf.CreateBatch(records)
+}
diff --git a/model/serviceOrderStatus.go b/model/serviceOrderStatus.go
index 4697fe2..44ff749 100644
--- a/model/serviceOrderStatus.go
+++ b/model/serviceOrderStatus.go
@@ -140,6 +140,11 @@
 	if total != 0 {
 		return nil
 	}
-	records := []*ServiceOrderStatus{}
+	records := []*ServiceOrderStatus{
+		{1, "鏈鐞�"},
+		{2, "澶勭悊涓�"},
+		{3, "绛夊緟鍥炲簲"},
+		{4, "鎴愬姛鍏抽棴"},
+	}
 	return slf.CreateBatch(records)
 }
diff --git a/model/serviceType.go b/model/serviceType.go
index 4602418..9938c03 100644
--- a/model/serviceType.go
+++ b/model/serviceType.go
@@ -12,7 +12,7 @@
 	// 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 鏈嶅姟鏂瑰紡鎼滅储鏉′欢
diff --git a/model/solveRate.go b/model/solveRate.go
index 97f6be1..6f3e24e 100644
--- a/model/solveRate.go
+++ b/model/solveRate.go
@@ -11,7 +11,7 @@
 		Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
 		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
 	}
-   
+
 	SolveRateSearch struct {
 		SolveRate
 		Orm *gorm.DB
@@ -83,3 +83,35 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *SolveRateSearch) CreateBatch(records []*SolveRate) error {
+	var db = slf.build()
+	return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *SolveRateSearch) InitDefaultData() error {
+	var (
+		db          = slf.Orm.Table(slf.TableName())
+		total int64 = 0
+	)
+	if err := db.Count(&total).Error; err != nil {
+		return err
+	}
+	if total != 0 {
+		return nil
+	}
+	records := []*SolveRate{
+		{1, "100%"},
+		{2, "90%"},
+		{3, "80%"},
+		{4, "70%"},
+		{5, "60%"},
+		{6, "50%"},
+		{7, "40%"},
+		{8, "30%"},
+		{9, "20%"},
+		{10, "10%"},
+	}
+	return slf.CreateBatch(records)
+}
diff --git a/model/timelyRate.go b/model/timelyRate.go
index b98e414..143e456 100644
--- a/model/timelyRate.go
+++ b/model/timelyRate.go
@@ -11,7 +11,7 @@
 		Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
 		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
 	}
-   
+
 	TimelyRateSearch struct {
 		TimelyRate
 		Orm *gorm.DB
@@ -83,3 +83,35 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *TimelyRateSearch) CreateBatch(records []*TimelyRate) error {
+	var db = slf.build()
+	return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *TimelyRateSearch) InitDefaultData() error {
+	var (
+		db          = slf.Orm.Table(slf.TableName())
+		total int64 = 0
+	)
+	if err := db.Count(&total).Error; err != nil {
+		return err
+	}
+	if total != 0 {
+		return nil
+	}
+	records := []*TimelyRate{
+		{1, "100%"},
+		{2, "90%"},
+		{3, "80%"},
+		{4, "70%"},
+		{5, "60%"},
+		{6, "50%"},
+		{7, "40%"},
+		{8, "30%"},
+		{9, "20%"},
+		{10, "10%"},
+	}
+	return slf.CreateBatch(records)
+}

--
Gitblit v1.8.0