| | |
| | | |
| | | type ( |
| | | SystemSet struct { |
| | | Id int `json:"id" gorm:"column:id;primaryKey;autoIncrement;not null"` |
| | | Name string `json:"name" gorm:"type:varchar(255);comment:名称"` |
| | | Value string `json:"value" gorm:"type:varchar(255);comment:值"` |
| | | SystemType string `json:"systemType" gorm:"type:varchar(255);comment:系统类型"` |
| | | Id int `json:"id" gorm:"column:id;primaryKey;autoIncrement;not null"` |
| | | Name string `json:"name" gorm:"type:varchar(255);comment:名称"` |
| | | Value string `json:"value" gorm:"type:varchar(255);comment:值"` |
| | | ModeType string `json:"modeType" gorm:"type:varchar(255);comment:模块类型"` |
| | | } |
| | | SystemSetSearch struct { |
| | | SystemSet |
| | | Types []string |
| | | Orm *gorm.DB |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | |
| | | slf.Orm = tx |
| | | return slf |
| | | } |
| | | func (slf *SystemSetSearch) SetTypes(types []string) *SystemSetSearch { |
| | | slf.Types = types |
| | | return slf |
| | | } |
| | | func (slf *SystemSetSearch) SetName(name string) *SystemSetSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | func (slf *SystemSetSearch) SetModeType(modeType string) *SystemSetSearch { |
| | | slf.ModeType = modeType |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SystemSetSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | | if len(slf.Types) > 0 { |
| | | db = db.Where("system_type in (?)", slf.Types) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | if slf.ModeType != "" { |
| | | db = db.Where("mode_type = ?", slf.ModeType) |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | func (slf *SystemSetSearch) DeleteAll() (err error) { |
| | | var db = slf.build() |
| | | err = db.Delete(&SystemSet{}).Error |
| | | err = db.Where("1=1").Delete(&SystemSet{}).Error |
| | | return err |
| | | } |
| | | |