lab6 mvc done
This commit is contained in:
parent
5e6d8104dc
commit
421baebbf7
@ -263,9 +263,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
getArtistsInAlbum(id){
|
getArtistsInAlbum(id){
|
||||||
axios .create({
|
axios .create({
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||||
}}).get(this.URL + `album/${id}/getAllArtists`)
|
}}).get(this.URL + `album/${id}/getAllArtists`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.artistsInAlbum = response.data;
|
this.artistsInAlbum = response.data;
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
@ -300,19 +300,26 @@ export default {
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addAlbum(album){
|
addAlbum(album) {
|
||||||
console.log(this.album);
|
console.log(this.album);
|
||||||
axios .create({
|
axios
|
||||||
headers: {
|
.create({
|
||||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
headers: {
|
||||||
}}).post(this.URL + "album", album)
|
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||||
.then(() => {
|
}
|
||||||
this.getAlbums();
|
})
|
||||||
this.closeModal();
|
.post(this.URL + "album", album)
|
||||||
})
|
.then(() => {
|
||||||
.catch(error => {
|
this.getAlbums();
|
||||||
console.log(error);
|
this.closeModal();
|
||||||
});
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.response && error.response.status === 403) {
|
||||||
|
console.error("Forbidden: User does not have permission to perform this operation");
|
||||||
|
} else {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
deleteAlbum(id){
|
deleteAlbum(id){
|
||||||
axios .create({
|
axios .create({
|
||||||
|
@ -60,6 +60,8 @@ import 'axios';
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Song from "@/models/Song";
|
import Song from "@/models/Song";
|
||||||
export default {
|
export default {
|
||||||
|
name: 'Songs',
|
||||||
|
emits: ['login'],
|
||||||
created() {
|
created() {
|
||||||
this.getSongs();
|
this.getSongs();
|
||||||
this.getAlbums();
|
this.getAlbums();
|
||||||
|
@ -46,9 +46,13 @@ export default {
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
this.users = response.data;
|
this.users = response.data;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error);
|
if (error.response && error.response.status === 403) {
|
||||||
});
|
console.error("Forbidden: User does not have permission to perform this operation");
|
||||||
|
} else {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package ru.ulstu.is.sbapp.controllers;
|
|||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import org.springframework.security.access.annotation.Secured;
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import ru.ulstu.is.sbapp.database.model.User;
|
import ru.ulstu.is.sbapp.database.model.User;
|
||||||
import ru.ulstu.is.sbapp.database.model.Role;
|
import ru.ulstu.is.sbapp.database.model.Role;
|
||||||
@ -39,12 +40,11 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
@Secured({Role.AsString.ADMIN})
|
|
||||||
public UserDTO getUser(@PathVariable Long id) {
|
public UserDTO getUser(@PathVariable Long id) {
|
||||||
return new UserDTO(userService.findUser(id));
|
return new UserDTO(userService.findUser(id));
|
||||||
}
|
}
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
@Secured({Role.AsString.ADMIN})
|
@PreAuthorize("hasAuthority('ADMIN')")
|
||||||
public List<UserDTO> getUsers() {
|
public List<UserDTO> getUsers() {
|
||||||
return userService.findAllUsers().stream()
|
return userService.findAllUsers().stream()
|
||||||
.map(UserDTO::new)
|
.map(UserDTO::new)
|
||||||
|
Loading…
Reference in New Issue
Block a user