package com.icomsys.main_vm.biz.rcp.conversation.controller;

import com.google.gson.Gson;
import com.icomsys.main_vm.biz.advice.excep.CustomNotFoundException;
import com.icomsys.main_vm.biz.common.system.vo.DslDataTableRes;
import com.icomsys.main_vm.biz.rcp.conversation.service.ConversationApiNodeService;
import com.icomsys.main_vm.biz.rcp.conversation.vo.ConversationApiNodeInfoReq;
import com.icomsys.main_vm.biz.rcp.conversation.vo.ConversationApiNodeInfoRes;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@Controller
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/admin/rcp/conversation")
public class ConversationApiNodeController {

    private final ConversationApiNodeService conversationApiNodeService;

    @GetMapping("/apiNode/manage.do")
    public String ApiNodeView(){
    return "/adm/rcp/conversation/apiNode";
    }

    @PostMapping(value="/selectApiNodeList")
    @ResponseBody
    public DslDataTableRes<ConversationApiNodeInfoRes> searchApiNodeList(@RequestBody ConversationApiNodeInfoReq dto) throws CustomNotFoundException {
        log.info("dto -> {} ", new Gson().toJson(dto));
        return conversationApiNodeService.searchApiNodeList(dto);
    }

    @PostMapping("/deleteApiNode")
    @ResponseBody
    public int deleteApiNode(@RequestBody HashMap map){
        log.info("deleteApiNode -> {} " , new Gson().toJson(map));
        return conversationApiNodeService.deleteApiNode(map);
    }

}
