From 322353ff1658b6002f77aab819f54fca8cb1d5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B0=D1=82=D1=8C=D1=8F=D0=BD=D0=B0=20=D0=90=D1=80?= =?UTF-8?q?=D1=82=D0=B0=D0=BC=D0=BE=D0=BD=D0=BE=D0=B2=D0=B0?= Date: Mon, 25 Sep 2023 22:54:46 +0400 Subject: [PATCH] lab6 mvc done --- .../java/ru/ulstu/is/sbapp/controllers/AlbumController.java | 3 +++ .../java/ru/ulstu/is/sbapp/controllers/ArtistController.java | 4 ++++ .../java/ru/ulstu/is/sbapp/controllers/SongController.java | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/main/java/ru/ulstu/is/sbapp/controllers/AlbumController.java b/src/main/java/ru/ulstu/is/sbapp/controllers/AlbumController.java index ffc99b1..272731e 100644 --- a/src/main/java/ru/ulstu/is/sbapp/controllers/AlbumController.java +++ b/src/main/java/ru/ulstu/is/sbapp/controllers/AlbumController.java @@ -2,10 +2,12 @@ package ru.ulstu.is.sbapp.controllers; import javax.validation.Valid; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.*; import ru.ulstu.is.sbapp.configuration.WebConfiguration; import ru.ulstu.is.sbapp.database.model.Artist; import ru.ulstu.is.sbapp.database.model.Song; +import ru.ulstu.is.sbapp.database.model.UserRole; import ru.ulstu.is.sbapp.database.service.AlbumService; import java.util.List; @@ -33,6 +35,7 @@ public class AlbumController { } @PostMapping + @Secured({UserRole.AsString.ADMIN}) public AlbumDTO createAlbum(@RequestBody @Valid AlbumDTO albumDTO){ return new AlbumDTO(albumService.addAlbum(albumDTO.getAlbumName())); } diff --git a/src/main/java/ru/ulstu/is/sbapp/controllers/ArtistController.java b/src/main/java/ru/ulstu/is/sbapp/controllers/ArtistController.java index b2f2012..8f561eb 100644 --- a/src/main/java/ru/ulstu/is/sbapp/controllers/ArtistController.java +++ b/src/main/java/ru/ulstu/is/sbapp/controllers/ArtistController.java @@ -1,8 +1,11 @@ package ru.ulstu.is.sbapp.controllers; import javax.validation.Valid; + +import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.*; import ru.ulstu.is.sbapp.configuration.WebConfiguration; +import ru.ulstu.is.sbapp.database.model.UserRole; import ru.ulstu.is.sbapp.database.service.ArtistService; import java.util.List; @@ -29,6 +32,7 @@ public class ArtistController { } @PostMapping + @Secured({UserRole.AsString.ADMIN}) public ArtistDTO createArtist(@RequestBody @Valid ArtistDTO artistDTO){ return new ArtistDTO(artistService.addArtist(artistDTO.getArtistName(), artistDTO.getGenre())); } diff --git a/src/main/java/ru/ulstu/is/sbapp/controllers/SongController.java b/src/main/java/ru/ulstu/is/sbapp/controllers/SongController.java index a6c3024..1699751 100644 --- a/src/main/java/ru/ulstu/is/sbapp/controllers/SongController.java +++ b/src/main/java/ru/ulstu/is/sbapp/controllers/SongController.java @@ -1,8 +1,11 @@ package ru.ulstu.is.sbapp.controllers; import javax.validation.Valid; + +import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.*; import ru.ulstu.is.sbapp.configuration.WebConfiguration; +import ru.ulstu.is.sbapp.database.model.UserRole; import ru.ulstu.is.sbapp.database.service.AlbumService; import ru.ulstu.is.sbapp.database.service.SongService; @@ -32,6 +35,7 @@ public class SongController { } @PostMapping + @Secured({UserRole.AsString.ADMIN}) public SongDTO createSong(@RequestBody @Valid SongDTO songDTO){ return new SongDTO(songService.addSong(songDTO.getSongName(), songDTO.getDuration())); }