package com.eactive.eai.rms.common.schedulerStatus;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import com.eactive.eai.rms.common.base.BaseAnnotationController;
import com.eactive.eai.rms.common.vo.GridResponse;

@Controller
public class SchedulerStatusHistoryController extends BaseAnnotationController {

	@Autowired
	private SchedulerStatusHistoryService service;

	@GetMapping(value = "/common/scheduler/schedulerStatusHistoryMan.view")
	public String viewList() {
		return "/common/scheduler/schedulerStatusHistoryMan";
	}

	@PostMapping(value = "/common/scheduler/schedulerStatusHistoryMan.json", params = "cmd=LIST")
	public ResponseEntity<GridResponse<JobHistoryUI>> selectList(
			@SortDefault(sort= {"startDate"}, direction = Sort.Direction.DESC) Pageable pageable, String searchStartTime,
			String searchEndTime, String searchJobName, String searchInstanceName) {

		Page<JobHistoryUI> map = service
				.selectList(pageable, searchStartTime, searchEndTime, searchJobName, searchInstanceName);
		return ResponseEntity.ok(new GridResponse<>(map));
	}
}
