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

import com.its.op.dto.its.link.LinkParaClctSystDto;
import com.its.op.entity.its.link.TbLinkParaClctSyst;
import com.its.op.service.its.link.LinkParaClctSystService;
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 java.util.ArrayList;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
//@RestController
//@RequestMapping("/api/database/link-para-clct-syst")
//@Api(tags = "09.기초데이터관리-06.가공파라미터관리-04.링크파라미터수집시스템")
public class LinkParaClctSystController {

    private final LinkParaClctSystService service;

    /*
    @ApiOperation(value = "전체조회(TB_LINK_PARA_CLCT_SYST)", response = LinkParaClctSystDto.LinkParaClctSystInfo.class)
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<LinkParaClctSystDto.LinkParaClctSystInfo> findAll() {
        List<LinkParaClctSyst> objList = this.service.findAll();
        List<LinkParaClctSystDto.LinkParaClctSystInfo> result = new ArrayList<>();
        if (objList != null) {
            for (LinkParaClctSyst obj : objList) {
                result.add(new LinkParaClctSystDto.LinkParaClctSystInfo(obj));
            }
        }
        return result;
    }
*/

    @ApiOperation(value = "개별목록조회(TB_LINK_PARA_CLCT_SYST)", response = LinkParaClctSystDto.LinkParaClctSystInfo.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public List<LinkParaClctSystDto.LinkParaClctSystInfo> findById(@PathVariable final Long id) {
        List<TbLinkParaClctSyst> objList = this.service.findListById(id);
        List<LinkParaClctSystDto.LinkParaClctSystInfo> result = new ArrayList<>();
        if (objList != null) {
            for (TbLinkParaClctSyst obj : objList) {
                result.add(new LinkParaClctSystDto.LinkParaClctSystInfo(obj));
            }
        }
        return result;
    }

    @ApiOperation(value = "개별정보변경/생성(TB_LINK_PARA_CLCT_SYST)", response = LinkParaClctSystDto.LinkParaClctSystUpdateReq.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public List<LinkParaClctSystDto.LinkParaClctSystUpdateReq> updateById(
            @PathVariable final Long id,
            @RequestBody final List<LinkParaClctSystDto.LinkParaClctSystUpdateReq> req) {

        List<LinkParaClctSystDto.LinkParaClctSystUpdateReq> result = this.service.mergeById(id, req);
        return result;
    }

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

}
