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

import com.its.op.dto.its.facility.TbFcltImagDto;
import com.its.op.service.its.facility.TbFcltImagService;
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;

@Api(tags = "01.시설물관리-1.시설물-1.1.시설물 이미지정보 관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/facility/manager/fclt_imag")
public class TbFcltImagController {

    private final TbFcltImagService service;

    @ApiOperation(value = "시설물 이미지정보 개별조회(TB_FCLT_IMAG)", response = TbFcltImagDto.class)
    @GetMapping(value = "/{fcltNmbr}", produces = {"application/json; charset=utf8"})
    public TbFcltImagDto findById(@PathVariable("fcltNmbr") final Long fcltNmbr) {
        return this.service.findById(fcltNmbr);
    }

    @ApiOperation(value = "시설물 이미지정보 정보변경/생성-개별(TB_FCLT_IMAG)", response = TbFcltImagDto.class)
    @PostMapping(value = "/{fcltNmbr}", produces = {"application/json; charset=utf8"})
    public TbFcltImagDto mergeInfo(@PathVariable("fcltNmbr") Long fcltNmbr, @RequestBody @Valid final TbFcltImagDto.TbFcltImagUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "시설물 이미지정보 정보삭제-개별(TB_FCLT_IMAG)", response = TbFcltImagDto.class)
    @DeleteMapping(value = "/{fcltNmbr}", produces = {"application/json; charset=utf8"})
    public TbFcltImagDto deleteDataById(@PathVariable("fcltNmbr") Long fcltNmbr) {
        return this.service.deleteById(fcltNmbr);
    }

}
