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

import com.its.op.dto.its.facility.TbFcltFailStupDto;
import com.its.op.entity.its.facility.TbFcltFailStupKey;
import com.its.op.service.its.facility.TbFcltFailStupService;
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.코드관리-4.시설물 장애 처리 설정")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/facility/code/fail-stup")
public class TbFcltFailStupController {

    private final TbFcltFailStupService service;

    @ApiOperation(value = "시설물 장애 처리 설정 전체조회(TB_FCLT_FAIL_STUP)", response = TbFcltFailStupDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbFcltFailStupDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "시설물 장애 처리 설정 개별조회(TB_FCLT_FAIL_STUP)", response = TbFcltFailStupDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbFcltFailStupDto findById(@PathVariable final TbFcltFailStupKey id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "시설물 장애 처리 설정 정보변경/생성-개별(TB_FCLT_FAIL_STUP)", response = TbFcltFailStupDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbFcltFailStupDto mergeInfo(@PathVariable("id") TbFcltFailStupKey id, @RequestBody @Valid final TbFcltFailStupDto.TbFcltFailStupUpdReq req) {
        return this.service.mergeInfo(req);
    }

}
