feat: add update profile service
This commit is contained in:
@@ -6,15 +6,22 @@ import {
|
||||
import { Repository } from 'typeorm';
|
||||
import { User } from '../user.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { UpdateProfileDTO } from '../dto/update-profile.dto';
|
||||
import { UserProfileProvider } from './user-profile.provider';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
constructor(
|
||||
/**
|
||||
* Injecting User Repository
|
||||
* Inject User Repository
|
||||
*/
|
||||
@InjectRepository(User)
|
||||
private readonly userRepository: Repository<User>,
|
||||
|
||||
/**
|
||||
* Inject UpdateProfile Provider
|
||||
*/
|
||||
private readonly userProfileProvider: UserProfileProvider,
|
||||
) {}
|
||||
|
||||
public async findOneById(id: number) {
|
||||
@@ -62,11 +69,10 @@ export class UsersService {
|
||||
}
|
||||
|
||||
public getProfile(user: User) {
|
||||
return {
|
||||
phone: user.phone,
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
dateJoined: user.createdAt,
|
||||
};
|
||||
return this.userProfileProvider.getProfile(user);
|
||||
}
|
||||
|
||||
public async updateProfile(user: User, updateProfileDto: UpdateProfileDTO) {
|
||||
return await this.userProfileProvider.updateProfile(user, updateProfileDto);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user