package com.its.op.controller.its.vds;

import com.its.op.dto.its.common.NewIdLongDto;
import com.its.op.dto.its.common.NewIdStringDto;
import com.its.op.dto.its.vds.TbVdsCtlrDto;
import com.its.op.service.its.vds.TbVdsCtlrService;
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 = "13.VDS-1.VDS 관리-0.제어기관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/vds/manager/info")
public class TbVdsCtlrController {

    private final TbVdsCtlrService service;

    @ApiOperation(value = "VDS 제어기 전체조회(TB_VDS_CTLR)", response = TbVdsCtlrDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbVdsCtlrDto> findAllList() {
        return service.findAllList();
    }

    @ApiOperation(value = "VDS 제어기 개별조회(TB_VDS_CTLR)", response = TbVdsCtlrDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVdsCtlrDto findById(@PathVariable final Long id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "VDS 제어기 정보변경/생성-개별(TB_VDS_CTLR)", response = TbVdsCtlrDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVdsCtlrDto mergeInfo(@PathVariable("id") Long id, @RequestBody @Valid final TbVdsCtlrDto.TbVdsCtlrUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "VDS 제어기 정보삭제-개별(TB_VDS_CTLR)", response = TbVdsCtlrDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVdsCtlrDto deleteDataById(@PathVariable("id") Long id) {
        return this.service.deleteById(id);
    }

    @ApiOperation(value = "신규 VDS 제어기 ID 조회(TB_VDS_CTLR)", response = NewIdStringDto.class)
    @GetMapping(value = "/new-id", produces = {"application/json; charset=utf8"})
    public NewIdLongDto getNewNmbr() {
        return this.service.getNewNmbr();
    }


}
