Skip to content

Commit

Permalink
Merge pull request #229 from erupts/develop
Browse files Browse the repository at this point in the history
1.12.10
  • Loading branch information
erupts committed Feb 4, 2024
2 parents b432b02 + 0c340ac commit 389690e
Show file tree
Hide file tree
Showing 60 changed files with 126 additions and 80 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.9</version>
<version>1.12.10</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.9</version>
<version>1.12.10</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@
*/
public @interface InputType {

@Comment("最大输入长度")
@Comment("Maximum input length")
int length() default 255;

String type() default "text";

@Comment("是否整行显示")
@Comment("Display the whole line")
boolean fullSpan() default false;

@Transient
@Comment("对提交内容进行正则校验")
@Comment("Regex the input value")
String regex() default "";

@Transient
@Comment("Automatically trim input value")
boolean autoTrim() default true;

VL[] prefix() default {};

VL[] suffix() 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.9</version>
<version>1.12.10</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.9</version>
<version>1.12.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions 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.9</version>
<version>1.12.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand All @@ -36,7 +36,7 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-http</artifactId>
<version>5.8.16</version>
<version>5.8.25</version>
</dependency>
</dependencies>
</project>
Expand Down
4 changes: 2 additions & 2 deletions 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.9</version>
<version>1.12.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -53,7 +53,7 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-http</artifactId>
<version>5.8.16</version>
<version>5.8.25</version>
</dependency>
</dependencies>
</project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.EruptI18n;
import xyz.erupt.annotation.constant.AnnotationConst;
import xyz.erupt.annotation.expr.ExprBool;
import xyz.erupt.annotation.fun.DataProxy;
import xyz.erupt.annotation.fun.TagsFetchHandler;
Expand Down Expand Up @@ -134,7 +135,7 @@ public class CloudNode extends MetaModelUpdateVo implements DataProxy<CloudNode>
@Type(type = "org.hibernate.type.TextType")
@EruptField(
views = @View(title = "节点配置"),
edit = @Edit(title = "节点配置", type = EditType.CODE_EDITOR, codeEditType = @CodeEditorType(language = "json"))
edit = @Edit(title = "节点配置", desc = "配置后可在子节点中读取", type = EditType.CODE_EDITOR, codeEditType = @CodeEditorType(language = "json"))
)
private String config;

Expand All @@ -143,8 +144,7 @@ public class CloudNode extends MetaModelUpdateVo implements DataProxy<CloudNode>
)
private String accessToken;

@Lob
@Type(type = "org.hibernate.type.TextType")
@Column(length = AnnotationConst.REMARK_LENGTH)
@EruptField(
views = @View(title = "描述", type = ViewType.HTML),
edit = @Edit(title = "描述", type = EditType.TEXTAREA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;
import xyz.erupt.cloud.server.config.EruptCloudServerProp;
import xyz.erupt.cloud.server.model.CloudNode;
import xyz.erupt.jpa.dao.EruptDao;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
* @author YuePeng
Expand All @@ -22,6 +26,9 @@ public class NodeManager {

public static final String NODE_SPACE = "node:";

@Resource
private EruptDao eruptDao;

private RedisTemplate<String, MetaNode> redisTemplate;

@Autowired
Expand Down Expand Up @@ -64,11 +71,16 @@ public void removeNodeInstance(String nodeName, String instanceAddress) {


public List<MetaNode> findAllNodes() {
List<MetaNode> metaNodes = new ArrayList<>();
Optional.ofNullable(redisTemplate.keys(eruptCloudServerProp.getCloudNameSpace() + NODE_SPACE + "*")).flatMap(keys ->
Optional.ofNullable(redisTemplate.opsForValue().multiGet(keys))).ifPresent(metaNodes::addAll
);
return metaNodes;
List<String> keys = eruptDao.queryEntityList(CloudNode.class).stream().map(it ->
eruptCloudServerProp.getCloudNameSpace() + NODE_SPACE + it.getNodeName()
).collect(Collectors.toList());
if (!keys.isEmpty()) {
List<MetaNode> metaNodes = Optional.ofNullable(redisTemplate.opsForValue().multiGet(keys)).orElse(new ArrayList<>());
metaNodes.removeIf(Objects::isNull);
return metaNodes;
} else {
return new ArrayList<>();
}
}

}
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.9</version>
<version>1.12.10</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import xyz.erupt.core.util.EruptUtil;
import xyz.erupt.core.util.Erupts;
import xyz.erupt.core.util.ReflectUtil;
import xyz.erupt.core.view.EruptFieldModel;
import xyz.erupt.core.view.EruptModel;
import xyz.erupt.core.view.Page;
import xyz.erupt.core.view.TableQuery;
Expand Down Expand Up @@ -63,14 +64,19 @@ public Page getEruptData(EruptModel eruptModel, TableQuery tableQuery, List<Cond
if (dependTree.dependNode()) return new Page();
} else {
EruptModel treeErupt = EruptCoreService.getErupt(ReflectUtil.findClassField(eruptModel.getClazz(), dependTree.field()).getType().getSimpleName());
conditionStrings.add(String.format("%s = '%s'", dependTree.field() + EruptConst.DOT + treeErupt.getErupt().primaryKeyCol(), tableQuery.getLinkTreeVal()));
EruptFieldModel pk = treeErupt.getEruptFieldMap().get(treeErupt.getErupt().primaryKeyCol());
if (pk.getField().getType() == String.class) {
conditionStrings.add(String.format("%s = '%s'", dependTree.field() + EruptConst.DOT + pk.getFieldName(), tableQuery.getLinkTreeVal()));
} else {
conditionStrings.add(String.format("%s = %s", dependTree.field() + EruptConst.DOT + pk.getFieldName(), tableQuery.getLinkTreeVal()));
}
}
}
Layout layout = eruptModel.getErupt().layout();
if (Layout.PagingType.FRONT == layout.pagingType() || Layout.PagingType.NONE == layout.pagingType()) {
tableQuery.setPageSize(layout.pageSizes()[layout.pageSizes().length - 1]);
}
this.drillProcess(eruptModel, (link, val) -> conditionStrings.add(String.format("%s = '%s'", link.linkErupt().getSimpleName() + EruptConst.DOT + link.joinColumn(), val)));
this.drillProcess(eruptModel, (link, val) -> conditionStrings.add(String.format(val instanceof String ? "%s = '%s'" : "%s = %s", link.linkErupt().getSimpleName() + EruptConst.DOT + link.joinColumn(), val)));
conditionStrings.addAll(Arrays.asList(customCondition));
DataProxyInvoke.invoke(eruptModel, (dataProxy -> Optional.ofNullable(dataProxy.beforeFetch(legalConditions)).ifPresent(conditionStrings::add)));
Optional.ofNullable(serverCondition).ifPresent(legalConditions::addAll);
Expand Down
6 changes: 5 additions & 1 deletion erupt-core/src/main/java/xyz/erupt/core/util/EruptUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ public static Object dataTarget(EruptModel eruptModel, Object data, Object targe
f.set(target, s);
}
} else {
f.set(target, f.get(data));
if (eruptField.edit().type() == EditType.INPUT && eruptField.edit().inputType().autoTrim() && null != f.get(data)) {
f.set(target, f.get(data).toString().trim());
} else {
f.set(target, f.get(data));
}
}
} catch (IllegalAccessException e) {
log.error("erupt data copy error", e);
Expand Down
2 changes: 1 addition & 1 deletion erupt-data/erupt-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.9</version>
<version>1.12.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class EruptDao {

private static final String WHERE = " where ";

public <T> T findById(Class<T> clazz, Object id) {
entityManager.clear();
return entityManager.find(clazz, id);
}

//修改
public <T> T merge(T t) {
return entityManager.merge(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import javax.persistence.UniqueConstraint;
import javax.transaction.Transactional;
import java.lang.reflect.Field;
import java.sql.SQLException;
import java.util.*;

/**
Expand Down Expand Up @@ -114,17 +115,19 @@ private void loadSupport(Object jpaEntity) {

//优化异常提示类
private void handlerException(Exception e, EruptModel eruptModel) {
if (e instanceof DataIntegrityViolationException) {
if (e.getMessage().contains("ConstraintViolationException")) {
throw new EruptWebApiRuntimeException(gcRepeatHint(eruptModel));
} else if (e.getMessage().contains("DataException")) {
throw new EruptWebApiRuntimeException(I18nTranslate.$translate("erupt.data.limit_length"));
} else {
throw new EruptWebApiRuntimeException(e.getMessage());
Throwable throwable = e;
while (null != throwable) {
throwable = throwable.getCause();
if (throwable instanceof SQLException) {
if (throwable.getMessage().contains("Data too long")) {
throw new EruptWebApiRuntimeException(I18nTranslate.$translate("erupt.data.limit_length"));
} else if (throwable.getMessage().contains("Duplicate entry")) {
throw new EruptWebApiRuntimeException(gcRepeatHint(eruptModel));
}
throw new EruptWebApiRuntimeException(throwable.getMessage());
}
} else {
throw new EruptWebApiRuntimeException(e.getMessage());
}
throw new EruptWebApiRuntimeException(e.getMessage());
}

@Transactional
Expand Down
2 changes: 1 addition & 1 deletion erupt-data/erupt-mongodb/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.9</version>
<version>1.12.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-excel/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.9</version>
<version>1.12.10</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import xyz.erupt.core.view.Page;
import xyz.erupt.excel.util.ExcelUtil;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;

/**
Expand Down Expand Up @@ -276,7 +278,7 @@ public Workbook createExcelTemplate(EruptModel eruptModel) {
if (edit.show() && !edit.readonly().add() && StringUtils.isNotBlank(edit.title())
&& AnnotationProcess.getEditTypeMapping(edit.type()).excelOperator()) {
Cell cell = headRow.createCell(cellNum);
//256表格一个字节的宽度
//单字节宽度为256
sheet.setColumnWidth(cellNum, (edit.title().length() + 10) * 256);
DataValidationHelper dvHelper = sheet.getDataValidationHelper();
switch (edit.type()) {
Expand Down Expand Up @@ -304,7 +306,9 @@ public Workbook createExcelTemplate(EruptModel eruptModel) {
Integer.toString(edit.sliderType().min()), Integer.toString(edit.sliderType().max()))));
break;
case DATE:
if (fieldModel.getFieldReturnName().equals(Date.class.getSimpleName())) {
if (fieldModel.getFieldReturnName().equals(Date.class.getSimpleName())
|| fieldModel.getFieldReturnName().equals(LocalDate.class.getSimpleName())
|| fieldModel.getFieldReturnName().equals(LocalDateTime.class.getSimpleName())) {
sheet.addValidationData(generateValidation(cellNum, "请选择或输入有效时间!"
, dvHelper.createDateConstraint(DVConstraint.OperatorType.BETWEEN
, "1900-01-01", "2999-12-31", "yyyy-MM-dd")));
Expand Down
2 changes: 1 addition & 1 deletion erupt-extra/erupt-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.9</version>
<version>1.12.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-extra/erupt-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.9</version>
<version>1.12.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum GeneratorType {
COLOR(EditType.INPUT, "颜色选择", String.class.getSimpleName(), "inputType = @InputType(type = \"color\")"),
NUMBER(EditType.NUMBER, "数值框", Integer.class.getSimpleName(), "numberType = @NumberType"),
SLIDER(EditType.SLIDER, "数字滑块", Integer.class.getSimpleName(), "sliderType = @SliderType(max = 999)"),
RATE(EditType.RATE, "评分", Short.class.getSimpleName(), "rateType = @RateType(count = 10)"),
DATE(EditType.DATE, "日期", Date.class.getSimpleName(), "dateType = @DateType"),
DATE_TIME(EditType.DATE, "日期时间", Date.class.getSimpleName(), "dateType = @DateType(type = DateType.Type.DATE_TIME)"),
TIME(EditType.DATE, "时间", String.class.getSimpleName(), "dateType = @DateType(type = DateType.Type.TIME)"),
Expand Down
2 changes: 1 addition & 1 deletion erupt-extra/erupt-job/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.9</version>
<version>1.12.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ public class EruptJob extends MetaModelUpdateVo {
trueText = "启用", falseText = "禁用"
), notNull = true, search = @Search)
)
private Boolean status;
private Boolean status = true;

@EruptField(
views = @View(title = "记录日志"),
edit = @Edit(title = "记录日志", boolType = @BoolType(
trueText = "是", falseText = "否"
), notNull = true, search = @Search)
)
private Boolean recordLog = true;

@Column(length = AnnotationConst.REMARK_LENGTH)
@EruptField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public class EruptJobDataProxy implements DataProxy<EruptJob>, OperationHandler<
@Resource
private EruptJobService eruptJobService;

@Override
public void addBehavior(EruptJob eruptJob) {
eruptJob.setStatus(true);
}

@Override
public void beforeAdd(EruptJob eruptJob) {
if (null == eruptJob.getCode()) {
Expand Down
Loading

0 comments on commit 389690e

Please sign in to comment.