@@ -30,6 +30,14 @@ public class ModelProject extends DefaultEntity { | |||||
put("prj_name", prjName); | put("prj_name", prjName); | ||||
} | } | ||||
public String getModule() { | |||||
return getStr("prj_module"); | |||||
} | |||||
public void setModule(String prj_module) { | |||||
put("prj_module", prj_module); | |||||
} | |||||
public String getDepends() { | public String getDepends() { | ||||
return getStr("prj_depends"); | return getStr("prj_depends"); | ||||
} | } | ||||
@@ -13,6 +13,8 @@ import cc.smtweb.framework.core.util.CommUtil; | |||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; | ||||
import cc.smtweb.framework.core.util.MapUtil; | import cc.smtweb.framework.core.util.MapUtil; | ||||
import cc.smtweb.system.bpm.web.design.form.define.*; | import cc.smtweb.system.bpm.web.design.form.define.*; | ||||
import cc.smtweb.system.bpm.web.design.table.ModelCatalogCache; | |||||
import cc.smtweb.system.bpm.web.design.table.ModelProjectCache; | |||||
import com.fasterxml.jackson.core.JsonProcessingException; | import com.fasterxml.jackson.core.JsonProcessingException; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
@@ -23,6 +25,7 @@ import java.util.*; | |||||
* 辅助类 | * 辅助类 | ||||
*/ | */ | ||||
public class ModelFormHelper { | public class ModelFormHelper { | ||||
public static final String KEY_EVENT_PATH = "eventPath"; | |||||
/** | /** | ||||
* 从缓存获取Form对象 | * 从缓存获取Form对象 | ||||
* | * | ||||
@@ -235,6 +238,11 @@ public class ModelFormHelper { | |||||
SwMap ret = new SwMap(); | SwMap ret = new SwMap(); | ||||
PageModel pageInfo = parsePageInfo(form.getContent()); | PageModel pageInfo = parsePageInfo(form.getContent()); | ||||
if (pageInfo == null) return ""; | if (pageInfo == null) return ""; | ||||
ret.put("pageId", form.getEntityId()); | |||||
ret.put("label", form.getTitle()); | |||||
ret.put("service", form.getService()); | |||||
ret.put("module", ModelProjectCache.getInstance().getModule(form.getPrjId())); | |||||
buildOptsEx(form, ret); | |||||
//form不用管 | //form不用管 | ||||
if (pageInfo.form != null) ret.put("form", pageInfo.form); | if (pageInfo.form != null) ret.put("form", pageInfo.form); | ||||
List<SwMap> listModel = new ArrayList<>(); | List<SwMap> listModel = new ArrayList<>(); | ||||
@@ -325,4 +333,18 @@ public class ModelFormHelper { | |||||
listRet.sort((o1, o2) -> CommUtil.chineseCompare(o1.readString("label"), o2.readString("label"))); | listRet.sort((o1, o2) -> CommUtil.chineseCompare(o1.readString("label"), o2.readString("label"))); | ||||
return listRet; | return listRet; | ||||
} | } | ||||
/** | |||||
* 构建一些扩展属性,目前主要是eventPath | |||||
* @param opts | |||||
*/ | |||||
public static void buildOptsEx(ModelForm bean, SwMap opts) { | |||||
String moduleName = ModelProjectCache.getInstance().getModule(bean.getPrjId()); | |||||
if (StringUtils.isNotEmpty(moduleName)) { | |||||
String ep = moduleName; | |||||
String cn = ModelCatalogCache.getInstance().getFullName(bean.getMcId()); | |||||
if (StringUtils.isNotEmpty(cn)) ep = ep + "." + cn; | |||||
opts.put(KEY_EVENT_PATH, ep + "." + bean.getName()); | |||||
} | |||||
} | |||||
} | } |
@@ -2,7 +2,9 @@ package cc.smtweb.system.bpm.web.design.form; | |||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwException; | import cc.smtweb.framework.core.common.SwException; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | |||||
/** | /** | ||||
* Created by Akmm at 2022/5/9 16:17 | * Created by Akmm at 2022/5/9 16:17 | ||||
@@ -15,6 +17,11 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
@Override | @Override | ||||
protected ModelForm loadComp(long id) { | protected ModelForm loadComp(long id) { | ||||
ModelForm bean = super.loadComp(id); | ModelForm bean = super.loadComp(id); | ||||
SwMap opts = ModelFormHelper.parseFormOption(bean.getOption()); | |||||
if (opts != null) { | |||||
ModelFormHelper.buildOptsEx(bean, opts); | |||||
bean.setOption(JsonUtil.encodeString(opts)); | |||||
} | |||||
//去掉content和dataset | //去掉content和dataset | ||||
bean.getData().remove("mf_content"); | bean.getData().remove("mf_content"); | ||||
bean.getData().remove("mf_dataset"); | bean.getData().remove("mf_dataset"); | ||||
@@ -3,6 +3,7 @@ package cc.smtweb.system.bpm.web.design.form; | |||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwException; | import cc.smtweb.framework.core.common.SwException; | ||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
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,6 +11,7 @@ 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.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.mvc.service.DefaultSaveHandler; | import cc.smtweb.framework.core.mvc.service.DefaultSaveHandler; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
/** | /** | ||||
@@ -23,6 +25,12 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { | |||||
@Override | @Override | ||||
protected void updateBean(EntityDao<ModelForm> dao) { | protected void updateBean(EntityDao<ModelForm> dao) { | ||||
SwMap opts = ModelFormHelper.parseFormOption(bean.getOption()); | |||||
if (opts != null) { | |||||
opts.remove(ModelFormHelper.KEY_EVENT_PATH); | |||||
bean.setOption(JsonUtil.encodeString(opts)); | |||||
} | |||||
dao.updateEntityEx(bean, "mf_content", "mf_dataset"); | dao.updateEntityEx(bean, "mf_content", "mf_dataset"); | ||||
} | } | ||||
@@ -0,0 +1,52 @@ | |||||
package cc.smtweb.system.bpm.web.design.table; | |||||
import cc.smtweb.framework.core.annotation.SwCache; | |||||
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.EntityDao; | |||||
import cc.smtweb.framework.core.db.vo.ModelCatalog; | |||||
import cc.smtweb.framework.core.db.vo.ModelCatalog; | |||||
import cc.smtweb.framework.core.db.vo.ModelProject; | |||||
import java.util.List; | |||||
/** | |||||
* Created by Akmm at 2022/1/12 18:34 | |||||
*/ | |||||
@SwCache(ident = "ASP_MODEL_CATALOG", title = "目录") | |||||
public class ModelCatalogCache extends AbstractCache<ModelCatalog> { | |||||
public static ModelCatalogCache getInstance() { | |||||
return CacheManager.getIntance().getCache(ModelCatalogCache.class); | |||||
} | |||||
public ModelCatalogCache() { | |||||
} | |||||
@Override | |||||
protected String getId(ModelCatalog bean) { | |||||
return String.valueOf(bean.getId()); | |||||
} | |||||
@Override | |||||
protected List<ModelCatalog> loadAll() { | |||||
EntityDao<ModelCatalog> dao = DbEngine.getInstance().findDao(ModelCatalog.class); | |||||
return dao.query(); | |||||
} | |||||
public String getName(long id) { | |||||
ModelCatalog bean = get(id); | |||||
return bean != null ? bean.getName() : ""; | |||||
} | |||||
public String getFullName(long id) { | |||||
ModelCatalog bean = get(id); | |||||
if (bean == null) return null; | |||||
StringBuilder sret = new StringBuilder(); | |||||
while (bean != null) { | |||||
sret.insert(0, "." + bean.getCode()); | |||||
bean = get(bean.getParentId()); | |||||
} | |||||
return sret.substring(1); | |||||
} | |||||
} |
@@ -0,0 +1,43 @@ | |||||
package cc.smtweb.system.bpm.web.design.table; | |||||
import cc.smtweb.framework.core.annotation.SwCache; | |||||
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.EntityDao; | |||||
import cc.smtweb.framework.core.db.vo.ModelProject; | |||||
import java.util.ArrayList; | |||||
import java.util.Comparator; | |||||
import java.util.List; | |||||
import java.util.Set; | |||||
/** | |||||
* Created by Akmm at 2022/1/12 18:34 | |||||
*/ | |||||
@SwCache(ident = "ASP_MODEL_PROJECT", title = "项目定义") | |||||
public class ModelProjectCache extends AbstractCache<ModelProject> { | |||||
public static ModelProjectCache getInstance() { | |||||
return CacheManager.getIntance().getCache(ModelProjectCache.class); | |||||
} | |||||
public ModelProjectCache() { | |||||
} | |||||
@Override | |||||
protected String getId(ModelProject bean) { | |||||
return String.valueOf(bean.getId()); | |||||
} | |||||
@Override | |||||
protected List<ModelProject> loadAll() { | |||||
EntityDao<ModelProject> dao = DbEngine.getInstance().findDao(ModelProject.class); | |||||
return dao.query(); | |||||
} | |||||
public String getModule(long id) { | |||||
ModelProject bean = get(id); | |||||
return bean != null ? bean.getModule() : ""; | |||||
} | |||||
} |
@@ -49,11 +49,11 @@ public class DynPageLoadHandler extends AbstractDynPageHandler { | |||||
mapRet.put(dataSet.name, new SwMap()); | mapRet.put(dataSet.name, new SwMap()); | ||||
continue; | continue; | ||||
} | } | ||||
mapRet.put(dataSet.name, DynPageHelper.createBean(dataSet)); | |||||
mapRet.put(dataSet.name, DynRetBean.createBean(DynPageHelper.createBean(dataSet))); | |||||
} else if (SwEnum.DatasetType.TREE.value.equals(dataSet.type)) {//树 | } else if (SwEnum.DatasetType.TREE.value.equals(dataSet.type)) {//树 | ||||
mapRet.put(dataSet.name, new SwMap()); | |||||
mapRet.put(dataSet.name, DynRetBean.createBean(new SwMap())); | |||||
} else if (!SwEnum.DatasetType.ENUM.value.equals(dataSet.type)) {//非枚举 | } else if (!SwEnum.DatasetType.ENUM.value.equals(dataSet.type)) {//非枚举 | ||||
mapRet.put(dataSet.name, SwListData.create(null, 0)); | |||||
mapRet.put(dataSet.name, DynRetBean.createList(SwListData.create(null, 0))); | |||||
} | } | ||||
} | } | ||||
return R.success(mapRet); | return R.success(mapRet); | ||||
@@ -68,7 +68,7 @@ public class DynPageLoadHandler extends AbstractDynPageHandler { | |||||
return R.error("指定数据集为只读数据集[" + pageDataSet.label + "]!"); | return R.error("指定数据集为只读数据集[" + pageDataSet.label + "]!"); | ||||
} | } | ||||
//懒加载,给个空对象 | //懒加载,给个空对象 | ||||
return R.success(DynPageHelper.createBean(pageDataSet)); | |||||
return R.success(DynRetBean.createBean(DynPageHelper.createBean(pageDataSet))); | |||||
} | } | ||||
public R loadOne() { | public R loadOne() { | ||||
@@ -66,7 +66,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
afterRollback(bean); | afterRollback(bean); | ||||
} | } | ||||
}); | }); | ||||
return R.success(bean); | |||||
return R.success(DynRetBean.createBean(bean.getData())); | |||||
} | } | ||||
/** | /** | ||||
@@ -124,7 +124,11 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
return R.success(map); | |||||
Map<String, DynRetBean> mapRet = new HashMap<>(map.size()); | |||||
for (Map.Entry<String, DefaultEntity> entry: map.entrySet()) { | |||||
mapRet.put(entry.getKey(), DynRetBean.createBean(entry.getValue().getData())); | |||||
} | |||||
return R.success(mapRet); | |||||
} | } | ||||
/** | /** | ||||