Documentation
¶
Overview ¶
Package usecase coordinates operation and login audit workflows.
Index ¶
- type ListFilter
- type ListInput
- type LoginInput
- type LoginListOutput
- type LoginLog
- type OperationInput
- type OperationListOutput
- type OperationLog
- type ResolveSystemErrorInput
- type Store
- type SystemErrorInput
- type SystemErrorListOutput
- type SystemErrorLog
- type Usecase
- func (u *Usecase) DeleteLoginLogs(ctx context.Context, ids []int64) error
- func (u *Usecase) DeleteOperationLogs(ctx context.Context, ids []int64) error
- func (u *Usecase) DeleteSystemErrorLogs(ctx context.Context, ids []int64) error
- func (u *Usecase) FindLoginLog(ctx context.Context, id int64) (LoginLog, error)
- func (u *Usecase) FindOperationLog(ctx context.Context, id int64) (OperationLog, error)
- func (u *Usecase) FindSystemErrorLog(ctx context.Context, id int64) (SystemErrorLog, error)
- func (u *Usecase) ListLoginLogs(ctx context.Context, input ListInput) (LoginListOutput, error)
- func (u *Usecase) ListOperationLogs(ctx context.Context, input ListInput) (OperationListOutput, error)
- func (u *Usecase) ListSystemErrorLogs(ctx context.Context, input ListInput) (SystemErrorListOutput, error)
- func (u *Usecase) RecordLogin(ctx context.Context, input LoginInput) (LoginLog, error)
- func (u *Usecase) RecordOperation(ctx context.Context, input OperationInput) (OperationLog, error)
- func (u *Usecase) RecordSystemError(ctx context.Context, input SystemErrorInput) (SystemErrorLog, error)
- func (u *Usecase) ReopenSystemErrorLog(ctx context.Context, id int64) (SystemErrorLog, error)
- func (u *Usecase) ResolveSystemErrorLog(ctx context.Context, input ResolveSystemErrorInput) (SystemErrorLog, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListFilter ¶
ListFilter is the validated store-facing pagination window.
type LoginInput ¶
type LoginInput struct {
AdminID int64
Username string
IP string
UserAgent string
Success bool
Reason string
}
LoginInput carries a sign-in attempt audit request.
type LoginListOutput ¶
LoginListOutput is a paginated login log result.
type LoginLog ¶
type LoginLog struct {
ID int64 `json:"id"`
AdminID int64 `json:"admin_id"`
Username string `json:"username"`
IP string `json:"ip"`
UserAgent string `json:"user_agent"`
Success bool `json:"success"`
Reason string `json:"reason"`
CreatedAt time.Time `json:"created_at"`
}
LoginLog is the adapter-facing login log DTO.
type OperationInput ¶
type OperationInput struct {
ActorID int64
Action string
Resource string
ResourceID string
Method string
Path string
IP string
UserAgent string
Success bool
Message string
}
OperationInput carries an operation log request from adapters.
type OperationListOutput ¶
type OperationListOutput struct {
Items []OperationLog
Page int
PageSize int
Total int
}
OperationListOutput is a paginated operation log result.
type OperationLog ¶
type OperationLog struct {
ID int64 `json:"id"`
ActorID int64 `json:"actor_id"`
Action string `json:"action"`
Resource string `json:"resource"`
ResourceID string `json:"resource_id"`
Method string `json:"method"`
Path string `json:"path"`
IP string `json:"ip"`
UserAgent string `json:"user_agent"`
Success bool `json:"success"`
Message string `json:"message"`
CreatedAt time.Time `json:"created_at"`
}
OperationLog is the adapter-facing operation log DTO.
type ResolveSystemErrorInput ¶
ResolveSystemErrorInput carries a resolution decision for one error log.
type Store ¶
type Store interface {
RecordOperation(context.Context, domain.OperationLog) (domain.OperationLog, error)
FindOperationLog(context.Context, int64) (domain.OperationLog, error)
ListOperationLogs(context.Context, ListFilter) ([]domain.OperationLog, int, error)
DeleteOperationLogs(context.Context, []int64) error
RecordLogin(context.Context, domain.LoginLog) (domain.LoginLog, error)
FindLoginLog(context.Context, int64) (domain.LoginLog, error)
ListLoginLogs(context.Context, ListFilter) ([]domain.LoginLog, int, error)
DeleteLoginLogs(context.Context, []int64) error
RecordSystemError(context.Context, domain.SystemErrorLog) (domain.SystemErrorLog, error)
FindSystemErrorLog(context.Context, int64) (domain.SystemErrorLog, error)
ListSystemErrorLogs(context.Context, ListFilter) ([]domain.SystemErrorLog, int, error)
UpdateSystemErrorLog(context.Context, domain.SystemErrorLog) (domain.SystemErrorLog, error)
DeleteSystemErrorLogs(context.Context, []int64) error
}
Store persists operation and login logs.
type SystemErrorInput ¶
type SystemErrorInput struct {
Code int
Message string
Detail string
Method string
Path string
IP string
UserAgent string
RequestID string
UserID string
}
SystemErrorInput carries an internal API failure record from the server boundary.
type SystemErrorListOutput ¶
type SystemErrorListOutput struct {
Items []SystemErrorLog
Page int
PageSize int
Total int
}
SystemErrorListOutput is a paginated system error log result.
type SystemErrorLog ¶
type SystemErrorLog struct {
ID int64 `json:"id"`
Code int `json:"code"`
Message string `json:"message"`
Detail string `json:"detail"`
Method string `json:"method"`
Path string `json:"path"`
IP string `json:"ip"`
UserAgent string `json:"user_agent"`
RequestID string `json:"request_id"`
UserID string `json:"user_id"`
Resolved bool `json:"resolved"`
ResolveNote string `json:"resolve_note"`
ResolvedBy int64 `json:"resolved_by"`
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
SystemErrorLog is the adapter-facing system error log DTO.
type Usecase ¶
type Usecase struct {
// contains filtered or unexported fields
}
Usecase coordinates audit log rules.
func (*Usecase) DeleteLoginLogs ¶
DeleteLoginLogs removes login logs by id.
func (*Usecase) DeleteOperationLogs ¶
DeleteOperationLogs removes operation logs by id.
func (*Usecase) DeleteSystemErrorLogs ¶
DeleteSystemErrorLogs removes system error logs by id.
func (*Usecase) FindLoginLog ¶
FindLoginLog returns one login log by id.
func (*Usecase) FindOperationLog ¶
FindOperationLog returns one operation log by id.
func (*Usecase) FindSystemErrorLog ¶
FindSystemErrorLog returns one system error log by id.
func (*Usecase) ListLoginLogs ¶
ListLoginLogs returns paginated login logs.
func (*Usecase) ListOperationLogs ¶
func (u *Usecase) ListOperationLogs(ctx context.Context, input ListInput) (OperationListOutput, error)
ListOperationLogs returns paginated operation logs.
func (*Usecase) ListSystemErrorLogs ¶
func (u *Usecase) ListSystemErrorLogs(ctx context.Context, input ListInput) (SystemErrorListOutput, error)
ListSystemErrorLogs returns paginated internal API failure logs.
func (*Usecase) RecordLogin ¶
RecordLogin stores one login attempt log.
func (*Usecase) RecordOperation ¶
func (u *Usecase) RecordOperation(ctx context.Context, input OperationInput) (OperationLog, error)
RecordOperation stores one operation log.
func (*Usecase) RecordSystemError ¶
func (u *Usecase) RecordSystemError(ctx context.Context, input SystemErrorInput) (SystemErrorLog, error)
RecordSystemError stores one internal API failure log.
func (*Usecase) ReopenSystemErrorLog ¶
ReopenSystemErrorLog clears a wrong resolution from one system error.
func (*Usecase) ResolveSystemErrorLog ¶
func (u *Usecase) ResolveSystemErrorLog(ctx context.Context, input ResolveSystemErrorInput) (SystemErrorLog, error)
ResolveSystemErrorLog records that an administrator handled one system error.