mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat(api): fetch listens from spotify
This commit is contained in:
parent
f253a66f86
commit
f2065d3f1f
54 changed files with 1180 additions and 256 deletions
|
|
@ -2,6 +2,7 @@ import { Injectable, NotFoundException } from "@nestjs/common";
|
|||
import { CreateOrUpdateDto } from "./dto/create-or-update.dto";
|
||||
import { User } from "./user.entity";
|
||||
import { UserRepository } from "./user.repository";
|
||||
import { SpotifyConnection } from "src/sources/spotify/spotify-connection.entity";
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
|
|
@ -17,6 +18,10 @@ export class UsersService {
|
|||
return user;
|
||||
}
|
||||
|
||||
async findAll(): Promise<User[]> {
|
||||
return this.userRepository.find();
|
||||
}
|
||||
|
||||
async createOrUpdate(data: CreateOrUpdateDto): Promise<User> {
|
||||
let user = await this.userRepository.findOne({
|
||||
where: { spotify: { id: data.spotify.id } }
|
||||
|
|
@ -39,4 +44,12 @@ export class UsersService {
|
|||
|
||||
return user;
|
||||
}
|
||||
|
||||
async updateSpotifyConnection(
|
||||
user: User,
|
||||
spotify: SpotifyConnection
|
||||
): Promise<void> {
|
||||
user.spotify = spotify;
|
||||
await this.userRepository.save(user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue