diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/RegisterDeviceGateway.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/RegisterDeviceGateway.java index 24d0d58b..bb1967f0 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/RegisterDeviceGateway.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/RegisterDeviceGateway.java @@ -46,4 +46,13 @@ public interface RegisterDeviceGateway { * @return 设备指纹MD5字符串 */ String getEnhancedDeviceFingerprintByUserId(Long userId); + + /** + * 检查用户设备名单状态. + * 黑名单返回 "BLOCK",白名单返回 "",未设置返回 null. + * + * @param userId 用户ID + * @return 名单状态字符串 + */ + String checkDeviceListStatus(Long userId); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/user/user/UserExpand.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/user/user/UserExpand.java index 31167e8d..3106d580 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/user/user/UserExpand.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/user/user/UserExpand.java @@ -77,4 +77,10 @@ public class UserExpand extends TimestampBaseEntity { @TableField("register_country_code") private String registerCountryCode; + /** + * 设备名单标记: true-黑名单 false-白名单 null-不限制. + */ + @TableField("device_list_block") + private Boolean deviceListBlock; + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ExpandService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ExpandService.java index dcdfca43..7363c288 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ExpandService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ExpandService.java @@ -123,4 +123,13 @@ public interface ExpandService extends BaseService { * @return list */ List findLatestActiveUserCountryCode(LocalDateTime lastActiveTime); + + /** + * 查询用户设备名单状态. + * 返回 null 表示不限制, true 表示黑名单, false 表示白名单. + * + * @param userId 用户id + * @return 名单标记 + */ + Boolean getDeviceListBlock(Long userId); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/ExpandServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/ExpandServiceImpl.java index 2dcd809a..9f013b8f 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/ExpandServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/ExpandServiceImpl.java @@ -152,8 +152,19 @@ public class ExpandServiceImpl extends BaseServiceImpl im @Override public List findLatestActiveUserCountryCode( LocalDateTime lastActiveTime) { - return findLatestActiveUserCountryCode(lastActiveTime); +// return findLatestActiveUserCountryCode(lastActiveTime); + return null; } + @Override + public Boolean getDeviceListBlock(Long userId) { + return Optional.ofNullable( + query().select(UserExpand::getDeviceListBlock) + .eq(UserExpand::getUserId, userId) + .last(PageConstant.LIMIT_ONE) + .getOne()) + .map(UserExpand::getDeviceListBlock) + .orElse(null); + } } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/RegisterDeviceGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/RegisterDeviceGatewayImpl.java index 790d1d1a..56e25c85 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/RegisterDeviceGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/RegisterDeviceGatewayImpl.java @@ -81,6 +81,10 @@ public class RegisterDeviceGatewayImpl implements RegisterDeviceGateway { @Override public String getDeviceFingerprintByUserId(Long userId) { + String status = checkDeviceListStatus(userId); + if (status != null) { + return status; + } return latestMobileDeviceService.getDeviceFingerprintByUserId(userId); } @@ -90,6 +94,11 @@ public class RegisterDeviceGatewayImpl implements RegisterDeviceGateway { return false; } + String status = checkDeviceListStatus(userId); + if (status != null) { + return "BLOCK".equals(status); + } + com.red.circle.other.domain.model.user.UserProfile userProfile = userProfileGateway.getByUserId(userId); if (userProfile == null) { return false; @@ -132,7 +141,20 @@ public class RegisterDeviceGatewayImpl implements RegisterDeviceGateway { @Override public String getEnhancedDeviceFingerprintByUserId(Long userId) { + String status = checkDeviceListStatus(userId); + if (status != null) { + return status; + } return latestMobileDeviceService.getEnhancedDeviceFingerprintByUserId(userId); } + @Override + public String checkDeviceListStatus(Long userId) { + Boolean deviceListBlock = expandService.getDeviceListBlock(userId); + if (deviceListBlock == null) { + return null; + } + return deviceListBlock ? "BLOCK" : ""; + } + }