From 42257bfc8347267dc6009a36d7f2f11aa317c5df Mon Sep 17 00:00:00 2001 From: heqijun Date: Fri, 6 Jun 2025 15:30:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9api=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E4=BE=A7=E6=A0=A1=E9=AA=8C=E5=85=A5=E5=8F=82?= =?UTF-8?q?=E7=B1=BB=E5=9E=8BSingleSendRequest->StandardSubmit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mashibing/api/controller/SMSController.java | 10 +++++----- .../mashibing/api/feignClient/BeaconCacheClient.java | 2 +- .../api/service/sendCheck/SendCheckContext.java | 6 +++--- .../api/service/sendCheck/SendCheckService.java | 8 ++++++-- .../sendCheck/impl/ApikeySendCheckServiceImpl.java | 9 ++++++++- .../sendCheck/impl/FeeSendCheckServiceImpl.java | 3 ++- .../service/sendCheck/impl/IpSendCheckServiceImpl.java | 3 ++- .../sendCheck/impl/MobileSendCheckServiceImpl.java | 3 ++- .../sendCheck/impl/SignSendCheckServiceImpl.java | 3 ++- .../sendCheck/impl/TemplateSendCheckServiceImpl.java | 3 ++- .../mashibing/test/feignClient/BeaconCacheClient.java | 2 +- 11 files changed, 34 insertions(+), 18 deletions(-) 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 1f406bb..54af5ab 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 @@ -37,19 +37,19 @@ public class SMSController { SmsService smsService; @PostMapping("singleSend") - public JsonResult singleSend(@RequestBody @Validated SingleSendRequest request, - HttpServletRequest httpServletRequest) { - sendCheckContext.check(request); - + public JsonResult singleSend(@RequestBody @Validated SingleSendRequest request, HttpServletRequest httpServletRequest) { //获取真实ip String realIp = smsService.getRealIP(httpServletRequest); log.info("real ip: {}", realIp); - //TODO 构建StandardSubmit,各种业务处理 + // 构建StandardSubmit StandardSubmit standardSubmit = new StandardSubmit(); standardSubmit.setRealIp(realIp); BeanUtils.copyProperties(request, standardSubmit); + + //请求参数校验 + sendCheckContext.check(standardSubmit); //TODO 发送到MQ return JsonResultUtil.ok(); diff --git a/beacon-api/src/main/java/com/mashibing/api/feignClient/BeaconCacheClient.java b/beacon-api/src/main/java/com/mashibing/api/feignClient/BeaconCacheClient.java index 1e3b528..ffc6069 100644 --- a/beacon-api/src/main/java/com/mashibing/api/feignClient/BeaconCacheClient.java +++ b/beacon-api/src/main/java/com/mashibing/api/feignClient/BeaconCacheClient.java @@ -8,7 +8,7 @@ import java.util.Map; /** * @author heqijun * @ClassName: BeaconCacheClient - * @Description: TODO(这里用一句话描述这个类的作用) + * @Description: 缓存模块openFeignClient接口 * @date 2025/6/5 20:13 */ 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 index 761e974..7a8be2a 100644 --- 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 @@ -1,6 +1,6 @@ package com.mashibing.api.service.sendCheck; -import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.common.pojo.StandardSubmit; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; @@ -28,11 +28,11 @@ public class SendCheckContext { @Value("${filters}") private String[] filters; - public void check(SingleSendRequest request) { + public void check(StandardSubmit standardSubmit) { for (String filter : filters) { SendCheckService check = sendCheckServiceMap.get(filter); if (check != null) { - check.check(request); + check.check(standardSubmit); } } } 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 index c73f85e..e78575c 100644 --- 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 @@ -1,6 +1,6 @@ package com.mashibing.api.service.sendCheck; -import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.common.pojo.StandardSubmit; /** * @author heqijun @@ -11,6 +11,10 @@ import com.mashibing.api.pojo.SingleSendRequest; public interface SendCheckService { - void check(SingleSendRequest request); + /** + * 入口侧校验 + * @param standardSubmit + */ + void check(StandardSubmit standardSubmit); } 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 index 3112034..ec74f47 100644 --- 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 @@ -1,8 +1,11 @@ package com.mashibing.api.service.sendCheck.impl; +import com.mashibing.api.feignClient.BeaconCacheClient; import com.mashibing.api.pojo.SingleSendRequest; import com.mashibing.api.service.sendCheck.SendCheckService; +import com.mashibing.common.pojo.StandardSubmit; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -16,8 +19,12 @@ import org.springframework.stereotype.Service; @Service("ApikeySendCheck") public class ApikeySendCheckServiceImpl implements SendCheckService { + @Autowired + BeaconCacheClient beaconCacheClient; + @Override - public void check(SingleSendRequest request) { + public void check(StandardSubmit standardSubmit) { log.info("Check apikey..."); + beaconCacheClient.hget(standardSubmit.getApikey()); } } 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 index e2f70fe..7dcdf39 100644 --- 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 @@ -2,6 +2,7 @@ package com.mashibing.api.service.sendCheck.impl; import com.mashibing.api.pojo.SingleSendRequest; import com.mashibing.api.service.sendCheck.SendCheckService; +import com.mashibing.common.pojo.StandardSubmit; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -16,7 +17,7 @@ import org.springframework.stereotype.Service; @Service("FeeSendCheck") public class FeeSendCheckServiceImpl implements SendCheckService { @Override - public void check(SingleSendRequest request) { + public void check(StandardSubmit standardSubmit) { 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 index 09b55e4..6b0e49d 100644 --- 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 @@ -2,6 +2,7 @@ package com.mashibing.api.service.sendCheck.impl; import com.mashibing.api.pojo.SingleSendRequest; import com.mashibing.api.service.sendCheck.SendCheckService; +import com.mashibing.common.pojo.StandardSubmit; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -16,7 +17,7 @@ import org.springframework.stereotype.Service; @Service("IpSendCheck") public class IpSendCheckServiceImpl implements SendCheckService { @Override - public void check(SingleSendRequest request) { + public void check(StandardSubmit standardSubmit) { 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 index 24acb91..be49484 100644 --- 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 @@ -2,6 +2,7 @@ package com.mashibing.api.service.sendCheck.impl; import com.mashibing.api.pojo.SingleSendRequest; import com.mashibing.api.service.sendCheck.SendCheckService; +import com.mashibing.common.pojo.StandardSubmit; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -16,7 +17,7 @@ import org.springframework.stereotype.Service; @Service("MobileSendCheck") public class MobileSendCheckServiceImpl implements SendCheckService { @Override - public void check(SingleSendRequest request) { + public void check(StandardSubmit standardSubmit) { 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 index 071af4a..1a7f87d 100644 --- 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 @@ -2,6 +2,7 @@ package com.mashibing.api.service.sendCheck.impl; import com.mashibing.api.pojo.SingleSendRequest; import com.mashibing.api.service.sendCheck.SendCheckService; +import com.mashibing.common.pojo.StandardSubmit; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -16,7 +17,7 @@ import org.springframework.stereotype.Service; @Service("SignSendCheck") public class SignSendCheckServiceImpl implements SendCheckService { @Override - public void check(SingleSendRequest request) { + public void check(StandardSubmit standardSubmit) { 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 index 36fc533..e71ece9 100644 --- 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 @@ -2,6 +2,7 @@ package com.mashibing.api.service.sendCheck.impl; import com.mashibing.api.pojo.SingleSendRequest; import com.mashibing.api.service.sendCheck.SendCheckService; +import com.mashibing.common.pojo.StandardSubmit; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -16,7 +17,7 @@ import org.springframework.stereotype.Service; @Service("TemplateSendCheck") public class TemplateSendCheckServiceImpl implements SendCheckService { @Override - public void check(SingleSendRequest request) { + public void check(StandardSubmit standardSubmit) { log.info("Check TemplateSendCheckServiceImpl"); } } diff --git a/beacon-test/src/main/java/com/mashibing/test/feignClient/BeaconCacheClient.java b/beacon-test/src/main/java/com/mashibing/test/feignClient/BeaconCacheClient.java index 6697b2e..62715bb 100644 --- a/beacon-test/src/main/java/com/mashibing/test/feignClient/BeaconCacheClient.java +++ b/beacon-test/src/main/java/com/mashibing/test/feignClient/BeaconCacheClient.java @@ -8,7 +8,7 @@ import java.util.Map; /** * @author heqijun * @ClassName: BeaconCacheClient - * @Description: TODO(这里用一句话描述这个类的作用) + * @Description: 缓存模块openFeignClient接口 * @date 2025/6/5 20:13 */