zhangqian
2023-08-18 c0305be973254bd1b5a351064f8639d490564b30
增加一些表的数据初始化
9个文件已修改
201 ■■■■■ 已修改文件
model/index.go 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/isVisit.go 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/satisfaction.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceContractStatus.go 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceContractType.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceOrderStatus.go 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceType.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/solveRate.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/timelyRate.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 {
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)
}
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)
}
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)
}
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)
}
model/serviceOrderStatus.go
@@ -140,6 +140,11 @@
    if total != 0 {
        return nil
    }
    records := []*ServiceOrderStatus{}
    records := []*ServiceOrderStatus{
        {1, "未处理"},
        {2, "处理中"},
        {3, "等待回应"},
        {4, "成功关闭"},
    }
    return slf.CreateBatch(records)
}
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 服务方式搜索条件
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)
}
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)
}