From 104db2ea4e4c76ed83e04b5ea7f9d427d16474a0 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 18 八月 2023 11:05:28 +0800
Subject: [PATCH] Merge branch 'master' into fly

---
 model/serviceContractType.go |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

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)
+}

--
Gitblit v1.8.0