import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { RequirePermissions } from '../../common/permissions.decorator';
import { RegionsService } from './regions.service';

@ApiBearerAuth()
@ApiTags('区域管理')
@Controller('regions')
export class RegionsController {
  constructor(private readonly regionsService: RegionsService) {}

  @Get('tree')
  tree() {
    return this.regionsService.tree();
  }

  @RequirePermissions('system:manage')
  @Post()
  create(@Body() dto: any) {
    return this.regionsService.create(dto);
  }

  @RequirePermissions('system:manage')
  @Patch(':id')
  update(@Param('id') id: string, @Body() dto: any) {
    return this.regionsService.update(id, dto);
  }
}
