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

import com.its.op.dto.its.facility.TbFcltFailTypeDto;
import com.its.op.service.its.facility.TbFcltFailTypeService;
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.코드관리-2.시설물 장애 유형")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/facility/code/fail-type")
public class TbFcltFailTypeController {

    private final TbFcltFailTypeService service;

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

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

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

}
