fix: align admin behavior and Kratos integrations
This commit is contained in:
+47
-18
@@ -14,7 +14,16 @@ type OperationRecord struct {
|
||||
Agent, ErrorMessage, Body, Response string
|
||||
UserID uint
|
||||
RequestID, TraceID, DeviceID string
|
||||
User *User
|
||||
}
|
||||
|
||||
type OperationLogRepo interface {
|
||||
RecordOperation(context.Context, *OperationRecord) error
|
||||
ListOperations(context.Context, int, int, *OperationRecord) ([]*OperationRecord, int64, error)
|
||||
FindOperation(context.Context, uint) (*OperationRecord, error)
|
||||
DeleteOperations(context.Context, []uint) error
|
||||
}
|
||||
|
||||
type LoginLog struct {
|
||||
ID uint
|
||||
CreatedAt time.Time
|
||||
@@ -22,7 +31,17 @@ type LoginLog struct {
|
||||
Status bool
|
||||
ErrorMessage, Agent string
|
||||
UserID uint
|
||||
User *User
|
||||
FilterByStatus bool
|
||||
}
|
||||
|
||||
type LoginLogRepo interface {
|
||||
RecordLogin(context.Context, *LoginLog) error
|
||||
ListLogins(context.Context, int, int, *LoginLog) ([]*LoginLog, int64, error)
|
||||
FindLogin(context.Context, uint) (*LoginLog, error)
|
||||
DeleteLogins(context.Context, []uint) error
|
||||
}
|
||||
|
||||
type DataAccessLog struct {
|
||||
ID uint
|
||||
CreatedAt time.Time
|
||||
@@ -31,6 +50,13 @@ type DataAccessLog struct {
|
||||
Scope int
|
||||
RequestID, Method, Path, Detail string
|
||||
}
|
||||
|
||||
type DataAccessLogRepo interface {
|
||||
RecordDataAccess(context.Context, *DataAccessLog) error
|
||||
ListDataAccess(context.Context, int, int, *DataAccessLog) ([]*DataAccessLog, int64, error)
|
||||
DeleteDataAccess(context.Context, []uint) error
|
||||
}
|
||||
|
||||
type LogDate struct {
|
||||
Date string
|
||||
FileCount int
|
||||
@@ -48,33 +74,36 @@ type LogContent struct {
|
||||
Size int64
|
||||
ModifiedAt time.Time
|
||||
}
|
||||
|
||||
type LogFileRepo interface {
|
||||
LogDates(context.Context, string) ([]LogDate, error)
|
||||
LogFiles(context.Context, string) ([]LogFile, error)
|
||||
LogContent(context.Context, string, string, *int64) (*LogContent, error)
|
||||
}
|
||||
|
||||
type ErrorRecord struct {
|
||||
ID uint
|
||||
CreatedAt time.Time
|
||||
Form, Info, Level, RequestID, TraceID, Solution, Status string
|
||||
CreatedAtRange []time.Time
|
||||
}
|
||||
type AuditRepo interface {
|
||||
RecordOperation(context.Context, *OperationRecord) error
|
||||
ListOperations(context.Context, int, int, *OperationRecord) ([]*OperationRecord, int64, error)
|
||||
FindOperation(context.Context, uint) (*OperationRecord, error)
|
||||
DeleteOperations(context.Context, []uint) error
|
||||
RecordLogin(context.Context, *LoginLog) error
|
||||
ListLogins(context.Context, int, int, *LoginLog) ([]*LoginLog, int64, error)
|
||||
FindLogin(context.Context, uint) (*LoginLog, error)
|
||||
DeleteLogins(context.Context, []uint) error
|
||||
RecordDataAccess(context.Context, *DataAccessLog) error
|
||||
ListDataAccess(context.Context, int, int, *DataAccessLog) ([]*DataAccessLog, int64, error)
|
||||
DeleteDataAccess(context.Context, []uint) error
|
||||
LogDates(context.Context, string) ([]LogDate, error)
|
||||
LogFiles(context.Context, string) ([]LogFile, error)
|
||||
LogContent(context.Context, string, string, *int64) (*LogContent, error)
|
||||
|
||||
type ErrorRecordRepo interface {
|
||||
CreateError(context.Context, *ErrorRecord) 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)
|
||||
}
|
||||
type AuditUsecase struct{ repo AuditRepo }
|
||||
|
||||
func NewAuditUsecase(repo AuditRepo) *AuditUsecase { return &AuditUsecase{repo: repo} }
|
||||
func (uc *AuditUsecase) Repo() AuditRepo { return uc.repo }
|
||||
type AuditRepo interface {
|
||||
OperationLogRepo
|
||||
LoginLogRepo
|
||||
DataAccessLogRepo
|
||||
LogFileRepo
|
||||
ErrorRecordRepo
|
||||
}
|
||||
|
||||
type AuditUsecase struct{ AuditRepo }
|
||||
|
||||
func NewAuditUsecase(repo AuditRepo) *AuditUsecase { return &AuditUsecase{AuditRepo: repo} }
|
||||
|
||||
Reference in New Issue
Block a user