CommandController.kt
package fr.codetics.ev_server.controllers.commands
import fr.codetics.ev_server.core.AppPrincipal
import fr.codetics.ev_server.services.commands.CommandService
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/api/v1/commands")
@PreAuthorize("hasAnyRole('ADMIN','OPERATOR','VIEWER')")
class CommandController(private val commands: CommandService) {
@GetMapping fun list(@AuthenticationPrincipal user: AppPrincipal) = commands.list(user.tenantId)
}