import { Body, Controller, Delete, Get, Post, Query } from "@nestjs/common";
import ResponseDto from "../../dto/response.dto";
import MediaProvider from "./media.provider";
import { ApiQuery, ApiResponse } from "@nestjs/swagger";
import MediaLoadDto from "../../dto/media.dto";

@Controller("/api/v1/media")
export default class MediaController {

    constructor(private mediaProvider: MediaProvider){}
    
    @ApiResponse({type: ResponseDto})
    @Post("/loadMedia")
    async loadMedia(@Body() payload: MediaLoadDto): Promise<ResponseDto>{
        return await this.mediaProvider.loadMedia(payload);
    }

    @ApiResponse({type: ResponseDto})
    @ApiQuery({name: "idNext", required: false})
    @ApiQuery({name: "filter", required: false})
    @Get("/listMedia")
    async listMedia(@Query("idNext") idNext?: string, @Query("filter") filter?: string): Promise<ResponseDto>{
        return await this.mediaProvider.listMedia(idNext, filter);
    }

    @ApiResponse({type: ResponseDto})
    @Delete("/trashMedia")
    async trashMedia(@Query("uuid") uuid: string): Promise<ResponseDto>{
        return await this.mediaProvider.trashMedia(uuid);
    }

}