import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { OriginGoodsService } from './origin-goods.service';
import { QueryOriginGoodDto } from './dto/query-origin-good.dto';

@ApiTags('origin-goods')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('origin-goods')
export class OriginGoodsController {
  constructor(private readonly service: OriginGoodsService) {}

  @Get('tree')
  @ApiOperation({
    summary: 'Origin goods grouped by SDS category with config status',
  })
  getTree() {
    return this.service.getTree();
  }

  @Get()
  @ApiOperation({ summary: 'Paginated list of origin goods (read-only)' })
  findAll(@Query() query: QueryOriginGoodDto) {
    return this.service.findAll(query);
  }
}
