import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { AuthUser, CurrentUser } from '../../common/current-user.decorator';
import { RequirePermissions } from '../../common/permissions.decorator';
import { LampsService } from './lamps.service';

@ApiBearerAuth()
@ApiTags('路灯资产')
@RequirePermissions('lamps:manage')
@Controller('lamps')
export class LampsController {
  constructor(private readonly lampsService: LampsService) {}

  @Get()
  findAll(@CurrentUser() user: AuthUser, @Query() query: any) {
    return this.lampsService.findAll(user, query);
  }

  @Post()
  create(@CurrentUser() user: AuthUser, @Body() dto: any) {
    return this.lampsService.create(user, dto);
  }

  @Post('sync-ilc')
  syncIlc(@CurrentUser() user: AuthUser) {
    return this.lampsService.syncExternalIlcList(user);
  }

  @Post('sync-platform')
  syncPlatform(@CurrentUser() user: AuthUser, @Body() dto: any) {
    return this.lampsService.syncExternalIlcList(user, dto);
  }

  @Patch(':id')
  update(@CurrentUser() user: AuthUser, @Param('id') id: string, @Body() dto: any) {
    return this.lampsService.update(user, id, dto);
  }

  @Delete(':id')
  remove(@CurrentUser() user: AuthUser, @Param('id') id: string) {
    return this.lampsService.remove(user, id);
  }
}
