登录保存stationCode参数
master
xins 8 months ago
parent 04ca4eb29c
commit 7de8f4c03c

@ -63,6 +63,11 @@ public class LoginUser implements Serializable
*/
private Long stationId;
/**
*
*/
private String stationCode;
public String getToken()
{
return token;
@ -160,4 +165,12 @@ public class LoginUser implements Serializable
public void setStationId(Long stationId) {
this.stationId = stationId;
}
public String getStationCode() {
return stationCode;
}
public void setStationCode(String stationCode) {
this.stationCode = stationCode;
}
}

@ -44,6 +44,7 @@ public class TokenController
// 用户登录
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
userInfo.setStationId(form.getStationId());
userInfo.setStationCode(form.getStationCode());
// 获取登录token
return R.ok(tokenService.createToken(userInfo));
}

@ -23,6 +23,10 @@ public class LoginBody
*/
private Long stationId;
/**
*
*/
private String stationCode;
public String getUsername()
{
@ -51,4 +55,12 @@ public class LoginBody
public void setStationId(Long stationId) {
this.stationId = stationId;
}
public String getStationCode() {
return stationCode;
}
public void setStationCode(String stationCode) {
this.stationCode = stationCode;
}
}

@ -52,4 +52,9 @@ public class SecurityConstants
* ID
*/
public static final String DETAILS_STATION_ID = "station_id";
/**
*
*/
public static final String DETAILS_STATION_CODE = "station_code";
}

@ -107,4 +107,14 @@ public class SecurityContextHolder
set(SecurityConstants.DETAILS_STATION_ID, stationId);
}
public static String getStationCode()
{
return get(SecurityConstants.DETAILS_STATION_CODE);
}
public static void setStationCode(String stationCode)
{
set(SecurityConstants.DETAILS_STATION_CODE, stationCode);
}
}

@ -133,4 +133,14 @@ public class JwtUtils
return getValue(claims, SecurityConstants.DETAILS_STATION_ID);
}
/**
*
*
* @param claims
* @return
*/
public static String getStationCode(Claims claims)
{
return getValue(claims, SecurityConstants.DETAILS_STATION_CODE);
}
}

@ -32,6 +32,7 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor
SecurityContextHolder.setUserName(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USERNAME));
SecurityContextHolder.setUserKey(ServletUtils.getHeader(request, SecurityConstants.USER_KEY));
SecurityContextHolder.setStationId(ServletUtils.getHeader(request, SecurityConstants.DETAILS_STATION_ID));
SecurityContextHolder.setStationCode(ServletUtils.getHeader(request, SecurityConstants.DETAILS_STATION_CODE));
String token = SecurityUtils.getToken();
if (StringUtils.isNotEmpty(token))

@ -62,6 +62,7 @@ public class TokenService
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
claimsMap.put(SecurityConstants.DETAILS_STATION_ID, loginUser.getStationId());
claimsMap.put(SecurityConstants.DETAILS_STATION_CODE, loginUser.getStationCode());
// 接口返回信息
Map<String, Object> rspMap = new HashMap<String, Object>();

@ -48,6 +48,14 @@ public class SecurityUtils
return SecurityContextHolder.getStationId();
}
/**
*
*/
public static String getStationCode()
{
return SecurityContextHolder.getStationCode();
}
/**
*
*/

@ -70,6 +70,7 @@ public class AuthFilter implements GlobalFilter, Ordered
String userid = JwtUtils.getUserId(claims);
String username = JwtUtils.getUserName(claims);
String stationId = JwtUtils.getStationId(claims);
String stationCode = JwtUtils.getStationCode(claims);
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username))
{
return unauthorizedResponse(exchange, "令牌验证失败");
@ -80,6 +81,7 @@ public class AuthFilter implements GlobalFilter, Ordered
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
addHeader(mutate, SecurityConstants.DETAILS_STATION_ID, stationId);
addHeader(mutate, SecurityConstants.DETAILS_STATION_CODE, stationCode);
// 内部请求来源参数清除
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
return chain.filter(exchange.mutate().request(mutate.build()).build());

@ -1,7 +1,7 @@
import request from '@/utils/request'
// 登录方法
export function login(username, password, code, uuid, stationId) {
export function login(username, password, code, uuid, stationId,stationCode) {
return request({
url: '/auth/login',
headers: {
@ -9,7 +9,7 @@ export function login(username, password, code, uuid, stationId) {
repeatSubmit: false
},
method: 'post',
data: {username, password, code, uuid, stationId}
data: {username, password, code, uuid, stationId,stationCode}
})
}

@ -43,8 +43,9 @@ const user = {
const code = userInfo.code
const uuid = userInfo.uuid
const stationId = userInfo.stationId || ''
const stationCode = userInfo.stationCode || ''
return new Promise((resolve, reject) => {
login(username, password, code, uuid,stationId).then(res => {
login(username, password, code, uuid,stationId,stationCode).then(res => {
let data = res.data
setToken(data.access_token)
commit('SET_TOKEN', data.access_token)

@ -1,7 +1,7 @@
<template>
<div class="login">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
<h3 class="title">京源环保办公系统</h3>
<h3 class="title">京源环保MES系统</h3>
<el-form-item prop="username">
<el-input
v-model="loginForm.username"
@ -24,11 +24,14 @@
</el-input>
</el-form-item>
<el-form-item v-if="isStationId" prop="stationId">
<el-select v-model="loginForm.stationId" placeholder="请选择工位" style="width: 100%">
<el-select v-model="loginForm.stationId" placeholder="请选择工位" style="width: 100%" @change="changeStation">
<el-option v-for="item in options" :key="item.stationId" :label="item.stationName"
:value="item.stationId"></el-option>
</el-select>
</el-form-item>
<el-form-item label="工位编号" prop="stationCode" v-if="false">
<el-input v-model="loginForm.stationCode"/>
</el-form-item>
<el-form-item v-if="captchaEnabled" prop="code">
<el-input
v-model="loginForm.code"
@ -82,6 +85,7 @@ export default {
password: "admin123",
rememberMe: false,
stationId: '',
stationCode:'',
code: "",
uuid: ""
},
@ -204,6 +208,12 @@ export default {
});
}
});
},
changeStation(stationId){
let station = this.options.find(v=>v.stationId === stationId)
this.loginForm.stationCode = station.stationCode;
}
}
};

Loading…
Cancel
Save