Skip to content

Commit

Permalink
Fix 3.6.5 (#763)
Browse files Browse the repository at this point in the history
* fix: clearFields N2N

* fix: v3.7 BW 无需修正,值由用户提供

* be: isEnableBizzPart

* be: dbInfo, allowPublicKeyRetrieval

* 3.6.5

* be
  • Loading branch information
getrebuild committed May 22, 2024
1 parent ba912dc commit bcdd1e0
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>3.6.4</version>
<version>3.6.5</version>
<name>rebuild</name>
<description>Building your business-systems freely!</description>
<url>https://getrebuild.com/</url>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rebuild/core/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* Rebuild Version
*/
public static final String VER = "3.6.4";
public static final String VER = "3.6.5";
/**
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
*/
public static final int BUILD = 3060409;
public static final int BUILD = 3060510;

static {
// Driver for DB
Expand Down
24 changes: 18 additions & 6 deletions src/main/java/com/rebuild/core/privileges/UserFilters.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static boolean isEnableBizzPart(ID user) {
}

/**
* 是否允许访问
* 指定用户是否允许访问
*
* @param user
* @param bizzId
Expand All @@ -55,20 +55,32 @@ public static boolean allowAccessBizz(ID user, ID bizzId) {
if (isEnableBizzPart(user)) {
final User ub = Application.getUserStore().getUser(user);

// 本部门及子部门的用户
if (bizzId.getEntityCode() == EntityHelper.User) {
if (user.equals(bizzId)) return true;
if (ub.getOwningDept() == null) return false;

// 可访问部门就是可访问部门下的用户
Department dept = UserHelper.getDepartment(bizzId);
if (dept == null) return false;
bizzId = (ID) dept.getIdentity();
}

// 本部门及子部门
if (bizzId.getEntityCode() == EntityHelper.Department) {
return ub.getOwningDept() != null && bizzId.equals(ub.getOwningDept().getIdentity());
Department dept = ub.getOwningDept();
if (dept == null) return false;
if (bizzId.equals(dept.getIdentity())) return true;
return UserHelper.getAllChildren(dept).contains(bizzId);
}

// 所在团队
if (bizzId.getEntityCode() == EntityHelper.Team) {
for (Team m : ub.getOwningTeams()) {
if (bizzId.equals(m.getIdentity())) return true;
}
return false;
}

if (bizzId.getEntityCode() == EntityHelper.User) {
return user.equals(bizzId);
}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ else if (field.getType() == FieldType.DATE && valueLen == 10) {
EasyMetaFactory.valueOf(field).getExtraAttr(EasyFieldConfigProps.DATE_FORMAT),
DisplayType.DATE.getDefaultFormat());

// v3.7 BW 无需修正,值由用户提供
if (ParseHelper.BW.equals(op)) dateFormat = "0";

if (dateFormat.length() == 4) {
value = value.substring(0, 4) + "-01-01";
} else if (dateFormat.length() == 7) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,12 @@ else if (isOne2One) {
}

// v3.3 修改/清空时修改前值
// TODO N2N 是否也需要???
boolean clearFields = ((JSONObject) actionContext.getActionContent()).getBooleanValue("clearFields");
if (clearFields) {
Record beforeRecord = operatingContext.getBeforeRecord();
Object beforeValue = beforeRecord == null ? null : beforeRecord.getObjectValue(targetFieldEntity[0]);
if (beforeValue != null && !beforeValue.equals(o)) {
fieldWritebackRefresh = new FieldWritebackRefresh(this, (ID) beforeValue);
fieldWritebackRefresh = new FieldWritebackRefresh(this, beforeValue);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import com.rebuild.core.service.general.OperatingContext;
import com.rebuild.core.service.trigger.ActionContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collections;
import java.util.HashSet;

/**
* @author RB
Expand All @@ -27,16 +28,18 @@
public class FieldWritebackRefresh {

final private FieldWriteback parent;
final private ID beforeValue;
// ID or ID[]
final private Object beforeValue;

protected FieldWritebackRefresh(FieldWriteback parent, ID beforeValue) {
protected FieldWritebackRefresh(FieldWriteback parent, Object beforeValue) {
this.parent = parent;
this.beforeValue = beforeValue;
}

/**
*/
public void refresh() {
if (beforeValue instanceof ID[] && ((ID[]) beforeValue).length == 0) return;
if (NullValue.isNull(beforeValue)) return;

ID triggerUser = UserService.SYSTEM_USER;
Expand All @@ -48,7 +51,10 @@ public void refresh() {
FieldWriteback fa = new FieldWriteback(actionContext);
fa.sourceEntity = parent.sourceEntity;
fa.targetEntity = parent.targetEntity;
fa.targetRecordIds = Collections.singleton(beforeValue);

fa.targetRecordIds = new HashSet<>();
if (beforeValue instanceof ID[]) CollectionUtils.addAll(fa.targetRecordIds, (ID[]) beforeValue);
else fa.targetRecordIds.add((ID) beforeValue);

ID fakeSourceId = EntityHelper.newUnsavedId(fa.sourceEntity.getEntityCode());
Record fakeSourceRecord = EntityHelper.forUpdate(fakeSourceId, triggerUser, false);
Expand Down
61 changes: 61 additions & 0 deletions src/main/java/com/rebuild/core/support/setup/DbInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*!
Copyright (c) REBUILD <https://getrebuild.com/> and/or its owners. All rights reserved.
rebuild is dual-licensed under commercial and open source licenses (GPLv3).
See LICENSE and COMMERCIAL in the project root for license information.
*/

package com.rebuild.core.support.setup;

/**
* @author RB
* @since 2024/4/10
*/
public class DbInfo {

final private String desc;

protected DbInfo(String desc) {
this.desc = desc;
}

public boolean isOceanBase() {
return desc.contains("OceanBase");
}

public boolean isH2() {
return desc.contains("H2");
}

public boolean isMySQL56() {
if (isOceanBase()) return false;
return desc.contains("5.6.");
}

public boolean isMySQL80() {
if (isOceanBase()) return false;
return desc.contains("8.0.") || desc.contains("8.1.");
}

/**
* @param L
* @return
*/
protected boolean isIgnoredSqlLine(String L) {
if (isH2()) {
// NOTE `double` 字段也不支持
return L.startsWith("fulltext ") || L.startsWith("unique ") || L.startsWith("index ");
}

if (isOceanBase()) {
return L.startsWith("fulltext ");
}

if (isMySQL56()) {
// FIXME 针对实体,注意后续添加
return L.startsWith("index IX0_attachment_folder");
}

return false;
}
}
Loading

0 comments on commit bcdd1e0

Please sign in to comment.