feat: complete admin panel and backend admin api migration

This commit is contained in:
s.esmaeili
2026-09-13 21:02:25 +03:30
parent 03119cd655
commit 267fc7b7d1
239 changed files with 25431 additions and 935 deletions
@@ -0,0 +1,52 @@
import { Body, Controller, Get, HttpCode, Param, Post, Put } from '@nestjs/common';
import { AdminBranchesService } from '../admin-branches/admin-branches.service';
import { TableQueryDto } from '../admin-table/table-query.dto';
import { RequirePermission } from '../auth/guards';
/**
* Workshops — legacy views/workshop/*, served by WorkshopController:
* POST workshop/table -> the grid (also the picker the PreOrder detail uses)
* POST workshop -> create (workshop + its supervisor, together)
* GET/PUT workshop/{id}
* GET workshop/active/{id} -> toggle
*
* The list route predates the rest (Batch 3 added it for the made-to-order
* screen's workshop picker); the CRUD arrived with Batch 11. Both live here so
* there is one owner of /admin/workshops, and the logic sits in
* AdminBranchesService alongside the branch code it mirrors.
*/
@Controller('admin/workshops')
export class AdminWorkshopsController {
constructor(private readonly branches: AdminBranchesService) {}
@Post('list')
@HttpCode(200)
list(@Body() query: TableQueryDto) {
return this.branches.listWorkshops(query);
}
@Post()
@HttpCode(200)
@RequirePermission('workshop.create')
create(@Body() data: Record<string, unknown>) {
return this.branches.createWorkshop(data);
}
@Get('active/:id')
@RequirePermission('workshop.list')
toggleActive(@Param('id') id: string) {
return this.branches.toggleWorkshopActive(id);
}
@Get(':id')
@RequirePermission('workshop.list')
findOne(@Param('id') id: string) {
return this.branches.findWorkshop(id);
}
@Put(':id')
@RequirePermission('workshop.list')
update(@Param('id') id: string, @Body() data: Record<string, unknown>) {
return this.branches.updateWorkshop(id, data);
}
}
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { PrismaModule } from '../../prisma/prisma.module';
import { AdminBranchesModule } from '../admin-branches/admin-branches.module';
import { AdminWorkshopsController } from './admin-workshops.controller';
@Module({
imports: [PrismaModule, AdminBranchesModule],
controllers: [AdminWorkshopsController],
})
export class AdminWorkshopsModule {}