import { Controller, Get, Param } from '@nestjs/common';
import { UsersService } from './users.service';
import { RetrievePhysicalActivitiesResponseDto } from './dtos/retrieve-physical-activities.dto';
import { IsPublic } from '../../shared/decorators/auth/is-public.decorator';
import { ApiTags } from '@nestjs/swagger';
import {
  ApiDefaultResponseStatus,
  ApiResponseStatuses,
} from '../../shared/decorators/swagger/api-response-statuses.decorator';
import {
  RetrievePhysicalActivityParamsDto,
  RetrievePhysicalActivityResponseDto,
} from './dtos/retrieve-physical-activity.dto';
import { RetrieveGoalsResponseDto } from './dtos/retrieve-goals.dto';
import {
  RetrieveGoalParamsDto,
  RetrieveGoalResponseDto,
} from './dtos/retrieve-goal.dto';
import { SingleIdParamsDto } from '../../shared/dtos/params/single-id-params.dto';
import { RetrieveAnyUserResponseDto } from './dtos/retrieve-any-user.dto';
import { SingleUsernameDto } from '../../shared/dtos/users/single-username.dto';
import { SimpleNumberDto } from '../../shared/dtos/simple-number.dto';

@ApiTags('Users')
@Controller('users')
export class UsersController {
  constructor(private readonly _usersService: UsersService) {}

  @Get('count')
  @IsPublic()
  @ApiDefaultResponseStatus(200, SimpleNumberDto)
  @ApiResponseStatuses(502)
  async retrieveUsersCount(): Promise<SimpleNumberDto> {
    return this._usersService.retrieveUsersCount();
  }

  @Get('physical-activities')
  @IsPublic()
  @ApiDefaultResponseStatus(200, RetrievePhysicalActivitiesResponseDto)
  @ApiResponseStatuses(502)
  async retrievePhysicalActivities(): Promise<RetrievePhysicalActivitiesResponseDto> {
    return this._usersService.retrievePhysicalActivities();
  }

  @Get('physical-activities/:id')
  @IsPublic()
  @ApiDefaultResponseStatus(200, RetrievePhysicalActivityResponseDto)
  @ApiResponseStatuses(400, 404, 502)
  async retrievePhysicalActivity(
    @Param() params: RetrievePhysicalActivityParamsDto,
  ): Promise<RetrievePhysicalActivityResponseDto> {
    return this._usersService.retrievePhysicalActivity(params);
  }

  @Get('goals')
  @IsPublic()
  @ApiDefaultResponseStatus(200, RetrieveGoalsResponseDto)
  @ApiResponseStatuses(502)
  async retrieveGoals(): Promise<RetrieveGoalsResponseDto> {
    return this._usersService.retrieveGoals();
  }

  @Get('goals/:id')
  @IsPublic()
  @ApiDefaultResponseStatus(200, RetrieveGoalResponseDto)
  @ApiResponseStatuses(400, 404, 502)
  async retrieveGoal(
    @Param() params: RetrieveGoalParamsDto,
  ): Promise<RetrieveGoalResponseDto> {
    return this._usersService.retrieveGoal(params);
  }

  @Get('username/:username')
  @IsPublic()
  @ApiDefaultResponseStatus(200, RetrieveAnyUserResponseDto)
  @ApiResponseStatuses(400, 404, 502)
  async retrieveAnyUserByUsername(@Param() params: SingleUsernameDto) {
    return this._usersService.retrieveAnyUserByUsername(params);
  }

  @Get(':id')
  @IsPublic()
  @ApiDefaultResponseStatus(200, RetrieveAnyUserResponseDto)
  @ApiResponseStatuses(400, 404, 502)
  async retrieveAnyUser(@Param() params: SingleIdParamsDto) {
    return this._usersService.retrieveAnyUser(params);
  }
}
