isdeleted

This commit is contained in:
FangfangZhao 2018-12-25 02:24:47 +08:00
parent 6e5bc58a25
commit 9b287028c0
9 changed files with 53 additions and 29 deletions

View file

@ -256,7 +256,7 @@ public class FormManager extends LayoutManager {
}
}
else if (dt == DisplayType.SERIES) {
el.put("value", "自动生成");
el.put("value", "自动值 (保存后显示)");
}
// TODO 字段的默认值

View file

@ -117,8 +117,6 @@ public class EntityHelper {
// 公共字段
public static final String AutoId = "autoId";
public static final String QuickCode = "quickCode";
public static final String CreatedOn = "createdOn";
public static final String CreatedBy = "createdBy";
public static final String ModifiedOn = "modifiedOn";
@ -126,6 +124,10 @@ public class EntityHelper {
public static final String OwningUser = "owningUser";
public static final String OwningDept = "owningDept";
public static final String AutoId = "autoId";
public static final String QuickCode = "quickCode";
public static final String IsDeleted = "isDeleted";
// 系统实体
public static final int User = 1;

View file

@ -35,7 +35,6 @@ import cn.devezhao.commons.CalendarUtils;
import cn.devezhao.persist4j.Entity;
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.record.JsonRecordCreator;
@ -102,8 +101,7 @@ public class ExtRecordCreator extends JsonRecordCreator {
List<String> notNulls = new ArrayList<String>();
for (Field field : entity.getFields()) {
String fieldName = field.getName();
if (FieldType.PRIMARY.equals(field.getType()) || field.isAutoValue() || fieldName.equalsIgnoreCase(EntityHelper.QuickCode)) {
if (MetadataHelper.isSystemField(field)) {
continue;
}
EasyMeta easy = EasyMeta.valueOf(field);

View file

@ -189,6 +189,25 @@ public class MetadataHelper {
return false;
}
/**
* 仅供系统使用的字段
*
* @param field
* @return
*/
public static boolean isSystemField(Field field) {
String fieldName = field.getName();
if (EntityHelper.AutoId.equalsIgnoreCase(fieldName)
|| EntityHelper.QuickCode.equalsIgnoreCase(fieldName)
|| EntityHelper.IsDeleted.equalsIgnoreCase(fieldName)) {
return true;
}
if (field.getType() == FieldType.PRIMARY) {
return true;
}
return false;
}
/**
* 是否 Bizz 实体
*

View file

@ -35,7 +35,6 @@ import com.rebuild.server.metadata.entityhub.EasyMeta;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
import cn.devezhao.persist4j.dialect.FieldType;
import cn.devezhao.persist4j.engine.ID;
import cn.devezhao.persist4j.metadata.BaseMeta;
@ -138,7 +137,7 @@ public class MetadataSorter {
if (dtAllowed == null || dtAllowed.length == 0) {
List<Field> list = new ArrayList<>();
for (Field field : fields) {
if (!(field.getType() == FieldType.PRIMARY || field.isAutoValue() || EntityHelper.QuickCode.equalsIgnoreCase(field.getName()))) {
if (!MetadataHelper.isSystemField(field)) {
list.add(field);
}
}

View file

@ -52,6 +52,7 @@ public class EasyMeta implements BaseMeta {
static {
BUILTIN_FIELD.add(EntityHelper.AutoId);
BUILTIN_FIELD.add(EntityHelper.QuickCode);
BUILTIN_FIELD.add(EntityHelper.IsDeleted);
BUILTIN_FIELD.add(EntityHelper.CreatedOn);
BUILTIN_FIELD.add(EntityHelper.CreatedBy);
BUILTIN_FIELD.add(EntityHelper.ModifiedOn);
@ -138,7 +139,7 @@ public class EasyMeta implements BaseMeta {
}
/**
* 系统内建字段一般系统用
* 系统内建字段
*
* @return
*/
@ -148,11 +149,10 @@ public class EasyMeta implements BaseMeta {
}
if (isField()) {
DisplayType dt = getDisplayType();
Field field = (Field) this.baseMeta;
if (dt == DisplayType.ID || BUILTIN_FIELD.contains(getName())) {
if (MetadataHelper.isSystemField(field) || BUILTIN_FIELD.contains(getName())) {
return true;
} else if (dt == DisplayType.REFERENCE) {
} else if (getDisplayType() == DisplayType.REFERENCE) {
// 明细-引用主记录的字段也是内建
Entity hasMaster = field.getOwnEntity().getMasterEntity();
if (hasMaster != null && hasMaster.equals(field.getReferenceEntity()) && !field.isCreatable()) {

View file

@ -121,10 +121,12 @@ public class Entity2Schema extends Field2Schema {
try {
String primaryFiled = entityName + "Id";
createBuiltinField(tempEntity, primaryFiled, "ID", DisplayType.ID, null, null, null);
// 数字自增 ID
// 自增ID
createBuiltinField(tempEntity, EntityHelper.AutoId, "AUTOID", DisplayType.NUMBER, null, null, null);
// 助记码/搜索码
createBuiltinField(tempEntity, EntityHelper.QuickCode, "QUICKCODE", DisplayType.TEXT, null, null, null);
// 是否删除
createBuiltinField(tempEntity, EntityHelper.IsDeleted, "ISDELETED", DisplayType.BOOL, null, null, null);
if (haveNameField) {
createField(tempEntity, nameFiled, entityLabel + "名称", DisplayType.TEXT, false, true, true, null, null, null, false);

View file

@ -218,9 +218,11 @@ public class Field2Schema {
tempMetaId.add(record.getPrimary());
boolean autoValue = EntityHelper.AutoId.equals(fieldName);
String defaultValue = EntityHelper.IsDeleted.equals(fieldName) ? "F" : null;
Field unsafeField = new FieldImpl(
fieldName, physicalName, fieldLabel, entity, displayType.getFieldType(), CascadeModel.Ignore, displayType.getMaxLength(),
dbNullable, creatable, updatable, true, 6, null, autoValue);
dbNullable, creatable, updatable, true, 6, defaultValue, autoValue);
if (entity instanceof UnsafeEntity) {
((UnsafeEntity) entity).addField(unsafeField);
}

View file

@ -126,14 +126,17 @@ public class GeneralEntityService extends BaseService {
}
DisplayType dt = EasyMeta.getDisplayType(nameField);
if (dt == DisplayType.TEXT) {
if (dt != DisplayType.TEXT) {
return;
}
String name = record.getString(nameField.getName());
String qcode = null;
if (StringUtils.isNotBlank(name)) {
try {
qcode = PinyinHelper.getShortPinyin(name).toUpperCase();
} catch (Exception e) {
LOG.error("ShortPinyin : " + name, e);
LOG.error("QuickCode shorting error : " + name, e);
}
}
@ -143,7 +146,6 @@ public class GeneralEntityService extends BaseService {
record.setString(EntityHelper.QuickCode, qcode);
}
}
}
/**
* 设置自动编号