Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
manager
Project
Overview
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
reyun
manager
Commits
c219238a
Commit
c219238a
authored
Jul 16, 2021
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
跑流量
parent
73730be0
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
14 deletions
+40
-14
TkioFlowRepository.java
src/main/java/common/repository/TkioFlowRepository.java
+5
-0
AuthorizationInterceptor.java
...n/java/security/interceptor/AuthorizationInterceptor.java
+14
-14
TestFlowController.java
src/main/java/track/controller/TestFlowController.java
+21
-0
TrackingFlowTask.java
src/main/java/track/task/TrackingFlowTask.java
+0
-0
No files found.
src/main/java/common/repository/TkioFlowRepository.java
View file @
c219238a
...
@@ -24,4 +24,9 @@ public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> {
...
@@ -24,4 +24,9 @@ public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> {
@Query
(
value
=
"select sum(flow) from tkio_flow where contract_code in ?3 and ds >= ?1 and ds <= ?2"
,
nativeQuery
=
true
)
@Query
(
value
=
"select sum(flow) from tkio_flow where contract_code in ?3 and ds >= ?1 and ds <= ?2"
,
nativeQuery
=
true
)
BigDecimal
sumFlowByDsAndContractCodes
(
String
startDate
,
String
endDate
,
ArrayList
<
String
>
contractCode
);
BigDecimal
sumFlowByDsAndContractCodes
(
String
startDate
,
String
endDate
,
ArrayList
<
String
>
contractCode
);
@Transactional
@Modifying
@Query
(
value
=
"delete from tkio_flow where email = ?1 and ds = ?2"
,
nativeQuery
=
true
)
void
deleteByEmailDs
(
String
email
,
String
yesterday
);
}
}
src/main/java/security/interceptor/AuthorizationInterceptor.java
View file @
c219238a
...
@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedWriter
;
import
java.io.BufferedWriter
;
import
java.io.OutputStreamWriter
;
import
java.io.OutputStreamWriter
;
import
java.util.Enumeration
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -61,8 +60,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
...
@@ -61,8 +60,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
//放开登录
//放开登录
String
requestURL
=
request
.
getRequestURL
().
toString
();
String
requestURL
=
request
.
getRequestURL
().
toString
();
if
(
requestURL
.
contains
(
"findSaleInfo"
))
{
if
(
requestURL
.
contains
(
"findSaleInfo"
))
{
System
.
out
.
println
(
"-----"
+
requestURL
.
contains
(
"findSaleInfo"
));
System
.
out
.
println
(
"-----"
+
requestURL
.
contains
(
"findSaleInfo"
));
return
true
;
return
true
;
}
}
// System.out.println("============="+requestURL);
// System.out.println("============="+requestURL);
...
@@ -72,15 +71,16 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
...
@@ -72,15 +71,16 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
||
requestURL
.
indexOf
(
"user/forget"
)
!=
-
1
||
requestURL
.
indexOf
(
"user/forget"
)
!=
-
1
||
requestURL
.
indexOf
(
"user/code"
)
!=
-
1
||
requestURL
.
indexOf
(
"user/code"
)
!=
-
1
||
requestURL
.
indexOf
(
"txt2db"
)
!=
-
1
||
requestURL
.
indexOf
(
"txt2db"
)
!=
-
1
||
requestURL
.
indexOf
(
"/test/contract/flow"
)
!=
-
1
||
requestURL
.
indexOf
(
"contract/build"
)
!=
-
1
||
requestURL
.
indexOf
(
"contract/build"
)
!=
-
1
||
requestURL
.
indexOf
(
"accountmng/findSaleInfo"
)
!=
-
1
){
||
requestURL
.
indexOf
(
"accountmng/findSaleInfo"
)
!=
-
1
)
{
return
true
;
return
true
;
}
}
//从header中得到token
//从header中得到token
String
token
=
request
.
getHeader
(
httpHeaderName
);
String
token
=
request
.
getHeader
(
httpHeaderName
);
//token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
//token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
if
(
null
!=
token
)
{
if
(
null
!=
token
)
{
token
=
token
.
substring
(
httpHeaderPrefix
.
length
());
token
=
token
.
substring
(
httpHeaderPrefix
.
length
());
//验证token
//验证token
String
key
=
manager
.
getKeyFromToken
(
token
);
String
key
=
manager
.
getKeyFromToken
(
token
);
...
@@ -101,15 +101,15 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
...
@@ -101,15 +101,15 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
one
.
setAuthdataDic
(
authdata
);
one
.
setAuthdataDic
(
authdata
);
}
}
request
.
getSession
().
setAttribute
(
Constant
.
CURRENT_ACCOUNT
,
one
);
request
.
getSession
().
setAttribute
(
Constant
.
CURRENT_ACCOUNT
,
one
);
sessionAct
=
one
;
sessionAct
=
one
;
}
}
if
(!
sessionAct
.
getRole
().
equals
(
RoleEnum
.
MANAGER
.
getKey
()))
{
if
(!
sessionAct
.
getRole
().
equals
(
RoleEnum
.
MANAGER
.
getKey
()))
{
//权限控制
//权限控制
AuthKey
authKey
=
handler
.
getClass
().
getAnnotation
(
AuthKey
.
class
);
AuthKey
authKey
=
handler
.
getClass
().
getAnnotation
(
AuthKey
.
class
);
if
(
authKey
!=
null
&&
sessionAct
.
getAuthdataDic
().
get
(
authKey
.
value
().
getIdKey
())==
null
)
{
if
(
authKey
!=
null
&&
sessionAct
.
getAuthdataDic
().
get
(
authKey
.
value
().
getIdKey
())
==
null
)
{
printJsonResponse
(
response
,
"权限不足!"
);
printJsonResponse
(
response
,
"权限不足!"
);
return
false
;
return
false
;
}
}
...
@@ -121,31 +121,31 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
...
@@ -121,31 +121,31 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
}
}
printJsonResponse
(
response
,
null
);
printJsonResponse
(
response
,
null
);
return
false
;
return
false
;
}
}
private
void
printJsonResponse
(
HttpServletResponse
response
,
String
message
)
{
private
void
printJsonResponse
(
HttpServletResponse
response
,
String
message
)
{
try
{
try
{
//如果验证token失败,并且方法注明了Authorization,返回401错误
//如果验证token失败,并且方法注明了Authorization,返回401错误
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
BufferedWriter
writer
=
new
BufferedWriter
(
new
OutputStreamWriter
(
response
.
getOutputStream
()));
BufferedWriter
writer
=
new
BufferedWriter
(
new
OutputStreamWriter
(
response
.
getOutputStream
()));
response
.
setContentType
(
MediaType
.
APPLICATION_JSON_VALUE
);
response
.
setContentType
(
MediaType
.
APPLICATION_JSON_VALUE
);
if
(
StringUtils
.
isEmpty
(
message
))
{
if
(
StringUtils
.
isEmpty
(
message
))
{
message
=
new
ObjectMapper
().
writeValueAsString
(
ResultModel
.
ERROR
(
ResultStatus
.
USERNAME_LOGIN_EXPIRE
));
message
=
new
ObjectMapper
().
writeValueAsString
(
ResultModel
.
ERROR
(
ResultStatus
.
USERNAME_LOGIN_EXPIRE
));
}
}
writer
.
write
(
message
);
writer
.
write
(
message
);
writer
.
close
();
writer
.
close
();
}
catch
(
Exception
e
){
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
private
String
getCookieToken
(
Cookie
[]
cookies
,
String
name
){
private
String
getCookieToken
(
Cookie
[]
cookies
,
String
name
)
{
String
token
=
null
;
String
token
=
null
;
...
...
src/main/java/track/controller/TestFlowController.java
0 → 100644
View file @
c219238a
package
track
.
controller
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RestController
;
import
track.task.TrackingFlowTask
;
@RestController
public
class
TestFlowController
{
@Autowired
TrackingFlowTask
trackingFlowTask
;
@GetMapping
(
"/test/contract/flow"
)
public
void
testFlow
(
String
email
)
{
trackingFlowTask
.
reset
(
email
);
}
}
src/main/java/track/task/TrackingFlowTask.java
View file @
c219238a
This diff is collapsed.
Click to expand it.
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