import { Injectable } from '@nestjs/common' ; import { InjectModel } from '@nestjs/sequelize' ; import { User } from './users.model' ; import { SignupRequest } from './dto/signup.dto' ; import { EditUserInfoRequest } from './dto/editUserInfo.dto' ; @ Injectable ( ) export class UsersService { constructor ( @ InjectModel ( User ) private userModel ) { } async getByUserId ( userId ) { const user = await this . userModel . findOne ( { where : { userId } , attributes : [ 'id' , 'password' ] , } ) ; return user ; } async getById ( id ) { const user = await this . userModel . findOne ( { where : { id } , attributes : [ 'refreshToken' , 'id' , 'familyName' , 'givenName' ] , } ) ; return user ; } async updateRefreshToken ( id , refreshToken ) { await this . userModel . update ( { refreshToken } , { where : { id } } ) ; } async create ( input ) { try { await this . userModel . create ( input ) ; return { ok : true } ; } catch ( error ) { return { ok : false , error } ; } } async update ( { id , ... updateInfo } ) { try { const user = await this . userModel . findOne ( { where : { id } } ) ; await user ?. update ( updateInfo ) ; return { ok : true } ; } catch ( error ) { return { ok : false , error } ; } } }