feat: create junior

This commit is contained in:
Abdalhamid Alhamad
2024-12-09 13:11:18 +03:00
parent 3fd29b3905
commit 970a41c895
35 changed files with 625 additions and 26 deletions

View File

@ -1,4 +1,5 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { BadRequestException, forwardRef, Inject, Injectable } from '@nestjs/common';
import { User } from '~/auth/entities';
import { UserService } from '~/auth/services/user.service';
import { UpdateCustomerRequestDto, UpdateNotificationsSettingsRequestDto } from '../dtos/request';
import { Customer } from '../entities';
@ -6,7 +7,10 @@ import { CustomerRepository } from '../repositories/customer.repository';
@Injectable()
export class CustomerService {
constructor(private readonly userService: UserService, private readonly customerRepository: CustomerRepository) {}
constructor(
@Inject(forwardRef(() => UserService)) private readonly userService: UserService,
private readonly customerRepository: CustomerRepository,
) {}
updateNotificationSettings(userId: string, data: UpdateNotificationsSettingsRequestDto) {
return this.userService.updateNotificationSettings(userId, data);
}
@ -16,6 +20,10 @@ export class CustomerService {
return this.findCustomerById(userId);
}
createCustomer(customerData: Partial<Customer>, user: User) {
return this.customerRepository.createCustomer(customerData, user);
}
async findCustomerById(id: string) {
const customer = await this.customerRepository.findOne({ id });
if (!customer) {