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

调整策略

parent 7a985147
......@@ -157,7 +157,7 @@ public class LoginInterceptorAspect {
.isPass(Boolean.TRUE).build();
}
Long deviceNum = loginInfoRepository.countByDeviceId(deviceId);
Long deviceNum = loginInfoRepository.countByDeviceId(deviceId, phone);
if (DEVICE_REFUSE_COUNT.compareTo(deviceNum) <= 0) {
if (!isWhite(deviceId, KeyType.DEVICEID)) {
......@@ -172,7 +172,7 @@ public class LoginInterceptorAspect {
}
CountDevice countDevice = loginInfoRepository.countByPhoneAndDevice(phone, device.ordinal());
CountDevice countDevice = loginInfoRepository.countByPhoneAndDevice(phone, device.ordinal(),);
if (null == countDevice) {
return LoginRefuseResult.builder()
......
......@@ -17,7 +17,7 @@ import javax.persistence.*;
{
@NamedNativeQuery(
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
)
}
......
......@@ -7,8 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.scheduling.annotation.Async;
import java.util.List;
public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> {
/**
* 根据设备ID看有多少手机号
......@@ -16,8 +14,8 @@ public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> {
* @param deviceId 设备维度策略
* @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)
Long countByDeviceId(String deviceId);
@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, String phone);
/**
......@@ -27,10 +25,11 @@ public interface LoginInfoRepository extends JpaRepository<LoginInfo, Long> {
* @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)
CountDevice countByPhoneAndDevice(String phone,int device);
CountDevice countByPhoneAndDevice(String phone, int device, String deviceId);
/**
* 查询有没有(手机+设备唯一)
*
* @param phone
* @param device
* @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