mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 13:49:40 +00:00
feat: registration jounrey for parents
This commit is contained in:
26
src/customer/services/customer.service.ts
Normal file
26
src/customer/services/customer.service.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
||||
import { UserService } from '~/auth/services/user.service';
|
||||
import { UpdateCustomerRequestDto, UpdateNotificationsSettingsRequestDto } from '../dtos/request';
|
||||
import { Customer } from '../entities';
|
||||
import { CustomerRepository } from '../repositories/customer.repository';
|
||||
|
||||
@Injectable()
|
||||
export class CustomerService {
|
||||
constructor(private readonly userService: UserService, private readonly customerRepository: CustomerRepository) {}
|
||||
updateNotificationSettings(userId: string, data: UpdateNotificationsSettingsRequestDto) {
|
||||
return this.userService.updateNotificationSettings(userId, data);
|
||||
}
|
||||
|
||||
async updateCustomer(userId: string, data: UpdateCustomerRequestDto): Promise<Customer> {
|
||||
await this.customerRepository.updateCustomer(userId, data);
|
||||
return this.findCustomerById(userId);
|
||||
}
|
||||
|
||||
async findCustomerById(id: string) {
|
||||
const customer = await this.customerRepository.findOne({ id });
|
||||
if (!customer) {
|
||||
throw new BadRequestException('CUSTOMER.NOT_FOUND');
|
||||
}
|
||||
return customer;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user