|
@@ -1,9 +1,17 @@
|
|
|
-package com.ruoyi.web.controller.common;
|
|
|
+package com.iot.web.controller.common;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
-import com.ruoyi.common.utils.file.MimeTypeUtils;
|
|
|
+import com.iot.common.config.IotConfig;
|
|
|
+import com.iot.common.constant.Constants;
|
|
|
+import com.iot.common.core.domain.AjaxResult;
|
|
|
+import com.iot.common.utils.StringUtils;
|
|
|
+import com.iot.common.utils.file.FileUploadUtils;
|
|
|
+import com.iot.common.utils.file.FileUtils;
|
|
|
+import com.iot.common.utils.file.ImageUtils;
|
|
|
+import com.iot.common.utils.file.MimeTypeUtils;
|
|
|
+import com.iot.framework.config.ServerConfig;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -12,22 +20,11 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
-import com.ruoyi.common.config.RuoYiConfig;
|
|
|
-import com.ruoyi.common.constant.Constants;
|
|
|
-import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
-import com.ruoyi.common.utils.StringUtils;
|
|
|
-import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
-import com.ruoyi.common.utils.file.FileUtils;
|
|
|
-import com.ruoyi.framework.config.ServerConfig;
|
|
|
-
|
|
|
-import static com.ruoyi.common.utils.file.FileUploadUtils.getExtension;
|
|
|
-import static com.ruoyi.common.utils.file.FileUploadUtils.isPicture;
|
|
|
-import static com.ruoyi.common.utils.file.ImageUtils.imageMethod;
|
|
|
|
|
|
/**
|
|
|
* 通用请求处理
|
|
|
*
|
|
|
- * @author ruoyi
|
|
|
+ * @author iot
|
|
|
*/
|
|
|
@RestController
|
|
|
public class CommonController
|
|
@@ -54,7 +51,7 @@ public class CommonController
|
|
|
}
|
|
|
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);*/
|
|
|
String realFileName = fileName;
|
|
|
- String filePath = RuoYiConfig.getDownloadPath() + fileName;
|
|
|
+ String filePath = IotConfig.getDownloadPath() + fileName;
|
|
|
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
FileUtils.setAttachmentResponseHeader(response, realFileName);
|
|
@@ -80,11 +77,11 @@ public class CommonController
|
|
|
{
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
// 上传文件路径
|
|
|
- String filePath = RuoYiConfig.getUploadPath();
|
|
|
- String extension = getExtension(file);
|
|
|
+ String filePath = IotConfig.getUploadPath();
|
|
|
+ String extension = FileUploadUtils.getExtension(file);
|
|
|
MultipartFile multipartFile = null;
|
|
|
- if (isPicture(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
|
|
|
- multipartFile = imageMethod(file);
|
|
|
+ if (FileUploadUtils.isPicture(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
|
|
|
+ multipartFile = ImageUtils.imageMethod(file);
|
|
|
String thumbnail = FileUploadUtils.upload(filePath, multipartFile);
|
|
|
String url = serverConfig.getUrl() + thumbnail;
|
|
|
ajax.put("thumbnailUrl", url);
|
|
@@ -120,7 +117,7 @@ public class CommonController
|
|
|
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
|
|
|
}
|
|
|
// 本地资源路径
|
|
|
- String localPath = RuoYiConfig.getProfile();
|
|
|
+ String localPath = IotConfig.getProfile();
|
|
|
// 数据库资源地址
|
|
|
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
|
|
// 下载名称
|