抽奖攻击

This commit is contained in:
wangw 2025-08-18 09:41:37 +08:00
parent 1d30708270
commit c717c044c5
2 changed files with 12 additions and 6 deletions

View File

@ -1746,12 +1746,14 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
@Override @Override
public void addBlackUser(Long userId, String behavior) { public void addBlackUser(Long userId, String behavior) {
log.info("异常用户id, 异常操作: {},{}", userId, behavior); log.info("异常用户id, 异常操作: {},{}", userId, behavior);
UserInfo userInfo = userInfoService.getOne(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, userId)); if(!"恶意抽奖".equals(behavior)){
if (userInfo != null && StrUtil.isNotBlank(userInfo.getCertNo())) { UserInfo userInfo = userInfoService.getOne(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, userId));
TbUserBlacklist userBlacklist = new TbUserBlacklist(); if (userInfo != null && StrUtil.isNotBlank(userInfo.getCertNo())) {
userBlacklist.setRealName(userInfo.getCertName()); TbUserBlacklist userBlacklist = new TbUserBlacklist();
userBlacklist.setIdCardNo(userInfo.getCertNo()); userBlacklist.setRealName(userInfo.getCertName());
tbUserBlacklistMapper.insert(userBlacklist); userBlacklist.setIdCardNo(userInfo.getCertNo());
tbUserBlacklistMapper.insert(userBlacklist);
}
} }
update(null, new LambdaUpdateWrapper<UserEntity>().eq(UserEntity::getUserId, userId) update(null, new LambdaUpdateWrapper<UserEntity>().eq(UserEntity::getUserId, userId)

View File

@ -27,6 +27,7 @@ import com.sqx.modules.taskCenter.service.TaskCenterService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
@ -303,6 +304,9 @@ public class DiscSpinningController {
throw e; throw e;
} catch (SqxException e) { } catch (SqxException e) {
ret.put("msg", e.getMsg()); ret.put("msg", e.getMsg());
} catch (DuplicateKeyException e){
userService.addBlackUser(userId,"恶意抽奖");
ret.put("msg", "请求失败,请联系管理员。");
} catch (Exception e) { } catch (Exception e) {
log.error("抽奖异常", e); log.error("抽奖异常", e);
ret.put("msg", "请求失败,请联系管理员"); ret.put("msg", "请求失败,请联系管理员");