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
e45688c9
Commit
e45688c9
authored
Jan 30, 2018
by
manxiaoqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合同
parent
40808c16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
177 additions
and
12 deletions
+177
-12
workspace.xml
.idea/workspace.xml
+0
-0
AuthorizationInterceptor.java
...n/java/security/interceptor/AuthorizationInterceptor.java
+14
-11
AccountRepository.java
src/main/java/tkio/repository/AccountRepository.java
+1
-1
MeasuresTrackNew.java
src/main/java/track/model/MeasuresTrackNew.java
+68
-0
MeasureRepository.java
src/main/java/track/repository/MeasureRepository.java
+15
-0
TrackAccountFlowRestrictService.java
...n/java/track/service/TrackAccountFlowRestrictService.java
+15
-0
TrackAccountFlowRestrictServiceImpl.java
...ack/service/impl/TrackAccountFlowRestrictServiceImpl.java
+60
-0
AccountTask.java
src/main/java/track/task/AccountTask.java
+4
-0
No files found.
.idea/workspace.xml
View file @
e45688c9
This diff is collapsed.
Click to expand it.
src/main/java/security/interceptor/AuthorizationInterceptor.java
View file @
e45688c9
...
...
@@ -56,21 +56,24 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
//从header中得到token
String
token
=
request
.
getHeader
(
httpHeaderName
);
//token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
token
=
token
.
substring
(
httpHeaderPrefix
.
length
());
//验证token
String
key
=
manager
.
getKeyFromToken
(
token
);
//登陆状态
boolean
loginStatus
=
redisLoginStatusManager
.
getLoginStatusByKey
(
token
);
if
(
null
!=
token
){
token
=
token
.
substring
(
httpHeaderPrefix
.
length
());
//验证token
String
key
=
manager
.
getKeyFromToken
(
token
);
//登陆状态
boolean
loginStatus
=
redisLoginStatusManager
.
getLoginStatusByKey
(
token
);
if
(!
StringUtil
.
isEmpty
(
key
))
{
User
one
=
userRepository
.
findOne
(
Long
.
parseLong
(
key
));
if
(!
StringUtil
.
isEmpty
(
key
))
{
User
one
=
userRepository
.
findOne
(
Long
.
parseLong
(
key
));
User
sessionAct
=
(
User
)
request
.
getSession
().
getAttribute
(
Constant
.
CURRENT_ACCOUNT
);
if
(
sessionAct
==
null
)
{
request
.
getSession
().
setAttribute
(
Constant
.
CURRENT_ACCOUNT
,
one
);
User
sessionAct
=
(
User
)
request
.
getSession
().
getAttribute
(
Constant
.
CURRENT_ACCOUNT
);
if
(
sessionAct
==
null
)
{
request
.
getSession
().
setAttribute
(
Constant
.
CURRENT_ACCOUNT
,
one
);
}
return
true
;
}
return
true
;
}
try
{
//如果验证token失败,并且方法注明了Authorization,返回401错误
response
.
setStatus
(
HttpStatus
.
UNAUTHORIZED
.
value
());
...
...
src/main/java/tkio/repository/AccountRepository.java
View file @
e45688c9
...
...
@@ -22,7 +22,7 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
@Query
(
value
=
"SELECT * from account where is_super_user is true and `status` = 1 and past_date < ?1"
,
nativeQuery
=
true
)
List
<
Account
>
findRootParentsPast
(
String
today
);
@Query
(
value
=
"SELECT * from account where is_super_user is true and bussinessman
=
?1"
,
nativeQuery
=
true
)
@Query
(
value
=
"SELECT * from account where is_super_user is true and bussinessman
in
?1"
,
nativeQuery
=
true
)
List
<
Account
>
findBussnissMan
(
List
<
Integer
>
bussinussIds
);
@Query
(
value
=
"select * from account where root_parent = ?1"
,
nativeQuery
=
true
)
...
...
src/main/java/track/model/MeasuresTrackNew.java
0 → 100644
View file @
e45688c9
package
track
.
model
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
/**
* Created by mxq on 2018/1/29.
*/
@Entity
public
class
MeasuresTrackNew
{
private
Long
id
;
private
String
ds
;
private
Double
clickNum
;
private
String
appid
;
private
Integer
eventNum
;
private
Integer
blackInstallNum
;
@Id
@GeneratedValue
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getDs
()
{
return
ds
;
}
public
void
setDs
(
String
ds
)
{
this
.
ds
=
ds
;
}
public
Double
getClickNum
()
{
return
clickNum
;
}
public
void
setClickNum
(
Double
clickNum
)
{
this
.
clickNum
=
clickNum
;
}
public
String
getAppid
()
{
return
appid
;
}
public
void
setAppid
(
String
appid
)
{
this
.
appid
=
appid
;
}
public
Integer
getEventNum
()
{
return
eventNum
;
}
public
void
setEventNum
(
Integer
eventNum
)
{
this
.
eventNum
=
eventNum
;
}
public
Integer
getBlackInstallNum
()
{
return
blackInstallNum
;
}
public
void
setBlackInstallNum
(
Integer
blackInstallNum
)
{
this
.
blackInstallNum
=
blackInstallNum
;
}
}
src/main/java/track/repository/MeasureRepository.java
0 → 100644
View file @
e45688c9
package
track
.
repository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
track.model.App
;
import
track.model.MeasuresTrackNew
;
import
java.math.BigInteger
;
import
java.util.List
;
public
interface
MeasureRepository
extends
JpaRepository
<
MeasuresTrackNew
,
Long
>
{
@Query
(
value
=
"select sum(click_num) from measures_track_new where appid in ?1 and ds <= ?2 and ds >= ?3"
,
nativeQuery
=
true
)
Double
findByApp
(
List
<
String
>
appid
,
String
endDate
,
String
startDate
);
}
src/main/java/track/service/TrackAccountFlowRestrictService.java
0 → 100644
View file @
e45688c9
package
track
.
service
;
import
tkio.model.AccountRestrict4Web
;
import
track.model.Account
;
import
java.math.BigInteger
;
/**
* Created by song on 2017/10/19.
*/
public
interface
TrackAccountFlowRestrictService
{
BigInteger
findRestrictByAccount
(
Account
accountId
);
}
src/main/java/track/service/impl/TrackAccountFlowRestrictServiceImpl.java
0 → 100644
View file @
e45688c9
package
track
.
service
.
impl
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
tkio.model.AccountRestrict4Web
;
import
track.model.Account
;
import
track.model.App
;
import
track.repository.MeasureRepository
;
import
track.repository.TrackAppRepository
;
import
track.service.TrackAccountFlowRestrictService
;
import
util.Constant
;
import
util.DateUtil
;
import
util.HttpClientUtil
;
import
util.ValidateUtil
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* Created by song on 2017/10/19.
*/
@Service
public
class
TrackAccountFlowRestrictServiceImpl
implements
TrackAccountFlowRestrictService
{
@Autowired
TrackAppRepository
trackAppRepository
;
@Autowired
MeasureRepository
measureRepository
;
@Override
public
BigInteger
findRestrictByAccount
(
Account
account
)
{
BigInteger
re
=
new
BigInteger
(
"0"
);
List
<
App
>
apps
=
trackAppRepository
.
findByAccount
(
account
.
getId
());
StringBuffer
appsStr
=
new
StringBuffer
();
if
(
ValidateUtil
.
isValid
(
apps
)){
List
<
String
>
appids
=
new
ArrayList
<>();
for
(
App
app
:
apps
)
{
appids
.
add
(
app
.
getAppkey
());
}
String
startDate
=
DateUtil
.
format
(
account
.
getPubDate
());
String
endDate
=
DateUtil
.
getBeforeDays
(
0
);
Double
click
=
measureRepository
.
findByApp
(
appids
,
endDate
,
startDate
);
return
null
==
click
?
re
:
new
BigInteger
(
click
.
intValue
()
+
""
);
}
return
re
;
}
}
src/main/java/track/task/AccountTask.java
View file @
e45688c9
...
...
@@ -8,6 +8,7 @@ import org.jsoup.helper.DataUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
track.model.Account
;
import
track.repository.TrackAccountRepository
;
import
track.service.TrackAccountFlowRestrictService
;
import
util.DateUtil
;
import
util.ValidateUtil
;
...
...
@@ -23,6 +24,8 @@ public class AccountTask {
TrackAccountRepository
trackAccountRepository
;
@Autowired
TrackAccount4WebRepository
trackAccount4WebRepository
;
@Autowired
TrackAccountFlowRestrictService
trackAccountFlowRestrictService
;
public
void
task
(){
trackAccount4WebRepository
.
deleteAll
();
...
...
@@ -41,6 +44,7 @@ public class AccountTask {
}
else
{
account4Web
.
setStatus
(
"已激活"
);
}
account4Web
.
setTrack
(
trackAccountFlowRestrictService
.
findRestrictByAccount
(
ac
));
account4Web
.
setPastDate
(
ac
.
getPastDate
());
account4Web
.
setUser
(
ac
.
getName
());
account4Web
.
setTell
(
ac
.
getPhone
());
...
...
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