parent
615c0558d9
commit
3c47fd0adc
@ -0,0 +1,32 @@
|
|||||||
|
package com.mashibing.api.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-21 0:19
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.mashibing.common.constant.RabbitMQConstants;
|
||||||
|
import org.springframework.amqp.core.Queue;
|
||||||
|
import org.springframework.amqp.core.QueueBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建队列&交换机信息
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RabbitMQConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口模块发送消息到策略模块的队列
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Queue preSendQueue(){
|
||||||
|
return QueueBuilder.durable(RabbitMQConstants.SMS_PRE_SEND).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.mashibing.api.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-20 22:25
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验手机号格式的合法性正则
|
||||||
|
*
|
||||||
|
* @author zjw
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public class PhoneFormatCheckUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国内手机号的正则表达式
|
||||||
|
*/
|
||||||
|
private final static Pattern CHINA_PATTERN = Pattern.compile("^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据正则校验手机号是否合法
|
||||||
|
*
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isChinaPhone(String number) {
|
||||||
|
Matcher matcher = CHINA_PATTERN.matcher(number);
|
||||||
|
return matcher.matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.mashibing.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-20 20:54
|
||||||
|
*/
|
||||||
|
public interface ApiConstant {
|
||||||
|
|
||||||
|
String SIGN_PREFIX = "【";
|
||||||
|
|
||||||
|
String SIGN_SUFFIX = "】";
|
||||||
|
|
||||||
|
Long SINGLE_FEE = 50L;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.mashibing.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-21 0:17
|
||||||
|
* common中声明
|
||||||
|
* RabbitMQ中的一些队列信息
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public interface RabbitMQConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口模块发送消息到策略模块的队列名称
|
||||||
|
*/
|
||||||
|
String SMS_PRE_SEND = "sms_pre_send_topic";
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.mashibing.strategy;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-21 1:19
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
public class StrategyStarterApp {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(StrategyStarterApp.class,args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.mashibing.strategy.mq;
|
||||||
|
|
||||||
|
import com.mashibing.common.constant.RabbitMQConstants;
|
||||||
|
import com.mashibing.common.model.StandardSubmit;
|
||||||
|
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.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-21 1:45
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class PreSendListener {
|
||||||
|
|
||||||
|
@RabbitListener(queues = RabbitMQConstants.SMS_PRE_SEND)
|
||||||
|
public void listen(StandardSubmit submit, Message message, Channel channel) throws IOException {
|
||||||
|
log.info("【策略模块-接收消息】 接收到接口模块发送的消息 submit = {}",submit);
|
||||||
|
// 处理业务…………
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
log.info("【策略模块-消费完毕】手动ack");
|
||||||
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
# 服务名称
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: beacon-strategy
|
||||||
|
# 多环境
|
||||||
|
profiles:
|
||||||
|
active: dev
|
||||||
|
# nacos注册中心地址
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: 192.168.43.132:8848
|
||||||
|
# nacos配置中心地址:
|
||||||
|
config:
|
||||||
|
server-addr: 192.168.43.132:8848
|
||||||
|
file-extension: yml
|
||||||
|
# beacon-strategy-dev.yml
|
Loading…
Reference in new issue