Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
4bf4f957
Commit
4bf4f957
authored
Apr 16, 2019
by
sam.x.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交sso问题
parent
c47bd1cc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
96 deletions
+98
-96
IndexController.java
...java/pwc/taxtech/atms/web/controller/IndexController.java
+5
-1
OrangeHeapController.java
...pwc/taxtech/atms/web/controller/OrangeHeapController.java
+31
-33
OrangeHeapService.java
.../java/pwc/taxtech/atms/web/service/OrangeHeapService.java
+62
-62
No files found.
atms-web/src/main/java/pwc/taxtech/atms/web/controller/IndexController.java
View file @
4bf4f957
...
...
@@ -116,6 +116,10 @@ public class IndexController {
try
{
logger
.
info
(
"jumpto="
+
jumpto
+
"code="
+
code
);
String
ticketStr
=
getTicket
(
code
);
Cookie
ddTicket
=
new
Cookie
(
"ddTicket"
,
URLEncoder
.
encode
(
ticketStr
,
"UTF-8"
));
ddTicket
.
setPath
(
"/"
);
ddTicket
.
setMaxAge
(
18000
);
response
.
addCookie
(
ddTicket
);
response
.
sendRedirect
(
jumpto
+
"?code="
+
code
+
"&ticketStr="
+
ticketStr
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"ddSSOCallback error"
,
e
);
...
...
@@ -212,7 +216,7 @@ public class IndexController {
public
String
getCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
orangeHeapService
.
getDDTicketByCookie
();
orangeHeapService
.
getDDTicketByCookie
(
request
);
return
null
;
}
...
...
atms-web/src/main/java/pwc/taxtech/atms/web/controller/OrangeHeapController.java
View file @
4bf4f957
...
...
@@ -4,8 +4,6 @@ package pwc.taxtech.atms.web.controller;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -14,7 +12,7 @@ import pwc.taxtech.atms.dto.ApiResultDto;
import
pwc.taxtech.atms.web.service.OrangeHeapService
;
import
javax.annotation.Resource
;
import
java
.util.Optional
;
import
java
x.servlet.http.HttpServletRequest
;
@RestController
@RequestMapping
(
"/OrangeHeap"
)
...
...
@@ -36,94 +34,94 @@ public class OrangeHeapController {
@ResponseBody
@GetMapping
(
"getTableauTaxCategoryUnreturnedTax"
)
public
ApiResultDto
getTableauTaxCategoryUnreturnedTax
()
{
public
ApiResultDto
getTableauTaxCategoryUnreturnedTax
(
HttpServletRequest
request
)
{
logger
.
info
(
"进入税种未返还税金分析=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
);
return
ApiResultDto
.
success
(
tableauService
.
getTableauTaxCategoryUnreturnedTax
().
orElse
(
StringUtils
.
EMPTY
));
return
ApiResultDto
.
success
(
tableauService
.
getTableauTaxCategoryUnreturnedTax
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauDistrictUnreturnedTax"
)
public
ApiResultDto
getTableauDistrictUnreturnedTax
()
{
public
ApiResultDto
getTableauDistrictUnreturnedTax
(
HttpServletRequest
request
)
{
logger
.
info
(
"地区未返还税金分析=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
);
return
ApiResultDto
.
success
(
tableauService
.
getTableauDistrictUnreturnedTax
().
orElse
(
StringUtils
.
EMPTY
));
return
ApiResultDto
.
success
(
tableauService
.
getTableauDistrictUnreturnedTax
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauUnreturnedAndReturnedTax"
)
public
ApiResultDto
getTableauUnreturnedAndReturnedTax
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauUnreturnedAndReturnedTax
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauUnreturnedAndReturnedTax
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauUnreturnedAndReturnedTax
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauCostAnalysis"
)
public
ApiResultDto
getTableauCostAnalysis
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauCostAnalysis
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauCostAnalysis
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauCostAnalysis
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauDistrictProfitAndLoss"
)
public
ApiResultDto
getTableauDistrictProfitAndLoss
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauDistrictProfitAndLoss
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauDistrictProfitAndLoss
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauDistrictProfitAndLoss
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauCompanyProfitAndLoss"
)
public
ApiResultDto
getTableauCompanyProfitAndLoss
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauCompanyProfitAndLoss
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauCompanyProfitAndLoss
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauCompanyProfitAndLoss
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauDriverAndEmployee"
)
public
ApiResultDto
getTableauDriverAndEmployee
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauDriverAndEmployee
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauDriverAndEmployee
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauDriverAndEmployee
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauGmvAndSubsidy"
)
public
ApiResultDto
getTableauGmvAndSubsidy
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauGmvAndSubsidy
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauGmvAndSubsidy
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauGmvAndSubsidy
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauFileArrangement"
)
public
ApiResultDto
getTableauFileArrangement
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauFileArrangement
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauFileArrangement
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauFileArrangement
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauGlobalOverview"
)
public
ApiResultDto
getTableauGlobalOverview
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauGlobalOverview
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauGlobalOverview
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauGlobalOverview
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauGlobalBusiness"
)
public
ApiResultDto
getTableauGlobalBusiness
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauGlobalBusiness
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauGlobalBusiness
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauGlobalBusiness
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauMexicanTax"
)
public
ApiResultDto
getTableauMexicanTax
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauMexicanTax
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauMexicanTax
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauMexicanTax
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauAustralianTax"
)
public
ApiResultDto
getTableauAustralianTax
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauAustralianTax
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauAustralianTax
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauAustralianTax
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauBrazilianTax"
)
public
ApiResultDto
getTableauBrazilianTax
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauBrazilianTax
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauBrazilianTax
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauBrazilianTax
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
@ResponseBody
@GetMapping
(
"getTableauOtherTaxAnalysis"
)
public
ApiResultDto
getTableauOtherTaxAnalysis
()
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauOtherTaxAnalysis
().
orElse
(
StringUtils
.
EMPTY
));
public
ApiResultDto
getTableauOtherTaxAnalysis
(
HttpServletRequest
request
)
{
return
ApiResultDto
.
success
(
tableauService
.
getTableauOtherTaxAnalysis
(
request
).
orElse
(
StringUtils
.
EMPTY
));
}
}
atms-web/src/main/java/pwc/taxtech/atms/web/service/OrangeHeapService.java
View file @
4bf4f957
...
...
@@ -9,13 +9,15 @@ import org.apache.http.impl.client.CloseableHttpClient;
import
org.apache.http.impl.client.HttpClients
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
pwc.taxtech.atms.common.DDUserInfoRes
;
import
pwc.taxtech.atms.common.HttpUtil
;
import
pwc.taxtech.atms.web.OrangeHeapConfig
;
import
javax.annotation.Resource
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -33,11 +35,6 @@ public class OrangeHeapService {
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
OrangeHeapService
.
class
);
@Autowired
private
HttpServletRequest
request
;
@Autowired
private
HttpServletResponse
response
;
@Value
(
"${get_user_info_url}"
)
private
String
getUserInfoUrl
;
...
...
@@ -53,12 +50,12 @@ public class OrangeHeapService {
CloseableHttpClient
httpClient
=
null
;
try
{
String
ticketUrl
=
String
.
format
(
systemConfig
.
getTableauGetTicket
(),
username
);
logger
.
info
(
"进去获取tableau的url"
+
ticketUrl
);
logger
.
info
(
"进去获取tableau的url"
+
ticketUrl
);
httpClient
=
HttpClients
.
createDefault
();
HttpPost
httpPost
=
new
HttpPost
(
ticketUrl
);
HttpResponse
httpResponse
=
httpClient
.
execute
(
httpPost
);
String
response
=
IOUtils
.
toString
(
httpResponse
.
getEntity
().
getContent
(),
"UTF-8"
);
logger
.
info
(
"获取tableau的结果"
+
response
);
logger
.
info
(
"获取tableau的结果"
+
response
);
return
StringUtils
.
equals
(
response
,
"-1"
)
?
Optional
.
empty
()
:
Optional
.
of
(
response
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"getTicket error."
,
e
);
...
...
@@ -82,102 +79,102 @@ public class OrangeHeapService {
// }
public
Optional
<
String
>
getTableauTaxCategoryUnreturnedTax
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauTaxCategoryUnreturnedTax
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauTaxCategoryUnreturnedTax
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauDistrictUnreturnedTax
()
{
public
Optional
<
String
>
getTableauDistrictUnreturnedTax
(
HttpServletRequest
request
)
{
//TODO
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauDistrictUnreturnedTax
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauUnreturnedAndReturnedTax
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauUnreturnedAndReturnedTax
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauUnreturnedAndReturnedTax
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauCostAnalysis
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauCostAnalysis
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauCostAnalysis
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauDistrictProfitAndLoss
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauDistrictProfitAndLoss
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauDistrictProfitAndLoss
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauCompanyProfitAndLoss
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauCompanyProfitAndLoss
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauCompanyProfitAndLoss
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauDriverAndEmployee
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauDriverAndEmployee
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauDriverAndEmployee
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauGmvAndSubsidy
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauGmvAndSubsidy
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauGmvAndSubsidy
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauFileArrangement
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauFileArrangement
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauFileArrangement
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauGlobalOverview
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauGlobalOverview
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauGlobalOverview
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauGlobalBusiness
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauGlobalBusiness
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauGlobalBusiness
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauMexicanTax
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauMexicanTax
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauMexicanTax
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauAustralianTax
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauAustralianTax
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauAustralianTax
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauBrazilianTax
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauBrazilianTax
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauBrazilianTax
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
public
Optional
<
String
>
getTableauOtherTaxAnalysis
()
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
());
public
Optional
<
String
>
getTableauOtherTaxAnalysis
(
HttpServletRequest
request
)
{
Optional
<
String
>
optional
=
Optional
.
of
(
getDDUserName
(
request
));
return
optional
.
map
(
s
->
String
.
format
(
systemConfig
.
getTableauOtherTaxAnalysis
(),
getTicket
(
s
).
orElse
(
StringUtils
.
EMPTY
)));
}
//sso通过cookie获取登录的DD用户
public
String
getDDUserName
()
{
//sso通过cookie获取登录的DD用户
public
String
getDDUserName
(
HttpServletRequest
request
)
{
logger
.
info
(
"进入 获取DD user的方法~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
);
String
ticket
=
getDDTicketByCookie
();
logger
.
info
(
"ticket=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
ticket
);
String
ticket
=
getDDTicketByCookie
(
request
);
logger
.
info
(
"ticket=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
ticket
);
return
findUsernameByDDTicket
(
ticket
);
}
//通過cookie 取出ddTicket
public
String
getDDTicketByCookie
()
{
public
String
getDDTicketByCookie
(
HttpServletRequest
request
)
{
logger
.
info
(
"进去获取cookie方法"
);
Map
<
String
,
Cookie
>
cookieMap
=
ReadCookieMap
(
);
Map
<
String
,
Cookie
>
cookieMap
=
ReadCookieMap
(
request
);
//TODO 修改token的名字到配置文件,判断ddTicket是否过期
if
(
cookieMap
.
containsKey
(
"ddTicket"
))
{
logger
.
info
(
"ddTicket=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
Optional
.
ofNullable
(
cookieMap
.
get
(
"ddTicket"
)).
map
(
s
->
s
.
getValue
()).
orElse
(
""
));
if
(
cookieMap
.
containsKey
(
"ddTicket"
))
{
logger
.
info
(
"ddTicket=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
Optional
.
ofNullable
(
cookieMap
.
get
(
"ddTicket"
)).
map
(
s
->
s
.
getValue
()).
orElse
(
""
));
return
Optional
.
ofNullable
(
cookieMap
.
get
(
"ddTicket"
)).
map
(
s
->
s
.
getValue
()).
orElse
(
""
);
}
else
{
logger
.
info
(
"code=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
Optional
.
ofNullable
(
cookieMap
.
get
(
"code"
)).
map
(
z
->
z
.
getValue
()).
orElse
(
""
));
return
getDDTicket
(
Optional
.
ofNullable
(
cookieMap
.
get
(
"code"
)).
map
(
z
->
z
.
getValue
()).
orElse
(
""
));
return
Optional
.
ofNullable
(
cookieMap
.
get
(
"ddTicket"
)).
map
(
s
->
s
.
getValue
()).
orElse
(
""
);
}
else
{
logger
.
info
(
"code=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
Optional
.
ofNullable
(
cookieMap
.
get
(
"code"
)).
map
(
z
->
z
.
getValue
()).
orElse
(
""
));
return
getDDTicket
(
Optional
.
ofNullable
(
cookieMap
.
get
(
"code"
)).
map
(
z
->
z
.
getValue
()).
orElse
(
""
));
}
}
...
...
@@ -205,38 +202,41 @@ public class OrangeHeapService {
/**
* 将cookie封装到Map里面
*
* @return
*/
private
Map
<
String
,
Cookie
>
ReadCookieMap
()
{
Map
<
String
,
Cookie
>
cookieMap
=
new
HashMap
<
String
,
Cookie
>();
private
Map
<
String
,
Cookie
>
ReadCookieMap
(
HttpServletRequest
request
)
{
Map
<
String
,
Cookie
>
cookieMap
=
new
HashMap
<
String
,
Cookie
>();
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
null
!=
cookies
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
null
!=
cookies
)
{
for
(
Cookie
cookie
:
cookies
)
{
cookieMap
.
put
(
cookie
.
getName
(),
cookie
);
}
}
return
cookieMap
;
}
//copy過來的 沒對象
public
String
getDDTicket
(
String
code
)
{
logger
.
info
(
"code=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
code
);
try
{
logger
.
info
(
"code=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
code
);
try
{
JSONObject
object
;
String
ddResponse
=
HttpUtil
.
post
(
getUserInfoUrl
+
"check_code"
,
"code="
+
code
+
"&app_key="
+
appKey
+
"&app_id="
+
appId
,
"application/x-www-form-urlencoded"
,
"UTF-8"
,
10000
,
10000
);
String
ddResponse
=
HttpUtil
.
post
(
getUserInfoUrl
+
"check_code"
,
"code="
+
code
+
"&app_key="
+
appKey
+
"&app_id="
+
appId
,
"application/x-www-form-urlencoded"
,
"UTF-8"
,
10000
,
10000
);
object
=
JSONObject
.
parseObject
(
ddResponse
);
Map
<
String
,
Object
>
res
=
object
.
getInnerMap
();
int
errno
=
(
int
)
res
.
get
(
"errno"
);
if
(
errno
!=
0
)
{
logger
.
warn
(
String
.
format
(
"DDTicket get Failed:[%s]"
,
object
.
toJSONString
()));
return
null
;
}
else
{
Map
<
String
,
String
>
dataMap
=
(
Map
)
res
.
get
(
"data"
);
Cookie
cookie
=
new
Cookie
(
"ddTicket"
,
dataMap
.
get
(
"ticket"
));
}
else
{
Map
<
String
,
String
>
dataMap
=
(
Map
)
res
.
get
(
"data"
);
Cookie
cookie
=
new
Cookie
(
"ddTicket"
,
dataMap
.
get
(
"ticket"
));
HttpServletResponse
response
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getResponse
();
response
.
addCookie
(
cookie
);
return
dataMap
.
get
(
"ticket"
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
String
.
format
(
"通过code:[%s]获取Ticket失败"
,
code
));
}
catch
(
Exception
e
)
{
logger
.
error
(
String
.
format
(
"通过code:[%s]获取Ticket失败"
,
code
));
}
return
null
;
}
...
...
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