黑名单及用户访问拦截
This commit is contained in:
parent
6832745f99
commit
1ed411578f
|
|
@ -8,19 +8,21 @@ import lombok.Data;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 支付宝黑名单
|
||||
* 用户黑名单
|
||||
* @author tankaikai
|
||||
* @since 2025-01-07 12:56
|
||||
*/
|
||||
@Data
|
||||
@TableName(value ="alipay_blacklist")
|
||||
public class AlipayBlacklist implements Serializable {
|
||||
@TableName(value ="tb_user_blacklist")
|
||||
public class TbUserBlacklist implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type=IdType.INPUT)
|
||||
private String alipayAccountNo;
|
||||
@TableId(type=IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String alipayAccountName;
|
||||
private String idCardNo;
|
||||
|
||||
private String realName;
|
||||
|
||||
}
|
||||
|
|
@ -61,6 +61,18 @@ public class UserEntity implements Serializable {
|
|||
@ApiModelProperty("性别 1男 2女")
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@TableField("cert_name")
|
||||
private String certName;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
@TableField("cert_no")
|
||||
private String certNo;
|
||||
|
||||
/**
|
||||
* 微信小程序openid
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@ package com.sqx.modules.app.interceptor;
|
|||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.sqx.common.exception.CzgException;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.IPUtils;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.AlipayBlacklist;
|
||||
import com.sqx.modules.app.entity.TbUserBlacklist;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.mapper.AlipayBlacklistMapper;
|
||||
import com.sqx.modules.app.mapper.TbUserBlacklistMapper;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.utils.JwtUtils;
|
||||
import com.sqx.modules.redisService.RedisService;
|
||||
|
|
@ -40,7 +41,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|
|||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AlipayBlacklistMapper alipayBlacklistMapper;
|
||||
private TbUserBlacklistMapper tbUserBlacklistMapper;
|
||||
|
||||
private final RedisService redisService;
|
||||
|
||||
|
|
@ -106,10 +107,10 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|
|||
throw new CzgException("异常行为用户: {}" + user.getUserId());
|
||||
}
|
||||
|
||||
if(StrUtil.isNotBlank(user.getZhiFuBao())){
|
||||
AlipayBlacklist blacklist = alipayBlacklistMapper.selectById(user.getZhiFuBao());
|
||||
if(blacklist != null){
|
||||
throw new CzgException("禁止访问");
|
||||
if (StrUtil.isNotBlank(user.getCertNo())) {
|
||||
TbUserBlacklist blacklist = tbUserBlacklistMapper.selectOne(Wrappers.<TbUserBlacklist>lambdaQuery().eq(TbUserBlacklist::getIdCardNo, user.getCertNo()));
|
||||
if (blacklist != null) {
|
||||
throw new CzgException(StrUtil.format("黑名单用户,禁止访问:{} / {}", blacklist.getRealName(), blacklist.getIdCardNo()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.sqx.modules.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.AlipayBlacklist;
|
||||
import com.sqx.modules.app.entity.TbUserBlacklist;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
|
|
@ -10,5 +10,5 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* @since 2025-01-07 12:56
|
||||
*/
|
||||
@Mapper
|
||||
public interface AlipayBlacklistMapper extends BaseMapper<AlipayBlacklist> {
|
||||
public interface TbUserBlacklistMapper extends BaseMapper<TbUserBlacklist> {
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ spring:
|
|||
- qrtz_cron_triggers
|
||||
- qrtz_calendars
|
||||
- qrtz_blob_triggers
|
||||
- alipay_blacklist
|
||||
- tb_user_blacklist
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
|
|
|
|||
Loading…
Reference in New Issue