package com.itsol.quantrivanphong.manager.reportdetail.controller;

import com.itsol.quantrivanphong.manager.reportdetail.bussiness.ReportProjectBussiness;
import com.itsol.quantrivanphong.manager.reportdetail.dto.request.ReportDTO;
import com.itsol.quantrivanphong.model.Project;
import com.itsol.quantrivanphong.model.ProjectReport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(path = "/admin/report")
public class ReportProjectController {
    @Autowired
    private ReportProjectBussiness reportProjectBussiness;

    @GetMapping(path = "/project/all",consumes = "application/json", produces = "application/json")
    public ResponseEntity<List<Project>> listProjectWorking(){
        List<Project> projectList = reportProjectBussiness.listProjectWorking();
      return ResponseEntity.ok(projectList);
    }

    @GetMapping(path = "/project/latest",consumes = "application/json", produces = "application/json")
    public ResponseEntity<ProjectReport> latestReport(@RequestBody ReportDTO reportDTO){
            ProjectReport projectReport = reportProjectBussiness.latestReport(reportDTO);
        return  ResponseEntity.ok(projectReport);
    }

    @GetMapping(path = "/project/allReport",consumes = "application/json", produces = "application/json")
    public ResponseEntity<List<ProjectReport>> allProjectReport(@RequestBody ReportDTO reportDTO){
            List<ProjectReport> projectReportList = reportProjectBussiness.allProjectReport(reportDTO);
        return  ResponseEntity.ok(projectReportList);
    }
}
