package com.oqpo.api.web.controller.system;

import com.oqpo.api.service.system.JobService;
import com.oqpo.api.web.dto.request.job.JobGridRequest;
import com.oqpo.api.web.dto.response.GridResponse;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Slf4j
@RestController
@RequestMapping("/api/job")
public class JobController {
    @Autowired
    private JobService jobService;

    /**
     * 설명 : 작업 상세 그리드 리스트
     *
     * @param jobGridRequest
     * @return
     * @throws Exception
     */
    @ApiImplicitParams({
            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
    })
    @ApiOperation(value = "작업 상세 그리드 리스트")
    @PostMapping("/detail-grid-list")
    public ResponseEntity<GridResponse> detailGridList(@RequestBody @Valid JobGridRequest jobGridRequest) throws Exception {
        return ResponseEntity.ok(jobService.jobGridList(jobGridRequest.getFromDt(), jobGridRequest.getToDt(), jobGridRequest.getMenuNo(), jobGridRequest.getActTpCd(), jobGridRequest.getUserId(), jobGridRequest.toDTO(jobGridRequest)));
    }
}
