Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
4b06caab
Commit
4b06caab
authored
Jul 18, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改设备管理系统单点登录
parent
b0cd12b9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
72 additions
and
152 deletions
+72
-152
common-lib/src/main/java/com/mortals/xhx/feign/user/IUserFeign.java
.../src/main/java/com/mortals/xhx/feign/user/IUserFeign.java
+1
-1
device-manager-ui/admin/.env
device-manager-ui/admin/.env
+4
-1
device-manager-ui/admin/.env.production
device-manager-ui/admin/.env.production
+4
-1
device-manager-ui/admin/.env.stage
device-manager-ui/admin/.env.stage
+3
-0
device-manager-ui/admin/src/router.js
device-manager-ui/admin/src/router.js
+13
-2
device-manager-ui/admin/src/views/Home.vue
device-manager-ui/admin/src/views/Home.vue
+2
-0
device-manager-ui/admin/src/views/login/authentication.vue
device-manager-ui/admin/src/views/login/authentication.vue
+11
-6
device-manager/pom.xml
device-manager/pom.xml
+3
-3
device-manager/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthTokenServiceImpl.java
.../xhx/base/framework/interceptor/AuthTokenServiceImpl.java
+14
-126
device-manager/src/main/java/com/mortals/xhx/module/sitestat/service/impl/SitestatServiceImpl.java
...xhx/module/sitestat/service/impl/SitestatServiceImpl.java
+17
-12
No files found.
common-lib/src/main/java/com/mortals/xhx/feign/user/IUserFeign.java
View file @
4b06caab
...
...
@@ -18,7 +18,7 @@ import java.util.List;
* @author zxfei
* @date 2022-07-06
*/
@FeignClient
(
name
=
"
base-manager"
,
path
=
"/base
"
,
fallbackFactory
=
UserFeignFallbackFactory
.
class
)
@FeignClient
(
name
=
"
portal-manager"
,
path
=
"/zwfw
"
,
fallbackFactory
=
UserFeignFallbackFactory
.
class
)
public
interface
IUserFeign
extends
IFeign
{
...
...
device-manager-ui/admin/.env
View file @
4b06caab
...
...
@@ -5,5 +5,8 @@ NODE_ENV = development
VUE_APP_BASE_API =http://plm.testnew.com:8082/m
# websocket地址
VUE_APP_WEBSOCKET_API =127.0.0.1:18221/m
VUE_APP_WEBSOCKET_API =127.0.0.1:18222/m
# 门户登录地址
VUE_APP_PORTAL_URL = http://192.168.0.98:11072
device-manager-ui/admin/.env.production
View file @
4b06caab
...
...
@@ -5,5 +5,8 @@ NODE_ENV = production
VUE_APP_BASE_API = http://192.168.0.26:9005/m
# websocket地址
VUE_APP_WEBSOCKET_API =192.168.0.26:18221/m
VUE_APP_WEBSOCKET_API =192.168.0.98:18222/m
# 门户登录地址
VUE_APP_PORTAL_URL = http://192.168.0.98:11072
device-manager-ui/admin/.env.stage
View file @
4b06caab
...
...
@@ -7,3 +7,6 @@ VUE_APP_BASE_API = http://192.168.0.98:11091/m
# websocket地址
VUE_APP_WEBSOCKET_API =192.168.0.98:18222/m
# 门户登录地址
VUE_APP_PORTAL_URL = http://192.168.0.98:11072
device-manager-ui/admin/src/router.js
View file @
4b06caab
...
...
@@ -6,11 +6,19 @@ import fileNotFound from './views/errors/fileNotFound.vue'
Vue
.
use
(
Router
);
const
originalPush
=
VueRouter
.
prototype
.
push
VueRouter
.
prototype
.
push
=
function
push
(
location
,
onResolve
,
onReject
)
{
if
(
onResolve
||
onReject
)
return
originalPush
.
call
(
this
,
location
,
onResolve
,
onReject
)
return
originalPush
.
call
(
this
,
location
).
catch
(
err
=>
err
)
}
const
router
=
new
Router
({
routes
:
[
builder
(
'
/authentication
'
,
'
login/authentication
'
),
builder
(
'
/login
'
,
'
login/login
'
),
builder
(
'
/go
'
,
'
codeGen/index
'
),
builder
(
'
/sso
'
,
'
SSO
'
),
{
path
:
'
/
'
,
name
:
'
layout
'
,
...
...
@@ -38,7 +46,7 @@ const router = new Router({
...
restBuilder
(
'
platform
'
,
'
platform
'
),
//平台
...
restBuilder
(
'
product
'
,
'
product
'
),
//产品
...
restBuilder
(
'
device
'
,
'
device
'
),
//设备
...
restBuilder
(
'
device/alarm/info
'
,
'
device/alarm/info
'
),
//设备告警信息
...
restBuilder
(
'
device/module
'
,
'
device/module
'
),
//设备模块使用率
...
restBuilder
(
'
device/module/use
'
,
'
device/module/use
'
),
//设备模块使用率
...
...
@@ -104,7 +112,10 @@ function getComponent(fileName) {
}
}
//检查是否跳转到sso地址
function
ssoCheck
(
to
,
from
,
next
)
{
function
ssoCheck
(
to
,
from
,
next
)
{
console
.
log
(
"
to
"
,
to
)
console
.
log
(
"
from
"
,
from
)
console
.
log
(
"
next
"
,
next
)
let
redirect
=
(
to
.
path
===
'
/login/updatePwd
'
)
?
'
/#/updatePwd
'
:
''
redirect
=
(
redirect
===
''
&&
to
.
path
===
'
/login
'
)
?
(
location
.
protocol
+
'
//
'
+
location
.
host
+
'
/#
'
+
from
.
fullPath
)
:
redirect
if
(
redirect
!=
''
)
{
...
...
device-manager-ui/admin/src/views/Home.vue
View file @
4b06caab
...
...
@@ -215,6 +215,8 @@ export default {
this
.
findDeviceAlarm
(
beforeday
);
this
.
findDevicePush
(
beforeday
);
console
.
log
(
"
process
"
,
process
.
env
)
},
methods
:
{
findDeviceTotalStat
(
beforeday
)
{
...
...
device-manager-ui/admin/src/views/login/authentication.vue
View file @
4b06caab
...
...
@@ -22,12 +22,17 @@ export default {
},
loginFail
(
error
)
{
this
.
$message
.
error
(
error
.
message
||
'
请登录
'
);
this
.
$router
.
replace
({
path
:
'
/login
'
,
query
:
{
redirect
:
this
.
redirect
,
}
});
console
.
log
(
"
href:
"
+
process
.
env
.
VUE_APP_PORTAL_URL
)
// window.location.href=process.env.VUE_APP_PORTAL_URL=='undefined'?'http://192.168.0.98:11072':process.env.VUE_APP_PORTAL_URL
// window.location.href=process.env.VUE_APP_PORTAL_URL
// this.$router.replace({
// path: '/login',
// query: {
// redirect: this.redirect,
// }
// });
}
},
computed
:
{
...
...
device-manager/pom.xml
View file @
4b06caab
...
...
@@ -28,11 +28,11 @@
<![CDATA[jdbc:mysql://localhost:3306/device-new-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]>
</profiles.datasource.uri>
<profiles.datasource.username>
root
</profiles.datasource.username>
<profiles.datasource.password>
12345678
</profiles.datasource.password>
<profiles.redis.uri>
1
27.0.0.1
</profiles.redis.uri>
<profiles.redis.uri>
1
92.168.0.252
</profiles.redis.uri>
<profiles.redis.port>
6379
</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password></profiles.redis.password>
<profiles.redis.database>
1
</profiles.redis.database>
<profiles.redis.password>
hotel@2020
</profiles.redis.password>
<profiles.redis.database>
7
</profiles.redis.database>
<profiles.kafka.brokers>
192.168.0.251:9092
</profiles.kafka.brokers>
<profiles.queue.type>
rabbitmq
</profiles.queue.type>
<profiles.rabbitmq.host>
192.168.0.98
</profiles.rabbitmq.host>
...
...
device-manager/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthTokenServiceImpl.java
View file @
4b06caab
...
...
@@ -8,6 +8,7 @@ import com.mortals.framework.service.ICacheService;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
...
...
@@ -28,7 +29,7 @@ import java.util.Map;
* @author zxfei
*/
//
@Service
@Service
@Order
(
1
)
@Slf4j
public
class
AuthTokenServiceImpl
implements
IAuthTokenService
{
...
...
@@ -51,20 +52,20 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
@Value
(
"${spring.redis.database:}"
)
private
Integer
db
;
@Value
(
"${token.database:
1
}"
)
@Value
(
"${token.database:
0
}"
)
private
Integer
portalDb
;
protected
static
final
Long
MILLIS_SECOND
=
1000
l
;
protected
static
final
Long
SECOND
=
1
l
;
protected
static
final
Long
MILLIS_MINUTE
=
60
*
MILLIS_
SECOND
;
protected
static
final
Long
SECOND_MINUTE
=
60
*
SECOND
;
protected
static
final
Long
MILLIS_HOUR
=
60
*
MILLIS
_MINUTE
;
protected
static
final
Long
SECOND_HOUR
=
60
*
SECOND
_MINUTE
;
protected
static
final
Long
MILLIS_DAY
=
24
*
MILLIS
_HOUR
;
protected
static
final
Long
SECOND_DAY
=
24
*
SECOND
_HOUR
;
protected
static
final
Long
MILLIS_WEEK
=
7
*
MILLIS
_DAY
;
protected
static
final
Long
SECOND_WEEK
=
7
*
SECOND
_DAY
;
private
static
final
Long
MILLIS_MINUTE_TEN
=
20
*
60
*
1000L
;
private
static
final
Long
SECOND_MINUTE_TEN
=
1
*
SECOND_MINUTE
;
@Autowired
private
ICacheService
cacheService
;
...
...
@@ -88,122 +89,9 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
String
userStr
=
cacheService
.
get
(
userKey
);
cacheService
.
select
(
db
);
if
(
StringUtils
.
isNotEmpty
(
userStr
))
{
JSONObject
userObj
=
JSON
.
parseObject
(
userStr
);
Long
userId
=
userObj
.
getLongValue
(
"id"
);
Integer
userType
=
userObj
.
getIntValue
(
"userType"
);
Long
customerId
=
userObj
.
getLongValue
(
"customerId"
);
Long
siteId
=
userObj
.
getLongValue
(
"siteId"
);
Long
loginTime
=
userObj
.
getLongValue
(
"loginTime"
);
Long
expireTime
=
userObj
.
getLongValue
(
"expireTime"
);
String
loginName
=
userObj
.
getString
(
"loginName"
);
String
realName
=
userObj
.
getString
(
"realName"
);
String
siteIds
=
userObj
.
getString
(
"siteIds"
);
String
menuUrl
=
userObj
.
getString
(
"menuUrl"
);
Boolean
isManager
=
userObj
.
getBoolean
(
"manager"
);
Boolean
isSystemUser
=
userObj
.
getBoolean
(
"systemUser"
);
return
new
IUser
()
{
@Override
public
Long
getId
()
{
return
userId
;
}
@Override
public
Long
getDeptId
()
{
return
null
;
}
@Override
public
String
getDeptName
()
{
return
null
;
}
@Override
public
Long
getCustomerId
()
{
return
customerId
;
}
@Override
public
Long
getSiteId
()
{
return
siteId
;
}
@Override
public
String
getSiteIds
()
{
return
siteIds
;
}
@Override
public
Long
getCustomerJoinId
()
{
return
null
;
}
@Override
public
String
getCustomerNum
()
{
return
null
;
}
@Override
public
String
getLoginName
()
{
return
loginName
;
}
@Override
public
String
getRealName
()
{
return
realName
;
}
@Override
public
boolean
isAdmin
()
{
return
userId
==
1L
;
}
@Override
public
boolean
isSystemUser
()
{
return
isSystemUser
;
}
@Override
public
boolean
isManager
()
{
return
isManager
;
}
@Override
public
Integer
getUserType
()
{
return
userType
;
}
@Override
public
String
getToken
()
{
return
token
;
}
@Override
public
Long
getLoginTime
()
{
return
loginTime
;
}
@Override
public
Long
getExpireTime
()
{
return
expireTime
;
}
@Override
public
void
setExpireTime
(
Long
expireTime
)
{
}
@Override
public
String
getMenuUrl
()
{
return
menuUrl
;
}
};
UserEntity
userEntity
=
JSONObject
.
parseObject
(
userStr
,
UserEntity
.
class
);
return
userEntity
;
}
// return cacheService.get(userKey, IUser.class);
}
catch
(
Exception
e
)
{
log
.
error
(
"解析jwt token异常!"
,
e
);
return
null
;
...
...
@@ -259,7 +147,7 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
public
void
verifyToken
(
IUser
user
)
{
long
expireTime
=
user
.
getExpireTime
();
long
currentTime
=
System
.
currentTimeMillis
();
if
(
expireTime
-
currentTime
<=
MILLIS
_MINUTE_TEN
)
{
if
(
expireTime
-
currentTime
<=
SECOND
_MINUTE_TEN
)
{
log
.
info
(
"不足十分钟,刷新过期时间"
);
refreshToken
(
user
);
}
...
...
@@ -272,11 +160,11 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
*/
public
void
refreshToken
(
IUser
user
)
{
//user.setLoginTime(System.currentTimeMillis());
user
.
setExpireTime
(
user
.
getLoginTime
()
==
null
?
System
.
currentTimeMillis
()
:
user
.
getLoginTime
()
+
expireTime
*
MILLIS
_MINUTE
);
user
.
setExpireTime
(
user
.
getLoginTime
()
==
null
?
System
.
currentTimeMillis
()
:
user
.
getLoginTime
()
+
expireTime
*
SECOND
_MINUTE
);
// 根据uuid将user缓存
String
userKey
=
getTokenKey
(
user
.
getToken
());
//设置有效时间 单位秒
cacheService
.
set
nx
(
userKey
,
user
,
expireTime
*
MILLIS
_MINUTE
);
cacheService
.
set
(
userKey
,
user
,
expireTime
*
SECOND
_MINUTE
);
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/sitestat/service/impl/SitestatServiceImpl.java
View file @
4b06caab
...
...
@@ -10,6 +10,7 @@ import com.mortals.framework.model.Result;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.xhx.common.code.DeviceStatusEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.key.ErrorCode
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.common.utils.MemoryPagination
;
...
...
@@ -31,6 +32,8 @@ import org.springframework.util.ObjectUtils;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
ErrorCode
.
ERROR_TOKEN_EXPIRED_CONTENT
;
/**
* SitestatService
* 站点统计 service实现
...
...
@@ -121,18 +124,20 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
@Override
public
String
getSiteTree
(
Context
context
)
{
//
UserPdu
userPdu
=
new
UserPdu
();
userPdu
.
setLoginName
(
"admin"
);
userPdu
.
setPassword
(
"admin"
);
userPdu
.
setSecurityCode
(
"8888"
);
String
loginResp
=
userFeign
.
portalLogin
(
userPdu
);
JSONObject
loginRespJson
=
JSON
.
parseObject
(
loginResp
);
String
token
=
loginRespJson
.
getJSONObject
(
"data"
).
getString
(
"token"
);
// String token = context.getUser().getToken();
String
resp
=
siteFeign
.
siteTree
(
token
);
log
.
info
(
"treeResp:"
+
resp
);
return
resp
;
// UserPdu userPdu = new UserPdu();
// userPdu.setLoginName("admin");
// userPdu.setPassword("admin");
// userPdu.setSecurityCode("8888");
// String loginResp = userFeign.portalLogin(userPdu);
// JSONObject loginRespJson = JSON.parseObject(loginResp);
// String token = loginRespJson.getJSONObject("data").getString("token");
String
token
=
context
.
getUser
().
getToken
();
if
(!
ObjectUtils
.
isEmpty
(
token
))
{
String
resp
=
siteFeign
.
siteTree
(
token
);
log
.
info
(
"treeResp:"
+
resp
);
}
return
JSON
.
toJSONString
(
Rest
.
fail
(
ErrorCode
.
ERROR_TOKEN_EXPIRED
,
ERROR_TOKEN_EXPIRED_CONTENT
));
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment