parent
c0bda71520
commit
49a871c972
@ -0,0 +1,21 @@
|
||||
package com.mashibing.strategy;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author zjw
|
||||
* @description
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
public class StrategyStarterApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(StrategyStarterApp.class,args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.mashibing.strategy.client;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
/**
|
||||
* @author zjw
|
||||
* @description
|
||||
*/
|
||||
@FeignClient(value = "beacon-cache")
|
||||
public interface BeaconCacheClient {
|
||||
|
||||
@GetMapping("/cache/hget/{key}/{field}")
|
||||
String hget(@PathVariable(value = "key")String key, @PathVariable(value = "field")String field);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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,20 @@
|
||||
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 = "dirtyword")
|
||||
@Slf4j
|
||||
public class DirtyWordStrategyFilter implements StrategyFilter {
|
||||
@Override
|
||||
public void strategy(StandardSubmit submit) {
|
||||
log.info("【策略模块-敏感词校验】 校验ing…………");
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.mashibing.strategy.mq;
|
||||
|
||||
import com.mashibing.common.constant.RabbitMQConstants;
|
||||
import com.mashibing.common.model.StandardSubmit;
|
||||
import com.mashibing.strategy.filter.StrategyFilterContext;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 监听接口模块推送过来的消息
|
||||
* @author zjw
|
||||
* @description
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PreSendListener {
|
||||
|
||||
|
||||
/**
|
||||
* 整个策略模块的校验
|
||||
*/
|
||||
@Autowired
|
||||
private StrategyFilterContext filterContext;
|
||||
|
||||
@RabbitListener(queues = RabbitMQConstants.SMS_PRE_SEND)
|
||||
public void listen(StandardSubmit submit, Message message, Channel channel) throws IOException {
|
||||
log.info("【策略模块-接收消息】 接收到接口模块发送的消息 submit = {}",submit);
|
||||
// 处理业务…………
|
||||
try {
|
||||
filterContext.strategy(submit);
|
||||
log.info("【策略模块-消费完毕】手动ack");
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("【策略模块-消费失败】凉凉~~~");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
# 服务名称
|
||||
spring:
|
||||
application:
|
||||
name: beacon-strategy
|
||||
# 多环境
|
||||
profiles:
|
||||
active: dev
|
||||
# nacos注册中心地址
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 114.116.226.76:8848
|
||||
# nacos配置中心地址:
|
||||
config:
|
||||
server-addr: 114.116.226.76:8848
|
||||
file-extension: yml
|
||||
# beacon-api-dev.yml
|
||||
|
||||
|
Loading…
Reference in new issue