package com.its.op.controller.its.database;

import com.its.op.dto.its.link.LinkPrcsParaDto;
import com.its.op.service.its.link.LinkPrcsParaService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
//@RestController
//@RequestMapping("/api/database/link-prcs-para")
//@Api(tags = "09.기초데이터관리-06.가공파라미터관리-01.가공파라미터관리")
public class LinkPrcsParaController {

    private final LinkPrcsParaService service;

    @ApiOperation(value = "개별정보조회(TB_LINK_PARA_STUP, TB_LINK_PARA_DETL, TB_LINK_PARA_CLCT_SYST)", response = LinkPrcsParaDto.LinkPrcsParaInfo.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public LinkPrcsParaDto.LinkPrcsParaInfo findById(@PathVariable final Long id) {
        LinkPrcsParaDto.LinkPrcsParaInfo result = this.service.findListById(id);
        return result;
    }

    @ApiOperation(value = "개별정보변경/생성(TB_LINK_PARA_STUP, TB_LINK_PARA_DETL, TB_LINK_PARA_CLCT_SYST)", response = LinkPrcsParaDto.LinkPrcsParaUpdateReq.class)
    @PostMapping(value = "/{ids}", produces = {"application/json; charset=utf8"})
    public LinkPrcsParaDto.LinkPrcsParaUpdateReq mergeById(
            @PathVariable final List<Long> ids,
            @RequestBody @Valid final LinkPrcsParaDto.LinkPrcsParaUpdateReq req) {
        LinkPrcsParaDto.LinkPrcsParaUpdateReq result = this.service.mergeById(ids, req);
        return result;
    }

    @ApiOperation(value = "전체정보변경/생성(TB_LINK_PARA_STUP, TB_LINK_PARA_DETL, TB_LINK_PARA_CLCT_SYST)", response = LinkPrcsParaDto.LinkPrcsParaUpdateReq.class)
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public LinkPrcsParaDto.LinkPrcsParaUpdateReq updateById(@RequestBody final LinkPrcsParaDto.LinkPrcsParaUpdateReq req) {
        LinkPrcsParaDto.LinkPrcsParaUpdateReq result = this.service.mergeAll(req);
        return result;
    }

}
