package com.its.api.its.controller.vds;

import com.its.api.its.global.CodeManager;
import com.its.api.its.model.dto.code.VdsDtctTypeDto;
import com.its.api.its.model.dto.vds.TbVdsDtctDto;
import com.its.api.its.service.vds.TbVdsDtctService;
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 관리-1.검지기관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/Vds/manager/dtct")
public class TbVdsDtctController {

    private final TbVdsDtctService service;

    @ApiOperation(value = "VDS 검지기 마스터 전체조회(TB_VDS_DTCT_MSTR)", response = TbVdsDtctDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbVdsDtctDto> findAll() {
        return service.findAll();
    }

    @ApiOperation(value = "VDS 검지기 마스터 개별조회(TB_VDS_DTCT_MSTR)", response = TbVdsDtctDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVdsDtctDto findById(@PathVariable final String id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "VDS 검지기 마스터 정보변경/생성-개별(TB_VDS_DTCT_MSTR)", response = TbVdsDtctDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVdsDtctDto mergeInfo(@PathVariable("id") String id, @RequestBody @Valid final TbVdsDtctDto.TbVdsDtctMstrUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "VDS 검지기 마스터 정보삭제-개별(TB_VDS_DTCT_MSTR)", response = TbVdsDtctDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVdsDtctDto deleteDataById(@PathVariable("id") String id) {
        return this.service.deleteById(id);
    }

    @ApiOperation(value = "VDS 검지기 유형(방향) 코드", response = VdsDtctTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/dtct-type", produces = {"application/json; charset=utf8"})
    public List<VdsDtctTypeDto> findAllDtctType() {
        return service.findAllDtctType();
    }

}
