package com.its.op.controller.its.facility;

import com.its.op.dto.its.facility.TbFcltCmpyDto;
import com.its.op.service.its.facility.TbFcltCmpyService;
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 = "01.시설물관리-1.시설물-2.시설물 업체관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/facility/company")
public class TbFcltCmpyController {

    private final TbFcltCmpyService service;

    @ApiOperation(value = "시설물업체 전체조회(TB_FCLT_CMPY)", response = TbFcltCmpyDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbFcltCmpyDto> findAll() {
        return service.findAll();
    }

    @ApiOperation(value = "시설물업체 정보변경/생성-목록(TB_FCLT_CMPY)", response = TbFcltCmpyDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbFcltCmpyDto> mergeInfoList(@RequestBody @Valid final List<TbFcltCmpyDto.TbFcltCmpyUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "시설물업체 정보삭제-목록(TB_FCLT_CMPY)", response = TbFcltCmpyDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbFcltCmpyDto> deleteDataByIds(@RequestBody @Valid final List<String> ids) {
        return this.service.deleteByIds(ids);
    }

}
