Commit ca466351 authored by 董建华's avatar 董建华

调整策略

parent 7a985147
...@@ -157,7 +157,7 @@ public class LoginInterceptorAspect { ...@@ -157,7 +157,7 @@ public class LoginInterceptorAspect {
.isPass(Boolean.TRUE).build(); .isPass(Boolean.TRUE).build();
} }
Long deviceNum = loginInfoRepository.countByDeviceId(deviceId); Long deviceNum = loginInfoRepository.countByDeviceId(deviceId, phone);
if (DEVICE_REFUSE_COUNT.compareTo(deviceNum) <= 0) { if (DEVICE_REFUSE_COUNT.compareTo(deviceNum) <= 0) {
if (!isWhite(deviceId, KeyType.DEVICEID)) { if (!isWhite(deviceId, KeyType.DEVICEID)) {
...@@ -172,7 +172,7 @@ public class LoginInterceptorAspect { ...@@ -172,7 +172,7 @@ public class LoginInterceptorAspect {
} }
CountDevice countDevice = loginInfoRepository.countByPhoneAndDevice(phone, device.ordinal()); CountDevice countDevice = loginInfoRepository.countByPhoneAndDevice(phone, device.ordinal(),);
if (null == countDevice) { if (null == countDevice) {
return LoginRefuseResult.builder() return LoginRefuseResult.builder()
......
...@@ -17,7 +17,7 @@ import javax.persistence.*; ...@@ -17,7 +17,7 @@ import javax.persistence.*;
{ {
@NamedNativeQuery( @NamedNativeQuery(
name = "LoginInfo.countByPhoneAndDevice", name = "LoginInfo.countByPhoneAndDevice",
query = "select count(DISTINCT device_id) num ,device from login_info where phone_no=?1 and device =?2 and created_at > DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL -90 DAY)", query = "select count(DISTINCT device_id) num ,device from login_info where phone_no=?1 and device =?2 and device_id != ?3 and created_at > DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL -90 DAY)",
resultClass = CountDevice.class resultClass = CountDevice.class
) )
} }
......
...@@ -7,8 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -7,8 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import java.util.List;
public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> { public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> {
/** /**
* 根据设备ID看有多少手机号 * 根据设备ID看有多少手机号
...@@ -16,8 +14,8 @@ public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> { ...@@ -16,8 +14,8 @@ public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> {
* @param deviceId 设备维度策略 * @param deviceId 设备维度策略
* @return * @return
*/ */
@Query(value = "select count(distinct phone_no) from login_info where device_id=?1 and created_at> DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL -90 DAY)", nativeQuery = true) @Query(value = "select count(distinct phone_no) from login_info where device_id=?1 and phone_no != ?2 and created_at> DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL -90 DAY)", nativeQuery = true)
Long countByDeviceId(String deviceId); Long countByDeviceId(String deviceId, String phone);
/** /**
...@@ -27,10 +25,11 @@ public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> { ...@@ -27,10 +25,11 @@ public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> {
* @return * @return
*/ */
// @Query(value = "select count(1) ,device from login_info where phone_no=?1 and last_login_at> DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL -90 DAY group by device", nativeQuery = true) // @Query(value = "select count(1) ,device from login_info where phone_no=?1 and last_login_at> DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL -90 DAY group by device", nativeQuery = true)
CountDevice countByPhoneAndDevice(String phone,int device); CountDevice countByPhoneAndDevice(String phone, int device, String deviceId);
/** /**
* 查询有没有(手机+设备唯一) * 查询有没有(手机+设备唯一)
*
* @param phone * @param phone
* @param device * @param device
* @return * @return
......
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