From 9dc8a5be16c3340ef3c9a7356404f6ee0eeeffb0 Mon Sep 17 00:00:00 2001 From: emkartal1 Date: Sat, 28 Oct 2023 00:15:27 +0200 Subject: [PATCH] Re add model --- src/FLAD/model/Artist.ts | 15 ++++++++ src/FLAD/model/Music.ts | 55 ++++++++++++++++++++++++++++ src/FLAD/model/Spot.ts | 27 ++++++++++++++ src/FLAD/model/User.ts | 33 +++++++++++++++++ src/FLAD/model/mapper/MusicMapper.ts | 13 +++++++ src/FLAD/model/mapper/UserMapper.ts | 8 ++++ 6 files changed, 151 insertions(+) create mode 100644 src/FLAD/model/Artist.ts create mode 100644 src/FLAD/model/Music.ts create mode 100644 src/FLAD/model/Spot.ts create mode 100644 src/FLAD/model/User.ts create mode 100644 src/FLAD/model/mapper/MusicMapper.ts create mode 100644 src/FLAD/model/mapper/UserMapper.ts diff --git a/src/FLAD/model/Artist.ts b/src/FLAD/model/Artist.ts new file mode 100644 index 0000000..814e0ca --- /dev/null +++ b/src/FLAD/model/Artist.ts @@ -0,0 +1,15 @@ +export default class Artist { + private id: string; + private name: string; + private _url: string; + + constructor(id: string, name: string, url: string) { + this.id = id; + this.name = name; + this._url = url; + } + + get url(): string { + return this.url; + } +} \ No newline at end of file diff --git a/src/FLAD/model/Music.ts b/src/FLAD/model/Music.ts new file mode 100644 index 0000000..b339e5b --- /dev/null +++ b/src/FLAD/model/Music.ts @@ -0,0 +1,55 @@ +export default class Music { + private _id: string; + private _title: string; + private _bio: string; + private _image: string; + private _trackPreviewUrl: string; + + constructor(id: string, title: string, bio: string, image: string, trackPreviewUrl: string) { + this._title = title; + this._bio = bio; + this._image = image; + this._id = id; + this._trackPreviewUrl = trackPreviewUrl; + } + + get id(): string { + return this._id; + } + + set id(value: string) { + this._id = value; + } + + get title(): string { + return this._title; + } + + set title(value: string) { + this._title = value; + } + + get bio(): string { + return this._bio; + } + + set bio(value: string) { + this._bio = value; + } + + get image(): string { + return this._image; + } + + set image(value: string) { + this._image = value; + } + + get trackPreviewUrl(): string { + return this._trackPreviewUrl; + } + + set trackPreviewUrl(value: string) { + this._trackPreviewUrl = value; + } +} diff --git a/src/FLAD/model/Spot.ts b/src/FLAD/model/Spot.ts new file mode 100644 index 0000000..af2b426 --- /dev/null +++ b/src/FLAD/model/Spot.ts @@ -0,0 +1,27 @@ +import Music from "./Music"; + +export class Spot { + private _userId: string; + private _music: Music; + + constructor(userId: string, music: Music) { + this._userId = userId; + this._music = music; + } + + get userSpotifyId(): string { + return this._userId; + } + + set userSpotifyId(value: string) { + this._userId = value; + } + + get music(): Music { + return this._music; + } + + set music(value: Music) { + this._music = value; + } +} \ No newline at end of file diff --git a/src/FLAD/model/User.ts b/src/FLAD/model/User.ts new file mode 100644 index 0000000..e5c3cb8 --- /dev/null +++ b/src/FLAD/model/User.ts @@ -0,0 +1,33 @@ +export class User { + private _idFlad: string; + private _idSpotify: string; + private _email: string; + private _createdAt: Date; + private _name: string; + public image: string; + + constructor(idFlad: string, idSpotify: string, email: string, createdAt: Date, name: string, image: string) { + this._name = name; + this._idFlad = idFlad; + this._idSpotify = idSpotify; + this._createdAt = createdAt; + this._email = email; + this.image = image; + } + + get idFlad(): string { + return this._idFlad; + } + get idSpotify(): string { + return this._idSpotify; + } + get email(): string { + return this._email; + } + get createAt(): Date { + return this._createdAt; + } + get name(): string { + return this._name; + } +} \ No newline at end of file diff --git a/src/FLAD/model/mapper/MusicMapper.ts b/src/FLAD/model/mapper/MusicMapper.ts new file mode 100644 index 0000000..8b8260b --- /dev/null +++ b/src/FLAD/model/mapper/MusicMapper.ts @@ -0,0 +1,13 @@ +import Music from "../Music"; + +export default class MusicMapper { + static toModel(music: any): Music { + return new Music( + music.id, + music.name, + music.artists[0].name, + music.album.images[0].url, + music.preview_url + ); + } +} \ No newline at end of file diff --git a/src/FLAD/model/mapper/UserMapper.ts b/src/FLAD/model/mapper/UserMapper.ts new file mode 100644 index 0000000..30f1b31 --- /dev/null +++ b/src/FLAD/model/mapper/UserMapper.ts @@ -0,0 +1,8 @@ +import { User } from "../User"; + +export class UserMapper { + + public static toModel(user: any): User { + return new User(user.idFlad, user.idSpotify, user.email, user.createdAt, user.name, user.imageUrl); + } +} \ No newline at end of file