mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
26 lines
720 B
TypeScript
26 lines
720 B
TypeScript
|
|
import { inject, injectable } from "tsyringe";
|
||
|
|
import { WishlistsRepository } from "../repositories/wishlists.repository";
|
||
|
|
import { generateRandomAnimalName } from "$lib/utils/randomDataUtil";
|
||
|
|
|
||
|
|
@injectable()
|
||
|
|
export class WishlistsService {
|
||
|
|
|
||
|
|
constructor(
|
||
|
|
@inject(WishlistsRepository) private readonly wishlistsRepository: WishlistsRepository
|
||
|
|
) { }
|
||
|
|
|
||
|
|
async findAllByUserId(userId: string) {
|
||
|
|
return this.wishlistsRepository.findAllByUserId(userId);
|
||
|
|
}
|
||
|
|
|
||
|
|
async createEmptyNoName(userId: string) {
|
||
|
|
return this.createEmpty(userId, null);
|
||
|
|
}
|
||
|
|
|
||
|
|
async createEmpty(userId: string, name: string | null) {
|
||
|
|
return this.wishlistsRepository.create({
|
||
|
|
user_id: userId,
|
||
|
|
name: name ?? generateRandomAnimalName(),
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|