package com.its.op.controller.its.rse;

import com.its.op.dto.its.rse.TbRseSectTrafHsDto;
import com.its.op.entity.its.rse.TbRseSectTrafHsKey;
import com.its.op.service.its.rse.TbRseSectTrafHsService;
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 = "14.RSE-1.RSE 관리-RSE 구간 소통상황")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/rse/tb_rse_sect_traf_hs")
public class TbRseSectTrafHsController {

    private final TbRseSectTrafHsService service;

    @ApiOperation(value = "RSE 구간 소통상황 전체조회(TB_RSE_SECT_TRAF_HS)", response = TbRseSectTrafHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseSectTrafHsDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "RSE 구간 소통상황 개별조회(TB_RSE_SECT_TRAF_HS)", response = TbRseSectTrafHsDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseSectTrafHsDto findById(@PathVariable final TbRseSectTrafHsKey id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "RSE 구간 소통상황 정보변경(TB_RSE_SECT_TRAF_HS)", response = TbRseSectTrafHsDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseSectTrafHsDto updateById(@PathVariable final TbRseSectTrafHsKey id, @RequestBody @Valid final TbRseSectTrafHsDto.TbRseSectTrafHsUpdReq req) {
        return this.service.updateById(id, req);
    }

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

    @ApiOperation(value = "RSE 구간 소통상황 정보변경/생성-개별(TB_RSE_SECT_TRAF_HS)", response = TbRseSectTrafHsDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseSectTrafHsDto mergeInfo(@PathVariable("id") TbRseSectTrafHsKey id, @RequestBody @Valid final TbRseSectTrafHsDto.TbRseSectTrafHsUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "RSE 구간 소통상황 정보삭제-개별(TB_RSE_SECT_TRAF_HS)", response = TbRseSectTrafHsDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbRseSectTrafHsDto deleteDataById(@PathVariable("id") TbRseSectTrafHsKey id) {
        return this.service.deleteById(id);
    }

    @ApiOperation(value = "RSE 구간 소통상황 정보삭제-목록(TB_RSE_SECT_TRAF_HS)", response = TbRseSectTrafHsDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRseSectTrafHsDto> deleteDataByIds(@RequestBody @Valid final List<TbRseSectTrafHsKey> ids) {
        return this.service.deleteByIds(ids);
    }

}
