|
@@ -1,23 +1,19 @@
|
|
|
package com.zanxiang.game.module.sdk.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.github.sd4324530.jtuple.Tuple2;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.BanStatusEnum;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.HttpStatusEnum;
|
|
|
import com.zanxiang.game.module.mybatis.entity.IpBan;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.UserBan;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.IpBanMapper;
|
|
|
import com.zanxiang.game.module.sdk.pojo.param.UserData;
|
|
|
import com.zanxiang.game.module.sdk.service.IIpBanService;
|
|
|
import com.zanxiang.game.module.sdk.service.IUserBanService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import java.util.Objects;
|
|
|
+import reactor.util.function.Tuple2;
|
|
|
+import reactor.util.function.Tuples;
|
|
|
|
|
|
/**
|
|
|
* @author : lingfeng
|
|
@@ -32,14 +28,6 @@ public class IpBanServiceImpl extends ServiceImpl<IpBanMapper, IpBan> implements
|
|
|
private IUserBanService userBanService;
|
|
|
|
|
|
@Override
|
|
|
- public boolean checkIpBan(UserData userData) {
|
|
|
- IpBan ipBan = super.getOne(new LambdaUpdateWrapper<IpBan>()
|
|
|
- .eq(IpBan::getIp, userData.getIp())
|
|
|
- .eq(IpBan::getGameId, userData.getGameId())
|
|
|
- );
|
|
|
- return ipBan != null && Objects.equals(ipBan.getStatus(), BanStatusEnum.BAN_STATUS.getStatus());
|
|
|
- }
|
|
|
-
|
|
|
public Tuple2<Boolean, HttpStatusEnum> banCheck(UserData userData) {
|
|
|
//IP检测
|
|
|
if (super.count(new LambdaQueryWrapper<IpBan>()
|
|
@@ -47,40 +35,9 @@ public class IpBanServiceImpl extends ServiceImpl<IpBanMapper, IpBan> implements
|
|
|
.eq(IpBan::getIp, userData.getIp())
|
|
|
.eq(IpBan::getStatus, BanStatusEnum.BAN_STATUS.getStatus())
|
|
|
) > 0) {
|
|
|
- return Tuple2.with(Boolean.TRUE, HttpStatusEnum.IP_HALT);
|
|
|
- }
|
|
|
- //封禁检测
|
|
|
- if (StringUtils.isAllBlank(userData.getImei(), userData.getAndroidId(), userData.getOaid())) {
|
|
|
- return Tuple2.with(Boolean.FALSE, HttpStatusEnum.SUCCESS);
|
|
|
- }
|
|
|
- //匹配已封禁设备标识
|
|
|
- LambdaQueryWrapper<UserBan> queryWrapper = new LambdaQueryWrapper<UserBan>();
|
|
|
- queryWrapper.and(qw -> {
|
|
|
- boolean hasCondition = false;
|
|
|
- //安卓id匹配
|
|
|
- if (StringUtils.isNoneBlank(userData.getAndroidId())) {
|
|
|
- qw.or().eq(UserBan::getAndroidId, userData.getAndroidId());
|
|
|
- hasCondition = true;
|
|
|
- }
|
|
|
- //imei匹配
|
|
|
- if (StringUtils.isNoneBlank(userData.getImei())) {
|
|
|
- qw.or().eq(UserBan::getImei, userData.getImei());
|
|
|
- hasCondition = true;
|
|
|
- }
|
|
|
- //oaid匹配
|
|
|
- if (StringUtils.isNoneBlank(userData.getOaid())) {
|
|
|
- qw.or().eq(UserBan::getOaid, userData.getOaid());
|
|
|
- hasCondition = true;
|
|
|
- }
|
|
|
- // 避免无条件的OR查询
|
|
|
- if (!hasCondition) {
|
|
|
- qw.or().apply("1=0");
|
|
|
- }
|
|
|
- });
|
|
|
- //查询
|
|
|
- if (userBanService.count(queryWrapper) > 0) {
|
|
|
- return Tuple2.with(Boolean.TRUE, HttpStatusEnum.IP_HALT);
|
|
|
+ return Tuples.of(Boolean.TRUE, HttpStatusEnum.IP_HALT);
|
|
|
}
|
|
|
- return Tuple2.with(Boolean.FALSE, HttpStatusEnum.SUCCESS);
|
|
|
+ //设备检测
|
|
|
+ return userBanService.banCheckByDevice(userData);
|
|
|
}
|
|
|
}
|