diff --git a/apps/api/src/movies/movies.controller.ts b/apps/api/src/movies/movies.controller.ts index 4115a6e..824c37e 100644 --- a/apps/api/src/movies/movies.controller.ts +++ b/apps/api/src/movies/movies.controller.ts @@ -24,7 +24,7 @@ export class MoviesController { @Get() findAll() { - return this.moviesService.findMany({}); + return this.moviesService.findMany(); } @Get(':id') diff --git a/apps/api/src/movies/movies.service.ts b/apps/api/src/movies/movies.service.ts index f973c35..9c90a80 100644 --- a/apps/api/src/movies/movies.service.ts +++ b/apps/api/src/movies/movies.service.ts @@ -1,46 +1,34 @@ import { Injectable } from '@nestjs/common'; import { PrismaService } from 'src/prisma/prisma.service'; - -import { Movies, Prisma } from '@prisma/client'; +import { Movies } from './entities/movies.entity'; +import { CreateMoviesDto } from './dto/create-movies.dto'; +import { UpdateMoviesDto } from './dto/update-movies.dto'; @Injectable() export class MoviesService { constructor(private prisma: PrismaService) {} - async findUnique( - moviesWhereUniqueInput: Prisma.MoviesWhereUniqueInput, - ): Promise { + async findUnique(moviesWhereUniqueInput: { + id: number; + }): Promise { return this.prisma.movies.findUnique({ where: moviesWhereUniqueInput, }); } - async findMany(params: { - skip?: number; - take?: number; - cursor?: Prisma.MoviesWhereUniqueInput; - where?: Prisma.MoviesWhereInput; - orderBy?: Prisma.MoviesOrderByWithRelationInput; - }): Promise { - const { skip, take, cursor, where, orderBy } = params; - return this.prisma.movies.findMany({ - skip, - take, - cursor, - where, - orderBy, - }); + async findMany(): Promise { + return this.prisma.movies.findMany(); } - async create(data: Prisma.MoviesCreateInput): Promise { + async create(data: CreateMoviesDto): Promise { return this.prisma.movies.create({ data, }); } async update(params: { - where: Prisma.MoviesWhereUniqueInput; - data: Prisma.MoviesUpdateInput; + where: { id: number }; + data: UpdateMoviesDto; }): Promise { const { data, where } = params; return this.prisma.movies.update({ @@ -49,7 +37,7 @@ export class MoviesService { }); } - async delete(where: Prisma.MoviesWhereUniqueInput): Promise { + async delete(where: { id: number }): Promise { return this.prisma.movies.delete({ where, });