迁移
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type OperationRecord struct {
|
||||
ID uint
|
||||
CreatedAt time.Time
|
||||
IP, Method, Path string
|
||||
Status int
|
||||
LatencyMS int64
|
||||
Agent, ErrorMessage, Body, Response string
|
||||
UserID uint
|
||||
RequestID, TraceID, DeviceID string
|
||||
}
|
||||
type LoginLog struct {
|
||||
ID uint
|
||||
CreatedAt time.Time
|
||||
Username, IP string
|
||||
Status bool
|
||||
ErrorMessage, Agent string
|
||||
UserID uint
|
||||
}
|
||||
type DataAccessLog struct {
|
||||
ID uint
|
||||
CreatedAt time.Time
|
||||
EventType, TargetTable, Operation string
|
||||
UserID, AuthorityID uint
|
||||
Scope int
|
||||
RequestID, Method, Path, Detail string
|
||||
}
|
||||
type LogDate struct {
|
||||
Date string
|
||||
FileCount int
|
||||
}
|
||||
type LogFile struct {
|
||||
Path, Name string
|
||||
Size int64
|
||||
ModifiedAt time.Time
|
||||
}
|
||||
type LogContent struct {
|
||||
Date, Path, Content string
|
||||
LineCount int
|
||||
NextCursor int64
|
||||
HasMore, LimitedByBytes bool
|
||||
Size int64
|
||||
ModifiedAt time.Time
|
||||
}
|
||||
type ErrorRecord struct {
|
||||
ID uint
|
||||
CreatedAt time.Time
|
||||
Form, Info, Level, RequestID, TraceID, Solution, Status string
|
||||
}
|
||||
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)
|
||||
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 }
|
||||
Reference in New Issue
Block a user