This commit is contained in:
2026-08-15 02:05:43 +08:00
parent 1a5969897a
commit bd5dbf2522
15 changed files with 174 additions and 108 deletions
+36 -8
View File
@@ -91,6 +91,12 @@ type LogFileRepo interface {
LogContent(context.Context, string, string, *int64) (*LogContent, error)
}
type LogViewerUsecase struct{ LogFileRepo }
func NewLogViewerUsecase(repo LogFileRepo) *LogViewerUsecase {
return &LogViewerUsecase{LogFileRepo: repo}
}
type ErrorRecord struct {
ID uint
CreatedAt time.Time
@@ -106,14 +112,36 @@ type ErrorRecordRepo interface {
ListErrors(context.Context, int, int, *ErrorRecord) ([]*ErrorRecord, int64, error)
}
type AuditRepo interface {
OperationLogRepo
LoginLogRepo
DataAccessLogRepo
LogFileRepo
ErrorRecordRepo
type AuditRecordRepo interface {
RecordOperation(context.Context, *OperationRecord) error
RecordLogin(context.Context, *LoginLog) error
RecordDataAccess(context.Context, *DataAccessLog) error
CreateError(context.Context, *ErrorRecord) error
}
type AuditUsecase struct{ AuditRepo }
type AuditQueryRepo interface {
ListOperations(context.Context, int, int, *OperationRecord) ([]*OperationRecord, int64, error)
FindOperation(context.Context, uint) (*OperationRecord, error)
DeleteOperations(context.Context, []uint) error
ListLogins(context.Context, int, int, *LoginLog) ([]*LoginLog, int64, error)
FindLogin(context.Context, uint) (*LoginLog, error)
DeleteLogins(context.Context, []uint) error
ListDataAccess(context.Context, int, int, *DataAccessLog) ([]*DataAccessLog, int64, error)
DeleteDataAccess(context.Context, []uint) error
UpdateError(context.Context, *ErrorRecord) error
DeleteErrors(context.Context, []uint) error
FindError(context.Context, uint) (*ErrorRecord, error)
ListErrors(context.Context, int, int, *ErrorRecord) ([]*ErrorRecord, int64, error)
}
func NewAuditUsecase(repo AuditRepo) *AuditUsecase { return &AuditUsecase{AuditRepo: repo} }
type AuditUsecase struct{ AuditQueryRepo }
func NewAuditUsecase(repo AuditQueryRepo) *AuditUsecase {
return &AuditUsecase{AuditQueryRepo: repo}
}
type AuditRecorderUsecase struct{ AuditRecordRepo }
func NewAuditRecorderUsecase(repo AuditRecordRepo) *AuditRecorderUsecase {
return &AuditRecorderUsecase{AuditRecordRepo: repo}
}