| | |
| | | // 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"` |
| | | } |
| | | |
| | | // 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 |
| | | } |
| | | ) |
| | | |
| | |
| | | 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 { |
| | |
| | | |
| | | err := db.Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *ServiceTypeSearch) 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 := []*ServiceType{ |
| | | {Name: "电话"}, |
| | | {Name: "远程"}, |
| | | {Name: "送修"}, |
| | | {Name: "上门"}, |
| | | {Name: "其他"}, |
| | | } |
| | | return slf.CreateBatch(records) |
| | | } |