package pwc.taxtech.atms.web.controller;

import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import pwc.taxtech.atms.web.AtmsWebSettings;

@Controller
@RequestMapping("/Config")
public class ConfigController {
    @Autowired
    private AtmsWebSettings atmsWebSettings;

    // private static Logger logger =
    // LoggerFactory.getLogger(ConfigController.class);

    @RequestMapping("/GetProperties")
    @ResponseBody
    public Map<String, Object> getProperties() {
        Map<String, Object> result = new LinkedHashMap<>();
        result.put("api_url", atmsWebSettings.getApiUrl());
        return result;
    }

    @RequestMapping("/config_js")
    public ModelAndView configJs() {
        ModelAndView view = new ModelAndView("config_js");
        view.addObject("properties", getProperties());
        return view;
    }
}