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

import com.its.api.its.model.dto.incident.TbIncdEstmSectDto;
import com.its.api.its.model.entity.incident.TbIncdEstmSectKey;
import com.its.api.its.service.incident.TbIncdEstmSectService;
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 = "돌발상황 예상 구간")
@Validated
//@RestController
@RequiredArgsConstructor
@RequestMapping("/api/tb_incd_estm_sect")
public class TbIncdEstmSectController {

    private final TbIncdEstmSectService service;

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

    @ApiOperation(value = "돌발상황 예상 구간 개별조회(TB_INCD_ESTM_SECT)", response = TbIncdEstmSectDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbIncdEstmSectDto findById(@PathVariable final TbIncdEstmSectKey id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "돌발상황 예상 구간 정보변경(TB_INCD_ESTM_SECT)", response = TbIncdEstmSectDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbIncdEstmSectDto updateById(@PathVariable final TbIncdEstmSectKey id, @RequestBody @Valid final TbIncdEstmSectDto.TbIncdEstmSectUpdReq req) {
        return this.service.updateById(id, req);
    }

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

    @ApiOperation(value = "돌발상황 예상 구간 정보변경/생성-개별(TB_INCD_ESTM_SECT)", response = TbIncdEstmSectDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbIncdEstmSectDto mergeInfo(@PathVariable("id") TbIncdEstmSectKey id, @RequestBody @Valid final TbIncdEstmSectDto.TbIncdEstmSectUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "돌발상황 예상 구간 정보삭제-개별(TB_INCD_ESTM_SECT)", response = TbIncdEstmSectDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbIncdEstmSectDto deleteDataById(@PathVariable("id") TbIncdEstmSectKey id) {
        return this.service.deleteById(id);
    }

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

}
