Skip to content

Commit 683b290

Browse files
authored
Merge pull request #261 from erupts/develop
1.12.15
2 parents dedc2e9 + 12c1b4c commit 683b290

File tree

304 files changed

+40459
-3981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

304 files changed

+40459
-3981
lines changed

erupt-admin/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.14</version>
12+
<version>1.12.15</version>
1313
<relativePath>../pom.xml</relativePath>
1414
</parent>
1515

erupt-annotation/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>xyz.erupt</groupId>
1313
<artifactId>erupt</artifactId>
14-
<version>1.12.14</version>
14+
<version>1.12.15</version>
1515
<relativePath>../pom.xml</relativePath>
1616
</parent>
1717
</project>

erupt-annotation/src/main/java/xyz/erupt/annotation/Erupt.java

-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@
6767
//布局配置
6868
Layout layout() default @Layout;
6969

70-
// @Comment("自定义页头")
71-
// @Match("#value.path() != ''")
72-
// Tpl header() default @Tpl(path = "");
73-
//
7470
// @Comment("画册视图定义")
7571
// @Match("#value.enable() == true")
7672
// Card cardView() default @Card(enable = false, galleryField = "", viewFields = {});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package xyz.erupt.annotation.sub_erupt;
2+
3+
public enum OpenWay {
4+
//抽屉
5+
DRAWER,
6+
//对话框
7+
MODAL
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package xyz.erupt.annotation.sub_erupt;
2+
3+
/**
4+
* @author YuePeng
5+
* date 2024/8/25 15:53
6+
*/
7+
public enum Placement {
8+
TOP,
9+
BOTTOM,
10+
LEFT,
11+
RIGHT
12+
}

erupt-annotation/src/main/java/xyz/erupt/annotation/sub_erupt/Tpl.java

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
@Comment("弹出层宽度")
3434
String width() default "";
3535

36+
@Comment("弹出层高度")
37+
String height() default "";
38+
39+
@Comment("弹出层打开方式")
40+
OpenWay openWay() default OpenWay.MODAL;
41+
42+
@Comment("抽屉打开方向")
43+
Placement drawerPlacement() default Placement.RIGHT;
44+
3645
@Getter
3746
enum Engine {
3847
@Comment("原生H5, Native模式下不支持tplHandler")

erupt-annotation/src/main/java/xyz/erupt/annotation/sub_field/sub_edit/TagsType.java

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
@Comment("是否允许自定义标签")
1414
boolean allowExtension() default true;
1515

16+
@Comment("最大标签数")
17+
int maxTagCount() default 9999;
18+
1619
@Transient
1720
@Comment("可选标签列表")
1821
String[] tags() default {};

erupt-cloud/erupt-cloud-common/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.14</version>
12+
<version>1.12.15</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-node-jpa/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.14</version>
12+
<version>1.12.15</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-node/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.14</version>
12+
<version>1.12.15</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-server/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.14</version>
12+
<version>1.12.15</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-server/src/main/java/xyz/erupt/cloud/server/model/CloudNode.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
import xyz.erupt.annotation.EruptI18n;
1111
import xyz.erupt.annotation.constant.AnnotationConst;
1212
import xyz.erupt.annotation.expr.ExprBool;
13-
import xyz.erupt.annotation.sub_erupt.Layout;
14-
import xyz.erupt.annotation.sub_erupt.RowOperation;
15-
import xyz.erupt.annotation.sub_erupt.Tpl;
13+
import xyz.erupt.annotation.sub_erupt.*;
1614
import xyz.erupt.annotation.sub_field.Edit;
1715
import xyz.erupt.annotation.sub_field.EditType;
1816
import xyz.erupt.annotation.sub_field.View;
@@ -48,7 +46,7 @@
4846
title = "节点日志", mode = RowOperation.Mode.SINGLE,
4947
ifExpr = "item.version && item.version != '-'",
5048
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.ERUPT_CLOUD_NODE_LOG),
51-
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/erupt-log.html", width = "85%")
49+
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/erupt-log.html", height = "80%", openWay = OpenWay.DRAWER, drawerPlacement = Placement.BOTTOM)
5250
),
5351
}, layout = @Layout(tableLeftFixed = 1, pageSize = 30)
5452
)

erupt-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>xyz.erupt</groupId>
1212
<artifactId>erupt</artifactId>
13-
<version>1.12.14</version>
13+
<version>1.12.15</version>
1414
<relativePath>../pom.xml</relativePath>
1515
</parent>
1616

erupt-core/src/main/java/xyz/erupt/core/config/GsonFactory.java

+25-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
*/
1616
public class GsonFactory {
1717

18+
public static final double JS_MAX_NUMBER = Math.pow(2, 53) - 1;
19+
20+
public static final double JS_MIN_NUMBER = Math.pow(-2, 53);
21+
1822
@Getter
1923
private final static GsonBuilder gsonBuilder = new GsonBuilder().setDateFormat(DateUtil.DATE_TIME)
2024
.registerTypeAdapter(LocalDateTime.class, (JsonSerializer<LocalDateTime>) (src, typeOfSrc, context)
@@ -25,10 +29,27 @@ public class GsonFactory {
2529
-> LocalDateTime.parse(json.getAsJsonPrimitive().getAsString(), DateTimeFormatter.ofPattern(DateUtil.DATE_TIME)))
2630
.registerTypeAdapter(LocalDate.class, (JsonDeserializer<LocalDate>) (json, type, jsonDeserializationContext)
2731
-> LocalDate.parse(json.getAsJsonPrimitive().getAsString(), DateTimeFormatter.ofPattern(DateUtil.DATE)))
28-
.registerTypeAdapter(Long.class, (JsonSerializer<Long>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
29-
.registerTypeAdapter(Double.class, (JsonSerializer<Double>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
30-
// .registerTypeAdapter(Integer.class, (JsonSerializer<Integer>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
31-
.registerTypeAdapter(BigDecimal.class, (JsonSerializer<BigDecimal>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
32+
.registerTypeAdapter(Long.class, (JsonSerializer<Long>) (src, type, jsonSerializationContext) -> {
33+
if (src > JS_MAX_NUMBER || src < JS_MIN_NUMBER) {
34+
return new JsonPrimitive((src).toString());
35+
} else {
36+
return new JsonPrimitive(src);
37+
}
38+
})
39+
.registerTypeAdapter(Double.class, (JsonSerializer<Double>) (src, type, jsonSerializationContext) -> {
40+
if (src > JS_MAX_NUMBER || src < JS_MIN_NUMBER) {
41+
return new JsonPrimitive((src).toString());
42+
} else {
43+
return new JsonPrimitive(src);
44+
}
45+
})
46+
.registerTypeAdapter(BigDecimal.class, (JsonSerializer<BigDecimal>) (src, type, jsonSerializationContext) -> {
47+
if (src.longValue() > JS_MAX_NUMBER || src.longValue() < JS_MIN_NUMBER) {
48+
return new JsonPrimitive((src).toString());
49+
} else {
50+
return new JsonPrimitive(src);
51+
}
52+
})
3253
.serializeNulls().setExclusionStrategies(new EruptGsonExclusionStrategies());
3354

3455
@Getter

erupt-core/src/main/java/xyz/erupt/core/controller/EruptFileController.java

+17-37
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import lombok.RequiredArgsConstructor;
66
import lombok.SneakyThrows;
77
import lombok.extern.slf4j.Slf4j;
8-
import org.apache.commons.lang3.RandomStringUtils;
98
import org.springframework.http.HttpStatus;
109
import org.springframework.http.MediaType;
1110
import org.springframework.util.StreamUtils;
@@ -16,13 +15,12 @@
1615
import xyz.erupt.annotation.sub_field.sub_edit.AttachmentType;
1716
import xyz.erupt.annotation.sub_field.sub_edit.HtmlEditorType;
1817
import xyz.erupt.core.annotation.EruptRouter;
19-
import xyz.erupt.core.constant.EruptConst;
2018
import xyz.erupt.core.constant.EruptRestPath;
2119
import xyz.erupt.core.exception.EruptWebApiRuntimeException;
2220
import xyz.erupt.core.i18n.I18nTranslate;
2321
import xyz.erupt.core.prop.EruptProp;
2422
import xyz.erupt.core.service.EruptCoreService;
25-
import xyz.erupt.core.util.DateUtil;
23+
import xyz.erupt.core.service.EruptFileService;
2624
import xyz.erupt.core.util.EruptUtil;
2725
import xyz.erupt.core.util.Erupts;
2826
import xyz.erupt.core.view.EruptApiModel;
@@ -38,7 +36,10 @@
3836
import java.io.InputStream;
3937
import java.nio.charset.Charset;
4038
import java.nio.charset.StandardCharsets;
41-
import java.util.*;
39+
import java.util.ArrayList;
40+
import java.util.HashMap;
41+
import java.util.List;
42+
import java.util.Map;
4243
import java.util.stream.Stream;
4344

4445
/**
@@ -53,6 +54,8 @@ public class EruptFileController {
5354

5455
private final EruptProp eruptProp;
5556

57+
private final EruptFileService eruptFileService;
58+
5659
private static final String FS_SEP = "/";
5760

5861
@SneakyThrows
@@ -63,15 +66,7 @@ public EruptApiModel upload(@PathVariable("erupt") String eruptName, @PathVariab
6366
EruptModel eruptModel = EruptCoreService.getErupt(eruptName);
6467
Erupts.powerLegal(eruptModel, powerObject -> powerObject.isEdit() || powerObject.isAdd());
6568
Edit edit = eruptModel.getEruptFieldMap().get(fieldName).getEruptField().edit();
66-
String path;
67-
if (eruptProp.isKeepUploadFileName()) {
68-
path = File.separator + DateUtil.getFormatDate(new Date(), DateUtil.DATE) + File.separator + file.getOriginalFilename()
69-
.replaceAll("&|#|\\?|\\s", "").replace(edit.attachmentType().fileSeparator(), "");
70-
} else {
71-
String[] fileNameSplit = file.getOriginalFilename().split("\\.");
72-
path = File.separator + DateUtil.getFormatDate(new Date(), DateUtil.DATE)
73-
+ File.separator + RandomStringUtils.randomAlphabetic(12) + EruptConst.DOT + fileNameSplit[fileNameSplit.length - 1];
74-
}
69+
String path = eruptFileService.createPath(file).replace(edit.attachmentType().fileSeparator(), "");
7570
switch (edit.type()) {
7671
case ATTACHMENT:
7772
AttachmentType attachmentType = edit.attachmentType();
@@ -118,27 +113,8 @@ public EruptApiModel upload(@PathVariable("erupt") String eruptName, @PathVariab
118113
}
119114
break;
120115
}
121-
try {
122-
boolean localSave = true;
123-
AttachmentProxy attachmentProxy = EruptUtil.findAttachmentProxy();
124-
if (null != attachmentProxy) {
125-
path = attachmentProxy.upLoad(file.getInputStream(), path.replace("\\", "/"));
126-
localSave = attachmentProxy.isLocalSave();
127-
}
128-
if (localSave) {
129-
File dest = new File(eruptProp.getUploadPath() + path);
130-
if (!dest.getParentFile().exists()) {
131-
if (!dest.getParentFile().mkdirs()) {
132-
return EruptApiModel.errorApi(I18nTranslate.$translate("erupt.upload_error.cannot_created"));
133-
}
134-
}
135-
file.transferTo(dest);
136-
}
137-
return EruptApiModel.successApi(path.replace("\\", "/"));
138-
} catch (Exception e) {
139-
log.error("erupt upload error", e);
140-
return EruptApiModel.errorApi(I18nTranslate.$translate("erupt.upload_error") + " " + e.getMessage());
141-
}
116+
return EruptApiModel.successApi(eruptFileService.upload(file, path));
117+
142118
}
143119

144120

@@ -170,8 +146,10 @@ public Map<String, Object> uploadHtmlEditorImage(@PathVariable("erupt") String e
170146
map.put("url", EruptRestPath.ERUPT_ATTACHMENT + eruptApiModel.getData());
171147
}
172148
map.put("uploaded", true);
149+
map.put("state", "SUCCESS");
173150
} else {
174151
map.put("uploaded", false);
152+
map.put("state", "ERROR");
175153
throw new EruptWebApiRuntimeException(eruptApiModel.getMessage());
176154
}
177155
return map;
@@ -194,9 +172,11 @@ public void uploadUEditorImage(@PathVariable("erupt") String eruptName,
194172
response.getOutputStream().write((callback + "(" + json + ")").getBytes(StandardCharsets.UTF_8));
195173
}
196174
} else {
197-
Map<String, Object> map = uploadHtmlEditorImage(eruptName, fieldName, file);
198-
Boolean status = (Boolean) map.get("uploaded");
199-
map.put("state", status ? "SUCCESS" : "ERROR");
175+
Map<String, Object> map = this.uploadHtmlEditorImage(eruptName, fieldName, file);
176+
map.put("filename", file.getName());
177+
map.put("original", file.getOriginalFilename());
178+
map.put("name", file.getName());
179+
map.put("size", file.getSize());
200180
response.getOutputStream().write(new Gson().toJson(map).getBytes(StandardCharsets.UTF_8));
201181
}
202182
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package xyz.erupt.core.log;
2+
3+
import java.util.logging.Handler;
4+
import java.util.logging.LogRecord;
5+
6+
public class EruptJULAppender extends Handler implements EruptAppender {
7+
8+
@Override
9+
public void publish(LogRecord record) {
10+
EruptLogManager.log(new Formatter()
11+
.timestamp(record.getMillis())
12+
.space()
13+
.level(record.getLevel().toString())
14+
.value(" --- [")
15+
.thread(Thread.currentThread().getName())
16+
.value("] ")
17+
.name(record.getLoggerName())
18+
.value("(" + record.getSourceMethodName() + ":" + record.getSequenceNumber() + ")")
19+
.value(" : ")
20+
.value(record.getMessage())
21+
.throwable(record.getThrown())
22+
.toString()
23+
);
24+
}
25+
26+
@Override
27+
public void flush() {
28+
29+
}
30+
31+
@Override
32+
public void close() throws SecurityException {
33+
34+
}
35+
36+
@Override
37+
public void init() {
38+
39+
}
40+
41+
}

0 commit comments

Comments
 (0)