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

import com.its.op.dto.its.scrs.TbScIxrGemtMngmDto;
import com.its.op.entity.its.scrs.TbScIxrGemtMngmKey;
import com.its.op.service.its.scrs.TbScIxrGemtMngmService;
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.교차로 기하구조 관리-2.교차로 기하구조 설정")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/scrs/tb_sc_ixr_gemt_mngm")
public class TbScIxrGemtMngmController {

    private final TbScIxrGemtMngmService service;

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

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

    @ApiOperation(value = "교차로 기하구조 관리 개별조회(TB_SC_IXR_GEMT_MNGM)", response = TbScIxrGemtMngmDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public List<TbScIxrGemtMngmDto> findListById(@PathVariable("ixrId") final String ixrId) {
        return this.service.findListById(ixrId);
    }

    @ApiOperation(value = "교차로 기하구조 관리 정보변경(TB_SC_IXR_GEMT_MNGM)", response = TbScIxrGemtMngmDto.class)
    @PutMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrGemtMngmDto updateById(@PathVariable("ixrId") final TbScIxrGemtMngmKey ixrId, @RequestBody @Valid final TbScIxrGemtMngmDto.TbScIxrGemtMngmUpdReq req) {
        return this.service.updateById(ixrId, req);
    }

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

    @ApiOperation(value = "교차로 기하구조 관리 정보변경/생성-개별(TB_SC_IXR_GEMT_MNGM)", response = TbScIxrGemtMngmDto.class)
    @PostMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrGemtMngmDto mergeInfo(@PathVariable("ixrId") final TbScIxrGemtMngmKey ixrId, @RequestBody @Valid final TbScIxrGemtMngmDto.TbScIxrGemtMngmUpdReq req) {
        return this.service.mergeInfo(req);
    }

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

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

}
