feat: complete admin panel and backend admin api migration
This commit is contained in:
@@ -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 {}
|
||||
Reference in New Issue
Block a user