package com.its.op.controller.its.scrs;

import com.its.op.dto.its.scrs.TbScTrfcCndtMngmDto;
import com.its.op.entity.its.scrs.TbScTrfcCndtMngmKey;
import com.its.op.service.its.scrs.TbScTrfcCndtMngmService;
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.스마트교차로-1.관리-2.교차로 기하구조 관리-1.교통 조건 관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/scrs/tb_sc_trfc_cndt_mngm")
public class TbScTrfcCndtMngmController {

    private final TbScTrfcCndtMngmService service;

    @ApiOperation(value = "교통 조건 관리 전체조회(TB_SC_TRFC_CNDT_MNGM)", response = TbScTrfcCndtMngmDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScTrfcCndtMngmDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "교통 조건 관리 전체조회(TB_SC_TRFC_CNDT_MNGM)", response = TbScTrfcCndtMngmDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/list", produces = {"application/json; charset=utf8"})
    public List<TbScTrfcCndtMngmDto> findAllList() {
        return this.service.findAllList();
    }

    @ApiOperation(value = "교통 조건 관리 개별조회(TB_SC_TRFC_CNDT_MNGM)", response = TbScTrfcCndtMngmDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public List<TbScTrfcCndtMngmDto> findListById(@PathVariable("ixrId") final String ixrId) {
        return this.service.findListById(ixrId);
    }

    @ApiOperation(value = "교통 조건 관리 정보변경(TB_SC_TRFC_CNDT_MNGM)", response = TbScTrfcCndtMngmDto.class)
    @PutMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScTrfcCndtMngmDto updateById(@PathVariable("ixrId") final TbScTrfcCndtMngmKey ixrId, @RequestBody @Valid final TbScTrfcCndtMngmDto.TbScTrfcCndtMngmUpdReq req) {
        return this.service.updateById(ixrId, req);
    }

    @ApiOperation(value = "교통 조건 관리 정보변경/생성-목록(TB_SC_TRFC_CNDT_MNGM)", response = TbScTrfcCndtMngmDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScTrfcCndtMngmDto> mergeInfoList(@RequestBody @Valid final List<TbScTrfcCndtMngmDto.TbScTrfcCndtMngmUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "교통 조건 관리 정보변경/생성-개별(TB_SC_TRFC_CNDT_MNGM)", response = TbScTrfcCndtMngmDto.class)
    @PostMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScTrfcCndtMngmDto mergeInfo(@PathVariable("ixrId") final TbScTrfcCndtMngmKey ixrId, @RequestBody @Valid final TbScTrfcCndtMngmDto.TbScTrfcCndtMngmUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "교통 조건 관리 정보삭제-개별(TB_SC_TRFC_CNDT_MNGM)", response = TbScTrfcCndtMngmDto.class)
    @DeleteMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScTrfcCndtMngmDto deleteDataById(@PathVariable("ixrId") final TbScTrfcCndtMngmKey ixrId) {
        return this.service.deleteById(ixrId);
    }

    @ApiOperation(value = "교통 조건 관리 정보삭제-목록(TB_SC_TRFC_CNDT_MNGM)", response = TbScTrfcCndtMngmDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScTrfcCndtMngmDto> deleteDataByIds(@RequestBody @Valid final List<TbScTrfcCndtMngmKey> ids) {
        return this.service.deleteByIds(ids);
    }

}
