优化代码

This commit is contained in:
TinyAnts
2022-11-17 11:39:14 +08:00
parent e211426c1a
commit bd97df6f7b
31 changed files with 400 additions and 240 deletions

View File

@@ -48,7 +48,7 @@ public class SmsNotice {
// 通知类型: [1=业务, 2=验证码]
if (smsTemplate.getType().equals(2) && StringUtil.isNotNull(params.get("code"))) {
String code = params.get("code").toLowerCase();
RedisUtil.set(GlobalConfig.redisSmsCode+scene+":"+mobile, code);
RedisUtil.set(GlobalConfig.redisSmsCode+scene+":"+mobile, code, 900);
}
}
}

View File

@@ -31,13 +31,13 @@ public class StorageDriver {
public StorageDriver() {
this.engine = ConfigUtil.get("storage", "default", "local");
Map<String, String> config1;
config1 = ConfigUtil.getMap("storage", this.engine);
if (config1 == null) {
config1 = new HashMap<>();
Map<String, String> config;
config = ConfigUtil.getMap("storage", this.engine);
if (config == null) {
config = new HashMap<>();
}
this.config = config1;
this.config = config;
}
/**
@@ -47,8 +47,9 @@ public class StorageDriver {
* @param multipartFile 文件对象
* @param folder 文件夹
* @param type 类型: 10=图片, 20=视频
* @return UploadFilesVo
*/
public Map<String, Object> upload(MultipartFile multipartFile, String folder, Integer type) {
public UploadFilesVo upload(MultipartFile multipartFile, String folder, Integer type) {
this.checkFile(multipartFile, type);
String key = this.buildSaveName(multipartFile);
switch (this.engine) {
@@ -74,14 +75,22 @@ public class StorageDriver {
String origFileExt = origFileName.substring(origFileName.lastIndexOf(".")).replace(".", "");
String newFileName = folder + "/" + key;
Map<String, Object> map = new LinkedHashMap<>();
map.put("id", 0);
map.put("name", multipartFile.getOriginalFilename());
map.put("size", multipartFile.getSize());
map.put("ext", origFileExt.toLowerCase());
map.put("url", newFileName);
map.put("path", UrlUtil.toAbsoluteUrl(newFileName));
return map;
UploadFilesVo vo = new UploadFilesVo();
vo.setId(0);
vo.setName(multipartFile.getOriginalFilename());
vo.setSize(multipartFile.getSize());
vo.setExt(origFileExt.toLowerCase());
vo.setUrl(newFileName);
vo.setPath(UrlUtil.toAbsoluteUrl(newFileName));
// Map<String, Object> map = new LinkedHashMap<>();
// map.put("id", 0);
// map.put("name", multipartFile.getOriginalFilename());
// map.put("size", multipartFile.getSize());
// map.put("ext", origFileExt.toLowerCase());
// map.put("url", newFileName);
// map.put("path", UrlUtil.toAbsoluteUrl(newFileName));
return vo;
}
/**

View File

@@ -0,0 +1,19 @@
package com.mdd.common.plugin.storage;
import lombok.Data;
import java.io.Serializable;
@Data
public class UploadFilesVo implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private Long size;
private String ext;
private String url;
private String path;
}