Commit e45688c9 by manxiaoqiang

合同

parent 40808c16
......@@ -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());
......
......@@ -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)
......
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;
}
}
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);
}
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);
}
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;
}
}
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment