package com.lightinit.hsdataportal.controller;
import com.lightinit.hsdataportal.common.ConfigUtils;
import com.lightinit.hsdataportal.common.SysContants;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by WangYao on 2017/6/6.
 */
@Controller
@RequestMapping(value = {"/", "/home"})
public class HomeController {

    @RequestMapping(value = {"/", "index"})
    public String index(ModelMap model, HttpServletRequest request) {
        String redirectHomeUrl = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.REDIRECT_HOME_URL);
        if (StringUtils.isEmpty(redirectHomeUrl)){
            redirectHomeUrl = InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/open/";
        }else {
            redirectHomeUrl = InternalResourceViewResolver.REDIRECT_URL_PREFIX + redirectHomeUrl;
        }
        return redirectHomeUrl;
    }
}
