generated from nhcarrigan/template
b6d66d34cb
I can log in and create a book! Woo!
37 lines
991 B
TypeScript
37 lines
991 B
TypeScript
/**
|
|
* @copyright 2026 NHCarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
import { ApiService } from './api.service';
|
|
import { Music, CreateMusicDto, UpdateMusicDto } from '@library/shared-types';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class MusicService {
|
|
constructor(private api: ApiService) {}
|
|
|
|
getAllMusic(): Observable<Music[]> {
|
|
return this.api.get<Music[]>('/music');
|
|
}
|
|
|
|
getMusicById(id: string): Observable<Music | null> {
|
|
return this.api.get<Music | null>(`/music/${id}`);
|
|
}
|
|
|
|
createMusic(music: CreateMusicDto): Observable<Music> {
|
|
return this.api.post<Music>('/music', music);
|
|
}
|
|
|
|
updateMusic(id: string, music: UpdateMusicDto): Observable<Music> {
|
|
return this.api.put<Music>(`/music/${id}`, music);
|
|
}
|
|
|
|
deleteMusic(id: string): Observable<{ success: boolean }> {
|
|
return this.api.delete<{ success: boolean }>(`/music/${id}`);
|
|
}
|
|
} |