feat(doctor): implement Doctors / Vets CRUD backend and DB model (TASK-2.18)

This commit is contained in:
parsa aghaei committed 2026-08-02 09:29:33 +03:30
1 parent d784f3fcc7
commit 47bff2c6ed
4 files changed
+63 -1

No files matched your search

+32
View File
@@ -236,4 +236,36 @@ export class AdminController {
const settings = await this.adminService.updateSettings(data);
return { success: true, data: settings };
}
// --- Doctors / Vets ---
@Get('doctors')
@ApiOperation({ summary: 'لیست پزشکان و متخصصان' })
async getDoctors() {
const doctors = await this.adminService.getDoctors();
return { success: true, data: doctors };
}
@UseGuards(JwtAuthGuard)
@Post('doctors')
@ApiOperation({ summary: 'افزودن پزشک جدید' })
async createDoctor(@Body() body: any) {
const doctor = await this.adminService.createDoctor(body);
return { success: true, data: doctor };
}
@UseGuards(JwtAuthGuard)
@Put('doctors/:id')
@ApiOperation({ summary: 'ویرایش اطلاعات پزشک' })
async updateDoctor(@Param('id') id: string, @Body() body: any) {
const doctor = await this.adminService.updateDoctor(id, body);
return { success: true, data: doctor };
}
@UseGuards(JwtAuthGuard)
@Delete('doctors/:id')
@ApiOperation({ summary: 'حذف پزشک' })
async deleteDoctor(@Param('id') id: string) {
await this.adminService.deleteDoctor(id);
return { success: true };
}
}
+18
View File
@@ -429,4 +429,22 @@ export class AdminService {
await this.prisma.$transaction(operations);
return this.getSettings();
}
async getDoctors() {
return this.prisma.doctor.findMany({
orderBy: { createdAt: 'desc' },
});
}
async createDoctor(data: { name: string; title: string; avatarUrl?: string; bio?: string; clinic?: string }) {
return this.prisma.doctor.create({ data });
}
async updateDoctor(id: string, data: { name?: string; title?: string; avatarUrl?: string; bio?: string; clinic?: string }) {
return this.prisma.doctor.update({ where: { id }, data });
}
async deleteDoctor(id: string) {
return this.prisma.doctor.delete({ where: { id } });
}
}