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

@ -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) {

@ -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));
}

@ -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);
}
}
}

@ -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> T getBean(Class<T> t) {

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

@ -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;
},

@ -123,6 +123,8 @@
<el-table-column
align="center"
prop="${item.getFName()}"
<#if item.fieldType.javaType() == 'Date'>width="140"</#if>
<#if item.fieldType.javaType() == 'Long'>width="140"</#if>
label="${item.fieldComment?default("")}">
</el-table-column>
</#if>
@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -28,7 +28,7 @@
<el-input v-model="vm.deptName" clearable size="small" placeholder="请输入部门名称"></el-input>
</el-form-item>
<el-form-item label="终端类型" prop="terminalType">
<el-input-dict v-model="vm.terminalType" clearable size="small" placeholder="请输入终端类型" dict-name="TERMINAL_TYPE" ></el-input-dict>
<el-input-dict v-model="vm.terminalType" clearable size="small" placeholder="请输入终端类型" dict-name="TERMINAL_TYPE"></el-input-dict>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" icon="el-icon-search" @click="onSearch">搜索</el-button>
@ -93,7 +93,8 @@
<el-table-column
align="center"
prop="userId"
label="用户主键">
label="用户主键"
width="140">
</el-table-column>
<el-table-column
align="center"
@ -103,22 +104,14 @@
<el-table-column
align="center"
prop="loginTime"
label="登录时间">
label="登录时间"
width="140">
</el-table-column>
<el-table-column
align="center"
prop="validTime"
label="有效时间">
</el-table-column>
<el-table-column
align="center"
prop="deptId"
label="部门主键">
</el-table-column>
<el-table-column
align="center"
prop="deptCode"
label="部门代码">
label="有效时间"
width="140">
</el-table-column>
<el-table-column
align="center"
@ -133,11 +126,13 @@
<el-table-column
align="center"
prop="terminalIp"
label="终端地址">
label="终端地址"
width="140">
</el-table-column>
<el-table-column
align="center"
prop="terminalInfo"
width="200"
label="终端信息">
</el-table-column>
<el-table-column
@ -152,9 +147,9 @@
width="120"
label="操作">
<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">
<i class="el-icon-edit"></i>编辑
<i class="el-icon-edit"></i>注销
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除
</el-dropdown-item>
@ -168,7 +163,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"
@ -198,8 +194,8 @@
pageNumber: 1,
pageSize: 10,
totalCount: 0,
sortKey:'CREATE_TIME',
sortType:'DESC'
sortKey: 'CREATE_TIME',
sortType: 'DESC'
},
form: {//待提交表单
title: "",
@ -235,16 +231,14 @@
valid: [
{required: true, message: '是否有效不能为空', trigger: 'blur'},
],
deptId: [
],
deptId: [],
deptCode: [
{min: 1, max: 50, message: '部门代码长度在 1 到 50 个字符', trigger: 'blur'}
],
deptName: [
{min: 1, max: 100, message: '部门名称长度在 1 到 100 个字符', trigger: 'blur'}
],
terminalType: [
],
terminalType: [],
terminalIp: [
{min: 1, max: 50, message: '终端地址长度在 1 到 50 个字符', trigger: 'blur'}
],
@ -258,26 +252,34 @@
const cmd = arg[0];
const item = arg[1];
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":
this.onDelete(item);
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:
this.w("未找到对应的命令");
break;

@ -144,7 +144,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"

@ -130,9 +130,9 @@ public class ResourceTest {
@Test
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());
}

Loading…
Cancel
Save

Powered by TurnKey Linux.