Former-commit-id: e48efb2355e93e67f358e1743c8819d276b80d1a
master
wangbing 5 years ago
parent d3bdd43d58
commit 531102b1d0

@ -113,7 +113,7 @@ public class GlobalController implements ErrorController {
case 404: case 404:
return "404"; return "404";
case 403: case 403:
if (LocalData.getToken() == null) { if ((request.getServletPath().equals(homePage) || request.getServletPath().equals("/")) && LocalData.getToken() == null) {
try { try {
response.sendRedirect("/login.htm"); response.sendRedirect("/login.htm");
} catch (IOException e) { } catch (IOException e) {
@ -173,8 +173,8 @@ public class GlobalController implements ErrorController {
layout = sb.toString(); layout = sb.toString();
View view = viewResolver.resolveViewName(layout, locale); View view = viewResolver.resolveViewName(layout, locale);
if (view == null) { if (view == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.sendError(HttpServletResponse.SC_NOT_FOUND,"");
return error(request, response); return null;
} }
// 尝试执行Screen执行器(服务器渲染),并返回视图模板 // 尝试执行Screen执行器(服务器渲染),并返回视图模板
@ -184,7 +184,8 @@ public class GlobalController implements ErrorController {
screenExec.exec(model, request, response); screenExec.exec(model, request, response);
if (response.getStatus() != HttpServletResponse.SC_OK) { if (response.getStatus() != HttpServletResponse.SC_OK) {
return error(request, response); response.sendError(response.getStatus(),"");
return null;
} }
} catch (BeansException e) { } catch (BeansException e) {

@ -19,11 +19,13 @@ import ${basePackage}.module.system.req.TokensCreateRequest;
import ${basePackage}.module.system.req.TokensDeleteRequest; import ${basePackage}.module.system.req.TokensDeleteRequest;
import ${basePackage}.module.system.req.TokensFindRequest; import ${basePackage}.module.system.req.TokensFindRequest;
import ${basePackage}.module.system.req.TokensGetRequest; import ${basePackage}.module.system.req.TokensGetRequest;
import ${basePackage}.module.system.req.TokensLogoutRequest;
import ${basePackage}.module.system.req.TokensUpdateRequest; import ${basePackage}.module.system.req.TokensUpdateRequest;
import ${basePackage}.module.system.rsp.TokensCreateResponse; import ${basePackage}.module.system.rsp.TokensCreateResponse;
import ${basePackage}.module.system.rsp.TokensDeleteResponse; import ${basePackage}.module.system.rsp.TokensDeleteResponse;
import ${basePackage}.module.system.rsp.TokensFindResponse; import ${basePackage}.module.system.rsp.TokensFindResponse;
import ${basePackage}.module.system.rsp.TokensGetResponse; import ${basePackage}.module.system.rsp.TokensGetResponse;
import ${basePackage}.module.system.rsp.TokensLogoutResponse;
import ${basePackage}.module.system.rsp.TokensUpdateResponse; import ${basePackage}.module.system.rsp.TokensUpdateResponse;
import java.io.IOException; import java.io.IOException;
@ -54,6 +56,10 @@ public class TokensAjax{
return tokensManager.get(request, LocalData.getToken()); return tokensManager.get(request, LocalData.getToken());
} }
public TokensLogoutResponse logout(TokensLogoutRequest request) {
return tokensManager.logout(request, LocalData.getToken());
}
public Object template(){ public Object template(){
return ResponseUtil.apply(new WSheet<>(Tokens.class)); return ResponseUtil.apply(new WSheet<>(Tokens.class));
} }

@ -3,6 +3,7 @@ package ${basePackage}.config;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 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.HttpSecurity;
@ -24,6 +25,7 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -77,6 +79,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
String token = request.getParameter("token"); String token = request.getParameter("token");
if (token == null || token.isEmpty()) { if (token == null || token.isEmpty()) {
token = CookieUtil.getCookieValue(request.getCookies(), "token"); token = CookieUtil.getCookieValue(request.getCookies(), "token");
@ -88,9 +91,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
TokensBuildRequest tokensBuildRequest = new TokensBuildRequest(); TokensBuildRequest tokensBuildRequest = new TokensBuildRequest();
tokensBuildRequest.setToken(token); tokensBuildRequest.setToken(token);
TokensBuildResponse tokensBuildResponse = tokensManager.build(tokensBuildRequest, LocalData.getSysToken()); TokensBuildResponse tokensBuildResponse = tokensManager.build(tokensBuildRequest, LocalData.getSysToken());
if (!tokensBuildResponse.hasError()) {
LocalData.setToken(tokensBuildResponse.getToken()); LocalData.setToken(tokensBuildResponse.getToken());
} } else {
LocalData.setToken(null);
} }
// Action // Action
@ -101,7 +104,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
LocalData.setAction(matcher.group(1)); LocalData.setAction(matcher.group(1));
} }
try {
filterChain.doFilter(servletRequest, servletResponse); filterChain.doFilter(servletRequest, servletResponse);
} catch (AccessDeniedException e) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} }
} }

@ -74,7 +74,7 @@ public class LocalData {
} }
public static void setApplicationContext(ApplicationContext applicationContext) { public static void setApplicationContext(ApplicationContext applicationContext) {
${basePackage}.frame.auth.LocalData.applicationContext = applicationContext; LocalData.applicationContext = applicationContext;
} }
public static <T> T getBean(Class<T> t) { public static <T> T getBean(Class<T> t) {

@ -13,7 +13,7 @@
} }
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background-color: #e8e8e8; background-color: #797979;
border-radius: 3px; border-radius: 3px;
} }

@ -396,6 +396,10 @@
this.vm.pageNumber = pageNumber; this.vm.pageNumber = pageNumber;
this.onFind(); this.onFind();
}, },
onPageSizeChange: function (pageSize) {
this.vm.pageSize = pageSize;
this.onFind();
},
onSelectionChange: function (select) { onSelectionChange: function (select) {
this.select = select; this.select = select;
}, },

@ -123,6 +123,8 @@
<el-table-column <el-table-column
align="center" align="center"
prop="${item.getFName()}" prop="${item.getFName()}"
<#if item.fieldType.javaType() == 'Date'>width="140"</#if>
<#if item.fieldType.javaType() == 'Long'>width="140"</#if>
label="${item.fieldComment?default("")}"> label="${item.fieldComment?default("")}">
</el-table-column> </el-table-column>
</#if> </#if>
@ -155,7 +157,7 @@
background background
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPage" @current-change="onPageChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"

@ -138,7 +138,8 @@
background background
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPage" @current-change="onPageChange"
@size-change="onPageSizeChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"

@ -120,6 +120,7 @@
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPageChange" @current-change="onPageChange"
@size-change="onPageSizeChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"

@ -121,7 +121,8 @@
background background
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPage" @current-change="onPageChange"
@size-change="onPageSizeChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"

@ -110,7 +110,8 @@
background background
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPage" @current-change="onPageChange"
@size-change="onPageSizeChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"

@ -136,7 +136,8 @@
background background
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPage" @current-change="onPageChange"
@size-change="onPageSizeChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"

@ -105,7 +105,8 @@
background background
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPage" @current-change="onPageChange"
@size-change="onPageSizeChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"

@ -93,7 +93,8 @@
<el-table-column <el-table-column
align="center" align="center"
prop="userId" prop="userId"
label="用户主键"> label="用户主键"
width="140">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
@ -103,22 +104,14 @@
<el-table-column <el-table-column
align="center" align="center"
prop="loginTime" prop="loginTime"
label="登录时间"> label="登录时间"
width="140">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="validTime" prop="validTime"
label="有效时间"> label="有效时间"
</el-table-column> width="140">
<el-table-column
align="center"
prop="deptId"
label="部门主键">
</el-table-column>
<el-table-column
align="center"
prop="deptCode"
label="部门代码">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
@ -133,11 +126,13 @@
<el-table-column <el-table-column
align="center" align="center"
prop="terminalIp" prop="terminalIp"
label="终端地址"> label="终端地址"
width="140">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="terminalInfo" prop="terminalInfo"
width="200"
label="终端信息"> label="终端信息">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -152,9 +147,9 @@
width="120" width="120"
label="操作"> label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-dropdown size="mini" split-button type="primary" @click="onCommand(['edit',scope.row])" <el-dropdown size="mini" split-button type="primary" @click="onCommand(['logout',scope.row])"
@command="onCommand"> @command="onCommand">
<i class="el-icon-edit"></i>编辑 <i class="el-icon-edit"></i>注销
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除 <el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除
</el-dropdown-item> </el-dropdown-item>
@ -168,7 +163,8 @@
background background
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPage" @current-change="onPageChange"
@size-change="onPageSizeChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
@ -235,16 +231,14 @@
valid: [ valid: [
{required: true, message: '是否有效不能为空', trigger: 'blur'}, {required: true, message: '是否有效不能为空', trigger: 'blur'},
], ],
deptId: [ deptId: [],
],
deptCode: [ deptCode: [
{min: 1, max: 50, message: '部门代码长度在 1 到 50 个字符', trigger: 'blur'} {min: 1, max: 50, message: '部门代码长度在 1 到 50 个字符', trigger: 'blur'}
], ],
deptName: [ deptName: [
{min: 1, max: 100, message: '部门名称长度在 1 到 100 个字符', trigger: 'blur'} {min: 1, max: 100, message: '部门名称长度在 1 到 100 个字符', trigger: 'blur'}
], ],
terminalType: [ terminalType: [],
],
terminalIp: [ terminalIp: [
{min: 1, max: 50, message: '终端地址长度在 1 到 50 个字符', trigger: 'blur'} {min: 1, max: 50, message: '终端地址长度在 1 到 50 个字符', trigger: 'blur'}
], ],
@ -258,26 +252,34 @@
const cmd = arg[0]; const cmd = arg[0];
const item = arg[1]; const item = arg[1];
switch (cmd) { switch (cmd) {
case "edit":
this.form.title = "通行证编辑";
this.form.dialog = true;
this.form.id = item.id;
this.form.userId = item.userId;
this.form.userName = item.userName;
this.form.loginTime = item.loginTime;
this.form.validTime = item.validTime;
this.form.valid = item.valid;
this.form.deptId = item.deptId;
this.form.deptCode = item.deptCode;
this.form.deptName = item.deptName;
this.form.terminalType = item.terminalType;
this.form.terminalIp = item.terminalIp;
this.form.terminalInfo = item.terminalInfo;
this.form.rowVersion = item.rowVersion;
break;
case "delete": case "delete":
this.onDelete(item); this.onDelete(item);
break; break;
case "logout":
this.$confirm('将注销该用户的登录信息, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
this.$ajax.post({
module: "system",
target: "tokens",
method: "logout",
data: {
token: item.token
}
}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.s("注销成功");
this.onFind();
}
}.bind(this));
}.bind(this)).catch(function (action) {
});
break;
default: default:
this.w("未找到对应的命令"); this.w("未找到对应的命令");
break; break;

@ -144,7 +144,8 @@
background background
v-if="vm.totalCount > vm.pageSize" v-if="vm.totalCount > vm.pageSize"
style="margin-top: 10px" style="margin-top: 10px"
@current-change="onPage" @current-change="onPageChange"
@size-change="onPageSizeChange"
:current-page="vm.pageNumber" :current-page="vm.pageNumber"
:page-size="vm.pageSize" :page-size="vm.pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"

@ -130,9 +130,9 @@ public class ResourceTest {
@Test @Test
public void testTree() { public void testTree() {
//创建数据 //创建数据
${basePackage}.module.system.req.ResourceTreeRequest request = new ${basePackage}.module.system.req.ResourceTreeRequest(); ResourceTreeRequest request = new ResourceTreeRequest();
${basePackage}.module.system.rsp.ResourceTreeResponse response = resourceManager.tree(request, token); ResourceTreeResponse response = resourceManager.tree(request, token);
assertTrue(!response.hasError()); assertTrue(!response.hasError());
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.