mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 16:44:54 +00:00
feat: set theme for junior users
This commit is contained in:
@ -4,7 +4,7 @@ import { Roles } from '~/auth/enums';
|
||||
import { UserService } from '~/auth/services';
|
||||
import { PageOptionsRequestDto } from '~/core/dtos';
|
||||
import { CustomerService } from '~/customer/services';
|
||||
import { CreateJuniorRequestDto } from '../dtos/request';
|
||||
import { CreateJuniorRequestDto, SetThemeRequestDto } from '../dtos/request';
|
||||
import { Junior } from '../entities';
|
||||
import { JuniorRepository } from '../repositories';
|
||||
|
||||
@ -50,7 +50,7 @@ export class JuniorService {
|
||||
return this.findJuniorById(user.id, guardianId);
|
||||
}
|
||||
|
||||
async findJuniorById(juniorId: string, guardianId: string) {
|
||||
async findJuniorById(juniorId: string, guardianId?: string) {
|
||||
const junior = await this.juniorRepository.findJuniorById(juniorId, guardianId);
|
||||
|
||||
if (!junior) {
|
||||
@ -59,6 +59,16 @@ export class JuniorService {
|
||||
return junior;
|
||||
}
|
||||
|
||||
@Transactional()
|
||||
async setTheme(body: SetThemeRequestDto, juniorId: string) {
|
||||
const junior = await this.findJuniorById(juniorId);
|
||||
if (junior.theme) {
|
||||
await this.juniorRepository.removeTheme(junior.theme);
|
||||
}
|
||||
await this.juniorRepository.setTheme(body, junior);
|
||||
return this.juniorRepository.findThemeForJunior(juniorId);
|
||||
}
|
||||
|
||||
findJuniorsByGuardianId(guardianId: string, pageOptions: PageOptionsRequestDto) {
|
||||
return this.juniorRepository.findJuniorsByGuardianId(guardianId, pageOptions);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user