修改api模块入口侧校验入参类型SingleSendRequest->StandardSubmit

main
heqijun 4 months ago
parent 68d7e59a34
commit 42257bfc83

@ -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();

@ -8,7 +8,7 @@ import java.util.Map;
/**
* @author heqijun
* @ClassName: BeaconCacheClient
* @Description: TODO()
* @Description: openFeignClient
* @date 2025/6/5 20:13
*/

@ -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);
}
}
}

@ -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);
}

@ -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());
}
}

@ -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");
}
}

@ -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");
}
}

@ -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");
}
}

@ -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");
}
}

@ -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");
}
}

@ -8,7 +8,7 @@ import java.util.Map;
/**
* @author heqijun
* @ClassName: BeaconCacheClient
* @Description: TODO()
* @Description: openFeignClient
* @date 2025/6/5 20:13
*/

Loading…
Cancel
Save