package audit import ( "context" "time" "github.com/break/junhong_cmp_fiber/pkg/constants" "github.com/break/junhong_cmp_fiber/pkg/errors" ) // ActorEventFilter 定义操作者行为视角的受控筛选。 type ActorEventFilter struct { Kind string ID string Action string Result string Risk string ResourceType string ResourceID string CreatedFrom *time.Time CreatedTo *time.Time Page int PageSize int } // ListActorEvents 查询指定人工账号、OpenAPI、系统任务或外部系统的历史行为。 func (q *Query) ListActorEvents(ctx context.Context, filter ActorEventFilter) (*EventPage, error) { if filter.ID == "" || !validActorKind(filter.Kind) { return nil, errors.New(errors.CodeInvalidParam) } return q.List(ctx, EventFilter{ ActorKind: filter.Kind, ActorID: filter.ID, Action: filter.Action, Result: filter.Result, Risk: filter.Risk, ResourceType: filter.ResourceType, ResourceID: filter.ResourceID, CreatedFrom: filter.CreatedFrom, CreatedTo: filter.CreatedTo, Page: filter.Page, PageSize: filter.PageSize, }) } func validActorKind(kind string) bool { switch kind { case constants.AuditActorAccount, constants.AuditActorPersonalCustomer, constants.AuditActorOpenAPI, constants.AuditActorSystemTask, constants.AuditActorScheduledJob, constants.AuditActorExternalSystem: return true default: return false } }