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