diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java index 34d057bd..e5a5ef6d 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java @@ -504,6 +504,12 @@ public class JavaFxApplication extends Application { currentTable.setGetAll(newValue); } }); + detailTableController.getHtml().selectedProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { + currentTable.setHtml(newValue); + } + }); } ManagerFactory.getReflashManager(this).start(); diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java index 4621e6e6..52348ad3 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java @@ -729,6 +729,26 @@ public class SpringBootCallable implements Callable { Tool.outputResource(option + "/resources/templates/403.ftl", new File(templates.getAbsolutePath(), "403.ftl")); Tool.outputResource(option + "/resources/templates/404.ftl", new File(templates.getAbsolutePath(), "404.ftl")); Tool.outputResource(option + "/resources/templates/500.ftl", new File(templates.getAbsolutePath(), "500.ftl")); + + + for (Module mo : project.getModules()) { + if (mo.isHasSysFields()) {//标准模型才好生成简单的htm + for (Table table : mo.getTables()) { + if (table.getHtml()) { + File module = new File(screen.getAbsolutePath(), mo.getModuleName()); + module.mkdirs(); + HashMap ctx = new HashMap(); + ctx.put("basePackage", project.getProjectBasePackage()); + ctx.put("tool", Tool.class); + ctx.put("author", project.getProjectAuthor()); + ctx.put("date", new Date()); + ctx.put("table", table); + ctx.put("fields", table.getFields()); + freeMarkerManager.outputTemp(new File(module.getAbsolutePath(), table.getFName() + ".ftl"), option + "/resources/templates/screen/module/mgr.ftl", ctx); + } + } + } + } } } diff --git a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java index aba3c0aa..c9430a20 100644 --- a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java +++ b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java @@ -101,9 +101,7 @@ public class GlobalController implements ErrorController { @RequestMapping(value = ERROR_PATH) public String error(HttpServletRequest request, HttpServletResponse response) { - Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); - - switch (statusCode) { + switch (response.getStatus()) { case 404: return "404"; case 403: diff --git a/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java b/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java index ccac31df..6d108af5 100644 --- a/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java +++ b/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java @@ -6,6 +6,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.Authentication; @@ -17,6 +18,8 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; @Configuration @EnableGlobalMethodSecurity(securedEnabled = true) @@ -29,6 +32,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Value("${r"${spring.mvc.static-path-pattern}"}") private String[] staticPath; + @Override + public void configure(WebSecurity web) throws Exception { + web.ignoring().mvcMatchers(staticPath); + } + @Override protected void configure(HttpSecurity http) throws Exception { http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) @@ -80,6 +88,15 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { token1.putResource(".*"); LocalData.setToken(token1); } + + // Action + String servletPath = request.getServletPath(); + Pattern compile = Pattern.compile("^/(.+)\\.htm"); + Matcher matcher = compile.matcher(servletPath); + if (matcher.find()) { + LocalData.setAction(matcher.group(1)); + } + filterChain.doFilter(servletRequest, servletResponse); } } @@ -89,7 +106,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { return new Object() { public boolean hasPermission(HttpServletRequest request, Authentication authentication) { - // 授权 Token token_ = LocalData.getToken(); if (token_.hasResource(request.getServletPath())) { diff --git a/src/main/resources/modules/SpringBoot/java/config/WebMvcConfig.java b/src/main/resources/modules/SpringBoot/java/config/WebMvcConfig.java index 0641b24b..72fdb8d5 100644 --- a/src/main/resources/modules/SpringBoot/java/config/WebMvcConfig.java +++ b/src/main/resources/modules/SpringBoot/java/config/WebMvcConfig.java @@ -29,8 +29,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; @Configuration public class WebMvcConfig implements WebMvcConfigurer { @@ -41,42 +39,12 @@ public class WebMvcConfig implements WebMvcConfigurer { private String[] staticPath; /** - * 增加全局拦截器,可用于 + * 增加全局拦截器,可用于异常日志的收集 * * @param registry */ @Override public void addInterceptors(InterceptorRegistry registry) { - - // .htm拦截器 - registry.addInterceptor(new HandlerInterceptorAdapter() { - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - // Action - String servletPath = request.getServletPath(); - Pattern compile = Pattern.compile("^/(.+)\\.htm"); - Matcher matcher = compile.matcher(servletPath); - if (matcher.find()) { - LocalData.setAction(matcher.group(1)); - }return super.preHandle(request, response, handler); - } - - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { - super.postHandle(request, response, handler, modelAndView); - - //当请求为@ResponseBody,modelAndView为null,不处理 - if (modelAndView == null) { - return; - } - - //获取当前用户信息 - Token token = LocalData.getToken(); - modelAndView.addObject("token", token); - } - }).addPathPatterns("/**/*.htm"); - // 全局异常收集拦截器 registry.addInterceptor(new HandlerInterceptorAdapter() { @@ -94,7 +62,7 @@ public class WebMvcConfig implements WebMvcConfigurer { /** * Jackson序列化时的转化规则配置 - * + *

* 1、Long或long类型在序列化时转String,防止出现javascript中Number精度丢失的情况。 * * @param converters @@ -102,8 +70,8 @@ public class WebMvcConfig implements WebMvcConfigurer { @Override public void extendMessageConverters(List> converters) { for (HttpMessageConverter converter : converters) { - if (converter instanceof MappingJackson2HttpMessageConverter){ - ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter)converter).getObjectMapper(); + if (converter instanceof MappingJackson2HttpMessageConverter) { + ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter) converter).getObjectMapper(); SimpleModule simpleModule = new SimpleModule(); simpleModule.addSerializer(Long.class, ToStringSerializer.instance); simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); diff --git a/src/main/resources/modules/SpringBoot/java/frame/base/BaseEntity.java b/src/main/resources/modules/SpringBoot/java/frame/base/BaseEntity.java index c1e1d823..60d9db25 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/base/BaseEntity.java +++ b/src/main/resources/modules/SpringBoot/java/frame/base/BaseEntity.java @@ -28,7 +28,6 @@ public class BaseEntity implements Serializable { /** * 创建时间 */ - @JsonIgnore private Date createTime; /** diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl new file mode 100644 index 00000000..a3f5e350 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl @@ -0,0 +1,247 @@ +

+ + +<#list fields as item> +<#if item.isQuery> + + + + + + + 搜索 + 重置 + + + + + + + + 新增 + + 导出 + + + +<#list fields as item> +<#if item.isQuery && !item.isSystem> + + + + + + + + 取 消 + 保存 + + + + + + + + + + + + + + +<#list fields as item> +<#if item.isQuery && !item.isSystem> + + + + + + + + + + + + + + +
+ +