package com.its.api.its.controller.incident;

import com.its.api.its.model.dto.incident.TbIncdOcrrVmsDto;
import com.its.api.its.service.incident.TbIncdOcrrVmsService;
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 = "돌발상황 발생 VMS")
@Validated
//@RestController
@RequiredArgsConstructor
@RequestMapping("/api/tb_incd_ocrr_vms")
public class TbIncdOcrrVmsController {

    private final TbIncdOcrrVmsService service;

    @ApiOperation(value = "돌발상황 발생 VMS 전체조회(TB_INCD_OCRR_VMS)", response = TbIncdOcrrVmsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbIncdOcrrVmsDto> findAll() {
        return service.findAll();
    }

    @ApiOperation(value = "돌발상황 발생 VMS 개별조회(TB_INCD_OCRR_VMS)", response = TbIncdOcrrVmsDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbIncdOcrrVmsDto findById(@PathVariable final String id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "돌발상황 발생 VMS 정보변경(TB_INCD_OCRR_VMS)", response = TbIncdOcrrVmsDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbIncdOcrrVmsDto updateById(@PathVariable final String id, @RequestBody @Valid final TbIncdOcrrVmsDto.TbIncdOcrrVmsUpdReq req) {
        return this.service.updateById(id, req);
    }

    @ApiOperation(value = "돌발상황 발생 VMS 정보변경/생성-목록(TB_INCD_OCRR_VMS)", response = TbIncdOcrrVmsDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbIncdOcrrVmsDto> mergeInfoList(@RequestBody @Valid final List<TbIncdOcrrVmsDto.TbIncdOcrrVmsUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "돌발상황 발생 VMS 정보변경/생성-개별(TB_INCD_OCRR_VMS)", response = TbIncdOcrrVmsDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbIncdOcrrVmsDto mergeInfo(@PathVariable("id") String id, @RequestBody @Valid final TbIncdOcrrVmsDto.TbIncdOcrrVmsUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "돌발상황 발생 VMS 정보삭제-개별(TB_INCD_OCRR_VMS)", response = TbIncdOcrrVmsDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbIncdOcrrVmsDto deleteDataById(@PathVariable("id") String id) {
        return this.service.deleteById(id);
    }

    @ApiOperation(value = "돌발상황 발생 VMS 정보삭제-목록(TB_INCD_OCRR_VMS)", response = TbIncdOcrrVmsDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbIncdOcrrVmsDto> deleteDataByIds(@RequestBody @Valid final List<String> ids) {
        return this.service.deleteByIds(ids);
    }

}
