package processor import ( "context" "eslogad-be/internal/entities" "eslogad-be/internal/repository" "github.com/google/uuid" ) type ActivityLogProcessorImpl struct { repo *repository.LetterIncomingActivityLogRepository } func NewActivityLogProcessor(repo *repository.LetterIncomingActivityLogRepository) *ActivityLogProcessorImpl { return &ActivityLogProcessorImpl{repo: repo} } func (p *ActivityLogProcessorImpl) Log(ctx context.Context, letterID uuid.UUID, actionType string, actorUserID *uuid.UUID, actorDepartmentID *uuid.UUID, targetType *string, targetID *uuid.UUID, fromStatus *string, toStatus *string, contextData map[string]interface{}) error { ctxJSON := entities.JSONB{} for k, v := range contextData { ctxJSON[k] = v } entry := &entities.LetterIncomingActivityLog{ LetterID: letterID, ActionType: actionType, ActorUserID: actorUserID, ActorDepartmentID: actorDepartmentID, TargetType: targetType, TargetID: targetID, FromStatus: fromStatus, ToStatus: toStatus, Context: ctxJSON, } return p.repo.Create(ctx, entry) }