mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-15 07:06:35 +08:00
修复审计日志无法自动清理的Bug
This commit is contained in:
@@ -33,7 +33,7 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
// 创建管理员日志
|
||||
// CreateLog 创建管理员日志
|
||||
func (this *LogDAO) CreateLog(tx *dbs.Tx, adminType string, adminId int64, level string, description string, action string, ip string) error {
|
||||
op := NewLogOperator()
|
||||
op.Level = level
|
||||
@@ -57,7 +57,7 @@ func (this *LogDAO) CreateLog(tx *dbs.Tx, adminType string, adminId int64, level
|
||||
return err
|
||||
}
|
||||
|
||||
// 计算所有日志数量
|
||||
// CountLogs 计算所有日志数量
|
||||
func (this *LogDAO) CountLogs(tx *dbs.Tx, dayFrom string, dayTo string, keyword string, userType string) (int64, error) {
|
||||
dayFrom = this.formatDay(dayFrom)
|
||||
dayTo = this.formatDay(dayTo)
|
||||
@@ -86,7 +86,7 @@ func (this *LogDAO) CountLogs(tx *dbs.Tx, dayFrom string, dayTo string, keyword
|
||||
return query.Count()
|
||||
}
|
||||
|
||||
// 列出单页日志
|
||||
// ListLogs 列出单页日志
|
||||
func (this *LogDAO) ListLogs(tx *dbs.Tx, offset int64, size int64, dayFrom string, dayTo string, keyword string, userType string) (result []*Log, err error) {
|
||||
dayFrom = this.formatDay(dayFrom)
|
||||
dayTo = this.formatDay(dayTo)
|
||||
@@ -120,7 +120,7 @@ func (this *LogDAO) ListLogs(tx *dbs.Tx, offset int64, size int64, dayFrom strin
|
||||
return
|
||||
}
|
||||
|
||||
// 物理删除日志
|
||||
// DeleteLogPermanently 物理删除日志
|
||||
func (this *LogDAO) DeleteLogPermanently(tx *dbs.Tx, logId int64) error {
|
||||
if logId <= 0 {
|
||||
return errors.New("invalid logId")
|
||||
@@ -129,14 +129,14 @@ func (this *LogDAO) DeleteLogPermanently(tx *dbs.Tx, logId int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 物理删除所有日志
|
||||
// DeleteAllLogsPermanently 物理删除所有日志
|
||||
func (this *LogDAO) DeleteAllLogsPermanently(tx *dbs.Tx) error {
|
||||
_, err := this.Query(tx).
|
||||
Delete()
|
||||
return err
|
||||
}
|
||||
|
||||
// 物理删除某些天之前的日志
|
||||
// DeleteLogsPermanentlyBeforeDays 物理删除某些天之前的日志
|
||||
func (this *LogDAO) DeleteLogsPermanentlyBeforeDays(tx *dbs.Tx, days int) error {
|
||||
if days <= 0 {
|
||||
days = 0
|
||||
@@ -148,7 +148,7 @@ func (this *LogDAO) DeleteLogsPermanentlyBeforeDays(tx *dbs.Tx, days int) error
|
||||
return err
|
||||
}
|
||||
|
||||
// 计算当前日志容量大小
|
||||
// SumLogsSize 计算当前日志容量大小
|
||||
func (this *LogDAO) SumLogsSize() (int64, error) {
|
||||
col, err := this.Instance.FindCol(0, "SELECT DATA_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA=? AND TABLE_NAME=? LIMIT 1", this.Instance.Name(), this.Table)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user