lab6 mvc done

This commit is contained in:
Татьяна Артамонова 2023-09-26 13:47:36 +04:00
parent 322353ff16
commit 2eaf84e681
3 changed files with 6 additions and 3 deletions

View File

@ -3,6 +3,7 @@ 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.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import ru.ulstu.is.sbapp.configuration.WebConfiguration;
import ru.ulstu.is.sbapp.database.model.Artist;
@ -35,7 +36,7 @@ public class AlbumController {
}
@PostMapping
@Secured({UserRole.AsString.ADMIN})
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
public AlbumDTO createAlbum(@RequestBody @Valid AlbumDTO albumDTO){
return new AlbumDTO(albumService.addAlbum(albumDTO.getAlbumName()));
}

View File

@ -3,6 +3,7 @@ package ru.ulstu.is.sbapp.controllers;
import javax.validation.Valid;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import ru.ulstu.is.sbapp.configuration.WebConfiguration;
import ru.ulstu.is.sbapp.database.model.UserRole;
@ -32,7 +33,7 @@ public class ArtistController {
}
@PostMapping
@Secured({UserRole.AsString.ADMIN})
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
public ArtistDTO createArtist(@RequestBody @Valid ArtistDTO artistDTO){
return new ArtistDTO(artistService.addArtist(artistDTO.getArtistName(), artistDTO.getGenre()));
}

View File

@ -3,6 +3,7 @@ package ru.ulstu.is.sbapp.controllers;
import javax.validation.Valid;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import ru.ulstu.is.sbapp.configuration.WebConfiguration;
import ru.ulstu.is.sbapp.database.model.UserRole;
@ -35,7 +36,7 @@ public class SongController {
}
@PostMapping
@Secured({UserRole.AsString.ADMIN})
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
public SongDTO createSong(@RequestBody @Valid SongDTO songDTO){
return new SongDTO(songService.addSong(songDTO.getSongName(), songDTO.getDuration()));
}