|
@@ -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.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.CommUtil; |
|
|
import cc.smtweb.framework.core.util.JsonUtil; |
|
|
import cc.smtweb.framework.core.util.JsonUtil; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
@@ -33,25 +34,45 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void updateBean(EntityDao<ModelForm> dao) { |
|
|
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(); |
|
|
SwMap opts = bean.getOpts(); |
|
|
if (opts != null) { |
|
|
if (opts != null) { |
|
|
opts.remove(ModelFormHelper.KEY_EVENT_PATH); |
|
|
opts.remove(ModelFormHelper.KEY_EVENT_PATH); |
|
|
bean.setOption(JsonUtil.encodeString(opts)); |
|
|
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<>(); |
|
|
listFormChild = new ArrayList<>(); |
|
|
Set<ModelForm> setExists = ModelFormCache.getInstance().getListByModule(bean.getEntityId()); |
|
|
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; |
|
|
String name = bean.getName() + "_" + type; |
|
|
if (existsPage(setExists, name)) continue; |
|
|
if (existsPage(setExists, name)) continue; |
|
|
ModelForm page = new ModelForm(); |
|
|
ModelForm page = new ModelForm(); |
|
@@ -61,7 +82,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { |
|
|
page.setName(name); |
|
|
page.setName(name); |
|
|
page.setTitle(bean.getTitle() + "_" + SwEnum.PageType.instance.getName(type)); |
|
|
page.setTitle(bean.getTitle() + "_" + SwEnum.PageType.instance.getName(type)); |
|
|
listFormChild.add(page); |
|
|
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() { |
|
|
protected void saveSuccess() { |
|
|
ModelFormCache.getInstance().put(bean); |
|
|
ModelFormCache.getInstance().put(bean); |
|
|
if (listFormChild == null) { |
|
|
if (listFormChild == null) { |
|
|
for (ModelForm page: listFormChild) { |
|
|
|
|
|
|
|
|
for (ModelForm page : listFormChild) { |
|
|
ModelFormCache.getInstance().put(page); |
|
|
ModelFormCache.getInstance().put(page); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -79,7 +100,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { |
|
|
protected void saveFailed() { |
|
|
protected void saveFailed() { |
|
|
ModelFormCache.getInstance().reset(bean); |
|
|
ModelFormCache.getInstance().reset(bean); |
|
|
if (listFormChild == null) { |
|
|
if (listFormChild == null) { |
|
|
for (ModelForm page: listFormChild) { |
|
|
|
|
|
|
|
|
for (ModelForm page : listFormChild) { |
|
|
ModelFormCache.getInstance().reset(page); |
|
|
ModelFormCache.getInstance().reset(page); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -87,7 +108,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { |
|
|
|
|
|
|
|
|
//已经存在的,不管了 |
|
|
//已经存在的,不管了 |
|
|
private boolean existsPage(Set<ModelForm> setExists, String name) { |
|
|
private boolean existsPage(Set<ModelForm> setExists, String name) { |
|
|
for (ModelForm form: setExists) { |
|
|
|
|
|
|
|
|
for (ModelForm form : setExists) { |
|
|
if (name.equalsIgnoreCase(form.getName())) return true; |
|
|
if (name.equalsIgnoreCase(form.getName())) return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
|