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
3 years ago
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
跑流量
parent
73730be0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
16 deletions
+42
-16
TkioFlowRepository.java
src/main/java/common/repository/TkioFlowRepository.java
+6
-1
AuthorizationInterceptor.java
...n/java/security/interceptor/AuthorizationInterceptor.java
+15
-15
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
...
...
@@ -9,7 +9,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
public
interface
TkioFlowRepository
extends
JpaRepository
<
TkioFlow
,
Long
>
{
public
interface
TkioFlowRepository
extends
JpaRepository
<
TkioFlow
,
Long
>
{
@Query
(
value
=
"select sum(flow) from tkio_flow where email = ?1 and contract_code = ?2"
,
nativeQuery
=
true
)
BigDecimal
sumFlowByEmailAndContractCode
(
String
email
,
String
contractCode
);
...
...
@@ -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
)
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
);
}
This diff is collapsed.
Click to expand it.
src/main/java/security/interceptor/AuthorizationInterceptor.java
View file @
c219238a
...
...
@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedWriter
;
import
java.io.OutputStreamWriter
;
import
java.util.Enumeration
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -61,8 +60,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
//放开登录
String
requestURL
=
request
.
getRequestURL
().
toString
();
if
(
requestURL
.
contains
(
"findSaleInfo"
))
{
System
.
out
.
println
(
"-----"
+
requestURL
.
contains
(
"findSaleInfo"
));
if
(
requestURL
.
contains
(
"findSaleInfo"
))
{
System
.
out
.
println
(
"-----"
+
requestURL
.
contains
(
"findSaleInfo"
));
return
true
;
}
// System.out.println("============="+requestURL);
...
...
@@ -72,15 +71,16 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
||
requestURL
.
indexOf
(
"user/forget"
)
!=
-
1
||
requestURL
.
indexOf
(
"user/code"
)
!=
-
1
||
requestURL
.
indexOf
(
"txt2db"
)
!=
-
1
||
requestURL
.
indexOf
(
"/test/contract/flow"
)
!=
-
1
||
requestURL
.
indexOf
(
"contract/build"
)
!=
-
1
||
requestURL
.
indexOf
(
"accountmng/findSaleInfo"
)
!=
-
1
){
||
requestURL
.
indexOf
(
"accountmng/findSaleInfo"
)
!=
-
1
)
{
return
true
;
}
//从header中得到token
String
token
=
request
.
getHeader
(
httpHeaderName
);
//token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
if
(
null
!=
token
)
{
if
(
null
!=
token
)
{
token
=
token
.
substring
(
httpHeaderPrefix
.
length
());
//验证token
String
key
=
manager
.
getKeyFromToken
(
token
);
...
...
@@ -101,15 +101,15 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
one
.
setAuthdataDic
(
authdata
);
}
request
.
getSession
().
setAttribute
(
Constant
.
CURRENT_ACCOUNT
,
one
);
request
.
getSession
().
setAttribute
(
Constant
.
CURRENT_ACCOUNT
,
one
);
sessionAct
=
one
;
}
if
(!
sessionAct
.
getRole
().
equals
(
RoleEnum
.
MANAGER
.
getKey
()))
{
if
(!
sessionAct
.
getRole
().
equals
(
RoleEnum
.
MANAGER
.
getKey
()))
{
//权限控制
AuthKey
authKey
=
handler
.
getClass
().
getAnnotation
(
AuthKey
.
class
);
if
(
authKey
!=
null
&&
sessionAct
.
getAuthdataDic
().
get
(
authKey
.
value
().
getIdKey
())==
null
)
{
printJsonResponse
(
response
,
"权限不足!"
);
AuthKey
authKey
=
handler
.
getClass
().
getAnnotation
(
AuthKey
.
class
);
if
(
authKey
!=
null
&&
sessionAct
.
getAuthdataDic
().
get
(
authKey
.
value
().
getIdKey
())
==
null
)
{
printJsonResponse
(
response
,
"权限不足!"
);
return
false
;
}
...
...
@@ -121,31 +121,31 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
}
printJsonResponse
(
response
,
null
);
printJsonResponse
(
response
,
null
);
return
false
;
}
private
void
printJsonResponse
(
HttpServletResponse
response
,
String
message
)
{
private
void
printJsonResponse
(
HttpServletResponse
response
,
String
message
)
{
try
{
//如果验证token失败,并且方法注明了Authorization,返回401错误
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
BufferedWriter
writer
=
new
BufferedWriter
(
new
OutputStreamWriter
(
response
.
getOutputStream
()));
response
.
setContentType
(
MediaType
.
APPLICATION_JSON_VALUE
);
if
(
StringUtils
.
isEmpty
(
message
))
{
if
(
StringUtils
.
isEmpty
(
message
))
{
message
=
new
ObjectMapper
().
writeValueAsString
(
ResultModel
.
ERROR
(
ResultStatus
.
USERNAME_LOGIN_EXPIRE
));
}
writer
.
write
(
message
);
writer
.
close
();
}
catch
(
Exception
e
){
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
String
getCookieToken
(
Cookie
[]
cookies
,
String
name
){
private
String
getCookieToken
(
Cookie
[]
cookies
,
String
name
)
{
String
token
=
null
;
...
...
This diff is collapsed.
Click to expand it.
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
);
}
}
This diff is collapsed.
Click to expand it.
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