@@ -1,6 +1,7 @@ | |||||
package cc.smtweb.framework.core.cache; | package cc.smtweb.framework.core.cache; | ||||
import cc.smtweb.framework.core.annotation.SwCache; | import cc.smtweb.framework.core.annotation.SwCache; | ||||
import cc.smtweb.framework.core.common.SwConsts; | |||||
import cc.smtweb.framework.core.redis.RedisBroadcastEvent; | import cc.smtweb.framework.core.redis.RedisBroadcastEvent; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | import cc.smtweb.framework.core.redis.RedisManager; | ||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
@@ -30,7 +31,6 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||||
protected final static int LS_LOADING = 1; | protected final static int LS_LOADING = 1; | ||||
protected final static int LS_LOADED = 2; | protected final static int LS_LOADED = 2; | ||||
private final static String SPLIT_CHAR = "-"; | |||||
//唯一标识 | //唯一标识 | ||||
protected String ident; | protected String ident; | ||||
//展示名称 | //展示名称 | ||||
@@ -278,7 +278,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||||
//本地调用,删除一个对象时,更新列表缓存 | //本地调用,删除一个对象时,更新列表缓存 | ||||
private void doRemoveList(String regionKey, String key, T value) { | private void doRemoveList(String regionKey, String key, T value) { | ||||
if (StringUtils.isEmpty(key)) return; | if (StringUtils.isEmpty(key)) return; | ||||
Set<T> list = mapListLocal.get(regionKey + SPLIT_CHAR + key); | |||||
Set<T> list = mapListLocal.get(regionKey + SwConsts.SPLIT_CHAR + key); | |||||
if (list == null) { | if (list == null) { | ||||
return; | return; | ||||
} | } | ||||
@@ -297,7 +297,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||||
//本地调用,更新列表缓存 | //本地调用,更新列表缓存 | ||||
private void doUpdateList(String regionKey, String key, T value) { | private void doUpdateList(String regionKey, String key, T value) { | ||||
if (StringUtils.isEmpty(key)) return; | if (StringUtils.isEmpty(key)) return; | ||||
Set<T> list = mapListLocal.computeIfAbsent(regionKey + SPLIT_CHAR + key, k -> new LinkedHashSet<>()); | |||||
Set<T> list = mapListLocal.computeIfAbsent(regionKey + SwConsts.SPLIT_CHAR + key, k -> new LinkedHashSet<>()); | |||||
list.add(value); | list.add(value); | ||||
} | } | ||||
@@ -361,7 +361,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||||
} | } | ||||
public final Set<T> getListByKey(String rk, String key) { | public final Set<T> getListByKey(String rk, String key) { | ||||
return mapListLocal.get(rk + SPLIT_CHAR + key); | |||||
return mapListLocal.get(rk + SwConsts.SPLIT_CHAR + key); | |||||
} | } | ||||
/** | /** | ||||
@@ -1,10 +1,14 @@ | |||||
package cc.smtweb.framework.core.common; | package cc.smtweb.framework.core.common; | ||||
import lombok.Data; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/23 9:46 | * Created by Akmm at 2022/3/23 9:46 | ||||
*/ | */ | ||||
public interface SwConsts { | public interface SwConsts { | ||||
//树节点按parent的key | |||||
//缓存中:树节点按parent的key | |||||
String KEY_PARENT_ID = "pr"; | String KEY_PARENT_ID = "pr"; | ||||
//级次码、字符串连接符 | |||||
String SPLIT_CHAR = "-"; | |||||
} | } |
@@ -1,9 +1,71 @@ | |||||
package cc.smtweb.framework.core.common; | package cc.smtweb.framework.core.common; | ||||
import lombok.Data; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/23 9:39 | * Created by Akmm at 2022/3/23 9:39 | ||||
* 系统的一些枚举变量 | * 系统的一些枚举变量 | ||||
*/ | */ | ||||
public interface SwEnum { | public interface SwEnum { | ||||
/** | |||||
* Created by Akmm at 2022/2/9 10:01 | |||||
* 字段业务类别 | |||||
*/ | |||||
class FieldType extends IntEnum{ | |||||
public static FieldType instance = new FieldType(); | |||||
public static IntEnumBean ID = instance.addEnum(0, "主键"); | |||||
public static IntEnumBean PARENT_ID = instance.addEnum(1, "父ID"); | |||||
public static IntEnumBean LEVEL_CODE = instance.addEnum(2, "级次码"); | |||||
public static IntEnumBean ORDER = instance.addEnum(3, "排序字段"); | |||||
public static IntEnumBean CODE = instance.addEnum(4, "编码字段"); | |||||
public static IntEnumBean NAME = instance.addEnum(5, "名称字段"); | |||||
public static IntEnumBean CREATE_TIME = instance.addEnum(6, "创建时间"); | |||||
public static IntEnumBean LAST_TIME = instance.addEnum(7, "更新时间"); | |||||
} | |||||
/** | |||||
* 数据类型定义,参见design_db.yaml配置 | |||||
*/ | |||||
@Data | |||||
class DataType { | |||||
/*{type: "id", name: "ID", sql-type: "bigint", java-type: "long", widget: "fz-field-long", defaultValue: "0"} | |||||
- {type: "code", name: "编码", sql-type: "varchar", java-type: "string", data-length: 32, widget: "fz-field-string", defaultValue: ""} | |||||
- {type: "name", name: "名字", sql-type: "varchar", java-type: "string", data-length: 100, widget: "fz-field-string", defaultValue: ""} | |||||
- {type: "remark", name: "备注", sql-type: "varchar", data-length: 255, java-type: "string", widget: "fz-field-string", defaultValue: ""} | |||||
- {type: "text", name: "大文本", sql-type: "text", java-type: "string", widget: "fz-field-string", defaultValue: ""} | |||||
- {type: "currency", name: "货币", sql-type: "bigint", java-type: "long", widget: "fz-field-long", defaultValue: "0"} | |||||
- {type: "datetime", name: "时间日期", sql-type: "bigint", java-type: "long", widget: "fz-field-datetime", defaultValue: "0"} | |||||
- {type: "date", name: "日期", sql-type: "int", java-type: "int", widget: "fz-field-date", defaultValue: "0"} | |||||
- {type: "time", name: "时间", sql-type: "int", java-type: "int", widget: "fz-field-time", defaultValue: "0"} | |||||
- {type: "int", name: "整型", sql-type: "int", java-type: "int", widget: "fz-field-int", defaultValue: "0"} | |||||
- {type: "smallint", name: "短整型", sql-type: "smallint", java-type: "short", widget: "fz-field-int", defaultValue: "0"} | |||||
- {type: "bool", name: "布尔型", sql-type: "tinyint", java-type: "boolean", widget: "fz-field-bool", defaultValue: "0"}*/ | |||||
public static final String TYPE_STR = "varchar"; | |||||
public static final String TYPE_BOOL = "bool"; | |||||
public static final String TYPE_DATETIME = "datetime"; | |||||
public static final String TYPE_DATE = "date"; | |||||
private String type; | |||||
private String name; | |||||
private String sqlType; | |||||
private int dataLength; | |||||
private String javaType; | |||||
private String defaultValue; | |||||
} | |||||
/** | |||||
* 表类型 | |||||
*/ | |||||
class TableType extends IntEnum { | |||||
public static TableType instance = new TableType(); | |||||
public static AbstractEnum.IntEnumBean TYPE_GENERAL = instance.addEnum(0, "普通表"); | |||||
public static AbstractEnum.IntEnumBean TYPE_TREE = instance.addEnum(1, "树型表"); | |||||
public static AbstractEnum.IntEnumBean TYPE_CODE = instance.addEnum(2, "编码表"); | |||||
public static AbstractEnum.IntEnumBean TYPE_ABSTACT = instance.addEnum(3, "虚拟抽象表"); | |||||
public static AbstractEnum.IntEnumBean TYPE_VIEW = instance.addEnum(4, "视图"); | |||||
} | |||||
} | } |
@@ -1,21 +1,15 @@ | |||||
package cc.smtweb.framework.core.db; | package cc.smtweb.framework.core.db; | ||||
import cc.smtweb.framework.core.SwException; | import cc.smtweb.framework.core.SwException; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.dao.AbstractEntityDao; | import cc.smtweb.framework.core.db.dao.AbstractEntityDao; | ||||
import cc.smtweb.framework.core.db.dao.EntityColumn; | import cc.smtweb.framework.core.db.dao.EntityColumn; | ||||
import cc.smtweb.framework.core.db.jdbc.JdbcEngine; | import cc.smtweb.framework.core.db.jdbc.JdbcEngine; | ||||
import cc.smtweb.framework.core.db.vo.KeyValueVO; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.dao.DataAccessException; | |||||
import org.springframework.jdbc.core.ResultSetExtractor; | |||||
import org.springframework.jdbc.core.RowMapper; | |||||
import java.sql.ResultSet; | |||||
import java.sql.SQLException; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -147,7 +141,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> { | |||||
sql.append("insert into ").append(tableName).append("("); | sql.append("insert into ").append(tableName).append("("); | ||||
List<String> listFields = adjustFields(fields, FieldType.CREATE_TIME, FieldType.LAST_TIME); | |||||
List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value); | |||||
List<EntityColumn> insertColumns = new ArrayList<>(this.columns.size()); | List<EntityColumn> insertColumns = new ArrayList<>(this.columns.size()); | ||||
if (listFields == null) { | if (listFields == null) { | ||||
@@ -262,7 +256,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> { | |||||
*/ | */ | ||||
public Map<String, String> queryNames(List<String> ids) { | public Map<String, String> queryNames(List<String> ids) { | ||||
if (ids == null || ids.isEmpty()) return new HashMap<>(); | if (ids == null || ids.isEmpty()) return new HashMap<>(); | ||||
ModelField field = modelTable.findFieldByType(FieldType.NAME); | |||||
ModelField field = modelTable.findFieldByType(SwEnum.FieldType.NAME.value); | |||||
if (field == null) return new HashMap<>(); | if (field == null) return new HashMap<>(); | ||||
StringBuilder sb = new StringBuilder(); | StringBuilder sb = new StringBuilder(); | ||||
@@ -1,6 +1,6 @@ | |||||
package cc.smtweb.framework.core.db.config; | package cc.smtweb.framework.core.db.config; | ||||
import cc.smtweb.framework.core.db.vo.def.DataType; | |||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import org.springframework.boot.context.properties.ConfigurationProperties; | import org.springframework.boot.context.properties.ConfigurationProperties; | ||||
import org.springframework.context.annotation.PropertySource; | import org.springframework.context.annotation.PropertySource; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
@@ -14,16 +14,16 @@ import java.util.Map; | |||||
@PropertySource(value = "classpath:config/design_db.yaml", factory = YamlPropertyLoaderFactory.class) | @PropertySource(value = "classpath:config/design_db.yaml", factory = YamlPropertyLoaderFactory.class) | ||||
@ConfigurationProperties(prefix = "design") | @ConfigurationProperties(prefix = "design") | ||||
public class DesignConfig { | public class DesignConfig { | ||||
private List<DataType> dataTypes; | |||||
private List<SwEnum.DataType> dataTypes; | |||||
private Map<String, DataType> mapType = null; | |||||
private Map<String, SwEnum.DataType> mapType = null; | |||||
private void adjustMap() { | private void adjustMap() { | ||||
if (mapType == null) { | if (mapType == null) { | ||||
synchronized (DesignConfig.class) { | synchronized (DesignConfig.class) { | ||||
if (mapType == null) { | if (mapType == null) { | ||||
Map<String, DataType> map = new HashMap<>(); | |||||
for (DataType type : dataTypes) { | |||||
Map<String, SwEnum.DataType> map = new HashMap<>(); | |||||
for (SwEnum.DataType type : dataTypes) { | |||||
map.put(type.getType(), type); | map.put(type.getType(), type); | ||||
} | } | ||||
mapType = map; | mapType = map; | ||||
@@ -32,12 +32,12 @@ public class DesignConfig { | |||||
} | } | ||||
} | } | ||||
public DataType getDataType(String type) { | |||||
public SwEnum.DataType getDataType(String type) { | |||||
adjustMap(); | adjustMap(); | ||||
return mapType.get(type); | return mapType.get(type); | ||||
} | } | ||||
public List<DataType> getDataTypes() { | |||||
public List<SwEnum.DataType> getDataTypes() { | |||||
return dataTypes; | return dataTypes; | ||||
} | } | ||||
} | } |
@@ -2,10 +2,10 @@ package cc.smtweb.framework.core.db.dao; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.AbstractEnum; | |||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.BaseBean; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.exception.DbException; | import cc.smtweb.framework.core.exception.DbException; | ||||
@@ -123,7 +123,7 @@ public abstract class AbstractEntityDao<T> { | |||||
columns.put(field.getName(), beanColumn); | columns.put(field.getName(), beanColumn); | ||||
} | } | ||||
protected void updateTime(T obj, FieldType type) { | |||||
protected void updateTime(T obj, int type) { | |||||
ModelField field = modelTable.findFieldByType(type); | ModelField field = modelTable.findFieldByType(type); | ||||
if (field == null) return; | if (field == null) return; | ||||
EntityColumn col = columns.get(field.getName()); | EntityColumn col = columns.get(field.getName()); | ||||
@@ -138,7 +138,7 @@ public abstract class AbstractEntityDao<T> { | |||||
* @param fields | * @param fields | ||||
* @return | * @return | ||||
*/ | */ | ||||
protected List<String> adjustFields(String fields, FieldType... types) { | |||||
protected List<String> adjustFields(String fields, int... types) { | |||||
if (StringUtils.isEmpty(fields)) return null; | if (StringUtils.isEmpty(fields)) return null; | ||||
String[] fieldNames = fields.toLowerCase().split(","); | String[] fieldNames = fields.toLowerCase().split(","); | ||||
List<String> listFields = new ArrayList<>(fieldNames.length + 2); | List<String> listFields = new ArrayList<>(fieldNames.length + 2); | ||||
@@ -150,7 +150,7 @@ public abstract class AbstractEntityDao<T> { | |||||
for (String name : fieldNames) { | for (String name : fieldNames) { | ||||
EntityColumn column = this.columns.get(name.trim()); | EntityColumn column = this.columns.get(name.trim()); | ||||
for (int i = 0, len = types.length; i < len; i++) { | for (int i = 0, len = types.length; i < len; i++) { | ||||
if (types[i].name().equalsIgnoreCase(column.getField().getFieldType())) { | |||||
if (types[i]== column.getField().getFieldType()) { | |||||
includeTypes[i] = true; | includeTypes[i] = true; | ||||
} | } | ||||
} | } | ||||
@@ -175,11 +175,11 @@ public abstract class AbstractEntityDao<T> { | |||||
*/ | */ | ||||
protected Object[] handleInsert(T obj, StringBuilder sql, String fields) { | protected Object[] handleInsert(T obj, StringBuilder sql, String fields) { | ||||
List<Object> result; | List<Object> result; | ||||
List<String> listFields = adjustFields(fields, FieldType.CREATE_TIME, FieldType.LAST_TIME); | |||||
List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value); | |||||
sql.append("insert into ").append(tableName).append("("); | sql.append("insert into ").append(tableName).append("("); | ||||
updateTime(obj, FieldType.CREATE_TIME); | |||||
updateTime(obj, FieldType.LAST_TIME); | |||||
updateTime(obj, SwEnum.FieldType.CREATE_TIME.value); | |||||
updateTime(obj, SwEnum.FieldType.LAST_TIME.value); | |||||
if (listFields == null) { | if (listFields == null) { | ||||
result = new ArrayList<>(this.columns.size()); | result = new ArrayList<>(this.columns.size()); | ||||
@@ -222,8 +222,8 @@ public abstract class AbstractEntityDao<T> { | |||||
protected Object[] handleUpdate(T obj, StringBuilder sql, String fields, String whereFields) { | protected Object[] handleUpdate(T obj, StringBuilder sql, String fields, String whereFields) { | ||||
EntityColumn idColumn = findIdColumn(); | EntityColumn idColumn = findIdColumn(); | ||||
List<String> listFields = adjustFields(fields, FieldType.LAST_TIME); | |||||
updateTime(obj, FieldType.LAST_TIME); | |||||
List<String> listFields = adjustFields(fields, SwEnum.FieldType.LAST_TIME.value); | |||||
updateTime(obj, SwEnum.FieldType.LAST_TIME.value); | |||||
sql.append("update ").append(tableName).append(" set "); | sql.append("update ").append(tableName).append(" set "); | ||||
List<Object> result = new ArrayList<>(); | List<Object> result = new ArrayList<>(); | ||||
@@ -13,16 +13,16 @@ import java.io.Serializable; | |||||
*/ | */ | ||||
public class DefaultEntity extends BaseBean implements Serializable, Cloneable { | public class DefaultEntity extends BaseBean implements Serializable, Cloneable { | ||||
//表名 | //表名 | ||||
private String tableName; | |||||
private String _def_table_name; | |||||
public DefaultEntity() {} | public DefaultEntity() {} | ||||
public DefaultEntity(String tableName) { | |||||
this.tableName = tableName; | |||||
public DefaultEntity(String _def_table_name) { | |||||
this._def_table_name = _def_table_name; | |||||
} | } | ||||
public ModelTable getModelTable() { | public ModelTable getModelTable() { | ||||
return ModelTableCache.getInstance().getByName(tableName); | |||||
return ModelTableCache.getInstance().getByName(_def_table_name); | |||||
} | } | ||||
//根据实体定义,设默认值 | //根据实体定义,设默认值 | ||||
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.design.catalog; | |||||
package cc.smtweb.framework.core.db.vo; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |
@@ -1,11 +1,8 @@ | |||||
package cc.smtweb.framework.core.db.vo; | package cc.smtweb.framework.core.db.vo; | ||||
import cc.smtweb.framework.core.db.vo.def.DataType; | |||||
import com.fasterxml.jackson.annotation.JsonProperty; | import com.fasterxml.jackson.annotation.JsonProperty; | ||||
import lombok.Data; | import lombok.Data; | ||||
import java.util.List; | |||||
/** | /** | ||||
* 字段定义 | * 字段定义 | ||||
* {name:"字段名,如id",fieldType:"字段类型,如编码字段", dataType:"数据类型,如ID/CODE/NAME等", null:"0-空/1-非空", default: "默认值", title:"中文名",link:"外键关联表",editor:"控件类型:TEXT/TextArea/NUMBER/COMBO"} | * {name:"字段名,如id",fieldType:"字段类型,如编码字段", dataType:"数据类型,如ID/CODE/NAME等", null:"0-空/1-非空", default: "默认值", title:"中文名",link:"外键关联表",editor:"控件类型:TEXT/TextArea/NUMBER/COMBO"} | ||||
@@ -16,7 +13,7 @@ public class ModelField { | |||||
private String title; | private String title; | ||||
private String remark; | private String remark; | ||||
//字段类型,如编码字段,参见FieldTypeDef | //字段类型,如编码字段,参见FieldTypeDef | ||||
private String fieldType; | |||||
private int fieldType; | |||||
/** | /** | ||||
* 数据类型,参见DataType | * 数据类型,参见DataType | ||||
*/ | */ | ||||
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.design.project; | |||||
package cc.smtweb.framework.core.db.vo; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |
@@ -1,14 +1,14 @@ | |||||
package cc.smtweb.framework.core.db.vo; | package cc.smtweb.framework.core.db.vo; | ||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.common.AbstractEnum; | |||||
import cc.smtweb.framework.core.common.IntEnum; | |||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; | ||||
import lombok.Data; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.io.Serializable; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -250,12 +250,10 @@ public class ModelTable extends DefaultEntity { | |||||
return null; | return null; | ||||
} | } | ||||
public ModelField findFieldByType(FieldType type) { | |||||
if (type != null) { | |||||
for (ModelField value : fields) { | |||||
if (type.name().equalsIgnoreCase(value.getFieldType())) { | |||||
return value; | |||||
} | |||||
public ModelField findFieldByType(int type) { | |||||
for (ModelField value : fields) { | |||||
if (type == value.getFieldType()) { | |||||
return value; | |||||
} | } | ||||
} | } | ||||
@@ -281,7 +279,7 @@ public class ModelTable extends DefaultEntity { | |||||
if (linkTable == null) { | if (linkTable == null) { | ||||
continue; | continue; | ||||
} | } | ||||
ModelField linkNameField = linkTable.findFieldByType(FieldType.NAME); | |||||
ModelField linkNameField = linkTable.findFieldByType(SwEnum.FieldType.NAME.value); | |||||
if (linkNameField != null) { | if (linkNameField != null) { | ||||
list.add(new ModelLinkName(field.getName(), linkTable, linkNameField.getName())); | list.add(new ModelLinkName(field.getName(), linkTable, linkNameField.getName())); | ||||
} | } | ||||
@@ -1,33 +0,0 @@ | |||||
package cc.smtweb.framework.core.db.vo.def; | |||||
import lombok.Data; | |||||
/** | |||||
* 数据类型定义,参见design_db.yaml配置 | |||||
*/ | |||||
@Data | |||||
public class DataType { | |||||
/*{type: "id", name: "ID", sql-type: "bigint", java-type: "long", widget: "fz-field-long", defaultValue: "0"} | |||||
- {type: "code", name: "编码", sql-type: "varchar", java-type: "string", data-length: 32, widget: "fz-field-string", defaultValue: ""} | |||||
- {type: "name", name: "名字", sql-type: "varchar", java-type: "string", data-length: 100, widget: "fz-field-string", defaultValue: ""} | |||||
- {type: "remark", name: "备注", sql-type: "varchar", data-length: 255, java-type: "string", widget: "fz-field-string", defaultValue: ""} | |||||
- {type: "text", name: "大文本", sql-type: "text", java-type: "string", widget: "fz-field-string", defaultValue: ""} | |||||
- {type: "currency", name: "货币", sql-type: "bigint", java-type: "long", widget: "fz-field-long", defaultValue: "0"} | |||||
- {type: "datetime", name: "时间日期", sql-type: "bigint", java-type: "long", widget: "fz-field-datetime", defaultValue: "0"} | |||||
- {type: "date", name: "日期", sql-type: "int", java-type: "int", widget: "fz-field-date", defaultValue: "0"} | |||||
- {type: "time", name: "时间", sql-type: "int", java-type: "int", widget: "fz-field-time", defaultValue: "0"} | |||||
- {type: "int", name: "整型", sql-type: "int", java-type: "int", widget: "fz-field-int", defaultValue: "0"} | |||||
- {type: "smallint", name: "短整型", sql-type: "smallint", java-type: "short", widget: "fz-field-int", defaultValue: "0"} | |||||
- {type: "bool", name: "布尔型", sql-type: "tinyint", java-type: "boolean", widget: "fz-field-bool", defaultValue: "0"}*/ | |||||
public static final String TYPE_STR = "varchar"; | |||||
public static final String TYPE_BOOL = "bool"; | |||||
public static final String TYPE_DATETIME = "datetime"; | |||||
public static final String TYPE_DATE = "date"; | |||||
private String type; | |||||
private String name; | |||||
private String sqlType; | |||||
private int dataLength; | |||||
private String javaType; | |||||
private String defaultValue; | |||||
} |
@@ -1,24 +0,0 @@ | |||||
package cc.smtweb.framework.core.db.vo.def; | |||||
/** | |||||
* Created by Akmm at 2022/2/9 10:01 | |||||
* 字段业务类别 | |||||
*/ | |||||
public enum FieldType { | |||||
// 主键 | |||||
ID, | |||||
// 上级ID,树结构需要 | |||||
PARENT_ID, | |||||
//级次码 | |||||
LEVEL_CODE, | |||||
// 排序字段,树结构需要 | |||||
ORDER, | |||||
// 编码字段 | |||||
CODE, | |||||
// 名词字段 | |||||
NAME, | |||||
// 创建时间 | |||||
CREATE_TIME, | |||||
// 更新时间 | |||||
LAST_TIME | |||||
} |
@@ -1,14 +0,0 @@ | |||||
package cc.smtweb.framework.core.db.vo.def; | |||||
/** | |||||
* Created by Akmm at 2022/3/17 17:02 | |||||
*/ | |||||
public class TableType { | |||||
//0-普通表,1 树型表 2 编码表 9-虚拟抽象表 11 视图 | |||||
public static final int TYPE_GENERAL = 0; | |||||
public static final int TYPE_TREE = 1; | |||||
public static final int TYPE_CODE = 2; | |||||
public static final int TYPE_ABSTACT = 3; | |||||
public static final int TYPE_VIEW = 3; | |||||
} |
@@ -3,16 +3,12 @@ package cc.smtweb.framework.core.mvc.service; | |||||
import cc.smtweb.framework.core.R; | import cc.smtweb.framework.core.R; | ||||
import cc.smtweb.framework.core.SwException; | import cc.smtweb.framework.core.SwException; | ||||
import cc.smtweb.framework.core.SwMap; | import cc.smtweb.framework.core.SwMap; | ||||
import cc.smtweb.framework.core.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | |||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelLinkName; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.*; | import java.util.*; | ||||
@@ -77,10 +73,10 @@ public class DefaultComboHandler<T extends DefaultEntity> extends DefaultListHan | |||||
//构建参与搜索的字段,默认为code和name字段 | //构建参与搜索的字段,默认为code和name字段 | ||||
protected void getFilterFields(List<String> fields) { | protected void getFilterFields(List<String> fields) { | ||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ||||
ModelField field = table.findFieldByType(FieldType.CODE); | |||||
ModelField field = table.findFieldByType(SwEnum.FieldType.CODE.value); | |||||
if (field != null) fields.add(field.getName()); | if (field != null) fields.add(field.getName()); | ||||
field = table.findFieldByType(FieldType.NAME); | |||||
field = table.findFieldByType(SwEnum.FieldType.NAME.value); | |||||
if (field != null) fields.add(field.getName()); | if (field != null) fields.add(field.getName()); | ||||
} | } | ||||
} | } |
@@ -3,6 +3,7 @@ package cc.smtweb.framework.core.mvc.service; | |||||
import cc.smtweb.framework.core.SwMap; | import cc.smtweb.framework.core.SwMap; | ||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
@@ -10,7 +11,6 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelLinkName; | import cc.smtweb.framework.core.db.vo.ModelLinkName; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.*; | import java.util.*; | ||||
@@ -61,7 +61,7 @@ public class DefaultListHandler<T extends DefaultEntity> extends AbstractListHan | |||||
if (table == null) return; | if (table == null) return; | ||||
sql.append(" order by "); | sql.append(" order by "); | ||||
ModelField field = table.findFieldByType(FieldType.CODE); | |||||
ModelField field = table.findFieldByType(SwEnum.FieldType.CODE.value); | |||||
if (field != null) sql.append(field.getName()).append(","); | if (field != null) sql.append(field.getName()).append(","); | ||||
sql.append(table.getIdField()); | sql.append(table.getIdField()); | ||||
} | } | ||||
@@ -4,6 +4,7 @@ import cc.smtweb.framework.core.R; | |||||
import cc.smtweb.framework.core.SwException; | import cc.smtweb.framework.core.SwException; | ||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
@@ -12,11 +13,8 @@ import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelIndex; | import cc.smtweb.framework.core.db.vo.ModelIndex; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||||
import cc.smtweb.framework.core.db.vo.def.TableType; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.Collection; | |||||
import java.util.List; | import java.util.List; | ||||
/** | /** | ||||
@@ -86,7 +84,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||||
} else { | } else { | ||||
dao.updateEntity(bean); | dao.updateEntity(bean); | ||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ||||
if (table.getType() == TableType.TYPE_TREE) { | |||||
if (table.getType() == SwEnum.TableType.TYPE_TREE.value) { | |||||
listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); | listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); | ||||
} | } | ||||
} | } | ||||
@@ -123,7 +121,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||||
//树,改变父亲 | //树,改变父亲 | ||||
protected R changeParent() throws Exception { | protected R changeParent() throws Exception { | ||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ||||
if (table.getType() != TableType.TYPE_TREE) throw new SwException("非树型表,不支持更改父节点"); | |||||
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) throw new SwException("非树型表,不支持更改父节点"); | |||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
long parentId = params.readLong("parent_id"); | long parentId = params.readLong("parent_id"); | ||||
@@ -135,7 +133,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||||
bean = loadComp(id); | bean = loadComp(id); | ||||
} | } | ||||
//不考虑没有级次码等情况,这个在表设计时校验 | //不考虑没有级次码等情况,这个在表设计时校验 | ||||
ModelField fieldParentCode = table.findFieldByType(FieldType.PARENT_ID); | |||||
ModelField fieldParentCode = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value); | |||||
bean.put(fieldParentCode.getName(), parentId); | bean.put(fieldParentCode.getName(), parentId); | ||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | DbEngine.getInstance().doTrans(new AbsDbWorker() { | ||||
@@ -4,14 +4,13 @@ import cc.smtweb.framework.core.SwException; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.SwConsts; | import cc.smtweb.framework.core.common.SwConsts; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||||
import cc.smtweb.framework.core.db.vo.def.TableType; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
@@ -43,9 +42,9 @@ public class TreeHelper<T extends DefaultEntity> { | |||||
cache = CacheManager.getIntance().getCache(tableName); | cache = CacheManager.getIntance().getCache(tableName); | ||||
dao = DbEngine.getInstance().findDao(tableName); | dao = DbEngine.getInstance().findDao(tableName); | ||||
ModelField field = table.findFieldByType(FieldType.PARENT_ID); | |||||
ModelField field = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value); | |||||
fieldParent = field.getName(); | fieldParent = field.getName(); | ||||
field = table.findFieldByType(FieldType.LEVEL_CODE); | |||||
field = table.findFieldByType(SwEnum.FieldType.LEVEL_CODE.value); | |||||
fieldLevelCode = field.getName(); | fieldLevelCode = field.getName(); | ||||
} | } | ||||
@@ -75,7 +74,7 @@ public class TreeHelper<T extends DefaultEntity> { | |||||
public List<T> resetTreeLevel(T bean) throws Exception { | public List<T> resetTreeLevel(T bean) throws Exception { | ||||
List<T> list = new ArrayList<>(); | List<T> list = new ArrayList<>(); | ||||
if (table.getType() != TableType.TYPE_TREE) return list; | |||||
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return list; | |||||
if (!table.isNeedCache()) throw new SwException("请定义为需要缓存!"); | if (!table.isNeedCache()) throw new SwException("请定义为需要缓存!"); | ||||
T oldBean = cache.get(bean.getEntityId()); | T oldBean = cache.get(bean.getEntityId()); | ||||
@@ -88,7 +87,7 @@ public class TreeHelper<T extends DefaultEntity> { | |||||
private void resetParentChildren(T bean, List<T> list) throws Exception { | private void resetParentChildren(T bean, List<T> list) throws Exception { | ||||
T parent = cache.get(getParentId(bean)); | T parent = cache.get(getParentId(bean)); | ||||
if (parent != null) { | if (parent != null) { | ||||
bean.put(fieldLevelCode, getLevelCode(parent) + "-" + parent.getEntityId()); | |||||
bean.put(fieldLevelCode, getLevelCode(parent) + SwConsts.SPLIT_CHAR + parent.getEntityId()); | |||||
dao.updateEntity(bean, fieldLevelCode); | dao.updateEntity(bean, fieldLevelCode); | ||||
list.add(bean); | list.add(bean); | ||||
} | } | ||||
@@ -1,11 +1,8 @@ | |||||
package cc.smtweb.system.bpm.web.design.catalog; | |||||
package cc.smtweb.system.bpm.web.design.table; | |||||
import cc.smtweb.framework.core.R; | |||||
import cc.smtweb.framework.core.SwMap; | |||||
import cc.smtweb.framework.core.annotation.SwBody; | |||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.db.vo.ModelCatalog; | |||||
import cc.smtweb.framework.core.mvc.service.*; | import cc.smtweb.framework.core.mvc.service.*; | ||||
import cc.smtweb.framework.core.session.UserSession; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/1 17:00 | * Created by Akmm at 2022/3/1 17:00 |
@@ -1,18 +1,16 @@ | |||||
package cc.smtweb.system.bpm.web.design.catalog; | |||||
package cc.smtweb.system.bpm.web.design.table; | |||||
import cc.smtweb.framework.core.SwMap; | import cc.smtweb.framework.core.SwMap; | ||||
import cc.smtweb.framework.core.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.db.vo.ModelCatalog; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.mvc.service.AbstractTreeHandler; | import cc.smtweb.framework.core.mvc.service.AbstractTreeHandler; | ||||
import cc.smtweb.framework.core.mvc.service.TreeHelper; | import cc.smtweb.framework.core.mvc.service.TreeHelper; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.*; | import java.util.*; | ||||
@@ -2,9 +2,8 @@ package cc.smtweb.system.bpm.web.design.table; | |||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.db.vo.ModelDatabase; | import cc.smtweb.framework.core.db.vo.ModelDatabase; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
import cc.smtweb.framework.core.mvc.service.*; | import cc.smtweb.framework.core.mvc.service.*; | ||||
import cc.smtweb.system.bpm.web.design.catalog.ModelCatalog; | |||||
import cc.smtweb.framework.core.db.vo.ModelCatalog; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/22 9:12 | * Created by Akmm at 2022/3/22 9:12 | ||||
@@ -1,6 +1,7 @@ | |||||
package cc.smtweb.system.bpm.web.design.project; | |||||
package cc.smtweb.system.bpm.web.design.table; | |||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.db.vo.ModelProject; | |||||
import cc.smtweb.framework.core.mvc.service.*; | import cc.smtweb.framework.core.mvc.service.*; | ||||
/** | /** |
@@ -3,8 +3,7 @@ package cc.smtweb.system.bpm.web.design.table; | |||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.mvc.service.*; | import cc.smtweb.framework.core.mvc.service.*; | ||||
import cc.smtweb.system.bpm.web.design.catalog.ModelCatalog; | |||||
import cc.smtweb.system.bpm.web.design.catalog.ModelCatalogTreeHandler; | |||||
import cc.smtweb.framework.core.db.vo.ModelCatalog; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/22 9:12 | * Created by Akmm at 2022/3/22 9:12 | ||||
@@ -2,9 +2,9 @@ package cc.smtweb.system.bpm.web.task.service; | |||||
import cc.smtweb.framework.core.SwMap; | import cc.smtweb.framework.core.SwMap; | ||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.db.vo.def.DataType; | |||||
import cc.smtweb.system.bpm.engine.process.impl.AbstractTaskCardService; | import cc.smtweb.system.bpm.engine.process.impl.AbstractTaskCardService; | ||||
import cc.smtweb.system.bpm.engine.process.impl.entity.LoadTaskAckVO; | import cc.smtweb.system.bpm.engine.process.impl.entity.LoadTaskAckVO; | ||||
import cc.smtweb.system.bpm.engine.process.runtime.ProcessInstance; | import cc.smtweb.system.bpm.engine.process.runtime.ProcessInstance; | ||||
@@ -101,11 +101,11 @@ public class BpmTaskCardService extends AbstractTaskCardService { | |||||
} | } | ||||
} else { | } else { | ||||
switch (modelField.getDataType()) { | switch (modelField.getDataType()) { | ||||
case DataType.TYPE_BOOL: | |||||
case SwEnum.DataType.TYPE_BOOL: | |||||
uiField.put("component", "fy-checkbox"); | uiField.put("component", "fy-checkbox"); | ||||
break; | break; | ||||
case DataType.TYPE_DATETIME: | |||||
case DataType.TYPE_DATE: | |||||
case SwEnum.DataType.TYPE_DATETIME: | |||||
case SwEnum.DataType.TYPE_DATE: | |||||
uiField.put("component", "fy-datetime"); | uiField.put("component", "fy-datetime"); | ||||
break; | break; | ||||
default: | default: | ||||