Finish the System Cleanup feature.

This commit is contained in:
zicla
2019-04-04 03:14:47 +08:00
parent 7697891807
commit 5936f917b3
15 changed files with 158 additions and 15 deletions

View File

@ -17,7 +17,7 @@ func (this *PreferenceDao) Fetch() *Preference {
db := CONTEXT.DB.First(preference)
if db.Error != nil {
if db.Error.Error() == "record not found" {
if db.Error.Error() == DB_ERROR_NOT_FOUND {
preference.Name = "蓝眼云盘"
preference.ShowAlien = true
this.Create(preference)
@ -25,7 +25,6 @@ func (this *PreferenceDao) Fetch() *Preference {
} else {
return nil
}
}
return preference
@ -54,3 +53,12 @@ func (this *PreferenceDao) Save(preference *Preference) *Preference {
return preference
}
//执行清理操作
func (this *PreferenceDao) Cleanup() {
this.logger.Info("[PreferenceDao]执行清理清除数据库中所有Preference记录。")
db := CONTEXT.DB.Where("uuid is not null").Delete(Preference{})
this.PanicError(db.Error)
}