1 changed files with 14 additions and 23 deletions
@ -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(); |
||||
FILE_DOWNLOAD_PATH = RESOURCES_ROOT_PATH + "/file/"; |
||||
|
||||
@Value("${service.package.type:war}") |
||||
public void setPackageType(String type) { |
||||
if("jar".equals(type)) { |
||||
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, "电信"); |
||||
RESOURCES_ROOT_PATH = jarF.getParentFile().toString(); |
||||
}else { |
||||
RESOURCES_ROOT_PATH = GlobalConstant.class.getClassLoader().getResource("").getPath(); |
||||
} |
||||
|
||||
private GlobalConstant(){ |
||||
//Add a private constructor to hide the implicit public one.
|
||||
FILE_DOWNLOAD_PATH = RESOURCES_ROOT_PATH + "/file/"; |
||||
} |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue