Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
complex-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
赵啸非
complex-platform
Commits
ea227a05
Commit
ea227a05
authored
Dec 20, 2023
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改token存取方式
parent
0d7fef77
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
complex-window-manager/src/main/java/com/mortals/xhx/protocol/complex/AbstractComplexService.java
.../mortals/xhx/protocol/complex/AbstractComplexService.java
+15
-1
complex-window-manager/src/main/java/com/mortals/xhx/protocol/complex/IComplexService.java
...ava/com/mortals/xhx/protocol/complex/IComplexService.java
+1
-0
complex-window-manager/src/main/java/com/mortals/xhx/protocol/complex/matter/service/impl/ComplexMatterServiceImpl.java
...complex/matter/service/impl/ComplexMatterServiceImpl.java
+6
-1
No files found.
complex-window-manager/src/main/java/com/mortals/xhx/protocol/complex/AbstractComplexService.java
View file @
ea227a05
...
@@ -3,10 +3,12 @@ package com.mortals.xhx.protocol.complex;
...
@@ -3,10 +3,12 @@ package com.mortals.xhx.protocol.complex;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.xhx.protocol.complex.matter.model.req.DeviceLoginReq
;
import
com.mortals.xhx.protocol.complex.matter.model.req.DeviceLoginReq
;
import
com.mortals.xhx.protocol.complex.matter.model.rsp.LoginRspInfo
;
import
com.mortals.xhx.protocol.complex.matter.model.rsp.LoginRspInfo
;
import
com.mortals.xhx.protocol.complex.matter.service.IComplexMatterService
;
import
com.mortals.xhx.protocol.complex.matter.service.IComplexMatterService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -28,11 +30,18 @@ public abstract class AbstractComplexService implements IComplexMatterService {
...
@@ -28,11 +30,18 @@ public abstract class AbstractComplexService implements IComplexMatterService {
//综窗接件token deviceCode--对应tokenMap
//综窗接件token deviceCode--对应tokenMap
public
static
Map
<
String
,
String
>
tokenMap
=
new
HashMap
<>();
public
static
Map
<
String
,
String
>
tokenMap
=
new
HashMap
<>();
public
static
String
DEVICE_LOGO_TOKEN
=
"device:logo:token"
;
/***/
public
static
Long
TOKEN_TIMEOUT
=
3600
l
;
@Autowired
private
ICacheService
iCacheService
;
@Override
@Override
public
String
getToken
(
String
deviceLogo
)
{
public
String
getToken
(
String
deviceLogo
)
{
try
{
try
{
String
deviceToken
=
tokenMap
.
getOrDefault
(
deviceLogo
,
""
);
String
deviceToken
=
iCacheService
.
get
(
DEVICE_LOGO_TOKEN
);
if
(
ObjectUtils
.
isEmpty
(
deviceToken
))
{
if
(
ObjectUtils
.
isEmpty
(
deviceToken
))
{
DeviceLoginReq
loginReq
=
new
DeviceLoginReq
();
DeviceLoginReq
loginReq
=
new
DeviceLoginReq
();
loginReq
.
setDeviceLogo
(
deviceLogo
);
loginReq
.
setDeviceLogo
(
deviceLogo
);
...
@@ -47,4 +56,9 @@ public abstract class AbstractComplexService implements IComplexMatterService {
...
@@ -47,4 +56,9 @@ public abstract class AbstractComplexService implements IComplexMatterService {
}
}
}
}
@Override
public
void
setToken
(
String
token
){
iCacheService
.
set
(
DEVICE_LOGO_TOKEN
,
token
,
TOKEN_TIMEOUT
);
}
}
}
complex-window-manager/src/main/java/com/mortals/xhx/protocol/complex/IComplexService.java
View file @
ea227a05
...
@@ -7,4 +7,5 @@ package com.mortals.xhx.protocol.complex;
...
@@ -7,4 +7,5 @@ package com.mortals.xhx.protocol.complex;
*/
*/
public
interface
IComplexService
{
public
interface
IComplexService
{
String
getToken
(
String
deviceLogo
);
String
getToken
(
String
deviceLogo
);
void
setToken
(
String
token
);
}
}
complex-window-manager/src/main/java/com/mortals/xhx/protocol/complex/matter/service/impl/ComplexMatterServiceImpl.java
View file @
ea227a05
...
@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.xhx.protocol.complex.AbstractComplexService
;
import
com.mortals.xhx.protocol.complex.AbstractComplexService
;
import
com.mortals.xhx.protocol.complex.ComplexApiRest
;
import
com.mortals.xhx.protocol.complex.ComplexApiRest
;
import
com.mortals.xhx.protocol.complex.matter.model.req.AcceptReq
;
import
com.mortals.xhx.protocol.complex.matter.model.req.AcceptReq
;
...
@@ -23,6 +24,7 @@ import com.mortals.xhx.protocol.complex.matter.model.rsp.matter.MatterWorkInfo;
...
@@ -23,6 +24,7 @@ import com.mortals.xhx.protocol.complex.matter.model.rsp.matter.MatterWorkInfo;
import
com.mortals.xhx.protocol.complex.matter.model.rsp.work.WorkInfo
;
import
com.mortals.xhx.protocol.complex.matter.model.rsp.work.WorkInfo
;
import
com.mortals.xhx.protocol.complex.matter.service.IComplexMatterService
;
import
com.mortals.xhx.protocol.complex.matter.service.IComplexMatterService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -41,6 +43,8 @@ import java.util.Map;
...
@@ -41,6 +43,8 @@ import java.util.Map;
@Slf4j
@Slf4j
public
class
ComplexMatterServiceImpl
extends
AbstractComplexService
implements
IComplexMatterService
{
public
class
ComplexMatterServiceImpl
extends
AbstractComplexService
implements
IComplexMatterService
{
//token有效期 10小时
//token有效期 10小时
@Override
@Override
public
Rest
<
LoginRspInfo
>
deviceLogin
(
DeviceLoginReq
loginReq
)
{
public
Rest
<
LoginRspInfo
>
deviceLogin
(
DeviceLoginReq
loginReq
)
{
...
@@ -54,7 +58,8 @@ public class ComplexMatterServiceImpl extends AbstractComplexService implements
...
@@ -54,7 +58,8 @@ public class ComplexMatterServiceImpl extends AbstractComplexService implements
//更新token
//更新token
String
deviceLoginToken
=
complexApiRest
.
getResult
().
getToken
();
String
deviceLoginToken
=
complexApiRest
.
getResult
().
getToken
();
String
deviceLogo
=
complexApiRest
.
getResult
().
getSelfDeviceInfo
().
getDeviceLogo
();
String
deviceLogo
=
complexApiRest
.
getResult
().
getSelfDeviceInfo
().
getDeviceLogo
();
this
.
tokenMap
.
put
(
deviceLogo
,
deviceLoginToken
);
//this.tokenMap.put(deviceLogo, deviceLoginToken);
this
.
setToken
(
deviceLoginToken
);
return
Rest
.
ok
(
complexApiRest
.
getMessage
(),
complexApiRest
.
getResult
());
return
Rest
.
ok
(
complexApiRest
.
getMessage
(),
complexApiRest
.
getResult
());
}
}
return
Rest
.
fail
(
complexApiRest
.
getMessage
());
return
Rest
.
fail
(
complexApiRest
.
getMessage
());
...
...
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