package com.sonymusic.dx.dxadvsearchservice.controllers;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sonymusic.dx.dxadvsearchservice.model.ListModel;
import com.sonymusic.dx.dxadvsearchservice.model.TrackModel;
import com.sonymusic.dx.dxadvsearchservice.searchModel.TrackSearchModel;
import com.sonymusic.dx.dxadvsearchservice.service.TrackService;

import java.text.ParseException;

@RestController
@RequestMapping("/tracks")
public class TrackAdvSearchController {

    @Autowired
    private TrackService trackService;

    @PostMapping("/advSearchTrack")
    public ListModel<TrackModel> getAdvSearchTracks(@RequestBody TrackSearchModel tracks,
                                                    @RequestParam(defaultValue = "1")int page,
                                                    @RequestParam(defaultValue = "20")int size) throws ParseException {
        return trackService.advSearchTrack(tracks,page,size);
    }

}
