parent
e90cbff146
commit
29ee4f7ad6
@ -0,0 +1,20 @@
|
|||||||
|
package com.mashibing.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用的一些常量
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public interface SmsConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送成功
|
||||||
|
*/
|
||||||
|
int REPORT_SUCCESS = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送失败
|
||||||
|
*/
|
||||||
|
int REPORT_FAIL = 2;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.mashibing.common.exception;
|
||||||
|
|
||||||
|
import com.mashibing.common.enums.ExceptionEnums;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 策略模块的异常对象
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class StrategyException extends RuntimeException {
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
public StrategyException(String message, Integer code) {
|
||||||
|
super(message);
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StrategyException(ExceptionEnums enums) {
|
||||||
|
super(enums.getMsg());
|
||||||
|
this.code = enums.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
package com.mashibing.strategy.filter.impl;
|
|
||||||
|
|
||||||
import com.mashibing.common.model.StandardSubmit;
|
|
||||||
import com.mashibing.strategy.filter.StrategyFilter;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 黑名单校验
|
|
||||||
* @author zjw
|
|
||||||
* @description
|
|
||||||
*/
|
|
||||||
@Service(value = "black")
|
|
||||||
@Slf4j
|
|
||||||
public class BlackStrategyFilter implements StrategyFilter {
|
|
||||||
@Override
|
|
||||||
public void strategy(StandardSubmit submit) {
|
|
||||||
log.info("【策略模块-黑名单校验】 校验ing…………");
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.mashibing.strategy.util;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class SpringUtil implements ApplicationContextAware {
|
||||||
|
|
||||||
|
private static ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
SpringUtil.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getBeanByName(String beanName){
|
||||||
|
return SpringUtil.applicationContext.getBean(beanName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getBeanByClass(Class clazz){
|
||||||
|
return SpringUtil.applicationContext.getBean(clazz);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.mashibing.test.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public class MobileBlack {
|
||||||
|
|
||||||
|
private String blackNumber;
|
||||||
|
|
||||||
|
private Integer clientId;
|
||||||
|
|
||||||
|
|
||||||
|
public String getBlackNumber() {
|
||||||
|
return blackNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlackNumber(String blackNumber) {
|
||||||
|
this.blackNumber = blackNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getClientId() {
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientId(Integer clientId) {
|
||||||
|
this.clientId = clientId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.mashibing.test.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public class MobileTransfer {
|
||||||
|
|
||||||
|
// 手机号
|
||||||
|
private String transferNumber;
|
||||||
|
|
||||||
|
// 最终运营商
|
||||||
|
private Integer nowIsp;
|
||||||
|
|
||||||
|
public String getTransferNumber() {
|
||||||
|
return transferNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransferNumber(String transferNumber) {
|
||||||
|
this.transferNumber = transferNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNowIsp() {
|
||||||
|
return nowIsp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNowIsp(Integer nowIsp) {
|
||||||
|
this.nowIsp = nowIsp;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.mashibing.test.mapper;
|
||||||
|
|
||||||
|
import com.mashibing.test.entity.MobileArea;
|
||||||
|
import com.mashibing.test.entity.MobileBlack;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public interface MobileBlackMapper {
|
||||||
|
|
||||||
|
@Select("select black_number,client_id from mobile_black where is_delete = 0")
|
||||||
|
List<MobileBlack> findAll();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.mashibing.test.mapper;
|
||||||
|
|
||||||
|
import com.mashibing.test.entity.MobileBlack;
|
||||||
|
import com.mashibing.test.entity.MobileTransfer;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public interface MobileTransferMapper {
|
||||||
|
|
||||||
|
@Select("select transfer_number,now_isp from mobile_transfer where is_transfer = 1 and is_delete = 0")
|
||||||
|
List<MobileTransfer> findAll();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.mashibing.test.mapper;
|
||||||
|
|
||||||
|
import com.mashibing.test.client.CacheClient;
|
||||||
|
import com.mashibing.test.entity.MobileArea;
|
||||||
|
import com.mashibing.test.entity.MobileBlack;
|
||||||
|
import org.junit.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.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
public class MobileBlackMapperTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MobileBlackMapper mapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CacheClient cacheClient;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findAll() {
|
||||||
|
List<MobileBlack> mobileBlackList = mapper.findAll();
|
||||||
|
for (MobileBlack mobileBlack : mobileBlackList) {
|
||||||
|
if(mobileBlack.getClientId() == 0){
|
||||||
|
// 平台级别的黑名单 black:手机号 作为key
|
||||||
|
cacheClient.set("black:" + mobileBlack.getBlackNumber(),"1");
|
||||||
|
}else{
|
||||||
|
// 客户级别的黑名单 black:clientId:手机号
|
||||||
|
cacheClient.set("black:" + mobileBlack.getClientId() + ":" +mobileBlack.getBlackNumber(),"1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.mashibing.test.mapper;
|
||||||
|
|
||||||
|
import com.mashibing.test.client.CacheClient;
|
||||||
|
import com.mashibing.test.entity.MobileBlack;
|
||||||
|
import com.mashibing.test.entity.MobileTransfer;
|
||||||
|
import org.junit.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;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
public class MobileTransferMapperTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MobileTransferMapper mapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CacheClient cacheClient;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findAll() {
|
||||||
|
List<MobileTransfer> list = mapper.findAll();
|
||||||
|
|
||||||
|
for (MobileTransfer mobileTransfer : list) {
|
||||||
|
cacheClient.set("transfer:" + mobileTransfer.getTransferNumber(),mobileTransfer.getNowIsp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue