Selaa lähdekoodia

修正:模块子页面

master
郑根木 2 vuotta sitten
vanhempi
commit
47ea10053f
2 muutettua tiedostoa jossa 40 lisäystä ja 14 poistoa
  1. +34
    -13
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java
  2. +6
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java

+ 34
- 13
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java Näytä tiedosto

@@ -12,6 +12,7 @@ import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.mvc.service.DefaultSaveHandler;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import org.apache.commons.lang3.StringUtils;

@@ -33,25 +34,45 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {

@Override
protected void updateBean(EntityDao<ModelForm> dao) {
updateFormChild(dao);
dao.updateEntityEx(bean, "mf_content", "mf_dataset", "mf_tmpl");
}

@Override
protected void insertBean(EntityDao<ModelForm> dao) {
super.insertBean(dao);
updateFormChild(dao);
}

private void updateFormChild(EntityDao<ModelForm> dao) {
SwMap opts = bean.getOpts();
if (opts != null) {
opts.remove(ModelFormHelper.KEY_EVENT_PATH);
bean.setOption(JsonUtil.encodeString(opts));
if (bean.getType() == SwEnum.FormType.MODULE.value) {
addChildPage(opts);
}
}
dao.updateEntityEx(bean, "mf_content", "mf_dataset", "mf_tmpl");
if (bean.getType() == SwEnum.FormType.MODULE.value) {
addChildPage(dao, opts);
}
}

//自动增加子页面
private void addChildPage(SwMap opts) {
List<String> incPage = (List<String>) opts.get("incPage");
if (incPage == null || incPage.isEmpty()) return;
private void addChildPage(EntityDao<ModelForm> dao, SwMap opts) {
listFormChild = new ArrayList<>();
Set<ModelForm> setExists = ModelFormCache.getInstance().getListByModule(bean.getEntityId());
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class);
for (String type: incPage) {
//维护已有的子页面
for (ModelForm mf: setExists) {
if (!CommUtil.isStrEquals(mf.getService(), bean.getService())) {
mf.setService(bean.getService());
dao.updateEntityEx(bean, "mf_content", "mf_dataset", "mf_tmpl");
listFormChild.add(mf);
}
}
if (opts == null) return;
List<String> incPage = (List<String>) opts.get("incPage");
if (incPage == null || incPage.isEmpty()) return;

//增加新的子页面
for (String type : incPage) {
String name = bean.getName() + "_" + type;
if (existsPage(setExists, name)) continue;
ModelForm page = new ModelForm();
@@ -61,7 +82,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
page.setName(name);
page.setTitle(bean.getTitle() + "_" + SwEnum.PageType.instance.getName(type));
listFormChild.add(page);
dao.updateEntityEx(page, "mf_content", "mf_dataset", "mf_tmpl");
dao.insertEntity(page);
}
}

@@ -69,7 +90,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
protected void saveSuccess() {
ModelFormCache.getInstance().put(bean);
if (listFormChild == null) {
for (ModelForm page: listFormChild) {
for (ModelForm page : listFormChild) {
ModelFormCache.getInstance().put(page);
}
}
@@ -79,7 +100,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
protected void saveFailed() {
ModelFormCache.getInstance().reset(bean);
if (listFormChild == null) {
for (ModelForm page: listFormChild) {
for (ModelForm page : listFormChild) {
ModelFormCache.getInstance().reset(page);
}
}
@@ -87,7 +108,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {

//已经存在的,不管了
private boolean existsPage(Set<ModelForm> setExists, String name) {
for (ModelForm form: setExists) {
for (ModelForm form : setExists) {
if (name.equalsIgnoreCase(form.getName())) return true;
}
return false;


+ 6
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java Näytä tiedosto

@@ -88,7 +88,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
protected void saveDb() {
EntityDao<T> dao = DbEngine.getInstance().findDao(tableName);
if (isNew) {
dao.insertEntity(bean);
insertBean(dao);
} else {
ModelTable table = ModelTableCache.getInstance().getByName(tableName);
ModelField field = table.findFieldByType(SwEnum.FieldType.UPDATE_USER.value);
@@ -106,6 +106,11 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
dao.updateEntity(bean);
}

//更新入库
protected void insertBean(EntityDao<T> dao) {
dao.insertEntity(bean);
}


@Override
protected void saveSuccess() {


Ladataan…
Peruuta
Tallenna