prisma migration + back auth/me/likes + front API add and get methods for liked song

This commit is contained in:
danis
2023-08-30 13:06:25 +02:00
parent a3676fabf8
commit c81f8df61c
9 changed files with 998 additions and 7339 deletions
+39
View File
@@ -4,6 +4,7 @@ import Chapter from './models/Chapter';
import Lesson from './models/Lesson';
import Genre, { GenreHandler } from './models/Genre';
import LessonHistory from './models/LessonHistory';
import likedSong, { LikedSongHandler } from './models/LikedSong';
import Song, { SongHandler } from './models/Song';
import { SongHistoryHandler, SongHistoryItem, SongHistoryItemHandler } from './models/SongHistory';
import User, { UserHandler } from './models/User';
@@ -608,4 +609,42 @@ export default class API {
formData,
});
}
public static async addLikedSong(songId: number): Promise<void> {
const data = await API.fetch(
{
route: `/auth/me/likes${songId}`,
method: 'POST',
body: {
songId: songId
}
}
)
}
public static getLikedSongs(): Query<likedSong[]> {
return {
key: ['liked songs'],
exec: () =>
API.fetch(
{
route: '/auth/me/likes',
},
{ handler: ListHandler(LikedSongHandler)}
),
};
}
public static getUserPlaayHistory(): Query<SongHistoryItem[]> {
return {
key: ['history'],
exec: () =>
API.fetch(
{
route: '/history',
},
{ handler: ListHandler(SongHistoryItemHandler) }
),
};
}
}