diff --git a/beacon-api/src/main/java/com/mashibing/api/controller/SMSController.java b/beacon-api/src/main/java/com/mashibing/api/controller/SMSController.java index 57e1e74..4924beb 100644 --- a/beacon-api/src/main/java/com/mashibing/api/controller/SMSController.java +++ b/beacon-api/src/main/java/com/mashibing/api/controller/SMSController.java @@ -1,10 +1,10 @@ package com.mashibing.api.controller; import com.mashibing.api.pojo.SingleSendRequest; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import com.mashibing.api.service.sendCheck.SendCheckContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.web.bind.annotation.*; /** * @author heqijun @@ -15,11 +15,15 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("sms") +@RefreshScope public class SMSController { - @PostMapping("singleSend") - public String singleSend(@RequestParam SingleSendRequest request) { + @Autowired + SendCheckContext sendCheckContext; - return null; + @PostMapping("singleSend") + public String singleSend(@RequestBody SingleSendRequest request) { + sendCheckContext.check(request); + return "接口测试!!!"; } } diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/SendCheckContext.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/SendCheckContext.java new file mode 100644 index 0000000..761e974 --- /dev/null +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/SendCheckContext.java @@ -0,0 +1,40 @@ +package com.mashibing.api.service.sendCheck; + +import com.mashibing.api.pojo.SingleSendRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author heqijun + * @ClassName: SendCheckContext + * @Description: TODO(这里用一句话描述这个类的作用) + * @date 2025/6/4 20:19 + */ + +@Component +@RefreshScope +public class SendCheckContext { + + //Spring的IoC容器会把所有管理的bean方到一个map里 + //可以指定bean的类型获取到bean的map集合 + @Autowired + Map sendCheckServiceMap; + + // 从配置中心获取到的校验项目和顺序 + @Value("${filters}") + private String[] filters; + + public void check(SingleSendRequest request) { + for (String filter : filters) { + SendCheckService check = sendCheckServiceMap.get(filter); + if (check != null) { + check.check(request); + } + } + } + +} diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/SendCheckService.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/SendCheckService.java new file mode 100644 index 0000000..c73f85e --- /dev/null +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/SendCheckService.java @@ -0,0 +1,16 @@ +package com.mashibing.api.service.sendCheck; + +import com.mashibing.api.pojo.SingleSendRequest; + +/** + * @author heqijun + * @ClassName: SendCheckService + * @Description: 短信发送校验父接口 + * @date 2025/6/4 19:29 + */ + +public interface SendCheckService { + + void check(SingleSendRequest request); + +} diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/ApikeySendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/ApikeySendCheckServiceImpl.java new file mode 100644 index 0000000..3112034 --- /dev/null +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/ApikeySendCheckServiceImpl.java @@ -0,0 +1,23 @@ +package com.mashibing.api.service.sendCheck.impl; + +import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.service.sendCheck.SendCheckService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: ApikeyServiceImpl + * @Description: 发送短信Apikey校验 + * @date 2025/6/4 19:30 + */ + +@Slf4j +@Service("ApikeySendCheck") +public class ApikeySendCheckServiceImpl implements SendCheckService { + + @Override + public void check(SingleSendRequest request) { + log.info("Check apikey..."); + } +} diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/FeeSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/FeeSendCheckServiceImpl.java new file mode 100644 index 0000000..e2f70fe --- /dev/null +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/FeeSendCheckServiceImpl.java @@ -0,0 +1,22 @@ +package com.mashibing.api.service.sendCheck.impl; + +import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.service.sendCheck.SendCheckService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: FeeSendCheckServiceImpl + * @Description: 发送短信客户余额费用校验 + * @date 2025/6/4 19:37 + */ + +@Slf4j +@Service("FeeSendCheck") +public class FeeSendCheckServiceImpl implements SendCheckService { + @Override + public void check(SingleSendRequest request) { + log.info("Check Fee Send Check"); + } +} diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/IpSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/IpSendCheckServiceImpl.java new file mode 100644 index 0000000..09b55e4 --- /dev/null +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/IpSendCheckServiceImpl.java @@ -0,0 +1,22 @@ +package com.mashibing.api.service.sendCheck.impl; + +import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.service.sendCheck.SendCheckService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: IpSendCheckServiceImpl + * @Description: 发送短信客户端ip地址校验 + * @date 2025/6/4 19:34 + */ + +@Slf4j +@Service("IpSendCheck") +public class IpSendCheckServiceImpl implements SendCheckService { + @Override + public void check(SingleSendRequest request) { + log.info("Check IpSendCheck"); + } +} diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/MobileSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/MobileSendCheckServiceImpl.java new file mode 100644 index 0000000..24acb91 --- /dev/null +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/MobileSendCheckServiceImpl.java @@ -0,0 +1,22 @@ +package com.mashibing.api.service.sendCheck.impl; + +import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.service.sendCheck.SendCheckService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: MobileSendCheckServiceImpl + * @Description: 发送短信目标手机号校验 + * @date 2025/6/4 19:36 + */ + +@Slf4j +@Service("MobileSendCheck") +public class MobileSendCheckServiceImpl implements SendCheckService { + @Override + public void check(SingleSendRequest request) { + log.info("Check mobile send check"); + } +} diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/SignSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/SignSendCheckServiceImpl.java new file mode 100644 index 0000000..071af4a --- /dev/null +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/SignSendCheckServiceImpl.java @@ -0,0 +1,22 @@ +package com.mashibing.api.service.sendCheck.impl; + +import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.service.sendCheck.SendCheckService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: SignSendCheckServiceImpl + * @Description: 发送短信客户签名校验 + * @date 2025/6/4 19:34 + */ + +@Slf4j +@Service("SignSendCheck") +public class SignSendCheckServiceImpl implements SendCheckService { + @Override + public void check(SingleSendRequest request) { + log.info("Check SignSendCheck"); + } +} diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/TemplateSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/TemplateSendCheckServiceImpl.java new file mode 100644 index 0000000..36fc533 --- /dev/null +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/TemplateSendCheckServiceImpl.java @@ -0,0 +1,22 @@ +package com.mashibing.api.service.sendCheck.impl; + +import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.service.sendCheck.SendCheckService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: TemplateSendCheckServiceImpl + * @Description: 发送短信短信模板校验 + * @date 2025/6/4 19:35 + */ + +@Slf4j +@Service("TemplateSendCheck") +public class TemplateSendCheckServiceImpl implements SendCheckService { + @Override + public void check(SingleSendRequest request) { + log.info("Check TemplateSendCheckServiceImpl"); + } +}