Forráskód Böngészése

容器启动自动部署表单

周浩 9 éve
szülő
commit
69f1d9537d

+ 36 - 0
hsweb-web-service-impl-common/src/main/java/org/hsweb/web/service/impl/FromDeployContextLoaderListener.java

@@ -0,0 +1,36 @@
+package org.hsweb.web.service.impl;
+
+import org.hsweb.web.bean.common.QueryParam;
+import org.hsweb.web.service.form.DynamicFormService;
+import org.hsweb.web.service.form.FormService;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class FromDeployContextLoaderListener implements ApplicationListener {
+
+    @Resource
+    private FormService formService;
+    @Resource
+    private DynamicFormService dynamicFormService;
+
+    @Override
+    public void onApplicationEvent(ApplicationEvent event) {
+        QueryParam param = new QueryParam();
+        param.where("using", 1);
+        try {
+            formService.select(param).forEach(form -> {
+                try {
+                    dynamicFormService.deploy(form);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            });
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+}