| | |
| | | package models |
| | | |
| | | type AutoBackupConf struct { |
| | | Enable bool `json:"enable"` //自动备份开关 |
| | | Dir string `json:"dir"` //备份目录 |
| | | Period int `json:"period"` //备份间隔 |
| | | SaveDays int `json:"saveDays"` //保存天数 |
| | | } |
| | | |
| | | func (AutoBackupConf) TableName() string { |
| | | return "auto_backup" |
| | | } |
| | | |
| | | func (a *AutoBackupConf) Insert() bool { |
| | | result := db.Table(a.TableName()).Create(&a) |
| | | if result.Error !=nil { |
| | | return false |
| | | } |
| | | return result.RowsAffected>0 |
| | | } |
| | | |
| | | func (a *AutoBackupConf) Update() bool { |
| | | db.Table(a.TableName()).Delete(&a) |
| | | result := db.Table(a.TableName()).Create(&a) |
| | | if result.Error !=nil { |
| | | return false |
| | | } |
| | | return result.RowsAffected>0 |
| | | } |
| | | |
| | | func (a *AutoBackupConf) Select() (int64, error){ |
| | | result := db.Table(a.TableName()).First(&a) |
| | | if result.Error != nil || result.RowsAffected == 0 { |
| | | return 0, result.Error |
| | | } |
| | | return result.RowsAffected, nil |
| | | package models
|
| | |
|
| | | type AutoBackupConf struct {
|
| | | Enable bool `json:"enable"` //自动备份开关
|
| | | Dir string `json:"dir"` //备份目录
|
| | | Period int `json:"period"` //备份间隔
|
| | | SaveDays int `json:"saveDays"` //保存天数
|
| | | }
|
| | |
|
| | | func (AutoBackupConf) TableName() string {
|
| | | return "auto_backup"
|
| | | }
|
| | |
|
| | | func (a *AutoBackupConf) Insert() bool {
|
| | | result := db.Table(a.TableName()).Create(&a)
|
| | | if result.Error !=nil {
|
| | | return false
|
| | | }
|
| | | return result.RowsAffected>0
|
| | | }
|
| | |
|
| | | func (a *AutoBackupConf) Update() bool {
|
| | | db.Table(a.TableName()).Delete(&a)
|
| | | result := db.Table(a.TableName()).Create(&a)
|
| | | if result.Error !=nil {
|
| | | return false
|
| | | }
|
| | | return result.RowsAffected>0
|
| | | }
|
| | |
|
| | | func (a *AutoBackupConf) Select() (int64, error){
|
| | | result := db.Table(a.TableName()).First(&a)
|
| | | if result.Error != nil || result.RowsAffected == 0 {
|
| | | return 0, result.Error
|
| | | }
|
| | | return result.RowsAffected, nil
|
| | | } |