diff --git a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java index 6944deb4..e3fe49b7 100644 --- a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java +++ b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java @@ -113,7 +113,7 @@ public class GlobalController implements ErrorController { case 404: return "404"; case 403: - if (LocalData.getToken() == null) { + if ((request.getServletPath().equals(homePage) || request.getServletPath().equals("/")) && LocalData.getToken() == null) { try { response.sendRedirect("/login.htm"); } catch (IOException e) { @@ -173,8 +173,8 @@ public class GlobalController implements ErrorController { layout = sb.toString(); View view = viewResolver.resolveViewName(layout, locale); if (view == null) { - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - return error(request, response); + response.sendError(HttpServletResponse.SC_NOT_FOUND,""); + return null; } // 尝试执行Screen执行器(服务器渲染),并返回视图模板 @@ -184,7 +184,8 @@ public class GlobalController implements ErrorController { screenExec.exec(model, request, response); if (response.getStatus() != HttpServletResponse.SC_OK) { - return error(request, response); + response.sendError(response.getStatus(),""); + return null; } } catch (BeansException e) { diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/TokensAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/TokensAjax.java index 5c216860..5d624d38 100644 --- a/src/main/resources/modules/SpringBoot/java/action/ajax/system/TokensAjax.java +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/TokensAjax.java @@ -19,11 +19,13 @@ import ${basePackage}.module.system.req.TokensCreateRequest; import ${basePackage}.module.system.req.TokensDeleteRequest; import ${basePackage}.module.system.req.TokensFindRequest; import ${basePackage}.module.system.req.TokensGetRequest; +import ${basePackage}.module.system.req.TokensLogoutRequest; import ${basePackage}.module.system.req.TokensUpdateRequest; import ${basePackage}.module.system.rsp.TokensCreateResponse; import ${basePackage}.module.system.rsp.TokensDeleteResponse; import ${basePackage}.module.system.rsp.TokensFindResponse; import ${basePackage}.module.system.rsp.TokensGetResponse; +import ${basePackage}.module.system.rsp.TokensLogoutResponse; import ${basePackage}.module.system.rsp.TokensUpdateResponse; import java.io.IOException; @@ -54,6 +56,10 @@ public class TokensAjax{ return tokensManager.get(request, LocalData.getToken()); } + public TokensLogoutResponse logout(TokensLogoutRequest request) { + return tokensManager.logout(request, LocalData.getToken()); + } + public Object template(){ return ResponseUtil.apply(new WSheet<>(Tokens.class)); } diff --git a/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java b/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java index d6937177..23f0acb5 100644 --- a/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java +++ b/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java @@ -3,6 +3,7 @@ package ${basePackage}.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; @@ -24,6 +25,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -77,20 +79,21 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; + HttpServletResponse response = (HttpServletResponse) servletResponse; String token = request.getParameter("token"); if (token == null || token.isEmpty()) { token = CookieUtil.getCookieValue(request.getCookies(), "token"); } // 组装Token ~ 这边根据实际的业务组装Token - if (token != null){ + if (token != null) { TokensManager tokensManager = LocalData.getBean(TokensManager.class); TokensBuildRequest tokensBuildRequest = new TokensBuildRequest(); tokensBuildRequest.setToken(token); TokensBuildResponse tokensBuildResponse = tokensManager.build(tokensBuildRequest, LocalData.getSysToken()); - if (!tokensBuildResponse.hasError()) { - LocalData.setToken(tokensBuildResponse.getToken()); - } + LocalData.setToken(tokensBuildResponse.getToken()); + } else { + LocalData.setToken(null); } // Action @@ -101,7 +104,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { LocalData.setAction(matcher.group(1)); } - filterChain.doFilter(servletRequest, servletResponse); + try { + filterChain.doFilter(servletRequest, servletResponse); + } catch (AccessDeniedException e) { + response.sendError(HttpServletResponse.SC_FORBIDDEN); + } catch (Exception e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } } } diff --git a/src/main/resources/modules/SpringBoot/java/frame/auth/LocalData.java b/src/main/resources/modules/SpringBoot/java/frame/auth/LocalData.java index 97b00caf..cc104a83 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/auth/LocalData.java +++ b/src/main/resources/modules/SpringBoot/java/frame/auth/LocalData.java @@ -74,7 +74,7 @@ public class LocalData { } public static void setApplicationContext(ApplicationContext applicationContext) { - ${basePackage}.frame.auth.LocalData.applicationContext = applicationContext; + LocalData.applicationContext = applicationContext; } public static T getBean(Class t) { diff --git a/src/main/resources/modules/SpringBoot/resources/static/css/base.css b/src/main/resources/modules/SpringBoot/resources/static/css/base.css index 8d49641e..56d6528e 100644 --- a/src/main/resources/modules/SpringBoot/resources/static/css/base.css +++ b/src/main/resources/modules/SpringBoot/resources/static/css/base.css @@ -13,7 +13,7 @@ } ::-webkit-scrollbar-thumb { - background-color: #e8e8e8; + background-color: #797979; border-radius: 3px; } diff --git a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl index def9b65d..ee61c834 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl @@ -396,6 +396,10 @@ this.vm.pageNumber = pageNumber; this.onFind(); }, + onPageSizeChange: function (pageSize) { + this.vm.pageSize = pageSize; + this.onFind(); + }, onSelectionChange: function (select) { this.select = select; }, 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 index 17653955..7076bbcf 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl @@ -123,6 +123,8 @@ width="140" + <#if item.fieldType.javaType() == 'Long'>width="140" label="${item.fieldComment?default("")}"> @@ -155,7 +157,7 @@ background v-if="vm.totalCount > vm.pageSize" style="margin-top: 10px" - @current-change="onPage" + @current-change="onPageChange" :current-page="vm.pageNumber" :page-size="vm.pageSize" layout="total, sizes, prev, pager, next, jumper" diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dept.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dept.ftl index 13f2a39c..43624bc8 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dept.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dept.ftl @@ -138,7 +138,8 @@ background v-if="vm.totalCount > vm.pageSize" style="margin-top: 10px" - @current-change="onPage" + @current-change="onPageChange" + @size-change="onPageSizeChange" :current-page="vm.pageNumber" :page-size="vm.pageSize" layout="total, sizes, prev, pager, next, jumper" diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl index 884ddf09..6a9755be 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl @@ -120,6 +120,7 @@ v-if="vm.totalCount > vm.pageSize" style="margin-top: 10px" @current-change="onPageChange" + @size-change="onPageSizeChange" :current-page="vm.pageNumber" :page-size="vm.pageSize" layout="total, sizes, prev, pager, next, jumper" diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dictItem.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dictItem.ftl index 9c459152..a50baf67 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dictItem.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dictItem.ftl @@ -121,7 +121,8 @@ background v-if="vm.totalCount > vm.pageSize" style="margin-top: 10px" - @current-change="onPage" + @current-change="onPageChange" + @size-change="onPageSizeChange" :current-page="vm.pageNumber" :page-size="vm.pageSize" layout="total, sizes, prev, pager, next, jumper" diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/file.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/file.ftl index 40c6edb8..1164f815 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/file.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/file.ftl @@ -110,7 +110,8 @@ background v-if="vm.totalCount > vm.pageSize" style="margin-top: 10px" - @current-change="onPage" + @current-change="onPageChange" + @size-change="onPageSizeChange" :current-page="vm.pageNumber" :page-size="vm.pageSize" layout="total, sizes, prev, pager, next, jumper" diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/resource.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/resource.ftl index 9c05c527..dadffe37 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/resource.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/resource.ftl @@ -136,7 +136,8 @@ background v-if="vm.totalCount > vm.pageSize" style="margin-top: 10px" - @current-change="onPage" + @current-change="onPageChange" + @size-change="onPageSizeChange" :current-page="vm.pageNumber" :page-size="vm.pageSize" layout="total, sizes, prev, pager, next, jumper" diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/role.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/role.ftl index ec8459ab..c72f1715 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/role.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/role.ftl @@ -105,7 +105,8 @@ background v-if="vm.totalCount > vm.pageSize" style="margin-top: 10px" - @current-change="onPage" + @current-change="onPageChange" + @size-change="onPageSizeChange" :current-page="vm.pageNumber" :page-size="vm.pageSize" layout="total, sizes, prev, pager, next, jumper" diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/tokens.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/tokens.ftl index 9e3aaa2e..05a1ff64 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/tokens.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/tokens.ftl @@ -28,7 +28,7 @@ - + 搜索 @@ -93,7 +93,8 @@ + label="用户主键" + width="140"> + label="登录时间" + width="140"> - - - - + label="有效时间" + width="140"> + label="终端地址" + width="140">