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

import com.its.api.its.model.dto.cctv.TbCctvPsetDto;
import com.its.api.its.model.entity.cctv.TbCctvPsetKey;
import com.its.api.its.service.cctv.TbCctvPsetService;
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-5.CCTV 프리셋 설정")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/cctv/pset")
public class TbCctvPsetController {

    private final TbCctvPsetService service;

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

    @ApiOperation(value = "CCTV 프리셋 개별조회(TB_CCTV_PSET)", response = TbCctvPsetDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbCctvPsetDto findById(@PathVariable final TbCctvPsetKey id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "CCTV 프리셋 정보변경(TB_CCTV_PSET)", response = TbCctvPsetDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbCctvPsetDto updateById(@PathVariable final TbCctvPsetKey id, @RequestBody @Valid final TbCctvPsetDto.TbCctvPsetUpdReq req) {
        return this.service.updateById(id, req);
    }

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

    @ApiOperation(value = "CCTV 프리셋 정보변경/생성-개별(TB_CCTV_PSET)", response = TbCctvPsetDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbCctvPsetDto mergeInfo(@PathVariable("id") TbCctvPsetKey id, @RequestBody @Valid final TbCctvPsetDto.TbCctvPsetUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "CCTV 프리셋 정보삭제-개별(TB_CCTV_PSET)", response = TbCctvPsetDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbCctvPsetDto deleteDataById(@PathVariable("id") TbCctvPsetKey id) {
        return this.service.deleteById(id);
    }

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

}
