package com.its.api.its.controller.vms;

import com.its.api.its.model.dto.vms.TbVmsFormDto;
import com.its.api.its.service.vms.TbVmsFormService;
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 = "12.VMS-2.폼관리-1.문자식/도형식 폼관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/vms/form/manage")
public class TbVmsFormController {

    private final TbVmsFormService service;

    @ApiOperation(value = "VMS FORM 전체조회(TB_VMS_FORM)", response = TbVmsFormDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbVmsFormDto> findAll() {
        return service.findAll();
    }

    @ApiOperation(value = "VMS FORM 개별조회(TB_VMS_FORM)", response = TbVmsFormDto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVmsFormDto findById(@PathVariable final Integer id) {
        return this.service.findById(id);
    }

    @ApiOperation(value = "VMS FORM 정보변경(TB_VMS_FORM)", response = TbVmsFormDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVmsFormDto updateById(@PathVariable final Integer id, @RequestBody @Valid final TbVmsFormDto.TbVmsFormUpdReq req) {
        return this.service.updateById(id, req);
    }

    @ApiOperation(value = "VMS FORM 정보변경/생성-목록(TB_VMS_FORM)", response = TbVmsFormDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbVmsFormDto> mergeInfoList(@RequestBody @Valid final List<TbVmsFormDto.TbVmsFormUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "VMS FORM 정보변경/생성-개별(TB_VMS_FORM)", response = TbVmsFormDto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVmsFormDto mergeInfo(@PathVariable("id") Integer id, @RequestBody @Valid final TbVmsFormDto.TbVmsFormUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "VMS FORM 정보삭제-개별(TB_VMS_FORM)", response = TbVmsFormDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVmsFormDto deleteDataById(@PathVariable("id") Integer id) {
        return this.service.deleteById(id);
    }

    @ApiOperation(value = "VMS FORM 정보삭제-목록(TB_VMS_FORM)", response = TbVmsFormDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbVmsFormDto> deleteDataByIds(@RequestBody @Valid final List<Integer> ids) {
        return this.service.deleteByIds(ids);
    }

}
