diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java b/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
index 127ec43a..08f9c3c1 100644
--- a/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
+++ b/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
@@ -41,8 +41,6 @@ public class ElAdminConstant {
* 常用接口
*/
public static class Url {
- // 免费图床
- public static final String SM_MS_URL = "https://sm.ms/api";
// IP归属地查询
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true";
}
diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
index 8868ba6d..5edd7041 100644
--- a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
+++ b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
@@ -43,7 +43,9 @@ import java.util.Map;
* @date 2018-12-27
*/
public class FileUtil extends cn.hutool.core.io.FileUtil {
+
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
+
/**
* 系统临时目录
*
@@ -75,6 +77,13 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
*/
private static final DecimalFormat DF = new DecimalFormat("0.00");
+ public static final String IMAGE = "图片";
+ public static final String TXT = "文档";
+ public static final String MUSIC = "音乐";
+ public static final String VIDEO = "视频";
+ public static final String OTHER = "其他";
+
+
/**
* MultipartFile转File
*/
@@ -217,15 +226,15 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg";
String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg";
if (image.contains(type)) {
- return "图片";
+ return IMAGE;
} else if (documents.contains(type)) {
- return "文档";
+ return TXT;
} else if (music.contains(type)) {
- return "音乐";
+ return MUSIC;
} else if (video.contains(type)) {
- return "视频";
+ return VIDEO;
} else {
- return "其他";
+ return OTHER;
}
}
diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml
index a7123167..5474bfa3 100644
--- a/eladmin-system/src/main/resources/config/application.yml
+++ b/eladmin-system/src/main/resources/config/application.yml
@@ -53,7 +53,3 @@ code:
#密码加密传输,前端公钥加密,后端私钥解密
rsa:
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
-
-# sm.ms 图床的 token
-smms:
- token: 1oOP3ykFDI0K6ifmtvU7c8Y1eTWZSlyl
diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java b/eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java
deleted file mode 100644
index 737cdb06..00000000
--- a/eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2019-2020 Zheng Jie
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package me.zhengjie.domain;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import org.hibernate.annotations.CreationTimestamp;
-import javax.persistence.*;
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-/**
- * sm.ms图床
- *
- * @author Zheng Jie
- * @date 2018-12-27
- */
-@Data
-@Entity
-@Table(name = "tool_picture")
-public class Picture implements Serializable {
-
- @Id
- @Column(name = "picture_id")
- @ApiModelProperty(value = "ID", hidden = true)
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @ApiModelProperty(value = "文件名")
- private String filename;
-
- @ApiModelProperty(value = "图片url")
- private String url;
-
- @ApiModelProperty(value = "图片大小")
- private String size;
-
- @ApiModelProperty(value = "图片高")
- private String height;
-
- @ApiModelProperty(value = "图片宽")
- private String width;
-
- @Column(name = "delete_url")
- @ApiModelProperty(value = "用于删除的url")
- private String delete;
-
- @ApiModelProperty(value = "创建者")
- private String username;
-
- @CreationTimestamp
- @ApiModelProperty(value = "创建时间")
- private Timestamp createTime;
-
- /** 用于检测文件是否重复 */
- private String md5Code;
-
- @Override
- public String toString() {
- return "Picture{" +
- "filename='" + filename + '\'' +
- '}';
- }
-}
diff --git a/eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java b/eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java
deleted file mode 100644
index c8334e02..00000000
--- a/eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2019-2020 Zheng Jie
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package me.zhengjie.repository;
-
-import me.zhengjie.domain.Picture;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-/**
- * @author Zheng Jie
- * @date 2018-12-27
- */
-public interface PictureRepository extends JpaRepository, JpaSpecificationExecutor {
-
- /**
- * 根据 Mds 值查询文件
- * @param code 值
- * @return /
- */
- Picture findByMd5Code(String code);
-
- /**
- * 根据连接地址查询
- * @param url /
- * @return /
- */
- boolean existsByUrl(String url);
-}
diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java
index bed88d66..24ecb400 100644
--- a/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java
+++ b/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java
@@ -18,8 +18,11 @@ package me.zhengjie.rest;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.domain.LocalStorage;
+import me.zhengjie.exception.BadRequestException;
import me.zhengjie.service.LocalStorageService;
import me.zhengjie.service.dto.LocalStorageQueryCriteria;
+import me.zhengjie.utils.FileUtil;
+import me.zhengjie.utils.SecurityUtils;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -67,6 +70,19 @@ public class LocalStorageController {
return new ResponseEntity<>(HttpStatus.CREATED);
}
+ @Log("上传图片")
+ @PostMapping("/pictures")
+ @ApiOperation("上传图片")
+ public ResponseEntity