Fix 3.7 beta2-2 (#772)

* beta2

* fix: DbInfo

* be: move on pad

* login tip2mob

* be: reuse type-code

* fix

* sql \
This commit is contained in:
REBUILD 企业管理系统 2024-06-14 19:56:19 +08:00 committed by GitHub
parent 357768f115
commit 6bbae5fd17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 94 additions and 30 deletions

View file

@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>3.7.0-beta1</version>
<version>3.7.0-beta2</version>
<name>rebuild</name>
<description>Building your business-systems freely!</description>
<url>https://getrebuild.com/</url>

View file

@ -75,11 +75,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* Rebuild Version
*/
public static final String VER = "3.7.0-beta1";
public static final String VER = "3.7.0-beta2";
/**
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
*/
public static final int BUILD = 3070001;
public static final int BUILD = 3070002;
static {
// Driver for DB

View file

@ -286,7 +286,7 @@ public class Entity2Schema extends Field2Schema {
/**
* @return
*/
private int genEntityTypeCode() {
protected int genEntityTypeCode() {
final int starts = 100;
if (specEntityCode > starts) {
@ -296,6 +296,7 @@ public class Entity2Schema extends Field2Schema {
return specEntityCode;
}
// etc. 100,200,300
int s = CommandArgs.getInt(CommandArgs._StartEntityTypeCode);
if (s > starts) {
for (int typeCode = s; typeCode < 999; typeCode++) {
@ -305,7 +306,18 @@ public class Entity2Schema extends Field2Schema {
Object[] mTypeCode = Application.createQueryNoFilter(
"select min(typeCode) from MetaEntity").unique();
return mTypeCode == null || ObjectUtils.toInt(mTypeCode[0]) == 0
int typeCode = mTypeCode == null || ObjectUtils.toInt(mTypeCode[0]) == 0
? 999 : (ObjectUtils.toInt(mTypeCode[0]) - 1);
// 999 开始继续利用
if (typeCode < starts * 2) {
for (int c = 999; c > starts * 2; c--) {
if (!MetadataHelper.containsEntity(c)) {
log.warn("Recycling and reuse type-code : {}", c);
return c;
}
}
}
return typeCode;
}
}

View file

@ -98,7 +98,7 @@ public class NotificationService extends InternalPersistService {
try {
boolean sent = md.send(message, messageId);
log.info("Distribute message ({}) : {}", sent ? "success" : "fails", message);
log.info("Distribute message ({}) with {} : {}", sent ? "success" : "fails", md.getClass().getSimpleName(), message);
} catch (Exception ex) {
log.error("Distribute message error : {}", message, ex);
}

View file

@ -45,6 +45,7 @@ public class DatabaseFixer {
* 辅助数据库升级
*/
public static void fixIfNeed() {
// 最新升级过的
final int dbVer = RebuildConfiguration.getInt(ConfigurationItem.DBVer);
if (dbVer == 41 && !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_41))) {
@ -73,7 +74,7 @@ public class DatabaseFixer {
});
}
if (dbVer <= 55 && !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_370))) {
if (dbVer <= 57 && !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_370))) {
log.info("Database fixing `V370` ...");
ThreadPool.exec(() -> {
try {
@ -149,9 +150,9 @@ public class DatabaseFixer {
// V370:补充附件文件名称
private static void fixV370() {
Object[][] atts = QueryHelper.readArray(
Application.createQueryNoFilter("select attachmentId,filePath from Attachment"));
for (Object[] o : atts) {
Object[][] attachs = QueryHelper.readArray(
Application.createQueryNoFilter("select attachmentId,filePath from Attachment where fileName is null"));
for (Object[] o : attachs) {
String fileName = QiniuCloud.parseFileName((String) o[1]);
Record record = EntityHelper.forUpdate((ID) o[0], UserService.SYSTEM_USER, false);
record.setString("fileName", fileName);

View file

@ -356,9 +356,10 @@ public class Installer implements InstallState {
if (rs.next()) return new DbInfo(rs.getString(1));
}
}
} catch (SQLException ignored) {
} catch (SQLException ex) {
log.warn("Cannot get database info", ex);
}
return null;
return new DbInfo("MySQL");
}
/**

View file

@ -20,6 +20,7 @@ import java.util.Map;
*
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/22
* @see DatabaseFixer
*/
@Slf4j
public final class UpgradeDatabase {
@ -47,7 +48,8 @@ public final class UpgradeDatabase {
upgradeVer++;
if (sql.length > 0) {
log.info("\n>> UPGRADE SQL (#" + upgradeVer + ") >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + StringUtils.join(sql, "\n"));
log.info("\n>> UPGRADE SQL (#{}) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n{}",
upgradeVer, StringUtils.join(sql, "\n"));
Application.getSqlExecutor().executeBatch(sql, 180);
}
}
@ -55,7 +57,7 @@ public final class UpgradeDatabase {
} finally {
if (currentVer != upgradeVer) {
RebuildConfiguration.set(ConfigurationItem.DBVer, upgradeVer);
log.info("Upgraded database version : " + upgradeVer);
log.info("Upgraded database version : {}", upgradeVer);
}
}
}

View file

@ -136,6 +136,8 @@ public class CommonsUtils {
public static String escapeSql(Object text) {
// https://github.com/getrebuild/rebuild/issues/594
text = text.toString().replace("\\'", "'");
// https://gitee.com/getrebuild/rebuild/issues/IA5G7U
text = text.toString().replace("\\", "\\\\");
return StringEscapeUtils.escapeSql((String) text);
}

View file

@ -123,6 +123,7 @@ public class OshiUtils {
final String[] FROMURLS = new String[] {
"https://www.baidu.com/",
"https://www.microsoft.com/",
"https://getrebuild.com/",
};
for (String u : FROMURLS) {

View file

@ -46,6 +46,14 @@ public class PicklistDataController extends BaseController {
Field fieldMeta = getRealField(entity, field);
DisplayType dt = EasyMetaFactory.getDisplayType(fieldMeta);
// fix3.7: 下拉列表作为引用实体的名称字段
if (dt == DisplayType.REFERENCE) {
Field useNameField = fieldMeta.getReferenceEntity().getNameField();
if (EasyMetaFactory.getDisplayType(useNameField) == DisplayType.PICKLIST) {
fieldMeta = useNameField;
}
}
JSON options;
if (dt == DisplayType.STATE) {
options = StateManager.instance.getStateOptions(fieldMeta);

View file

@ -138,7 +138,8 @@ public class ReferenceSearchController extends EntityController {
return JSONUtils.EMPTY_ARRAY;
}
String like = " like '%" + CommonsUtils.escapeSql(q) + "%'";
q = CommonsUtils.escapeSql(q);
String like = " like '%" + q + "%'";
searchWhere = StringUtils.join(searchFields.iterator(), like + " or ") + like;
}
@ -196,7 +197,6 @@ public class ReferenceSearchController extends EntityController {
}
q = CommonsUtils.escapeSql(q);
int openLevel = ClassificationManager.instance.getOpenLevel(fieldMeta);
String sqlWhere = String.format(
"dataId = '%s' and level = %d and (fullName like '%%%s%%' or quickCode like '%%%s%%' or code like '%s%%') order by code,fullName",

View file

@ -9,7 +9,7 @@
<script th:src="@{/assets/lib/jquery.html5uploader.js?v=310}"></script>
<script th:src="@{/assets/lib/qiniu.min.js?v=3.4.1}"></script>
<script th:src="@{/assets/lib/widget/select2.js?v=4.0.13.fix2}"></script>
<script th:src="@{/assets/lib/jquery-ui.min.js?v=1.13.2}"></script>
<script th:src="@{/assets/lib/jquery-ui.min.js?v=1.13.2.fix1}"></script>
<script th:src="@{/assets/lib/widget/simplemde.min.js}"></script>
<script th:src="@{/assets/lib/jquery.textarea.js}"></script>
<script th:src="@{/assets/lib/react/babel.js?v=6.26.0}"></script>

View file

@ -5673,7 +5673,7 @@ span.icon-append .icon {
padding-right: 15px;
}
.input-search .input-group-btn,
/*.input-search .input-group-btn,*/
.input-group-append .btn,
.input-group-prepend .btn {
z-index: unset;

View file

@ -435,7 +435,7 @@ class FilterItem extends React.Component {
}
// v3.6-b4,v3.7
if (['TEXT', 'PHONE', 'EMAIL', 'URL', 'DATE', 'DATETIME', 'TIME', 'PICKLIST', 'CLASSIFICATION'].includes(fieldType)) op.push('REP')
if (['TEXT', 'PHONE', 'EMAIL', 'URL', 'DATE', 'DATETIME', 'TIME'].includes(fieldType)) op.push('REP')
if (this.isApprovalState()) op = ['IN', 'NIN']
else if (this.state.field === VF_ACU) op = ['IN', 'SFU', 'SFB', 'SFT'] // v3.7 准备废弃

View file

@ -1472,9 +1472,9 @@ class RbFormNText extends RbFormElement {
)
})
mde.codemirror.on('paste', (_mde, e) => {
$stopEvent(e, true)
const data = e.clipboardData || window.clipboardData
if (data && data.items && data.files && data.files.length > 0) {
$stopEvent(e, true)
this._fieldValue__upload.files = data.files
$(this._fieldValue__upload).trigger('change')
}

View file

@ -81,4 +81,16 @@ $(document).ready(() => {
if ($urlp('error') === 'TempAuth') {
RbHighbar.create($L('临时授权链接已过期'))
}
const tip2mob = $.browser.mobile
if (tip2mob) {
setTimeout(() => {
RbAlert.create($L('是否需要切换到手机版访问'), {
onConfirm: function () {
this.hide()
location.href = $('.h5-mobile a').attr('href')
},
})
}, 500)
}
})

View file

@ -156,7 +156,7 @@ class LevelBox extends React.Component {
res.data.forEach((item) => {
rbapi.push([item[0], item[1]])
})
rbapi.length > 0 && console.log(`RBAPI ASSISTANT *Classification* :\n %c${JSON.stringify(rbapi)}`, 'color:#e83e8c;font-size:16px;font-weight:bold;font-style:italic;')
rbapi.length > 0 && console.log(`RBAPI ASSISTANT *Classification* :\n%c${this.parentId || '-'}\n${JSON.stringify(rbapi)}`, 'color:#e83e8c;font-size:16px;font-weight:bold;font-style:italic;')
})
}

View file

@ -28,8 +28,14 @@ const SHARE_SELF = 'SELF'
class Share2 extends _ChangeHandler {
constructor(props) {
super(props)
// defaultValue
if (props.shareTo && props.shareTo !== SHARE_SELF) this.state.shared = true
// init
if (props.shareTo && props.shareTo !== SHARE_SELF) {
this.state.shared = true
} else if (rb.isAdminUser && !props.id) {
// new for Admin
this.state.shared = true
}
}
render() {

View file

@ -323,11 +323,12 @@ class ContentFieldAggregation extends ActionContentSpec {
setTimeout(() => this._MatchFields && this._MatchFields.setState({ groupFields: content.targetEntityMatchFields }), 200)
}
}
// v3.7
const targetFields2 = res.data.target2
this.setState({ targetFields2: targetFields2 })
this._MatchFields && this._MatchFields.reset({ targetFields: targetFields2, sourceFields: this.__sourceFieldsCache })
}
// v3.7
const targetFields2 = res.data.target2 || []
this.setState({ targetFields2: targetFields2 })
this._MatchFields && this._MatchFields.reset({ targetFields: targetFields2, sourceFields: this.__sourceFieldsCache })
})
}

File diff suppressed because one or more lines are too long

View file

@ -17,7 +17,7 @@
<div class="main-content container-fluid p-0">
<div class="ps-toolbar">
<div class="row">
<div class="col-sm-6">
<div class="col-sm-5">
<div class="project-head">
<h4>
[[${projectName}]]
@ -33,7 +33,7 @@
</div>
</div>
</div>
<div class="col-sm-6 text-right d-none d-md-block">
<div class="col-sm-7 text-right d-none d-md-block">
<div class="btn-group J_sorts float-right">
<button type="button" class="btn btn-link" data-toggle="dropdown">
<i class="icon mdi mdi-view-carousel-outline"></i>

View file

@ -56,4 +56,9 @@ class Meta2SchemaTest extends TestSupport {
drop = new Entity2Schema(UserService.ADMIN_USER).dropEntity(newEntity);
System.out.println("New Entity (for Field) is dropped : " + newEntityName + " > " + drop);
}
@Test
void genEntityTypeCode() {
new Entity2Schema(UserService.SYSTEM_USER).genEntityTypeCode();
}
}