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

import com.its.op.dto.its.scrs.TbScIxrMngmDto;
import com.its.op.service.its.scrs.TbScIxrMngmService;
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.관리-0.교차로 관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/scrs/tb_sc_ixr_mngm")
public class TbScIxrMngmController {

    private final TbScIxrMngmService service;

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

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

    @ApiOperation(value = "교차로 관리 개별조회(TB_SC_IXR_MNGM)", response = TbScIxrMngmDto.class)
    @GetMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrMngmDto findById(@PathVariable("ixrId") final String ixrId) {
        return this.service.findById(ixrId);
    }

    @ApiOperation(value = "교차로 관리 정보변경(TB_SC_IXR_MNGM)", response = TbScIxrMngmDto.class)
    @PutMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrMngmDto updateById(@PathVariable("ixrId") final String ixrId, @RequestBody @Valid final TbScIxrMngmDto.TbScIxrMngmUpdReq req) {
        return this.service.updateById(ixrId, req);
    }

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

    @ApiOperation(value = "교차로 관리 정보변경/생성-개별(TB_SC_IXR_MNGM)", response = TbScIxrMngmDto.class)
    @PostMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrMngmDto mergeInfo(@PathVariable("ixrId") final String ixrId, @RequestBody @Valid final TbScIxrMngmDto.TbScIxrMngmUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "교차로 관리 정보삭제-개별(TB_SC_IXR_MNGM)", response = TbScIxrMngmDto.class)
    @DeleteMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrMngmDto deleteDataById(@PathVariable("ixrId") final String ixrId) {
        return this.service.deleteById(ixrId);
    }

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

}
