From 58237a453465c32af4925ee79860938eae67aec1 Mon Sep 17 00:00:00 2001 From: devleejb Date: Thu, 18 Jan 2024 18:36:32 +0900 Subject: [PATCH] Add service for user --- backend/src/users/types/user-domain.type.ts | 6 ++++++ backend/src/users/users.service.ts | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 backend/src/users/types/user-domain.type.ts diff --git a/backend/src/users/types/user-domain.type.ts b/backend/src/users/types/user-domain.type.ts new file mode 100644 index 00000000..a039269b --- /dev/null +++ b/backend/src/users/types/user-domain.type.ts @@ -0,0 +1,6 @@ +export class UserDomain { + id: string; + nickname: string; + createdAt: Date; + updatedAt: Date; +} diff --git a/backend/src/users/users.service.ts b/backend/src/users/users.service.ts index 8d645fd9..91116c8f 100644 --- a/backend/src/users/users.service.ts +++ b/backend/src/users/users.service.ts @@ -1,11 +1,26 @@ import { Injectable } from "@nestjs/common"; import { User } from "@prisma/client"; import { PrismaService } from "src/db/prisma.service"; +import { UserDomain } from "./types/user-domain.type"; @Injectable() export class UsersService { constructor(private prismaService: PrismaService) {} + async findOne(userId: string): Promise { + return await this.prismaService.user.findUnique({ + select: { + id: true, + nickname: true, + createdAt: true, + updatedAt: true, + }, + where: { + id: userId, + }, + }); + } + async findOrCreate( socialProvider: string, socialUid: string,