enhance(god):增加清理关联缓存。

This commit is contained in:
徐涛 2022-09-06 16:46:14 +08:00
parent 0ec7f5fba1
commit 97bad80784

View File

@ -1,9 +1,11 @@
package service
import (
"electricity_bill_calc/cache"
"electricity_bill_calc/exceptions"
"electricity_bill_calc/global"
"electricity_bill_calc/model"
"fmt"
"time"
"github.com/samber/lo"
@ -163,7 +165,6 @@ func (_GodModeService) resetEndUserRecords(tx *xorm.Session, reportId string) (b
return false, err
}
}
return true, nil
}
@ -236,6 +237,7 @@ func (g _GodModeService) ClearReportSummary(reportId string) (bool, error) {
tx.Rollback()
return false, err
}
cache.AbolishRelation(fmt.Sprintf("report_%s", reportId))
return result, nil
}
@ -256,6 +258,7 @@ func (g _GodModeService) ClearReportMaintenances(reportId string) (bool, error)
tx.Rollback()
return false, err
}
cache.AbolishRelation(fmt.Sprintf("report_%s", reportId))
return result, nil
}
@ -276,6 +279,8 @@ func (g _GodModeService) ResetEndUserRegisterRecords(reportId string) (bool, err
tx.Rollback()
return false, err
}
cache.AbolishRelation("end_user_detail")
cache.AbolishRelation(fmt.Sprintf("report_%s", reportId))
return result, nil
}
@ -312,6 +317,8 @@ func (g _GodModeService) ResetReport(reportId string) (bool, error) {
tx.Rollback()
return false, err
}
cache.AbolishRelation("end_user_detail")
cache.AbolishRelation(fmt.Sprintf("report_%s", reportId))
return result, nil
}
@ -339,6 +346,9 @@ func (g _GodModeService) DeleteReport(reportId string) (bool, error) {
tx.Rollback()
return false, err
}
cache.AbolishRelation("end_user_detail")
cache.AbolishRelation(fmt.Sprintf("report_%s", reportId))
return result, nil
}
@ -417,6 +427,8 @@ func (g _GodModeService) RemoveSpecificMaintenance(parkId, maintenanceId string)
tx.Rollback()
return false, err
}
cache.AbolishRelation("maintenance_fee")
cache.AbolishRelation(fmt.Sprintf("maintenance_fee_%s", maintenanceId))
return result, nil
}
@ -437,6 +449,7 @@ func (g _GodModeService) RemoveAllMaintenance(parkId string) (bool, error) {
tx.Rollback()
return false, err
}
cache.AbolishRelation("maintenance_fee")
return result, nil
}
@ -457,6 +470,7 @@ func (g _GodModeService) RemoveAllMeters(parkId string) (bool, error) {
tx.Rollback()
return false, err
}
cache.AbolishRelation("meter_04kv")
return result, nil
}
@ -516,6 +530,8 @@ func (g _GodModeService) RemovePark(parkId string) (bool, error) {
tx.Rollback()
return false, err
}
cache.AbolishRelation("park")
cache.AbolishRelation(fmt.Sprintf("park_%s", parkId))
return result, nil
}
@ -566,5 +582,9 @@ func (g _GodModeService) DeleteUser(userId string) (bool, error) {
tx.Rollback()
return false, err
}
cache.AbolishRelation(fmt.Sprintf("user_%s", userId))
cache.AbolishRelation("user")
cache.AbolishRelation("park")
cache.AbolishRelation("report")
return result, nil
}