|
@@ -1,8 +1,12 @@
|
|
|
package org.hsweb.web.service.impl;
|
|
|
|
|
|
+import org.hsweb.ezorm.meta.TableMetaData;
|
|
|
import org.hsweb.web.bean.common.QueryParam;
|
|
|
+import org.hsweb.web.bean.po.form.Form;
|
|
|
import org.hsweb.web.service.form.DynamicFormService;
|
|
|
import org.hsweb.web.service.form.FormService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.context.ApplicationContextInitializer;
|
|
|
import org.springframework.context.ApplicationEvent;
|
|
@@ -16,10 +20,12 @@ import javax.annotation.Resource;
|
|
|
@Component
|
|
|
public class FormDeployContextLoaderListener implements ApplicationListener<ContextRefreshedEvent> {
|
|
|
@Resource
|
|
|
- private FormService formService;
|
|
|
+ private FormService formService;
|
|
|
@Resource
|
|
|
private DynamicFormService dynamicFormService;
|
|
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
+
|
|
|
@Override
|
|
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
|
if (event.getApplicationContext().getParent() != null) return;
|
|
@@ -28,9 +34,15 @@ public class FormDeployContextLoaderListener implements ApplicationListener<Cont
|
|
|
try {
|
|
|
formService.select(param).forEach(form -> {
|
|
|
try {
|
|
|
- dynamicFormService.deploy(form);
|
|
|
+ Form deployed = formService.selectDeployed(form.getName());
|
|
|
+ if (null != deployed) {
|
|
|
+ TableMetaData metaData = dynamicFormService.parseMeta(deployed);
|
|
|
+ dynamicFormService.getDefaultDatabase().reloadTable(metaData);
|
|
|
+ } else {
|
|
|
+ dynamicFormService.deploy(form);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ logger.error("部署{}:({})失败", form.getName(), form.getRemark(), e);
|
|
|
}
|
|
|
});
|
|
|
} catch (Exception e) {
|