package com.gcz.controller;
import cn.hutool.core.util.StrUtil;
import com.gcz.config.EnvConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller
@RequestMapping("/prop")
public class PropertiesController {
@Autowired
private EnvConfig envConfig;
private final static String SERVER_PORT="server.port";
private final static String USER_DIR="user.dir";
private final static String USER_HOME="user.home";
private final static String JAVA_HOME="JAVA_HOME";
@RequestMapping(value ="/{param}")
@ResponseBody
public String getProperties(@PathVariable String param){
if (StrUtil.equals(param, SERVER_PORT)) {
return envConfig.getServerPort();
}else if (StrUtil.equals(param, USER_DIR)) {
return envConfig.getUserDir();
}else if (StrUtil.equals(param, USER_HOME)) {
return envConfig.getUserHome();
}else if (StrUtil.equals(param, JAVA_HOME)) {
return envConfig.getJavaHome();
}else {
return "not exist";
}
}
}