import { Controller, Get, Param, Query } from '@nestjs/common';
import { V22QueryService } from './v22-query.service';

@Controller('v2.2')
export class V22QueryController {
  constructor(private readonly v22QueryService: V22QueryService) {}

  @Get('versions/:versionId/detail-data')
  getVersionDetailData(@Param('versionId') versionId: string) {
    return this.v22QueryService.getVersionDetailData(versionId);
  }

  @Get('requirements')
  listRequirements(
    @Query('productId') productId?: string,
    @Query('projectId') projectId?: string,
    @Query('versionId') versionId?: string,
    @Query('status') status?: string,
    @Query('priority') priority?: string,
    @Query('type') type?: string,
    @Query('q') q?: string,
    @Query('sort') sort?: string,
    @Query('cursor') cursor?: string,
    @Query('limit') limit?: string,
  ) {
    return this.v22QueryService.listRequirements({
      productId,
      projectId,
      versionId,
      status,
      priority,
      type,
      q,
      sort,
      cursor,
      limit,
    });
  }

  @Get('workspace')
  getWorkspaceData(@Query('userId') userId: string) {
    return this.v22QueryService.getWorkspaceData(userId);
  }

  @Get('xiaobao-warning')
  getXiaobaoWarnings(
    @Query('userId') userId?: string,
    @Query('manager') manager?: string,
  ) {
    return this.v22QueryService.getXiaobaoWarnings({ userId, manager });
  }
}
