Yimaru-BackEnd/internal/domain/activity_log.go

91 lines
3.5 KiB
Go

package domain
import (
"encoding/json"
"time"
)
type ActivityAction string
const (
ActionCourseCreated ActivityAction = "COURSE_CREATED"
ActionCourseUpdated ActivityAction = "COURSE_UPDATED"
ActionCourseDeleted ActivityAction = "COURSE_DELETED"
ActionSubCourseCreated ActivityAction = "SUB_COURSE_CREATED"
ActionSubCourseUpdated ActivityAction = "SUB_COURSE_UPDATED"
ActionSubCourseDeleted ActivityAction = "SUB_COURSE_DELETED"
ActionVideoCreated ActivityAction = "VIDEO_CREATED"
ActionVideoUploaded ActivityAction = "VIDEO_UPLOADED"
ActionVideoPublished ActivityAction = "VIDEO_PUBLISHED"
ActionVideoUpdated ActivityAction = "VIDEO_UPDATED"
ActionVideoArchived ActivityAction = "VIDEO_ARCHIVED"
ActionVideoDeleted ActivityAction = "VIDEO_DELETED"
ActionUserCreated ActivityAction = "USER_CREATED"
ActionUserUpdated ActivityAction = "USER_UPDATED"
ActionUserDeleted ActivityAction = "USER_DELETED"
ActionSettingsUpdated ActivityAction = "SETTINGS_UPDATED"
ActionTeamMemberCreated ActivityAction = "TEAM_MEMBER_CREATED"
ActionTeamMemberUpdated ActivityAction = "TEAM_MEMBER_UPDATED"
ActionTeamMemberDeleted ActivityAction = "TEAM_MEMBER_DELETED"
ActionCategoryCreated ActivityAction = "CATEGORY_CREATED"
ActionCategoryUpdated ActivityAction = "CATEGORY_UPDATED"
ActionCategoryDeleted ActivityAction = "CATEGORY_DELETED"
ActionAdminCreated ActivityAction = "ADMIN_CREATED"
ActionAdminUpdated ActivityAction = "ADMIN_UPDATED"
ActionSubscriptionPlanCreated ActivityAction = "SUBSCRIPTION_PLAN_CREATED"
ActionSubscriptionPlanUpdated ActivityAction = "SUBSCRIPTION_PLAN_UPDATED"
ActionSubscriptionPlanDeleted ActivityAction = "SUBSCRIPTION_PLAN_DELETED"
ActionQuestionCreated ActivityAction = "QUESTION_CREATED"
ActionQuestionUpdated ActivityAction = "QUESTION_UPDATED"
ActionQuestionDeleted ActivityAction = "QUESTION_DELETED"
ActionQuestionSetCreated ActivityAction = "QUESTION_SET_CREATED"
ActionQuestionSetUpdated ActivityAction = "QUESTION_SET_UPDATED"
ActionQuestionSetDeleted ActivityAction = "QUESTION_SET_DELETED"
ActionSubCourseDeactivated ActivityAction = "SUB_COURSE_DEACTIVATED"
ActionIssueCreated ActivityAction = "ISSUE_CREATED"
ActionIssueStatusUpdated ActivityAction = "ISSUE_STATUS_UPDATED"
ActionIssueDeleted ActivityAction = "ISSUE_DELETED"
)
type ResourceType string
const (
ResourceCourse ResourceType = "COURSE"
ResourceSubCourse ResourceType = "SUB_COURSE"
ResourceVideo ResourceType = "VIDEO"
ResourceUser ResourceType = "USER"
ResourceSettings ResourceType = "SETTINGS"
ResourceTeamMember ResourceType = "TEAM_MEMBER"
ResourceCategory ResourceType = "CATEGORY"
ResourceAdmin ResourceType = "ADMIN"
ResourceSubscriptionPlan ResourceType = "SUBSCRIPTION_PLAN"
ResourceQuestion ResourceType = "QUESTION"
ResourceQuestionSet ResourceType = "QUESTION_SET"
ResourceIssue ResourceType = "ISSUE"
)
type ActivityLog struct {
ID int64
ActorID *int64
ActorRole *string
Action string
ResourceType string
ResourceID *int64
Message *string
Metadata json.RawMessage
IPAddress *string
UserAgent *string
CreatedAt time.Time
}
type ActivityLogFilter struct {
ActorID *int64
Action *string
ResourceType *string
ResourceID *int64
After *time.Time
Before *time.Time
Limit int32
Offset int32
}