Compare commits

...

2 Commits

Author SHA1 Message Date
2eaf84e681 lab6 mvc done 2023-09-26 13:47:36 +04:00
322353ff16 lab6 mvc done 2023-09-25 22:54:46 +04:00
3 changed files with 14 additions and 0 deletions

View File

@ -2,10 +2,13 @@ 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;
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 +36,7 @@ public class AlbumController {
}
@PostMapping
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
public AlbumDTO createAlbum(@RequestBody @Valid AlbumDTO albumDTO){
return new AlbumDTO(albumService.addAlbum(albumDTO.getAlbumName()));
}

View File

@ -1,8 +1,12 @@
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;
import ru.ulstu.is.sbapp.database.service.ArtistService;
import java.util.List;
@ -29,6 +33,7 @@ public class ArtistController {
}
@PostMapping
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
public ArtistDTO createArtist(@RequestBody @Valid ArtistDTO artistDTO){
return new ArtistDTO(artistService.addArtist(artistDTO.getArtistName(), artistDTO.getGenre()));
}

View File

@ -1,8 +1,12 @@
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;
import ru.ulstu.is.sbapp.database.service.AlbumService;
import ru.ulstu.is.sbapp.database.service.SongService;
@ -32,6 +36,7 @@ public class SongController {
}
@PostMapping
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
public SongDTO createSong(@RequestBody @Valid SongDTO songDTO){
return new SongDTO(songService.addSong(songDTO.getSongName(), songDTO.getDuration()));
}