package com.its.op.controller.its.facility;

import com.its.op.dto.its.facility.TbFcltFailOcrrTypeDto;
import com.its.op.service.its.facility.TbFcltFailOcrrTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "01.시설물관리-0.코드관리-1.장애발생구분코드")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/facility/code/fail-ocrr")
public class TbFcltFailOcrrTypeController {

    private final TbFcltFailOcrrTypeService service;

    @ApiOperation(value = "시설물 장애 발생 구분 전체조회(TB_FCLT_FAIL_OCRR_TYPE)", response = TbFcltFailOcrrTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbFcltFailOcrrTypeDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "시설물 장애 발생 구분 개별조회(TB_FCLT_FAIL_OCRR_TYPE)", response = TbFcltFailOcrrTypeDto.class)
    @GetMapping(value = "/{ocrrCd}", produces = {"application/json; charset=utf8"})
    public TbFcltFailOcrrTypeDto findById(@PathVariable("ocrrCd") final String ocrrCd) {
        return this.service.findById(ocrrCd);
    }

    @ApiOperation(value = "시설물 장애 발생 구분 정보변경/생성-개별(TB_FCLT_FAIL_OCRR_TYPE)", response = TbFcltFailOcrrTypeDto.class)
    @PostMapping(value = "/{ocrrCd}", produces = {"application/json; charset=utf8"})
    public TbFcltFailOcrrTypeDto mergeInfo(@PathVariable("ocrrCd") String ocrrCd, @RequestBody @Valid final TbFcltFailOcrrTypeDto.TbFcltFailOcrrTypeUpdReq req) {
        return this.service.mergeInfo(req);
    }

}
