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

import com.its.op.dto.its.scrs.TbScSgnlIxrSttsDto;
import com.its.op.service.its.scrs.TbScSgnlIxrSttsService;
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.스마트교차로-0.공통-1.신호제어기-상태")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/scrs/tb_sc_sgnl_ixr_stts")
public class TbScSgnlIxrSttsController {

    private final TbScSgnlIxrSttsService service;

    @ApiOperation(value = "신호 교차로 상태 전체조회(TB_SC_SGNL_IXR_STTS)", response = TbScSgnlIxrSttsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScSgnlIxrSttsDto> findAll() {
        return this.service.findAll();
    }

    @ApiOperation(value = "신호 교차로 상태 전체조회(TB_SC_SGNL_IXR_STTS)", response = TbScSgnlIxrSttsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/list", produces = {"application/json; charset=utf8"})
    public List<TbScSgnlIxrSttsDto> findAllList() {
        return this.service.findAllList();
    }

    @ApiOperation(value = "신호 교차로 상태 개별조회(TB_SC_SGNL_IXR_STTS)", response = TbScSgnlIxrSttsDto.class)
    @GetMapping(value = "/{sgnlIxrNmbr}", produces = {"application/json; charset=utf8"})
    public TbScSgnlIxrSttsDto findById(@PathVariable("sgnlIxrNmbr") final Integer sgnlIxrNmbr) {
        return this.service.findById(sgnlIxrNmbr);
    }

    @ApiOperation(value = "신호 교차로 상태 정보변경(TB_SC_SGNL_IXR_STTS)", response = TbScSgnlIxrSttsDto.class)
    @PutMapping(value = "/{sgnlIxrNmbr}", produces = {"application/json; charset=utf8"})
    public TbScSgnlIxrSttsDto updateById(@PathVariable("sgnlIxrNmbr") final Integer sgnlIxrNmbr, @RequestBody @Valid final TbScSgnlIxrSttsDto.TbScSgnlIxrSttsUpdReq req) {
        return this.service.updateById(sgnlIxrNmbr, req);
    }

    @ApiOperation(value = "신호 교차로 상태 정보변경/생성-목록(TB_SC_SGNL_IXR_STTS)", response = TbScSgnlIxrSttsDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScSgnlIxrSttsDto> mergeInfoList(@RequestBody @Valid final List<TbScSgnlIxrSttsDto.TbScSgnlIxrSttsUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "신호 교차로 상태 정보변경/생성-개별(TB_SC_SGNL_IXR_STTS)", response = TbScSgnlIxrSttsDto.class)
    @PostMapping(value = "/{sgnlIxrNmbr}", produces = {"application/json; charset=utf8"})
    public TbScSgnlIxrSttsDto mergeInfo(@PathVariable("sgnlIxrNmbr") final Integer sgnlIxrNmbr, @RequestBody @Valid final TbScSgnlIxrSttsDto.TbScSgnlIxrSttsUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "신호 교차로 상태 정보삭제-개별(TB_SC_SGNL_IXR_STTS)", response = TbScSgnlIxrSttsDto.class)
    @DeleteMapping(value = "/{sgnlIxrNmbr}", produces = {"application/json; charset=utf8"})
    public TbScSgnlIxrSttsDto deleteDataById(@PathVariable("sgnlIxrNmbr") final Integer sgnlIxrNmbr) {
        return this.service.deleteById(sgnlIxrNmbr);
    }

    @ApiOperation(value = "신호 교차로 상태 정보삭제-목록(TB_SC_SGNL_IXR_STTS)", response = TbScSgnlIxrSttsDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbScSgnlIxrSttsDto> deleteDataByIds(@RequestBody @Valid final List<Integer> ids) {
        return this.service.deleteByIds(ids);
    }

}
