Commit c219238a by kangxiaoshan

跑流量

parent 73730be0
......@@ -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);
}
......@@ -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;
......
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);
}
}
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