Commit 3d6f6650 by lixian7

添加短信发送功能

parent 256fc793
...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.hikcreate.edl.common.sdk.util.EncryptStringAes; import com.hikcreate.edl.common.sdk.util.EncryptStringAes;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result; import com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation; import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.enums.ResultCode;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BaseEncryptRes; import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BaseEncryptRes;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
...@@ -35,8 +36,9 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice { ...@@ -35,8 +36,9 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice {
try { try {
log.info("Response body 明文: {}",objectMapper.writeValueAsString(o)); log.info("Response body 明文: {}",objectMapper.writeValueAsString(o));
if(methodParameter.getMethod().isAnnotationPresent(ResponseEncryptAnnotation.class) && o instanceof Result) { if(methodParameter.getMethod().isAnnotationPresent(ResponseEncryptAnnotation.class) && o instanceof Result) {
//进行加密
Result<Object> result= (Result<Object>)o; Result<Object> result= (Result<Object>)o;
if( ResultCode.SUCCESS.getCode().equals(result.getCode()) ) {
//进行加密
Object data = result.getData(); Object data = result.getData();
String dataStr = objectMapper.writeValueAsString(data); String dataStr = objectMapper.writeValueAsString(data);
String encryptStr = EncryptStringAes.encryptAes(dataStr, "AES/ECB/PKCS5Padding"); String encryptStr = EncryptStringAes.encryptAes(dataStr, "AES/ECB/PKCS5Padding");
...@@ -46,6 +48,7 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice { ...@@ -46,6 +48,7 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice {
o = result; o = result;
log.info("Response body 密文: {}",objectMapper.writeValueAsString(o)); log.info("Response body 密文: {}",objectMapper.writeValueAsString(o));
} }
}
} catch ( Exception e ) { } catch ( Exception e ) {
log.error("Response body 加密异常:{}", e); log.error("Response body 加密异常:{}", e);
} }
......
package com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.CheckVerifyCodeMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendVerifyCodeMicReq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 短信feign
*/
@FeignClient( value = "${biz.feign.service.sms}", path = "sms" )
public interface SmsFeign {
@PostMapping( {"send"} )
Result<Void> send( @RequestBody SendMicReq var1 );
@PostMapping( {"verifyCode/send"} )
Result<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq var1 );
@PostMapping( {"verifyCode/check"} )
Result<Void> checkVerifyCode( @RequestBody CheckVerifyCodeMicReq var1 );
}
\ No newline at end of file
package com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class CheckVerifyCodeMicReq {
private String phone; // 手机号码
private String templateCode; // 短信模板编码
private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。
// 比如车辆持有人是A,被B和C两个人绑定,这时需要将验证码短信发送给A,值被记录到redis的时候需要区分B和C。
private String verifyCode; // 短信验证码
}
\ No newline at end of file
package com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
@Data
@NoArgsConstructor
public class SendMicReq {
private String phone; // 手机号码
private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。
// 比如车辆持有人是A,被B和C两个人绑定,这时需要将验证码短信发送给A,值被记录到redis的时候需要区分B和C。
private String templateCode; // 短信模板编码
private Map<String, String> templateParamMap; // 短信模板参数
private String signName; //短信签名,默认是斑马信用
}
\ No newline at end of file
package com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request;
import lombok.Data;
@Data
public class SendVerifyCodeMicReq {
private String phone; // 手机号码
private String templateCode; // 短信模板编码
private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。
// 比如车辆持有人是A,被B和C两个人绑定,这时需要将验证码短信发送给A,值被记录到redis的时候需要区分B和C。
private String verifyCode; // 短信验证码
private String signName; //短信签名,默认是斑马信用
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment