2023-02-16 10:40:03 +08:00
|
|
|
import { Injectable, NotFoundException } from '@nestjs/common'
|
2023-02-15 20:32:14 +08:00
|
|
|
import { PrismaService } from 'nestjs-prisma'
|
2023-02-16 10:40:03 +08:00
|
|
|
import { Prisma } from '@prisma/client'
|
2023-02-17 14:21:08 +08:00
|
|
|
import { UserEntity } from './entities/user.entity'
|
2023-02-15 20:32:14 +08:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class UsersService {
|
2023-02-21 23:15:40 +08:00
|
|
|
constructor(private prismaService: PrismaService) {}
|
2023-02-16 10:40:03 +08:00
|
|
|
|
2023-02-17 14:21:08 +08:00
|
|
|
async findUser(where: Prisma.UserWhereUniqueInput): Promise<UserEntity> {
|
2023-02-21 23:15:40 +08:00
|
|
|
const user = await this.prismaService.user.findUnique({
|
2023-02-16 10:40:03 +08:00
|
|
|
where,
|
|
|
|
})
|
|
|
|
if (!user) {
|
|
|
|
throw new NotFoundException(`No user found`)
|
|
|
|
}
|
|
|
|
return user
|
|
|
|
}
|
2023-02-15 20:32:14 +08:00
|
|
|
}
|