package com.its.api.its.controller.cctv;

import com.its.api.its.model.dto.cctv.TbCctvScnrDto;
import com.its.api.its.model.entity.cctv.TbCctvScnrKey;
import com.its.api.its.service.cctv.TbCctvScnrService;
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 = "11.CCTV-6.CCTV 프리셋 제어 스케줄 관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/cctv/pset-scnr")
public class TbCctvScnrController {

    private final TbCctvScnrService service;

    @ApiOperation(value = "CCTV 시나리오 전체조회(TB_CCTV_SCNR)", response = TbCctvScnrDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbCctvScnrDto> findAll() {
        return service.findAll();
    }

    @ApiOperation(value = "CCTV 시나리오 개별조회(TB_CCTV_SCNR)", response = TbCctvScnrDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbCctvScnrDto findById(@PathVariable final TbCctvScnrKey id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "CCTV 시나리오 정보변경(TB_CCTV_SCNR)", response = TbCctvScnrDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbCctvScnrDto updateById(@PathVariable final TbCctvScnrKey id, @RequestBody @Valid final TbCctvScnrDto.TbCctvScnrUpdReq req) {
        return this.service.updateById(id, req);
    }

    @ApiOperation(value = "CCTV 시나리오 정보변경/생성-목록(TB_CCTV_SCNR)", response = TbCctvScnrDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbCctvScnrDto> mergeInfoList(@RequestBody @Valid final List<TbCctvScnrDto.TbCctvScnrUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "CCTV 시나리오 정보변경/생성-개별(TB_CCTV_SCNR)", response = TbCctvScnrDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbCctvScnrDto mergeInfo(@PathVariable("id") TbCctvScnrKey id, @RequestBody @Valid final TbCctvScnrDto.TbCctvScnrUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "CCTV 시나리오 정보삭제-개별(TB_CCTV_SCNR)", response = TbCctvScnrDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbCctvScnrDto deleteDataById(@PathVariable("id") TbCctvScnrKey id) {
        return this.service.deleteById(id);
    }

    @ApiOperation(value = "CCTV 시나리오 정보삭제-목록(TB_CCTV_SCNR)", response = TbCctvScnrDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbCctvScnrDto> deleteDataByIds(@RequestBody @Valid final List<TbCctvScnrKey> ids) {
        return this.service.deleteByIds(ids);
    }

}
