mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-09-20 07:25:54 +08:00
Fix 3.4.6 (#675)
* fix: auto-fillin * fix: default-value for tag * fix: 多引用高级查询 * v3.4.6
This commit is contained in:
parent
bc577795b8
commit
dba501d616
2
@rbv
2
@rbv
|
@ -1 +1 @@
|
|||
Subproject commit e59cdd3de2cbf05f2991a18485eacdd99ac854e3
|
||||
Subproject commit 0f5ad73c12a1f5a617314efe665074687f17e490
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
</parent>
|
||||
<groupId>com.rebuild</groupId>
|
||||
<artifactId>rebuild</artifactId>
|
||||
<version>3.4.5</version>
|
||||
<version>3.4.6</version>
|
||||
<name>rebuild</name>
|
||||
<description>Building your business-systems freely!</description>
|
||||
<!-- UNCOMMENT USE TOMCAT -->
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.rebuild.core.support.ConfigurationItem;
|
|||
import com.rebuild.core.support.License;
|
||||
import com.rebuild.core.support.RebuildConfiguration;
|
||||
import com.rebuild.core.support.i18n.Language;
|
||||
import com.rebuild.core.support.setup.DataMigrator;
|
||||
import com.rebuild.core.support.setup.DatabaseFixer;
|
||||
import com.rebuild.core.support.setup.Installer;
|
||||
import com.rebuild.core.support.setup.UpgradeDatabase;
|
||||
import com.rebuild.utils.JSONable;
|
||||
|
@ -73,11 +73,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
|
|||
/**
|
||||
* Rebuild Version
|
||||
*/
|
||||
public static final String VER = "3.4.5";
|
||||
public static final String VER = "3.4.6";
|
||||
/**
|
||||
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
|
||||
*/
|
||||
public static final int BUILD = 3040510;
|
||||
public static final int BUILD = 3040611;
|
||||
|
||||
static {
|
||||
// Driver for DB
|
||||
|
@ -249,7 +249,7 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
|
|||
|
||||
License.isRbvAttached();
|
||||
|
||||
DataMigrator.dataMigrateIfNeed();
|
||||
DatabaseFixer.fixIfNeed();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,11 +10,15 @@ package com.rebuild.core.metadata.easymeta;
|
|||
import cn.devezhao.persist4j.Field;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rebuild.core.metadata.MetadataHelper;
|
||||
import com.rebuild.core.support.general.TagSupport;
|
||||
import com.rebuild.core.metadata.impl.EasyFieldConfigProps;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zixin
|
||||
* @since 2022/12/12
|
||||
|
@ -45,7 +49,15 @@ public class EasyTag extends EasyField implements MultiValue, MixValue {
|
|||
|
||||
@Override
|
||||
public Object exprDefaultValue() {
|
||||
return TagSupport.getDefaultValue(this);
|
||||
JSONArray tagList = getExtraAttrs(true).getJSONArray(EasyFieldConfigProps.TAG_LIST);
|
||||
if (tagList == null || tagList.isEmpty()) return null;
|
||||
|
||||
List<String> dv = new ArrayList<>();
|
||||
for (Object o : tagList) {
|
||||
JSONObject tag = (JSONObject) o;
|
||||
if (tag.getBooleanValue("default")) dv.add(tag.getString("name"));
|
||||
}
|
||||
return dv.isEmpty() ? null : dv.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,35 +27,52 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.lang.BooleanUtils;
|
||||
|
||||
/**
|
||||
* 数据库修订
|
||||
*
|
||||
* @author devezhao
|
||||
* @since 2021/11/18
|
||||
*/
|
||||
@Slf4j
|
||||
public class DataMigrator {
|
||||
public class DatabaseFixer {
|
||||
|
||||
private static final String KEY_41 = "DataMigratorV41";
|
||||
private static final String KEY_346 = "DatabaseFixerV346";
|
||||
|
||||
/**
|
||||
* 辅助数据库升级
|
||||
*/
|
||||
public static void dataMigrateIfNeed() {
|
||||
if (RebuildConfiguration.getInt(ConfigurationItem.DBVer) == 41
|
||||
&& !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_41))) {
|
||||
log.info("Data migrating #41 ...");
|
||||
public static void fixIfNeed() {
|
||||
final int dbVer = RebuildConfiguration.getInt(ConfigurationItem.DBVer);
|
||||
|
||||
if (dbVer == 41 && !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_41))) {
|
||||
log.info("Database fixing `#41` ...");
|
||||
ThreadPool.exec(() -> {
|
||||
try {
|
||||
v41();
|
||||
fixV41();
|
||||
KVStorage.setCustomValue(KEY_41, "true");
|
||||
log.info("Data migrated #41 all succeeded");
|
||||
log.info("Database fixed `#41` all succeeded");
|
||||
} catch (Exception ex) {
|
||||
log.error("Data migrating #41 failed : {}", ThrowableUtils.getRootCause(ex).getLocalizedMessage());
|
||||
log.error("Database fixing `#41` failed : {}", ThrowableUtils.getRootCause(ex).getLocalizedMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (dbVer <= 52 && !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_346))) {
|
||||
log.info("Database fixing `V346` ...");
|
||||
ThreadPool.exec(() -> {
|
||||
try {
|
||||
fixV346();
|
||||
KVStorage.setCustomValue(KEY_346, "true");
|
||||
log.info("Database fixed `V346` all succeeded");
|
||||
} catch (Exception ex) {
|
||||
log.error("Database fixing `V346` failed : {}", ThrowableUtils.getRootCause(ex).getLocalizedMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// #41 多引用字段改为三方表
|
||||
private static void v41() {
|
||||
// #41:多引用字段改为三方表
|
||||
private static void fixV41() {
|
||||
for (Entity entity : MetadataHelper.getEntities()) {
|
||||
if (EasyMetaFactory.valueOf(entity).isBuiltin()) continue;
|
||||
|
||||
|
@ -87,7 +104,29 @@ public class DataMigrator {
|
|||
}
|
||||
|
||||
if (count > 0) {
|
||||
log.info("Data migrated #41 : {} > {}", entity.getName(), count);
|
||||
log.info("Database fixed `#41` : {} > {}", entity.getName(), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// V346:标签无效值问题
|
||||
private static void fixV346() {
|
||||
for (Entity entity : MetadataHelper.getEntities()) {
|
||||
if (EasyMetaFactory.valueOf(entity).isBuiltin()) continue;
|
||||
|
||||
Field[] tagFields = MetadataSorter.sortFields(entity, DisplayType.TAG);
|
||||
if (tagFields.length == 0) continue;
|
||||
|
||||
int count = 0;
|
||||
for (Field field : tagFields) {
|
||||
String usql = String.format(
|
||||
"update `%s` set `%s` = NULL where `%s` like '[Ljava.lang.String;@%%'",
|
||||
entity.getPhysicalName(), field.getPhysicalName(), field.getPhysicalName());
|
||||
count += Application.getSqlExecutor().execute(usql, 120);
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
log.info("Database fixed `V346` : {} > {}", entity.getName(), count);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -216,7 +216,9 @@ class DlgRuleEdit extends RbFormHandler {
|
|||
}
|
||||
})
|
||||
this.setState({ targetFields: targetFields }, () => {
|
||||
if (targetFields.length > 0) this.__select2[0].val(targetFields[0].name)
|
||||
if (targetFields.length > 0) {
|
||||
this.__select2[0].val(targetFields[0].name).trigger('change')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,8 @@ class AdvFilter extends React.Component {
|
|||
// 例如原名称字段为日期,其设置的过滤条件也是日期相关的,修改成文本后可能出错
|
||||
|
||||
if (['REFERENCE', 'N2NREFERENCE'].includes(item.type)) {
|
||||
REFENTITY_CACHE[`${this.props.entity}.${item.name}`] = item.ref
|
||||
REFENTITY_CACHE[item.name] = item.ref
|
||||
if ('N2NREFERENCE' === item.type) REFENTITY_CACHE[item.name]._n2n = true
|
||||
|
||||
// NOTE: Use `NameField` field-type
|
||||
if (!BIZZ_ENTITIES.includes(item.ref[0])) {
|
||||
|
@ -157,13 +158,15 @@ class AdvFilter extends React.Component {
|
|||
if (item.type === 'REFERENCE' && item.name === 'approvalLastUser') {
|
||||
const item2 = { ...item, name: VF_ACU, label: $L('当前审批人') }
|
||||
validFs.push(item2.name)
|
||||
REFENTITY_CACHE[`${this.props.entity}.${item2.name}`] = item2.ref
|
||||
REFENTITY_CACHE[item2.name] = item2.ref
|
||||
fields.push(item2)
|
||||
}
|
||||
}
|
||||
})
|
||||
this._fields = fields
|
||||
|
||||
console.log(REFENTITY_CACHE)
|
||||
|
||||
// init
|
||||
if (this.__initItems) {
|
||||
this.__initItems.forEach((item) => {
|
||||
|
@ -551,9 +554,9 @@ class FilterItem extends React.Component {
|
|||
// 引用 User/Department/Role/Team
|
||||
isBizzField(entity) {
|
||||
if (this.state.type === 'REFERENCE') {
|
||||
const ref = REFENTITY_CACHE[`${this._searchEntity}.${this.state.field}`]
|
||||
if (entity) return ref[0] === entity
|
||||
else return BIZZ_ENTITIES.includes(ref[0])
|
||||
const ifRefField = REFENTITY_CACHE[this.state.field]
|
||||
if (entity) return ifRefField[0] === entity
|
||||
else return BIZZ_ENTITIES.includes(ifRefField[0])
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -635,9 +638,9 @@ class FilterItem extends React.Component {
|
|||
}
|
||||
|
||||
if (this.isBizzField()) {
|
||||
let ref = REFENTITY_CACHE[`${this._searchEntity}.${state.field}`]
|
||||
ref = state.op === 'SFT' ? 'Team' : ref[0]
|
||||
this.renderBizzSearch(ref)
|
||||
let ifRefField = REFENTITY_CACHE[state.field]
|
||||
ifRefField = state.op === 'SFT' ? 'Team' : ifRefField[0]
|
||||
this.renderBizzSearch(ifRefField)
|
||||
} else if (lastType === 'REFERENCE') {
|
||||
this.removeBizzSearch()
|
||||
}
|
||||
|
@ -902,9 +905,11 @@ class FilterItem extends React.Component {
|
|||
if (s.value2) item.value2 = s.value2
|
||||
|
||||
// 引用字段查询名称字段
|
||||
const isRefField = REFENTITY_CACHE[`${this._searchEntity}.${s.field}`]
|
||||
if (isRefField && !BIZZ_ENTITIES.includes(isRefField[0])) {
|
||||
if (!(s.op === 'NL' || s.op === 'NT')) {
|
||||
const ifRefField = REFENTITY_CACHE[s.field]
|
||||
if (ifRefField && !(s.op === 'NL' || s.op === 'NT')) {
|
||||
if (BIZZ_ENTITIES.includes(ifRefField[0])) {
|
||||
if (ifRefField._n2n) item.field = NAME_FLAG + item.field
|
||||
} else {
|
||||
item.field = NAME_FLAG + item.field
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1352,7 +1352,7 @@ class RbFormTextarea extends RbFormElement {
|
|||
|
||||
setValue(val) {
|
||||
super.setValue(val)
|
||||
if (this.props.useMdedit) this._SimpleMDE.value(val)
|
||||
if (this.props.useMdedit) this._SimpleMDE.value(val || '')
|
||||
}
|
||||
|
||||
_initMde() {
|
||||
|
|
Loading…
Reference in a new issue