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

import com.its.op.dto.its.scrs.TbScIxrCmraMngmDto;
import com.its.op.entity.its.scrs.TbScIxrCmraMngmKey;
import com.its.op.service.its.scrs.TbScIxrCmraMngmService;
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.관리-1.스마트교차로카메라 관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/scrs/tb_sc_ixr_cmra_mngm")
public class TbScIxrCmraMngmController {

    private final TbScIxrCmraMngmService service;

    @ApiOperation(value = "카메라 관리 전체조회(TB_SC_IXR_CMRA_MNGM)", response = TbScIxrCmraMngmDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScIxrCmraMngmDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "카메라 관리 전체조회(TB_SC_IXR_CMRA_MNGM)", response = TbScIxrCmraMngmDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/list", produces = {"application/json; charset=utf8"})
    public List<TbScIxrCmraMngmDto> findAllList() {
        return this.service.findAllList();
    }

    @ApiOperation(value = "카메라 관리 개별조회(TB_SC_IXR_CMRA_MNGM)", response = TbScIxrCmraMngmDto.class)
    @GetMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrCmraMngmDto findById(@PathVariable("ixrId") final TbScIxrCmraMngmKey ixrId) {
        return this.service.findById(ixrId);
    }

    @ApiOperation(value = "카메라 관리 정보변경(TB_SC_IXR_CMRA_MNGM)", response = TbScIxrCmraMngmDto.class)
    @PutMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrCmraMngmDto updateById(@PathVariable("ixrId") final TbScIxrCmraMngmKey ixrId, @RequestBody @Valid final TbScIxrCmraMngmDto.TbScIxrCmraMngmUpdReq req) {
        return this.service.updateById(ixrId, req);
    }

    @ApiOperation(value = "카메라 관리 정보변경/생성-목록(TB_SC_IXR_CMRA_MNGM)", response = TbScIxrCmraMngmDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScIxrCmraMngmDto> mergeInfoList(@RequestBody @Valid final List<TbScIxrCmraMngmDto.TbScIxrCmraMngmUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "카메라 관리 정보변경/생성-개별(TB_SC_IXR_CMRA_MNGM)", response = TbScIxrCmraMngmDto.class)
    @PostMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrCmraMngmDto mergeInfo(@PathVariable("ixrId") final TbScIxrCmraMngmKey ixrId, @RequestBody @Valid final TbScIxrCmraMngmDto.TbScIxrCmraMngmUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "카메라 관리 정보삭제-개별(TB_SC_IXR_CMRA_MNGM)", response = TbScIxrCmraMngmDto.class)
    @DeleteMapping(value = "/{ixrId}", produces = {"application/json; charset=utf8"})
    public TbScIxrCmraMngmDto deleteDataById(@PathVariable("ixrId") final TbScIxrCmraMngmKey ixrId) {
        return this.service.deleteById(ixrId);
    }

    @ApiOperation(value = "카메라 관리 정보삭제-목록(TB_SC_IXR_CMRA_MNGM)", response = TbScIxrCmraMngmDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScIxrCmraMngmDto> deleteDataByIds(@RequestBody @Valid final List<TbScIxrCmraMngmKey> ids) {
        return this.service.deleteByIds(ids);
    }

}
