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

import com.its.op.dto.its.facility.TbFcltFailTypeActDto;
import com.its.op.service.its.facility.TbFcltFailTypeActService;
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.코드관리-3.시설물 장애 유형별 조치")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/facility/code/fail-type-act")
public class TbFcltFailTypeActController {

    private final TbFcltFailTypeActService service;

    @ApiOperation(value = "시설물 장애 유형별 조치 전체조회(TB_FCLT_FAIL_TYPE_ACT)", response = TbFcltFailTypeActDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbFcltFailTypeActDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "시설물 장애 유형별 조치 개별조회(TB_FCLT_FAIL_TYPE_ACT)", response = TbFcltFailTypeActDto.class)
    @GetMapping(value = "/{actCd}", produces = {"application/json; charset=utf8"})
    public TbFcltFailTypeActDto findById(@PathVariable("actCd") final String actCd) {
        return this.service.findById(actCd);
    }

    @ApiOperation(value = "시설물 장애 유형별 조치 정보변경/생성-개별(TB_FCLT_FAIL_TYPE_ACT)", response = TbFcltFailTypeActDto.class)
    @PostMapping(value = "/{actCd}", produces = {"application/json; charset=utf8"})
    public TbFcltFailTypeActDto mergeInfo(@PathVariable("actCd") final String actCd, @RequestBody @Valid final TbFcltFailTypeActDto.TbFcltFailTypeActUpdReq req) {
        return this.service.mergeInfo(req);
    }

}
