Browse Source

Update GlobalConstant.java

master
许孟阳 4 years ago
parent
commit
04c2d1dae4
  1. 37
      src/main/java/vip/xumy/core/golbal/GlobalConstant.java

37
src/main/java/vip/xumy/core/golbal/GlobalConstant.java

@ -1,44 +1,35 @@ @@ -1,44 +1,35 @@
package vip.xumy.core.golbal;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
@Component
public class GlobalConstant {
public static final String RESOURCES_ROOT_PATH;
public static final String JAR_RESOURCES_PATH;
public static final String JAR_DOWNLOAD_PATH;
public static final String FILE_DOWNLOAD_PATH;
public static String RESOURCES_ROOT_PATH;
public static String FILE_DOWNLOAD_PATH;
public static final String DEFAULT_PASSWORD = DigestUtils.md5DigestAsHex("888888".getBytes());
public static final String CODE_KEY_PREFIX = "login-code-";
public static final String TIKEN_KEY_PREFIX = "login-token-";
public static final String LOGIN_COOKIE_NAME = "UMLoginToken";
public static final String ENCODING_UTF8 = "UTF-8";
public static final Map<Integer, String> YYS_TYPES = new HashMap<>();
static{
RESOURCES_ROOT_PATH = GlobalConstant.class.getClassLoader().getResource("").getPath();
@Value("${service.package.type:war}")
public void setPackageType(String type) {
if("jar".equals(type)) {
ApplicationHome h = new ApplicationHome(GlobalConstant.class);
File jarF = h.getSource();
RESOURCES_ROOT_PATH = jarF.getParentFile().toString();
}else {
RESOURCES_ROOT_PATH = GlobalConstant.class.getClassLoader().getResource("").getPath();
}
FILE_DOWNLOAD_PATH = RESOURCES_ROOT_PATH + "/file/";
ApplicationHome h = new ApplicationHome(GlobalConstant.class);
File jarF = h.getSource();
JAR_RESOURCES_PATH = jarF.getParentFile().toString();
JAR_DOWNLOAD_PATH = JAR_RESOURCES_PATH + "/file/";
YYS_TYPES.put(0, "移动");
YYS_TYPES.put(1, "联通");
YYS_TYPES.put(2, "电信");
}
private GlobalConstant(){
//Add a private constructor to hide the implicit public one.
}
}

Loading…
Cancel
Save