import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { ServiceStandardsService } from './service-standards.service';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
import { RolesGuard } from '../common/guards/roles.guard';
import { Roles } from '../common/decorators/roles.decorator';

@ApiTags('Service Standards')
@Controller()
export class ServiceStandardsController {
  constructor(private service: ServiceStandardsService) {}

  @Get('service-standards')
  findAll() {
    return this.service.findAll();
  }

  @ApiBearerAuth()
  @UseGuards(JwtAuthGuard, RolesGuard)
  @Roles('SUPER_ADMIN', 'ADMIN')
  @Post('admin/service-standards')
  create(@Body() data: { title: string; content: string; orderNo?: number }) {
    return this.service.create(data);
  }

  @ApiBearerAuth()
  @UseGuards(JwtAuthGuard, RolesGuard)
  @Roles('SUPER_ADMIN', 'ADMIN')
  @Put('admin/service-standards/:id')
  update(@Param('id') id: string, @Body() data: { title?: string; content?: string; orderNo?: number }) {
    return this.service.update(+id, data);
  }

  @ApiBearerAuth()
  @UseGuards(JwtAuthGuard, RolesGuard)
  @Roles('SUPER_ADMIN', 'ADMIN')
  @Delete('admin/service-standards/:id')
  remove(@Param('id') id: string) {
    return this.service.remove(+id);
  }
}
