| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.common.constant.ChannelCode; |
| | | import com.ycl.dto.message.MessageParam; |
| | | import com.ycl.entity.message.Message; |
| | | import com.ycl.exception.ApiException; |
| | |
| | | import com.ycl.service.message.factory.InnerFactory; |
| | | import com.ycl.service.message.factory.MailFactory; |
| | | import com.ycl.service.message.factory.SmsFactory; |
| | | import com.ycl.service.user.UmsAdminService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | @Service |
| | | public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements IMessageService { |
| | | |
| | | @Autowired |
| | | private UmsAdminService adminService; |
| | | |
| | | @Override |
| | | public Message sendMessage(MessageParam messageParam) { |
| | | Message message = null; |
| | |
| | | switch (messageParam.getChannelCode()) |
| | | { |
| | | //内站发送 |
| | | case "01": |
| | | case ChannelCode.INNER: |
| | | provider = new InnerFactory(); |
| | | break; |
| | | //邮件发送 |
| | | case "02": |
| | | case ChannelCode.SMS: |
| | | provider = new MailFactory(); |
| | | //id换成邮箱号 |
| | | String targetToMail = adminService.getTargetTo(messageParam.getTargetTo(), messageParam.getChannelCode()); |
| | | messageParam.setTargetTo(targetToMail); |
| | | |
| | | //String targetToMail = adminService.getTargetTo(messageParam.getTargetTo(), messageParam.getChannelCode()); |
| | | //messageParam.setTargetTo(targetToMail); |
| | | break; |
| | | //短信发送 |
| | | case "03": |
| | | //短信发送 |
| | | case ChannelCode.MAIL: |
| | | provider = new SmsFactory(); |
| | | //id换成手机号 |
| | | String targetToPhone = adminService.getTargetTo(messageParam.getTargetTo(), messageParam.getChannelCode()); |
| | | messageParam.setTargetTo(targetToPhone); |
| | | //String targetToPhone = adminService.getTargetTo(messageParam.getTargetTo(), messageParam.getChannelCode()); |
| | | //messageParam.setTargetTo(targetToPhone); |
| | | break; |
| | | default: |
| | | throw new ApiException("未匹配到该类型"); |
| | |
| | | public IPage<Message> list(MessageParam messageParam) { |
| | | Page<Message> page = new Page<>(messageParam.getCurrent(), messageParam.getPageSize()); |
| | | LambdaQueryWrapper<Message> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (messageParam.getMessageType() != null) { |
| | | queryWrapper.eq(Message::getMessageType, messageParam.getMessageType()); |
| | | } |
| | | if (messageParam.getStatus() != null) { |
| | | queryWrapper.eq(Message::getStatus, messageParam.getStatus()); |
| | | } |
| | | Page<Message> result = baseMapper.selectPage(page, queryWrapper); |
| | | return result; |
| | | } |