package com.its.op.controller.its.history;

import com.its.op.dto.its.unit.TbUnitSystDto;
import com.its.op.dto.its.unit.TbUnitSystSttsHsHistDto;
import com.its.op.service.its.unit.TbUnitSystService;
import com.its.op.service.its.unit.TbUnitSystSttsHsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "02.이력조회-1.프로세스상태이력")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/history/unit-syst-stts-hs")
public class TbUnitSystSttsHsHistController {

    private final TbUnitSystSttsHsService service;
    private final TbUnitSystService unitService;

    @ApiOperation(value = "프로세스목록조회(TB_UNIT_SYST)", response = TbUnitSystDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/type", produces = {"application/json; charset=utf8"})
    public List<TbUnitSystDto> findAllProcess() {
        return this.unitService.findAllList();
    }

    @ApiOperation(value = "이력조회(TB_UNIT_SYST_STTS_HS, TB_UNIT_SYST)", response = TbUnitSystSttsHsHistDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbUnitSystSttsHsHistDto> findAllHistByDateRange(
            @ApiParam(name = "SYST_ID", value = "시스템 ID(syst_id)", example = "UTP01", required = true)
            @RequestParam String SYST_ID,
            @ApiParam(name = "CRTN_DT", value = "이력조회일자(YYYYMMDD)", example = "20220125", required = true)
            @RequestParam String CRTN_DT) {
        return service.findAllHistByDateRange(SYST_ID, CRTN_DT);
    }

}
