Compare commits
2 Commits
b6b676717c
...
2eaf84e681
Author | SHA1 | Date | |
---|---|---|---|
2eaf84e681 | |||
322353ff16 |
@ -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()));
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user