mirror of
https://github.com/getrebuild/rebuild.git
synced 2025-03-13 15:44:26 +08:00
fix: gitee#I5CXCS
This commit is contained in:
parent
4e55fc45ac
commit
6937cf1933
5 changed files with 25 additions and 11 deletions
2
@rbv
2
@rbv
|
@ -1 +1 @@
|
|||
Subproject commit 6f7dfcf6335fe0b8dc200cabc6702a53cf70fe28
|
||||
Subproject commit 5b9bdef713305913a18d48182595f22b1fa5125a
|
|
@ -14,6 +14,7 @@ import cn.devezhao.persist4j.Field;
|
|||
import cn.devezhao.persist4j.Record;
|
||||
import cn.devezhao.persist4j.dialect.FieldType;
|
||||
import cn.devezhao.persist4j.engine.ID;
|
||||
import cn.devezhao.persist4j.engine.NullValue;
|
||||
import cn.devezhao.persist4j.engine.StandardRecord;
|
||||
import cn.devezhao.persist4j.metadata.MissingMetaExcetion;
|
||||
import cn.devezhao.persist4j.record.RecordVisitor;
|
||||
|
@ -56,7 +57,12 @@ import java.util.*;
|
|||
@Slf4j
|
||||
public class FieldWriteback extends FieldAggregation {
|
||||
|
||||
public static final String WB_ONE2ONE = "one2one";
|
||||
/**
|
||||
* 设:线索1、客户N(即 1 <:> N)
|
||||
* 当线索作为目标,客户作为源时,更新客户时只会更新 1 个线索(one2one)
|
||||
* 当客户作为目标,线索作为源时,更新线索时会更新 N 个客户
|
||||
*/
|
||||
public static final String ONE2ONE_MODE = "one2one";
|
||||
|
||||
private static final String DATE_EXPR = "#";
|
||||
private static final String CODE_PREFIX = "{{{{"; // ends with }}}}
|
||||
|
@ -140,7 +146,7 @@ public class FieldWriteback extends FieldAggregation {
|
|||
sourceEntity = actionContext.getSourceEntity();
|
||||
targetEntity = MetadataHelper.getEntity(targetFieldEntity[1]);
|
||||
|
||||
boolean isOne2One = ((JSONObject) actionContext.getActionContent()).getBooleanValue(WB_ONE2ONE);
|
||||
boolean isOne2One = ((JSONObject) actionContext.getActionContent()).getBooleanValue(ONE2ONE_MODE);
|
||||
|
||||
targetRecordIds = new HashSet<>();
|
||||
|
||||
|
@ -149,12 +155,20 @@ public class FieldWriteback extends FieldAggregation {
|
|||
targetRecordIds.add(actionContext.getSourceRecord());
|
||||
|
||||
} else if (isOne2One) {
|
||||
// 只会存在一个记录
|
||||
// 只会存在一个记录的
|
||||
Record afterRecord = operatingContext.getAfterRecord();
|
||||
ID referenceId = afterRecord == null ? null : afterRecord.getID(targetFieldEntity[0]);
|
||||
if (referenceId == null) return;
|
||||
if (afterRecord == null) return;
|
||||
|
||||
targetRecordIds.add(referenceId);
|
||||
ID referenceId;
|
||||
if (afterRecord.hasValue(targetFieldEntity[0])) {
|
||||
referenceId = afterRecord.getID(targetFieldEntity[0]);
|
||||
if (NullValue.is(referenceId)) referenceId = null;
|
||||
} else {
|
||||
Object[] o = Application.getQueryFactory().uniqueNoFilter(afterRecord.getPrimary(), targetFieldEntity[0]);
|
||||
referenceId = (ID) o[0];
|
||||
}
|
||||
|
||||
if (referenceId != null) targetRecordIds.add(referenceId);
|
||||
|
||||
} else {
|
||||
String sql = String.format("select %s from %s where %s = ?",
|
||||
|
|
|
@ -61,7 +61,6 @@ public class FieldWritebackController extends BaseController {
|
|||
}
|
||||
|
||||
// 我引用了谁 v2.7.1
|
||||
// 通常用于一对一,如果业务上存在多对一可能冲突(会以最后触发的记录为准)
|
||||
|
||||
for (Field refFrom : MetadataSorter.sortFields(sourceEntity, DisplayType.REFERENCE)) {
|
||||
if (MetadataHelper.isCommonsField(refFrom)) {
|
||||
|
@ -75,7 +74,7 @@ public class FieldWritebackController extends BaseController {
|
|||
|
||||
String entityLabel = String.format("%s (%s.%s)",
|
||||
EasyMetaFactory.getLabel(refEntity), EasyMetaFactory.getLabel(sourceEntity), EasyMetaFactory.getLabel(refFrom));
|
||||
entities.add(new String[] { refEntity.getName(), entityLabel, refFrom.getName(), FieldWriteback.WB_ONE2ONE});
|
||||
entities.add(new String[] { refEntity.getName(), entityLabel, refFrom.getName(), FieldWriteback.ONE2ONE_MODE});
|
||||
}
|
||||
|
||||
FieldAggregationController.sortEntities(entities, sourceEntity);
|
||||
|
|
|
@ -2209,5 +2209,6 @@
|
|||
"确认解锁?":"确认解锁?",
|
||||
"解锁":"解锁",
|
||||
"列表模板":"列表模板",
|
||||
"未启用":"未启用"
|
||||
"未启用":"未启用",
|
||||
"请至少添加 1 个更新规则":"请至少添加 1 个更新规则"
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ class ContentFieldWriteback extends ActionContentSpec {
|
|||
return false
|
||||
}
|
||||
if (content.items.length === 0) {
|
||||
RbHighbar.create($L('请至少添加 1 个聚合规则'))
|
||||
RbHighbar.create($L('请至少添加 1 个更新规则'))
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue