Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-bi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林锐标
slm-bi
Commits
115abd61
Commit
115abd61
authored
Apr 22, 2021
by
梁光意
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改RestTemplateUtils方法
parent
32e82fcb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
27 deletions
+15
-27
SlmConstants.java
...n/java/com/syc/slm/common/core/constant/SlmConstants.java
+5
-0
R.java
src/main/java/com/syc/slm/common/core/util/R.java
+0
-2
RestTemplateUtils.java
.../java/com/syc/slm/common/core/util/RestTemplateUtils.java
+0
-0
BaseRestController.java
...java/com/syc/slm/slmbi/controller/BaseRestController.java
+3
-7
DeptServiceImpl.java
.../java/com/syc/slm/slmbi/service/impl/DeptServiceImpl.java
+2
-3
InstrumentPanelTreeServiceImpl.java
...lm/slmbi/service/impl/InstrumentPanelTreeServiceImpl.java
+1
-3
PositionServiceImpl.java
...a/com/syc/slm/slmbi/service/impl/PositionServiceImpl.java
+1
-3
UserServiceImpl.java
.../java/com/syc/slm/slmbi/service/impl/UserServiceImpl.java
+1
-3
VariableServiceImpl.java
...a/com/syc/slm/slmbi/service/impl/VariableServiceImpl.java
+2
-6
No files found.
src/main/java/com/syc/slm/common/core/constant/SlmConstants.java
View file @
115abd61
...
...
@@ -30,4 +30,9 @@ public final class SlmConstants {
*/
public
static
final
Integer
DATA_DELETED
=
-
1
;
/**
* 请求头token的key名称
*/
public
static
final
String
TOKEN_PREFIX
=
"X-Token"
;
}
src/main/java/com/syc/slm/common/core/util/R.java
View file @
115abd61
...
...
@@ -20,14 +20,12 @@
package
com
.
syc
.
slm
.
common
.
core
.
util
;
import
com.syc.slm.common.core.constant.CommonConstants
;
import
com.syc.slm.common.core.constant.SlmConstants
;
import
com.syc.slm.slmbi.exception.SysException
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.*
;
import
lombok.experimental.Accessors
;
import
javax.sound.midi.SysexMessage
;
import
java.io.Serializable
;
/**
...
...
src/main/java/com/syc/slm/common/core/util/RestTemplateUtils.java
View file @
115abd61
This diff is collapsed.
Click to expand it.
src/main/java/com/syc/slm/slmbi/controller/BaseRestController.java
View file @
115abd61
...
...
@@ -31,7 +31,6 @@ import java.util.function.Supplier;
* @date : 2021-04-06 09:09
**/
@Slf4j
public
class
BaseRestController
{
@Value
(
"${dc_client.host}"
)
...
...
@@ -73,7 +72,7 @@ public class BaseRestController {
}
}
log
.
info
(
"请求头参数--->>>>"
+
SlmConstants
.
gson
.
toJson
(
headers
));
String
token
=
request
.
getHeader
(
"X-Token"
);
String
token
=
request
.
getHeader
(
SlmConstants
.
TOKEN_PREFIX
);
if
(!
uri
.
contains
(
"tokens"
))
{
if
(
StringUtils
.
isEmpty
(
token
))
{
throw
new
SysException
(
"token不能为空"
);
...
...
@@ -81,13 +80,10 @@ public class BaseRestController {
log
.
info
(
"获取用户信息"
);
NativeWebRequest
webRequest
=
new
ServletWebRequest
(
request
);
Map
<
String
,
String
>
map
=
(
Map
<
String
,
String
>)
webRequest
.
getAttribute
(
HandlerMapping
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
,
RequestAttributes
.
SCOPE_REQUEST
);
// Map<String, Object> map = (Map<String, Object>) webRequest.getAttribute(View.PATH_VARIABLES, RequestAttributes.SCOPE_REQUEST);
Map
<
String
,
String
>
heads
=
Maps
.
newHashMap
();
heads
.
put
(
"X-Token"
,
token
);
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"appId"
,
map
.
get
(
"appId"
)+
""
);
String
getUrl
=
dcClientHost
+
"/{appId}/users/user-info"
;
R
<
CurrentUser
>
result
=
RestTemplateUtils
.
get
(
getUrl
,
heads
,
new
TypeToken
<
R
<
CurrentUser
>>()
{
R
<
CurrentUser
>
result
=
RestTemplateUtils
.
get
(
getUrl
,
token
,
new
TypeToken
<
R
<
CurrentUser
>>()
{
}.
getType
(),
uriVariables
);
request
.
getSession
().
setAttribute
(
token
,
SlmConstants
.
gson
.
toJson
(
result
.
detach
()));
}
...
...
@@ -103,7 +99,7 @@ public class BaseRestController {
}
protected
CurrentUser
getCurrentUser
(
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"X-Token"
);
String
token
=
request
.
getHeader
(
SlmConstants
.
TOKEN_PREFIX
);
return
SlmConstants
.
gson
.
fromJson
(
request
.
getSession
().
getAttribute
(
token
).
toString
(),
CurrentUser
.
class
);
}
}
src/main/java/com/syc/slm/slmbi/service/impl/DeptServiceImpl.java
View file @
115abd61
...
...
@@ -2,6 +2,7 @@ package com.syc.slm.slmbi.service.impl;
import
com.google.common.collect.Maps
;
import
com.google.gson.reflect.TypeToken
;
import
com.syc.slm.common.core.constant.SlmConstants
;
import
com.syc.slm.common.core.util.R
;
import
com.syc.slm.common.core.util.RestTemplateUtils
;
import
com.syc.slm.slmbi.service.DeptService
;
...
...
@@ -28,13 +29,11 @@ public class DeptServiceImpl implements DeptService {
public
List
<
DeptVo
>
selectPositionList
(
String
uri
,
String
token
,
String
appId
,
String
deptName
)
{
log
.
info
(
"部门查询uri:---------------->"
+
uri
);
log
.
info
(
"部门查询token:---------------->"
+
token
);
Map
<
String
,
String
>
heads
=
Maps
.
newHashMap
();
heads
.
put
(
"X-Token"
,
token
);
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"deptName"
,
deptName
);
uriVariables
.
put
(
"appId"
,
appId
);
R
<
List
<
DeptVo
>>
result
=
RestTemplateUtils
.
get
(
uri
,
heads
,
new
TypeToken
<
R
<
List
<
DeptVo
>>>()
{}.
getType
(),
uriVariables
);
R
<
List
<
DeptVo
>>
result
=
RestTemplateUtils
.
get
(
uri
,
token
,
new
TypeToken
<
R
<
List
<
DeptVo
>>>()
{}.
getType
(),
uriVariables
);
return
result
.
detach
();
}
}
src/main/java/com/syc/slm/slmbi/service/impl/InstrumentPanelTreeServiceImpl.java
View file @
115abd61
...
...
@@ -415,11 +415,9 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT
private
R
<
Map
<
String
,
String
>>
setDeptAndRole
(
CurrentUser
user
,
String
uri
){
Map
<
String
,
String
>
heads
=
Maps
.
newHashMap
();
heads
.
put
(
"X-Token"
,
user
.
getToken
());
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"appId"
,
user
.
getAppId
());
return
RestTemplateUtils
.
get
(
uri
,
heads
,
new
TypeToken
<
R
<
Map
<
String
,
String
>>>()
{}.
getType
(),
uriVariables
);
return
RestTemplateUtils
.
get
(
uri
,
user
.
getToken
()
,
new
TypeToken
<
R
<
Map
<
String
,
String
>>>()
{}.
getType
(),
uriVariables
);
}
}
src/main/java/com/syc/slm/slmbi/service/impl/PositionServiceImpl.java
View file @
115abd61
...
...
@@ -27,13 +27,11 @@ public class PositionServiceImpl implements PositionService {
@Override
public
List
<
PositionVo
>
selectPositionList
(
String
uri
,
String
token
,
String
appId
,
String
name
)
{
Map
<
String
,
String
>
heads
=
Maps
.
newHashMap
();
heads
.
put
(
"X-Token"
,
token
);
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"positionName"
,
name
);
uriVariables
.
put
(
"appId"
,
appId
);
R
<
List
<
PositionVo
>>
result
=
RestTemplateUtils
.
get
(
uri
,
heads
,
new
TypeToken
<
R
<
List
<
PositionVo
>>>()
{}.
getType
(),
uriVariables
);
R
<
List
<
PositionVo
>>
result
=
RestTemplateUtils
.
get
(
uri
,
token
,
new
TypeToken
<
R
<
List
<
PositionVo
>>>()
{}.
getType
(),
uriVariables
);
return
result
.
detach
();
}
}
src/main/java/com/syc/slm/slmbi/service/impl/UserServiceImpl.java
View file @
115abd61
...
...
@@ -26,12 +26,10 @@ import java.util.Map;
public
class
UserServiceImpl
implements
UserService
{
@Override
public
List
<
UserTreeVo
>
selectUserList
(
String
appId
,
String
uri
,
String
token
,
String
userName
)
{
Map
<
String
,
String
>
heads
=
Maps
.
newHashMap
();
heads
.
put
(
"X-Token"
,
token
);
Map
<
String
,
String
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"userName"
,
userName
);
uriVariables
.
put
(
"appId"
,
appId
);
R
<
List
<
UserTreeVo
>>
result
=
RestTemplateUtils
.
get
(
uri
,
heads
,
new
TypeToken
<
R
<
List
<
UserTreeVo
>>>()
{}.
getType
(),
uriVariables
);
R
<
List
<
UserTreeVo
>>
result
=
RestTemplateUtils
.
get
(
uri
,
token
,
new
TypeToken
<
R
<
List
<
UserTreeVo
>>>()
{}.
getType
(),
uriVariables
);
return
result
.
detach
();
}
}
src/main/java/com/syc/slm/slmbi/service/impl/VariableServiceImpl.java
View file @
115abd61
...
...
@@ -47,10 +47,8 @@ public class VariableServiceImpl implements VariableService {
p
.
put
(
"isCustomer"
,
null
);
p
.
put
(
"current"
,
variableDTO
.
getCurrent
()+
""
);
p
.
put
(
"size"
,
variableDTO
.
getSize
()+
""
);
Map
<
String
,
String
>
heads
=
Maps
.
newHashMap
();
heads
.
put
(
"X-Token"
,
token
);
R
<
Map
<
String
,
Object
>>
result
=
RestTemplateUtils
.
get
(
uri
,
heads
,
new
TypeToken
<
R
<
Map
<
String
,
Object
>>>()
{
R
<
Map
<
String
,
Object
>>
result
=
RestTemplateUtils
.
get
(
uri
,
token
,
new
TypeToken
<
R
<
Map
<
String
,
Object
>>>()
{
}.
getType
(),
p
);
Map
<
String
,
Object
>
detach
=
result
.
detach
();
if
(
CollectionUtils
.
isNotEmpty
(
detach
))
{
...
...
@@ -98,9 +96,7 @@ public class VariableServiceImpl implements VariableService {
p
.
put
(
"warranty_status"
,
null
);
p
.
put
(
"page_num"
,
queryPageDTO
.
getCurrent
()
+
""
);
p
.
put
(
"page_size"
,
queryPageDTO
.
getSize
()
+
""
);
Map
<
String
,
String
>
heads
=
Maps
.
newHashMap
();
heads
.
put
(
"X-Token"
,
token
);
R
<
Map
<
String
,
Object
>>
result
=
RestTemplateUtils
.
get
(
uri
,
heads
,
new
TypeToken
<
R
<
Map
<
String
,
Object
>>>()
{
R
<
Map
<
String
,
Object
>>
result
=
RestTemplateUtils
.
get
(
uri
,
token
,
new
TypeToken
<
R
<
Map
<
String
,
Object
>>>()
{
}.
getType
(),
p
);
Map
<
String
,
Object
>
detach
=
result
.
detach
();
if
(
CollectionUtils
.
isNotEmpty
(
detach
))
{
...
...
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