package com.supervision.controller;

import cn.hutool.core.collection.CollUtil;
import com.supervision.domain.IrRobotConfig;
import com.supervision.dto.QueryProcessDTO;
import com.supervision.service.IrRobotConfigService;
import com.supervision.service.QueryTemplateProcessor;
import com.supervision.util.freemark.StringTemplateConfig;
import freemarker.template.TemplateException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;


@RestController
@RequestMapping("test")
@RequiredArgsConstructor
@Slf4j
public class TestController {

    private final IrRobotConfigService irRobotConfigService;

    private final QueryTemplateProcessor queryTemplateProcessor;



    @PostMapping("freemarkerTest")
    public String freemarkerTest(@RequestBody Map<String,Object> params) throws TemplateException, IOException {

        return StringTemplateConfig.getInstance().process((String) params.get("template"),params);
    }

    @GetMapping("process")
    public String process(String templateId,String sessionId) {
        QueryProcessDTO process = queryTemplateProcessor.process(templateId, sessionId,null);
        return process.getStringContent();
    }


}
