Fixing delete
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Successful in 22s
Music Collection CI Workflow / test (./frontend) (push) Successful in 29s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-collection-backend, ./backend) (push) Failing after 35s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m49s
Music Collection CI Workflow / deploy (push) Has been skipped
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Successful in 22s
Music Collection CI Workflow / test (./frontend) (push) Successful in 29s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-collection-backend, ./backend) (push) Failing after 35s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m49s
Music Collection CI Workflow / deploy (push) Has been skipped
This commit is contained in:
parent
2aa1a3d071
commit
153460b8e9
@ -25,7 +25,7 @@ export class AlbumController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Put()
|
@Put()
|
||||||
async update(@Body() updateAlbumDto: UpdateAlbumDto): Promise<string> {
|
async update(@Param('id') id: number, @Body() updateAlbumDto: UpdateAlbumDto): Promise<string> {
|
||||||
return this.albumService.update(updateAlbumDto);
|
return this.albumService.update(updateAlbumDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ export class AlbumService {
|
|||||||
return savedAlbum.id;
|
return savedAlbum.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(updateAlbumDto: UpdateAlbumDto): Promise<string> {
|
async update(id: number, updateAlbumDto: UpdateAlbumDto): Promise<string> {
|
||||||
|
if (id === updateAlbumDto.id) {
|
||||||
const album = this.albumRepository.findOneBy({ id: updateAlbumDto.id });
|
const album = this.albumRepository.findOneBy({ id: updateAlbumDto.id });
|
||||||
if (!album)
|
if (!album)
|
||||||
return "Album not found";
|
return "Album not found";
|
||||||
@ -48,6 +49,9 @@ export class AlbumService {
|
|||||||
genre: updateAlbumDto.genre
|
genre: updateAlbumDto.genre
|
||||||
});
|
});
|
||||||
return "Album updated successfully";
|
return "Album updated successfully";
|
||||||
|
} else {
|
||||||
|
return "Album ID does not match posted data";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(id: number): Promise<void> {
|
async remove(id: number): Promise<void> {
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
'use server'
|
'use server'
|
||||||
|
|
||||||
export async function getAlbums() {
|
export async function getAlbums() {
|
||||||
return fetch('https://api.anatid.net/album').then(response => {
|
return fetch('https://api.anatid.net/album', {
|
||||||
|
method: "GET",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
}).then(response => {
|
||||||
return response.json();
|
return response.json();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -37,7 +40,7 @@ export async function updateAlbum(formData: FormData) {
|
|||||||
const title = formData.get('title');
|
const title = formData.get('title');
|
||||||
const artist = formData.get('artist');
|
const artist = formData.get('artist');
|
||||||
const genre = formData.get('genre');
|
const genre = formData.get('genre');
|
||||||
return fetch("https://api.anatid.net/album", {
|
return fetch(`https://api.anatid.net/album/${id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -52,7 +55,7 @@ export async function updateAlbum(formData: FormData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteAlbum(id: number) {
|
export async function deleteAlbum(id: number) {
|
||||||
return fetch("https://api.anatid.net/album", {
|
return fetch(`https://api.anatid.net/album/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -64,7 +67,12 @@ export async function deleteAlbum(id: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getSongs() {
|
export async function getSongs() {
|
||||||
return fetch("https://api.anatid.net/song/");
|
return fetch("https://api.anatid.net/song/", {
|
||||||
|
method: "GET",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
}).then(response => {
|
||||||
|
return response.json();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSong(id: number) {
|
export async function getSong(id: number) {
|
||||||
@ -98,7 +106,7 @@ export async function updateSong(formData: FormData) {
|
|||||||
const albumId = formData.get('album-id');
|
const albumId = formData.get('album-id');
|
||||||
const title = formData.get('title');
|
const title = formData.get('title');
|
||||||
const duration = formData.get('duration');
|
const duration = formData.get('duration');
|
||||||
return fetch("https://api.anatid.net/song", {
|
return fetch(`https://api.anatid.net/song/${id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -113,12 +121,9 @@ export async function updateSong(formData: FormData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteSong(id: number) {
|
export async function deleteSong(id: number) {
|
||||||
return fetch("https://api.anatid.net/song", {
|
return fetch(`https://api.anatid.net/song/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" }
|
||||||
body: JSON.stringify({
|
|
||||||
id: id,
|
|
||||||
})
|
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
return response.json();
|
return response.json();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user