TokenAssignmentEntity.kt

// EV Supervision Lite — built by Kevin Vavelin, Codetics
// https://codetics.fr
// Copyright (c) 2026 Kevin Vavelin, Codetics
// SPDX-License-Identifier: LicenseRef-Codetics-Attribution-1.0

package fr.codetics.ev_server.models.entities

import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import java.time.Instant
import java.util.UUID
import org.springframework.data.mongodb.core.mapping.Document

/**
 * One change of holder of a badge: who held it, who holds it now, who made the change and why.
 * Sessions keep the holder they were started with, so reports stay right after a reassignment.
 */
@Entity
@Table(name = "token_assignments")
@Document("token_assignments")
class TokenAssignmentEntity(
    @Id var id: UUID = UUID.randomUUID(),
    var tenantId: UUID = UUID.randomUUID(),
    var tokenUid: String = "",
    var fromUserId: UUID? = null,
    var toUserId: UUID? = null,
    var actorId: UUID? = null,
    var reason: String? = null,
    var createdAt: Instant = Instant.now(),
)