mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
去除 system、infra 模块,对 member 模块的依赖
This commit is contained in:
parent
e33b2f0dd3
commit
ae85fe8aaf
@ -19,11 +19,6 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-module-member-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-module-system-api</artifactId>
|
<artifactId>yudao-module-system-api</artifactId>
|
||||||
|
@ -23,11 +23,6 @@
|
|||||||
<artifactId>yudao-module-system-api</artifactId>
|
<artifactId>yudao-module-system-api</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-module-member-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-module-infra-api</artifactId>
|
<artifactId>yudao-module-infra-api</artifactId>
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.member;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Member Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface MemberService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会员用户的手机号码
|
||||||
|
*
|
||||||
|
* @param id 会员用户编号
|
||||||
|
* @return 手机号码
|
||||||
|
*/
|
||||||
|
String getMemberUserMobile(Long id);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.member;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ClassUtil;
|
||||||
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Member Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MemberServiceImpl implements MemberService {
|
||||||
|
|
||||||
|
@Value("${yudao.info.base-package}")
|
||||||
|
private String basePackage;
|
||||||
|
|
||||||
|
private volatile Object memberUserApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMemberUserMobile(Long id) {
|
||||||
|
if (id == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Object user = ReflectUtil.invoke(getMemberUserApi(), "getUser", id);
|
||||||
|
if (user == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ReflectUtil.invoke(user, "getMobile");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getMemberUserApi() {
|
||||||
|
if (memberUserApi == null) {
|
||||||
|
memberUserApi = SpringUtil.getBean(ClassUtil.loadClass(String.format("%s.module.member.api.user.MemberUserApi", basePackage)));
|
||||||
|
}
|
||||||
|
return memberUserApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* yudao-module-member 模块的适配,解除 yudao-module-system 对它们的依赖
|
||||||
|
*/
|
||||||
|
package cn.iocoder.yudao.module.system.service.member;
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.sms;
|
package cn.iocoder.yudao.module.system.service.sms;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
@ -10,16 +11,14 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory;
|
|||||||
import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult;
|
import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult;
|
||||||
import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
||||||
import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO;
|
import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage;
|
import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage;
|
||||||
import cn.iocoder.yudao.module.system.mq.producer.sms.SmsProducer;
|
import cn.iocoder.yudao.module.system.mq.producer.sms.SmsProducer;
|
||||||
|
import cn.iocoder.yudao.module.system.service.member.MemberService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -40,7 +39,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
|||||||
@Resource
|
@Resource
|
||||||
private AdminUserService adminUserService;
|
private AdminUserService adminUserService;
|
||||||
@Resource
|
@Resource
|
||||||
private MemberUserApi memberUserApi;
|
private MemberService memberService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SmsTemplateService smsTemplateService;
|
private SmsTemplateService smsTemplateService;
|
||||||
@ -70,10 +69,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
|||||||
public Long sendSingleSmsToMember(String mobile, Long userId, String templateCode, Map<String, Object> templateParams) {
|
public Long sendSingleSmsToMember(String mobile, Long userId, String templateCode, Map<String, Object> templateParams) {
|
||||||
// 如果 mobile 为空,则加载用户编号对应的手机号
|
// 如果 mobile 为空,则加载用户编号对应的手机号
|
||||||
if (StrUtil.isEmpty(mobile)) {
|
if (StrUtil.isEmpty(mobile)) {
|
||||||
UserRespDTO user = memberUserApi.getUser(userId);
|
mobile = memberService.getMemberUserMobile(userId);
|
||||||
if (user != null) {
|
|
||||||
mobile = user.getMobile();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 执行发送
|
// 执行发送
|
||||||
return this.sendSingleSms(mobile, userId, UserTypeEnum.MEMBER.getValue(), templateCode, templateParams);
|
return this.sendSingleSms(mobile, userId, UserTypeEnum.MEMBER.getValue(), templateCode, templateParams);
|
||||||
@ -146,7 +142,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
|||||||
public void doSendSms(SmsSendMessage message) {
|
public void doSendSms(SmsSendMessage message) {
|
||||||
// 获得渠道对应的 SmsClient 客户端
|
// 获得渠道对应的 SmsClient 客户端
|
||||||
SmsClient smsClient = smsClientFactory.getSmsClient(message.getChannelId());
|
SmsClient smsClient = smsClientFactory.getSmsClient(message.getChannelId());
|
||||||
Assert.notNull(smsClient, String.format("短信客户端(%d) 不存在", message.getChannelId()));
|
Assert.notNull(smsClient, "短信客户端({}) 不存在", message.getChannelId());
|
||||||
// 发送短信
|
// 发送短信
|
||||||
SmsCommonResult<SmsSendRespDTO> sendResult = smsClient.sendSms(message.getLogId(), message.getMobile(),
|
SmsCommonResult<SmsSendRespDTO> sendResult = smsClient.sendSms(message.getLogId(), message.getMobile(),
|
||||||
message.getApiTemplateId(), message.getTemplateParams());
|
message.getApiTemplateId(), message.getTemplateParams());
|
||||||
@ -159,7 +155,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
|||||||
public void receiveSmsStatus(String channelCode, String text) throws Throwable {
|
public void receiveSmsStatus(String channelCode, String text) throws Throwable {
|
||||||
// 获得渠道对应的 SmsClient 客户端
|
// 获得渠道对应的 SmsClient 客户端
|
||||||
SmsClient smsClient = smsClientFactory.getSmsClient(channelCode);
|
SmsClient smsClient = smsClientFactory.getSmsClient(channelCode);
|
||||||
Assert.notNull(smsClient, String.format("短信客户端(%s) 不存在", channelCode));
|
Assert.notNull(smsClient, "短信客户端({}) 不存在", channelCode);
|
||||||
// 解析内容
|
// 解析内容
|
||||||
List<SmsReceiveRespDTO> receiveResults = smsClient.parseSmsReceiveStatus(text);
|
List<SmsReceiveRespDTO> receiveResults = smsClient.parseSmsReceiveStatus(text);
|
||||||
if (CollUtil.isEmpty(receiveResults)) {
|
if (CollUtil.isEmpty(receiveResults)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user