parent
6f0de2a319
commit
f3c92a0c0f
@ -0,0 +1,25 @@
|
||||
package com.mashibing.common.enums;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: OperatorEnums
|
||||
* @Description: 运营商id和名称的枚举
|
||||
* @date 2025/6/10 18:25
|
||||
*/
|
||||
|
||||
public enum OperatorEnums {
|
||||
|
||||
MOBILE(1, "移动"),
|
||||
UNICOM(2, "联通"),
|
||||
TELECOM(3, "电信"),
|
||||
;
|
||||
|
||||
public final int operatorId;
|
||||
|
||||
public final String operatorName;
|
||||
|
||||
OperatorEnums(int operatorId, String operatorName) {
|
||||
this.operatorId = operatorId;
|
||||
this.operatorName = operatorName;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.mashibing.strategy.service.strategyfilter.impl;
|
||||
|
||||
import com.mashibing.common.constant.CacheConstant;
|
||||
import com.mashibing.common.enums.ExceptionEnums;
|
||||
import com.mashibing.common.exception.StrategyException;
|
||||
import com.mashibing.common.pojo.StandardSubmit;
|
||||
import com.mashibing.strategy.feignclient.CacheClient;
|
||||
import com.mashibing.strategy.service.strategyfilter.StrategyFilter;
|
||||
import com.mashibing.strategy.utils.StrategyCheckFailedUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: BlackClientStrategyFilter
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/10 17:29
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service(value = "blackClient")
|
||||
public class BlackClientStrategyFilter implements StrategyFilter {
|
||||
|
||||
@Autowired
|
||||
CacheClient cacheClient;
|
||||
|
||||
@Autowired
|
||||
StrategyCheckFailedUtil strategyCheckFailedUtil;
|
||||
|
||||
private static final String STRATEGY_NAME = "客户黑名单";
|
||||
|
||||
private static final String IN_BLACK = "1";
|
||||
|
||||
@Override
|
||||
public void strategy(StandardSubmit submit) {
|
||||
log.info("【策略模块-客户黑名单校验】开始=====================================");
|
||||
String mobile = submit.getMobile();
|
||||
Long clientId = submit.getClientId();
|
||||
String value = cacheClient.get(CacheConstant.BLACK + clientId + CacheConstant.COLON + mobile);
|
||||
if (IN_BLACK.equals(value)) {
|
||||
log.info("【策略模块-客户黑名单校验】当前手机号:{}是客户黑名单!", mobile);
|
||||
strategyCheckFailedUtil.smsSendLog(submit, STRATEGY_NAME);
|
||||
strategyCheckFailedUtil.smsPushReport(submit, STRATEGY_NAME);
|
||||
throw new StrategyException(ExceptionEnums.BLACK_CLIENT);
|
||||
}
|
||||
log.info("【策略模块-客户黑名单校验】当前手机号:{}客户黑名单校验通过!!!", mobile);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.mashibing.strategy.service.strategyfilter.impl;
|
||||
|
||||
import com.mashibing.common.constant.CacheConstant;
|
||||
import com.mashibing.common.enums.ExceptionEnums;
|
||||
import com.mashibing.common.exception.StrategyException;
|
||||
import com.mashibing.common.pojo.StandardSubmit;
|
||||
import com.mashibing.strategy.feignclient.CacheClient;
|
||||
import com.mashibing.strategy.service.strategyfilter.StrategyFilter;
|
||||
import com.mashibing.strategy.utils.StrategyCheckFailedUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: BlackStrategyFilter
|
||||
* @Description: 黑名单校验
|
||||
* @date 2025/6/7 20:26
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service(value = "blackGlobal")
|
||||
public class BlackGlobalStrategyFilter implements StrategyFilter {
|
||||
|
||||
@Autowired
|
||||
CacheClient cacheClient;
|
||||
|
||||
@Autowired
|
||||
StrategyCheckFailedUtil strategyCheckFailedUtil;
|
||||
|
||||
private static final String STRATEGY_NAME = "全局黑名单";
|
||||
|
||||
private static final String IN_BLACK = "1";
|
||||
|
||||
|
||||
@Override
|
||||
public void strategy(StandardSubmit submit) {
|
||||
log.info("【策略模块-全局黑名单校验】开始=====================================");
|
||||
String mobile = submit.getMobile();
|
||||
String value = cacheClient.get(CacheConstant.BLACK + mobile);
|
||||
if (IN_BLACK.equals(value)) {
|
||||
log.info("【策略模块-全局黑名单校验】当前手机号:{}是全局黑名单!", mobile);
|
||||
strategyCheckFailedUtil.smsSendLog(submit, STRATEGY_NAME);
|
||||
strategyCheckFailedUtil.smsPushReport(submit, STRATEGY_NAME);
|
||||
throw new StrategyException(ExceptionEnums.BLACK_GLOBAL);
|
||||
}
|
||||
log.info("【策略模块-全局黑名单校验】当前手机号:{}全局黑名单校验通过!!!", mobile);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.mashibing.strategy.service.strategyfilter.impl;
|
||||
|
||||
import com.mashibing.common.pojo.StandardSubmit;
|
||||
import com.mashibing.strategy.service.strategyfilter.StrategyFilter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: BlackStrategyFilter
|
||||
* @Description: 黑名单校验
|
||||
* @date 2025/6/7 20:26
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service(value = "black")
|
||||
public class BlackStrategyFilter implements StrategyFilter {
|
||||
|
||||
@Override
|
||||
public void strategy(StandardSubmit standardSubmit) {
|
||||
log.info("【策略模块-黑名单校验】。。。");
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.mashibing.strategy.service.strategyfilter.impl;
|
||||
|
||||
import com.mashibing.common.pojo.StandardSubmit;
|
||||
import com.mashibing.strategy.feignclient.CacheClient;
|
||||
import com.mashibing.strategy.service.strategyfilter.StrategyFilter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: LimitMinuteStrategyFilter
|
||||
* @Description: 分钟限流策略
|
||||
* @date 2025/6/10 20:41
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service(value = "limitMinute")
|
||||
public class LimitMinuteStrategyFilter implements StrategyFilter {
|
||||
|
||||
@Autowired
|
||||
CacheClient cacheClient;
|
||||
|
||||
@Override
|
||||
public void strategy(StandardSubmit submit) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.mashibing.strategy.service.strategyfilter.impl;
|
||||
|
||||
import com.mashibing.common.constant.CacheConstant;
|
||||
import com.mashibing.common.pojo.StandardSubmit;
|
||||
import com.mashibing.strategy.feignclient.CacheClient;
|
||||
import com.mashibing.strategy.service.strategyfilter.StrategyFilter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: TransferStrategyFilter
|
||||
* @Description: 携号转网判断
|
||||
* @date 2025/6/10 18:36
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service(value = "transfer")
|
||||
public class TransferStrategyFilter implements StrategyFilter {
|
||||
|
||||
@Autowired
|
||||
CacheClient cacheClient;
|
||||
|
||||
@Override
|
||||
public void strategy(StandardSubmit submit) {
|
||||
log.info("【策略模块-携号转网判断】开始=====================================");
|
||||
|
||||
String mobile = submit.getMobile();
|
||||
String value = cacheClient.get(CacheConstant.TRANSFER + mobile);
|
||||
if (!StringUtils.isBlank(value)) {
|
||||
submit.setOperatorId(Integer.valueOf(value));
|
||||
submit.setIsTransfer(Boolean.TRUE);
|
||||
log.info("【策略模块-携号转网判断】携号转网!!!手机号:{}", mobile);
|
||||
}
|
||||
log.info("【策略模块-携号转网判断】结束=====================================");
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package com.mashibing.test.entity;
|
||||
|
||||
|
||||
public class MobileTransfer {
|
||||
|
||||
private long id;
|
||||
private String transferNumber;
|
||||
private String areaCode;
|
||||
private long initIsp;
|
||||
private long nowIsp;
|
||||
private long isTransfer;
|
||||
private java.sql.Timestamp created;
|
||||
private long createId;
|
||||
private java.sql.Timestamp updated;
|
||||
private long updateId;
|
||||
private long isDelete;
|
||||
private String extend1;
|
||||
private String extend2;
|
||||
private String extend3;
|
||||
private String extend4;
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getTransferNumber() {
|
||||
return transferNumber;
|
||||
}
|
||||
|
||||
public void setTransferNumber(String transferNumber) {
|
||||
this.transferNumber = transferNumber;
|
||||
}
|
||||
|
||||
|
||||
public String getAreaCode() {
|
||||
return areaCode;
|
||||
}
|
||||
|
||||
public void setAreaCode(String areaCode) {
|
||||
this.areaCode = areaCode;
|
||||
}
|
||||
|
||||
|
||||
public long getInitIsp() {
|
||||
return initIsp;
|
||||
}
|
||||
|
||||
public void setInitIsp(long initIsp) {
|
||||
this.initIsp = initIsp;
|
||||
}
|
||||
|
||||
|
||||
public long getNowIsp() {
|
||||
return nowIsp;
|
||||
}
|
||||
|
||||
public void setNowIsp(long nowIsp) {
|
||||
this.nowIsp = nowIsp;
|
||||
}
|
||||
|
||||
|
||||
public long getIsTransfer() {
|
||||
return isTransfer;
|
||||
}
|
||||
|
||||
public void setIsTransfer(long isTransfer) {
|
||||
this.isTransfer = isTransfer;
|
||||
}
|
||||
|
||||
|
||||
public java.sql.Timestamp getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(java.sql.Timestamp created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
|
||||
public long getCreateId() {
|
||||
return createId;
|
||||
}
|
||||
|
||||
public void setCreateId(long createId) {
|
||||
this.createId = createId;
|
||||
}
|
||||
|
||||
|
||||
public java.sql.Timestamp getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(java.sql.Timestamp updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
|
||||
public long getUpdateId() {
|
||||
return updateId;
|
||||
}
|
||||
|
||||
public void setUpdateId(long updateId) {
|
||||
this.updateId = updateId;
|
||||
}
|
||||
|
||||
|
||||
public long getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(long isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
|
||||
public String getExtend1() {
|
||||
return extend1;
|
||||
}
|
||||
|
||||
public void setExtend1(String extend1) {
|
||||
this.extend1 = extend1;
|
||||
}
|
||||
|
||||
|
||||
public String getExtend2() {
|
||||
return extend2;
|
||||
}
|
||||
|
||||
public void setExtend2(String extend2) {
|
||||
this.extend2 = extend2;
|
||||
}
|
||||
|
||||
|
||||
public String getExtend3() {
|
||||
return extend3;
|
||||
}
|
||||
|
||||
public void setExtend3(String extend3) {
|
||||
this.extend3 = extend3;
|
||||
}
|
||||
|
||||
|
||||
public String getExtend4() {
|
||||
return extend4;
|
||||
}
|
||||
|
||||
public void setExtend4(String extend4) {
|
||||
this.extend4 = extend4;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.mashibing.test.mapper;
|
||||
|
||||
import com.mashibing.test.entity.MobileTransfer;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: MobileTransferMapper
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/10 18:14
|
||||
*/
|
||||
|
||||
public interface MobileTransferMapper {
|
||||
@Select("select transfer_number,now_isp from mobile_transfer where is_transfer = 1 and is_delete = 0")
|
||||
List<MobileTransfer> findAll1();
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.mashibing.test.mapper;
|
||||
|
||||
import com.mashibing.test.entity.MobileTransfer;
|
||||
import com.mashibing.test.feignClient.CacheClient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
class MobileTransferMapperTest {
|
||||
|
||||
@Autowired
|
||||
CacheClient cacheClient;
|
||||
|
||||
@Autowired
|
||||
MobileTransferMapper mapper;
|
||||
|
||||
@Test
|
||||
void findAll1() {
|
||||
List<MobileTransfer> mobileTransfers = mapper.findAll1();
|
||||
for (MobileTransfer mobileTransfer : mobileTransfers) {
|
||||
cacheClient.set("transfer:" + mobileTransfer.getTransferNumber(), String.valueOf(mobileTransfer.getNowIsp()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in new issue