抽奖攻击

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
public void addBlackUser(Long userId, String behavior) {
log.info("异常用户id, 异常操作: {},{}", userId, behavior);
UserInfo userInfo = userInfoService.getOne(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, userId));
if (userInfo != null && StrUtil.isNotBlank(userInfo.getCertNo())) {
TbUserBlacklist userBlacklist = new TbUserBlacklist();
userBlacklist.setRealName(userInfo.getCertName());
userBlacklist.setIdCardNo(userInfo.getCertNo());
tbUserBlacklistMapper.insert(userBlacklist);
if(!"恶意抽奖".equals(behavior)){
UserInfo userInfo = userInfoService.getOne(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, userId));
if (userInfo != null && StrUtil.isNotBlank(userInfo.getCertNo())) {
TbUserBlacklist userBlacklist = new TbUserBlacklist();
userBlacklist.setRealName(userInfo.getCertName());
userBlacklist.setIdCardNo(userInfo.getCertNo());
tbUserBlacklistMapper.insert(userBlacklist);
}
}
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -303,6 +304,9 @@ public class DiscSpinningController {
throw e;
} catch (SqxException e) {
ret.put("msg", e.getMsg());
} catch (DuplicateKeyException e){
userService.addBlackUser(userId,"恶意抽奖");
ret.put("msg", "请求失败,请联系管理员。");
} catch (Exception e) {
log.error("抽奖异常", e);
ret.put("msg", "请求失败,请联系管理员");