Skip to content

Commit

Permalink
Merge pull request #261 from erupts/develop
Browse files Browse the repository at this point in the history
1.12.15
  • Loading branch information
erupts authored Aug 25, 2024
2 parents dedc2e9 + 12c1b4c commit 683b290
Show file tree
Hide file tree
Showing 304 changed files with 40,459 additions and 3,981 deletions.
2 changes: 1 addition & 1 deletion erupt-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.14</version>
<version>1.12.15</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-annotation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.14</version>
<version>1.12.15</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@
//布局配置
Layout layout() default @Layout;

// @Comment("自定义页头")
// @Match("#value.path() != ''")
// Tpl header() default @Tpl(path = "");
//
// @Comment("画册视图定义")
// @Match("#value.enable() == true")
// Card cardView() default @Card(enable = false, galleryField = "", viewFields = {});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package xyz.erupt.annotation.sub_erupt;

public enum OpenWay {
//抽屉
DRAWER,
//对话框
MODAL
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package xyz.erupt.annotation.sub_erupt;

/**
* @author YuePeng
* date 2024/8/25 15:53
*/
public enum Placement {
TOP,
BOTTOM,
LEFT,
RIGHT
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
@Comment("弹出层宽度")
String width() default "";

@Comment("弹出层高度")
String height() default "";

@Comment("弹出层打开方式")
OpenWay openWay() default OpenWay.MODAL;

@Comment("抽屉打开方向")
Placement drawerPlacement() default Placement.RIGHT;

@Getter
enum Engine {
@Comment("原生H5, Native模式下不支持tplHandler")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
@Comment("是否允许自定义标签")
boolean allowExtension() default true;

@Comment("最大标签数")
int maxTagCount() default 9999;

@Transient
@Comment("可选标签列表")
String[] tags() default {};
Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.14</version>
<version>1.12.15</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-node-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.14</version>
<version>1.12.15</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.14</version>
<version>1.12.15</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.14</version>
<version>1.12.15</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import xyz.erupt.annotation.EruptI18n;
import xyz.erupt.annotation.constant.AnnotationConst;
import xyz.erupt.annotation.expr.ExprBool;
import xyz.erupt.annotation.sub_erupt.Layout;
import xyz.erupt.annotation.sub_erupt.RowOperation;
import xyz.erupt.annotation.sub_erupt.Tpl;
import xyz.erupt.annotation.sub_erupt.*;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
Expand Down Expand Up @@ -48,7 +46,7 @@
title = "节点日志", mode = RowOperation.Mode.SINGLE,
ifExpr = "item.version && item.version != '-'",
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.ERUPT_CLOUD_NODE_LOG),
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/erupt-log.html", width = "85%")
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/erupt-log.html", height = "80%", openWay = OpenWay.DRAWER, drawerPlacement = Placement.BOTTOM)
),
}, layout = @Layout(tableLeftFixed = 1, pageSize = 30)
)
Expand Down
2 changes: 1 addition & 1 deletion erupt-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.14</version>
<version>1.12.15</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
29 changes: 25 additions & 4 deletions erupt-core/src/main/java/xyz/erupt/core/config/GsonFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
public class GsonFactory {

public static final double JS_MAX_NUMBER = Math.pow(2, 53) - 1;

public static final double JS_MIN_NUMBER = Math.pow(-2, 53);

@Getter
private final static GsonBuilder gsonBuilder = new GsonBuilder().setDateFormat(DateUtil.DATE_TIME)
.registerTypeAdapter(LocalDateTime.class, (JsonSerializer<LocalDateTime>) (src, typeOfSrc, context)
Expand All @@ -25,10 +29,27 @@ public class GsonFactory {
-> LocalDateTime.parse(json.getAsJsonPrimitive().getAsString(), DateTimeFormatter.ofPattern(DateUtil.DATE_TIME)))
.registerTypeAdapter(LocalDate.class, (JsonDeserializer<LocalDate>) (json, type, jsonDeserializationContext)
-> LocalDate.parse(json.getAsJsonPrimitive().getAsString(), DateTimeFormatter.ofPattern(DateUtil.DATE)))
.registerTypeAdapter(Long.class, (JsonSerializer<Long>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
.registerTypeAdapter(Double.class, (JsonSerializer<Double>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
// .registerTypeAdapter(Integer.class, (JsonSerializer<Integer>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
.registerTypeAdapter(BigDecimal.class, (JsonSerializer<BigDecimal>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
.registerTypeAdapter(Long.class, (JsonSerializer<Long>) (src, type, jsonSerializationContext) -> {
if (src > JS_MAX_NUMBER || src < JS_MIN_NUMBER) {
return new JsonPrimitive((src).toString());
} else {
return new JsonPrimitive(src);
}
})
.registerTypeAdapter(Double.class, (JsonSerializer<Double>) (src, type, jsonSerializationContext) -> {
if (src > JS_MAX_NUMBER || src < JS_MIN_NUMBER) {
return new JsonPrimitive((src).toString());
} else {
return new JsonPrimitive(src);
}
})
.registerTypeAdapter(BigDecimal.class, (JsonSerializer<BigDecimal>) (src, type, jsonSerializationContext) -> {
if (src.longValue() > JS_MAX_NUMBER || src.longValue() < JS_MIN_NUMBER) {
return new JsonPrimitive((src).toString());
} else {
return new JsonPrimitive(src);
}
})
.serializeNulls().setExclusionStrategies(new EruptGsonExclusionStrategies());

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.util.StreamUtils;
Expand All @@ -16,13 +15,12 @@
import xyz.erupt.annotation.sub_field.sub_edit.AttachmentType;
import xyz.erupt.annotation.sub_field.sub_edit.HtmlEditorType;
import xyz.erupt.core.annotation.EruptRouter;
import xyz.erupt.core.constant.EruptConst;
import xyz.erupt.core.constant.EruptRestPath;
import xyz.erupt.core.exception.EruptWebApiRuntimeException;
import xyz.erupt.core.i18n.I18nTranslate;
import xyz.erupt.core.prop.EruptProp;
import xyz.erupt.core.service.EruptCoreService;
import xyz.erupt.core.util.DateUtil;
import xyz.erupt.core.service.EruptFileService;
import xyz.erupt.core.util.EruptUtil;
import xyz.erupt.core.util.Erupts;
import xyz.erupt.core.view.EruptApiModel;
Expand All @@ -38,7 +36,10 @@
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

/**
Expand All @@ -53,6 +54,8 @@ public class EruptFileController {

private final EruptProp eruptProp;

private final EruptFileService eruptFileService;

private static final String FS_SEP = "/";

@SneakyThrows
Expand All @@ -63,15 +66,7 @@ public EruptApiModel upload(@PathVariable("erupt") String eruptName, @PathVariab
EruptModel eruptModel = EruptCoreService.getErupt(eruptName);
Erupts.powerLegal(eruptModel, powerObject -> powerObject.isEdit() || powerObject.isAdd());
Edit edit = eruptModel.getEruptFieldMap().get(fieldName).getEruptField().edit();
String path;
if (eruptProp.isKeepUploadFileName()) {
path = File.separator + DateUtil.getFormatDate(new Date(), DateUtil.DATE) + File.separator + file.getOriginalFilename()
.replaceAll("&|#|\\?|\\s", "").replace(edit.attachmentType().fileSeparator(), "");
} else {
String[] fileNameSplit = file.getOriginalFilename().split("\\.");
path = File.separator + DateUtil.getFormatDate(new Date(), DateUtil.DATE)
+ File.separator + RandomStringUtils.randomAlphabetic(12) + EruptConst.DOT + fileNameSplit[fileNameSplit.length - 1];
}
String path = eruptFileService.createPath(file).replace(edit.attachmentType().fileSeparator(), "");
switch (edit.type()) {
case ATTACHMENT:
AttachmentType attachmentType = edit.attachmentType();
Expand Down Expand Up @@ -118,27 +113,8 @@ public EruptApiModel upload(@PathVariable("erupt") String eruptName, @PathVariab
}
break;
}
try {
boolean localSave = true;
AttachmentProxy attachmentProxy = EruptUtil.findAttachmentProxy();
if (null != attachmentProxy) {
path = attachmentProxy.upLoad(file.getInputStream(), path.replace("\\", "/"));
localSave = attachmentProxy.isLocalSave();
}
if (localSave) {
File dest = new File(eruptProp.getUploadPath() + path);
if (!dest.getParentFile().exists()) {
if (!dest.getParentFile().mkdirs()) {
return EruptApiModel.errorApi(I18nTranslate.$translate("erupt.upload_error.cannot_created"));
}
}
file.transferTo(dest);
}
return EruptApiModel.successApi(path.replace("\\", "/"));
} catch (Exception e) {
log.error("erupt upload error", e);
return EruptApiModel.errorApi(I18nTranslate.$translate("erupt.upload_error") + " " + e.getMessage());
}
return EruptApiModel.successApi(eruptFileService.upload(file, path));

}


Expand Down Expand Up @@ -170,8 +146,10 @@ public Map<String, Object> uploadHtmlEditorImage(@PathVariable("erupt") String e
map.put("url", EruptRestPath.ERUPT_ATTACHMENT + eruptApiModel.getData());
}
map.put("uploaded", true);
map.put("state", "SUCCESS");
} else {
map.put("uploaded", false);
map.put("state", "ERROR");
throw new EruptWebApiRuntimeException(eruptApiModel.getMessage());
}
return map;
Expand All @@ -194,9 +172,11 @@ public void uploadUEditorImage(@PathVariable("erupt") String eruptName,
response.getOutputStream().write((callback + "(" + json + ")").getBytes(StandardCharsets.UTF_8));
}
} else {
Map<String, Object> map = uploadHtmlEditorImage(eruptName, fieldName, file);
Boolean status = (Boolean) map.get("uploaded");
map.put("state", status ? "SUCCESS" : "ERROR");
Map<String, Object> map = this.uploadHtmlEditorImage(eruptName, fieldName, file);
map.put("filename", file.getName());
map.put("original", file.getOriginalFilename());
map.put("name", file.getName());
map.put("size", file.getSize());
response.getOutputStream().write(new Gson().toJson(map).getBytes(StandardCharsets.UTF_8));
}
}
Expand Down
41 changes: 41 additions & 0 deletions erupt-core/src/main/java/xyz/erupt/core/log/EruptJULAppender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package xyz.erupt.core.log;

import java.util.logging.Handler;
import java.util.logging.LogRecord;

public class EruptJULAppender extends Handler implements EruptAppender {

@Override
public void publish(LogRecord record) {
EruptLogManager.log(new Formatter()
.timestamp(record.getMillis())
.space()
.level(record.getLevel().toString())
.value(" --- [")
.thread(Thread.currentThread().getName())
.value("] ")
.name(record.getLoggerName())
.value("(" + record.getSourceMethodName() + ":" + record.getSequenceNumber() + ")")
.value(" : ")
.value(record.getMessage())
.throwable(record.getThrown())
.toString()
);
}

@Override
public void flush() {

}

@Override
public void close() throws SecurityException {

}

@Override
public void init() {

}

}
Loading

0 comments on commit 683b290

Please sign in to comment.