Skip to content

Commit

Permalink
全局配置保持和其他应用命名相同
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Nov 17, 2020
1 parent 18f6366 commit a825075
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.config.ServerConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
Expand Down Expand Up @@ -48,7 +48,7 @@ public void fileDownload(String fileName, Boolean delete, HttpServletResponse re
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = Global.getDownloadPath() + fileName;
String filePath = RuoYiConfig.getDownloadPath() + fileName;

response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);
Expand All @@ -74,7 +74,7 @@ public AjaxResult uploadFile(MultipartFile file) throws Exception
try
{
// 上传文件路径
String filePath = Global.getUploadPath();
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
Expand Down Expand Up @@ -103,7 +103,7 @@ public void resourceDownload(String resource, HttpServletRequest request, HttpSe
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
}
// 本地资源路径
String localPath = Global.getProfile();
String localPath = RuoYiConfig.getProfile();
// 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// 下载名称
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser;
Expand Down Expand Up @@ -49,8 +49,8 @@ public String index(ModelMap mmap)
mmap.put("sideTheme", configService.selectConfigByKey("sys.index.sideTheme"));
mmap.put("skinName", configService.selectConfigByKey("sys.index.skinName"));
mmap.put("ignoreFooter", configService.selectConfigByKey("sys.index.ignoreFooter"));
mmap.put("copyrightYear", Global.getCopyrightYear());
mmap.put("demoEnabled", Global.isDemoEnabled());
mmap.put("copyrightYear", RuoYiConfig.getCopyrightYear());
mmap.put("demoEnabled", RuoYiConfig.isDemoEnabled());
mmap.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate()));
mmap.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate()));

Expand Down Expand Up @@ -91,7 +91,7 @@ public void menuStyle(@PathVariable String style, HttpServletResponse response)
@GetMapping("/system/main")
public String main(ModelMap mmap)
{
mmap.put("version", Global.getVersion());
mmap.put("version", RuoYiConfig.getVersion());
return "main";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
Expand Down Expand Up @@ -156,7 +156,7 @@ public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
{
if (!file.isEmpty())
{
String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file);
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
currentUser.setAvatar(avatar);
if (userService.updateUserInfo(currentUser) > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.RuoYiConfig;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
Expand Down Expand Up @@ -61,9 +61,9 @@ private ApiInfo apiInfo()
// 描述
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
// 作者信息
.contact(new Contact(Global.getName(), null, null))
.contact(new Contact(RuoYiConfig.getName(), null, null))
// 版本
.version("版本号:" + Global.getVersion())
.version("版本号:" + RuoYiConfig.getVersion())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
@Component
@ConfigurationProperties(prefix = "ruoyi")
public class Global
public class RuoYiConfig
{
/** 项目名称 */
private static String name;
Expand All @@ -37,7 +37,7 @@ public static String getName()

public void setName(String name)
{
Global.name = name;
RuoYiConfig.name = name;
}

public static String getVersion()
Expand All @@ -47,7 +47,7 @@ public static String getVersion()

public void setVersion(String version)
{
Global.version = version;
RuoYiConfig.version = version;
}

public static String getCopyrightYear()
Expand All @@ -57,7 +57,7 @@ public static String getCopyrightYear()

public void setCopyrightYear(String copyrightYear)
{
Global.copyrightYear = copyrightYear;
RuoYiConfig.copyrightYear = copyrightYear;
}

public static boolean isDemoEnabled()
Expand All @@ -67,7 +67,7 @@ public static boolean isDemoEnabled()

public void setDemoEnabled(boolean demoEnabled)
{
Global.demoEnabled = demoEnabled;
RuoYiConfig.demoEnabled = demoEnabled;
}

public static String getProfile()
Expand All @@ -77,7 +77,7 @@ public static String getProfile()

public void setProfile(String profile)
{
Global.profile = profile;
RuoYiConfig.profile = profile;
}

public static boolean isAddressEnabled()
Expand All @@ -87,7 +87,7 @@ public static boolean isAddressEnabled()

public void setAddressEnabled(boolean addressEnabled)
{
Global.addressEnabled = addressEnabled;
RuoYiConfig.addressEnabled = addressEnabled;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.http.HttpUtils;

Expand All @@ -30,7 +30,7 @@ public static String getRealAddressByIP(String ip)
{
return "内网IP";
}
if (Global.isAddressEnabled())
if (RuoYiConfig.isAddressEnabled())
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.io.IOException;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class FileUploadUtils
/**
* 默认上传的地址
*/
private static String defaultBaseDir = Global.getProfile();
private static String defaultBaseDir = RuoYiConfig.getProfile();

public static void setDefaultBaseDir(String defaultBaseDir)
{
Expand Down Expand Up @@ -143,7 +143,7 @@ private static final File getAbsoluteFile(String uploadDir, String fileName) thr

private static final String getPathFileName(String uploadDir, String fileName) throws IOException
{
int dirLastIndex = Global.getProfile().length() + 1;
int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
return pathFileName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.annotation.Excels;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException;
Expand Down Expand Up @@ -824,7 +824,7 @@ public String encodingFilename(String filename)
*/
public String getAbsoluteFile(String filename)
{
String downloadPath = Global.getDownloadPath() + filename;
String downloadPath = RuoYiConfig.getDownloadPath() + filename;
File desc = new File(downloadPath);
if (!desc.getParentFile().exists())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;

Expand Down Expand Up @@ -41,7 +41,7 @@ public void addViewControllers(ViewControllerRegistry registry)
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
/** 本地文件上传路径 */
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + Global.getProfile() + "/");
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");

/** swagger配置 */
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
Expand Down

0 comments on commit a825075

Please sign in to comment.