yonge 5 年之前
父節點
當前提交
7bb5458cdd

+ 3 - 16
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysMessageParams.java

@@ -1,20 +1,16 @@
 package com.keao.edu.auth.api.entity;
 
-import com.keao.edu.common.enums.MessageTypeEnum;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
-
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 
+import com.keao.edu.common.enums.MessageTypeEnum;
+
 /**
  * @Author Joburgess
  * @Date 2020.07.02
  */
 public class SysMessageParams {
 
-    private MessageSenderPluginContext.MessageSender messageSender;
-
     private MessageTypeEnum messageType;
 
     private Map<Integer, String> receivers;
@@ -32,8 +28,7 @@ public class SysMessageParams {
     public SysMessageParams() {
     }
 
-    public SysMessageParams(MessageSenderPluginContext.MessageSender messageSender, MessageTypeEnum messageType, Map<Integer, String> receivers, Date triggerTime, Integer readStatus, String url, String jpushType, Object... args) {
-        this.messageSender = messageSender;
+    public SysMessageParams( MessageTypeEnum messageType, Map<Integer, String> receivers, Date triggerTime, Integer readStatus, String url, String jpushType, Object... args) {
         this.messageType = messageType;
         this.receivers = receivers;
         this.triggerTime = triggerTime;
@@ -43,14 +38,6 @@ public class SysMessageParams {
         this.args = args;
     }
 
-    public MessageSenderPluginContext.MessageSender getMessageSender() {
-        return messageSender;
-    }
-
-    public void setMessageSender(MessageSenderPluginContext.MessageSender messageSender) {
-        this.messageSender = messageSender;
-    }
-
     public MessageTypeEnum getMessageType() {
         return messageType;
     }

+ 10 - 11
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysMessageService.java

@@ -1,17 +1,17 @@
 package com.keao.edu.auth.service;
 
 
-import com.keao.edu.common.entity.SysMessage;
-import com.keao.edu.common.enums.MessageSendMode;
-import com.keao.edu.common.enums.MessageTypeEnum;
-import com.keao.edu.common.service.BaseService;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext.MessageSender;
-
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.keao.edu.common.entity.SysMessage;
+import com.keao.edu.common.enums.MessageSendMode;
+import com.keao.edu.common.enums.MessageTypeEnum;
+import com.keao.edu.common.service.BaseService;
+import com.keao.edu.thirdparty.message.MessageSenderPlugin;
+
 public interface SysMessageService extends BaseService<Long, SysMessage> {
 
 	/**
@@ -55,12 +55,11 @@ public interface SysMessageService extends BaseService<Long, SysMessage> {
 	 * @param group 组
 	 * @return
 	 */
-	public boolean batchSendMessage(MessageSender messageSender, String subject, String content, Map<Integer, String> receivers, Date triggerTime,
+	public boolean batchSendMessage(MessageSenderPlugin senderPlugin, String subject, String content, Map<Integer, String> receivers, Date triggerTime,
                                     Integer readStatus, String memo, String group, String jpushType);
 
 	/**
 	 * 发送消息
-	 * @param messageSender 消息发送者
 	 * @param messageType 消息类型
 	 * @param receivers 消息接收者(Key:用户编号  value:消息接收对象)
 	 * @param triggerTime 触发时间
@@ -69,7 +68,7 @@ public interface SysMessageService extends BaseService<Long, SysMessage> {
 	 * @param args 参数
 	 * @return
 	 */
-	public void batchSendMessage(MessageSender messageSender, MessageTypeEnum messageType, Map<Integer, String> receivers, Date triggerTime,
+	public void batchSendMessage(MessageTypeEnum messageType, Map<Integer, String> receivers, Date triggerTime,
                                  Integer readStatus, String url, String jpushType, Object... args);
 
 	/**
@@ -85,7 +84,7 @@ public interface SysMessageService extends BaseService<Long, SysMessage> {
 	 * @param group 组
 	 * @return
 	 */
-	public void sendMessage(MessageSender messageSender, Integer userId, String title, String content, String receiver, Date triggerTime, Integer readStatus,
+	public void sendMessage(MessageSenderPlugin senderPlugin, Integer userId, String title, String content, String receiver, Date triggerTime, Integer readStatus,
                             String url, String group, String jpushType);
 
 	/**
@@ -96,7 +95,7 @@ public interface SysMessageService extends BaseService<Long, SysMessage> {
 	 * @param receiver 消息接受者
 	 * @return
 	 */
-	public boolean sendSecurityCode(MessageSender messageSender, Integer userId, MessageTypeEnum messageType, String receiver);
+	public boolean sendSecurityCode(Integer userId, MessageTypeEnum messageType, String receiver);
 
 	/**
 	 * 获取已经发送的验证码

+ 8 - 8
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SmsCodeServiceImpl.java

@@ -1,6 +1,12 @@
 package com.keao.edu.auth.service.impl;
 
 
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.auth.service.SmsCodeService;
@@ -9,12 +15,6 @@ import com.keao.edu.common.entity.SysMessage;
 import com.keao.edu.common.enums.MessageSendMode;
 import com.keao.edu.common.enums.MessageTypeEnum;
 import com.keao.edu.common.exception.BizException;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
 
 @Service
 public class SmsCodeServiceImpl implements SmsCodeService {
@@ -23,7 +23,7 @@ public class SmsCodeServiceImpl implements SmsCodeService {
 	private SysMessageService sysMessageService;
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
-
+	
 	@Override
 	public boolean verifyValidCode(String mobile, String authCode) {
 		String verifyCode = sysMessageService.getSendedVerificationCode(MessageTypeEnum.SMS_VERIFY_CODE_LOGIN, mobile);
@@ -46,7 +46,7 @@ public class SmsCodeServiceImpl implements SmsCodeService {
 		if (list != null && list.size() >= times) {
 			throw new BizException("对不起,您发送太频繁请稍后重试!");
 		}
-		sysMessageService.sendSecurityCode(MessageSenderPluginContext.MessageSender.YIMEI, userId, MessageTypeEnum.SMS_VERIFY_CODE_LOGIN, mobile);
+		sysMessageService.sendSecurityCode(userId, MessageTypeEnum.SMS_VERIFY_CODE_LOGIN, mobile);
 		return true;
 	}
 

+ 34 - 24
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysMessageServiceImpl.java

@@ -1,6 +1,22 @@
 package com.keao.edu.auth.service.impl;
 
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.auth.service.SysMessageConfigService;
@@ -19,18 +35,10 @@ import com.keao.edu.common.service.impl.BaseServiceImpl;
 import com.keao.edu.im.api.client.ImFeignService;
 import com.keao.edu.im.api.entity.ImPrivateMessage;
 import com.keao.edu.im.api.entity.ImTxtMessage;
+import com.keao.edu.thirdparty.message.MessageSenderPlugin;
 import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext.MessageSender;
+import com.keao.edu.thirdparty.message.provider.YimeiSmsPlugin;
 import com.keao.edu.util.string.MessageFormatter;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-
-import java.util.*;
 
 @Service
 public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> implements SysMessageService {
@@ -232,7 +240,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 
 	@Override
 	@Async
-	public boolean batchSendMessage(MessageSender messageSender, String subject, String content, Map<Integer, String> receivers, Date triggerTime,
+	public boolean batchSendMessage(MessageSenderPlugin senderPlugin, String subject, String content, Map<Integer, String> receivers, Date triggerTime,
 									Integer readStatus, String memo, String group, String jpushType) {
 
 		if (receivers == null || receivers.size() == 0) {
@@ -251,7 +259,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 				// 立即发送
 				if (triggerTime == null || date.after(triggerTime)) {
 					status = SendStatusEnum.SENDING;
-					if (debugMode == true || messageSenderPluginContext.batchSend(messageSender, subject, content, tos, memo,jpushType)) {
+					if (debugMode == true || messageSenderPluginContext.batchSend(YimeiSmsPlugin.PLUGIN_NAME, subject, content, tos, memo,jpushType)) {
 						status = SendStatusEnum.SUCCESSED;
 					} else {
 						status = SendStatusEnum.FAILED;
@@ -263,9 +271,9 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 				LOGGER.warn("消息发送失败", e);
 			}
 			MessageSendMode mode = MessageSendMode.SMS;
-			if (messageSender.getSendMode().equals("PUSH")) {
+			if (senderPlugin.getSendMode().equals("PUSH")) {
 				mode = MessageSendMode.PUSH;
-			} else if (messageSender.getSendMode().equals("EMAIL")) {
+			} else if (senderPlugin.getSendMode().equals("EMAIL")) {
 				mode = MessageSendMode.EMAIL;
 			}
 			return addMessage(receivers, subject, content, triggerTime, mode, status, errorMsg, readStatus, memo, null) > 0;
@@ -276,7 +284,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 
 	@Override
 	@Async
-	public void batchSendMessage(MessageSender messageSender, MessageTypeEnum type, Map<Integer, String> receivers, Date triggerTime, Integer readStatus,
+	public void batchSendMessage(MessageTypeEnum type, Map<Integer, String> receivers, Date triggerTime, Integer readStatus,
 								 String url, String jpushType, Object... args) {
 
 		if (receivers == null || receivers.size() == 0) {
@@ -292,12 +300,13 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 		Date date = new Date();
 		SendStatusEnum status = SendStatusEnum.WAIT;
 		String errorMsg = null;
+		String pluginName = YimeiSmsPlugin.PLUGIN_NAME;
 		// 立即发送
 		if (triggerTime == null || date.after(triggerTime)) {
 			status = SendStatusEnum.SENDING;
 			try {
 				if (debugMode == true
-						|| messageSenderPluginContext.batchSend(messageSender, messageConfig.getDescription(),
+						|| messageSenderPluginContext.batchSend(pluginName, messageConfig.getDescription(),
 								MessageFormatter.arrayFormat(messageConfig.getContent(), args), tos, url,jpushType)) {
 					status = SendStatusEnum.SUCCESSED;
 				} else {
@@ -309,10 +318,11 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 				LOGGER.warn("消息发送失败", e);
 			}
 		}
+		MessageSenderPlugin senderPlugin = messageSenderPluginContext.getMessageSenderPlugin(pluginName);
 		MessageSendMode mode = MessageSendMode.SMS;
-		if (messageSender.getSendMode().equals("PUSH")) {
+		if (senderPlugin.getSendMode().equals("PUSH")) {
 			mode = MessageSendMode.PUSH;
-		} else if (messageSender.getSendMode().equals("EMAIL")) {
+		} else if (senderPlugin.getSendMode().equals("EMAIL")) {
 			mode = MessageSendMode.EMAIL;
 		}
 		addMessage(receivers, messageConfig.getDescription(), MessageFormatter.arrayFormat(messageConfig.getContent(), args), triggerTime, mode, status, errorMsg, readStatus,
@@ -321,7 +331,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 
 	@Override
 	@Async
-	public void sendMessage(MessageSender messageSender, Integer userId, String title, String content, String receiver, Date triggerTime, Integer readStatus,
+	public void sendMessage(MessageSenderPlugin senderPlugin, Integer userId, String title, String content, String receiver, Date triggerTime, Integer readStatus,
 			String url, String group,String jpushType) {
 		if (StringUtils.isBlank(receiver)) {
 			throw new BizException("接收地址不能为空");
@@ -333,7 +343,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 		if (triggerTime == null || date.after(triggerTime)) {
 			status = SendStatusEnum.SENDING;
 			try {
-				if (debugMode == true || messageSenderPluginContext.send(messageSender, receiver, title, content, url,jpushType)) {
+				if (debugMode == true || messageSenderPluginContext.send(YimeiSmsPlugin.PLUGIN_NAME, receiver, title, content, url,jpushType)) {
 					status = SendStatusEnum.SUCCESSED;
 				} else {
 					status = SendStatusEnum.FAILED;
@@ -345,9 +355,9 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 			}
 		}
 		MessageSendMode mode = MessageSendMode.SMS;
-		if (messageSender.getSendMode().equals("PUSH")) {
+		if (senderPlugin.getSendMode().equals("PUSH")) {
 			mode = MessageSendMode.PUSH;
-		} else if (messageSender.getSendMode().equals("EMAIL")) {
+		} else if (senderPlugin.getSendMode().equals("EMAIL")) {
 			mode = MessageSendMode.EMAIL;
 		}
 		Map<Integer, String> receivers = new HashMap<Integer, String>();
@@ -356,7 +366,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 	}
 
 	@Override
-	public boolean sendSecurityCode(MessageSender messageSender, Integer userId, MessageTypeEnum messageType, String receiver) {
+	public boolean sendSecurityCode(Integer userId, MessageTypeEnum messageType, String receiver) {
 		String key1 = getVerificationCode1CacheKey(messageType, receiver);
 		if (redisCache.get(key1) != null) {
 			throw new BizException("请勿频繁操作,获取验证码间隔时间为60秒");
@@ -369,7 +379,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 		}
 		Map<Integer, String> receivers = new HashMap<>(1);
 		receivers.put(userId, receiver);
-		batchSendMessage(messageSender, messageType, receivers, null, 1, "","", code);
+		batchSendMessage(messageType, receivers, null, 1, "","", code);
 		redisCache.put(key, code + "", CODE_EXPIRE);
 		redisCache.put(key1, code + "", CODE_INTERVAL_TIME);
 		return true;

+ 1 - 1
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/SysMessageController.java

@@ -32,7 +32,7 @@ public class SysMessageController extends BaseController {
     @ApiOperation(value = "发送消息")
     @PostMapping(value = "/batchSendMessage")
     public void batchSendMessage(@RequestBody SysMessageParams sysMessageParams){
-        sysMessageService.batchSendMessage(sysMessageParams.getMessageSender(), sysMessageParams.getMessageType(), sysMessageParams.getReceivers(),
+        sysMessageService.batchSendMessage(sysMessageParams.getMessageType(), sysMessageParams.getReceivers(),
                 sysMessageParams.getTriggerTime(), sysMessageParams.getReadStatus(), sysMessageParams.getUrl(), sysMessageParams.getJpushType(),
                 sysMessageParams.getArgs());
     }

+ 3 - 3
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/message/MessageSenderPlugin.java

@@ -14,7 +14,7 @@ public interface MessageSenderPlugin {
 	 * 发送模式(SMS/PUSH/EMAIL)
 	 * @return
 	 */
-	public SendMode sendMode();
+	public SendMode getSendMode();
 
 	/**
 	 * 发送消息至目的地
@@ -22,11 +22,11 @@ public interface MessageSenderPlugin {
 	 * @param content 消息内容
 	 * @param receiver 收件人
 	 * @param url 链接地址
-	 * @param jpushType 极光应用类型
+	 * @param appClient app客户端名称
 	 * @return 是否发送成功
 	 * @throws IOException
 	 */
-	public boolean send(String subject, String content, String receiver, String url, String jpushType) throws Exception;
+	public boolean send(String subject, String content, String receiver, String url, String appClient) throws Exception;
 
 	/**
 	 * 批量发送消息至目的地

+ 11 - 28
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/message/MessageSenderPluginContext.java

@@ -11,48 +11,31 @@ import com.keao.edu.thirdparty.exception.ThirdpartyException;
 @Component
 public class MessageSenderPluginContext {
 
-	public enum MessageSender {
-
-		JIGUANG("PUSH"), MOXINGTONG("SMS"), SHIYUAN("SMS"), YIMEI("SMS");
-
-		/**
-		 * 发送模式(SMS,PUSH,EMAIL)
-		 */
-		private String sendMode;
-
-		private MessageSender(String sendMode) {
-			this.sendMode = sendMode;
-		}
-
-		public String getSendMode() {
-			return sendMode;
-		}
-	}
-
 	private MessageSenderPlugin messageSenderPlugin;
 
 	private static final Map<String, MessageSenderPlugin> mapper = new HashMap<String, MessageSenderPlugin>();
 
 	/**
 	 * 发送消息至目的地
-	 * @param messageSender 消息发送方
+	 * @param pluginName 消息发送插件
 	 * @param subject 消息主题
 	 * @param content 消息内容
 	 * @param receiver 收件人
 	 * @param url 链接地址
+	 * @param appClient app客户端
 	 * @return 是否发送成功
 	 * @throws IOException
 	 */
-	public boolean send(MessageSender messageSender, String subject, String content, String receiver, String url, String jpushType) throws Exception {
+	public boolean send(String pluginName, String subject, String content, String receiver, String url, String appClient) throws Exception {
 
-		messageSenderPlugin = getMessageSenderPlugin(messageSender);
+		messageSenderPlugin = getMessageSenderPlugin(pluginName);
 
-		return messageSenderPlugin.send(subject, content, receiver, url, jpushType);
+		return messageSenderPlugin.send(subject, content, receiver, url, appClient);
 	}
 
 	/**
 	 * 批量发送消息至目的地
-	 * @param messageSender 消息发送方
+	 * @param pluginName 消息发送插件
 	 * @param subject 消息主题
 	 * @param content 消息内容
 	 * @param receivers 收件人列表
@@ -60,18 +43,18 @@ public class MessageSenderPluginContext {
 	 * @return 是否发送成功
 	 * @throws IOException
 	 */
-	public boolean batchSend(MessageSender messageSender, String subject, String content, String[] receivers, String url, String jpushType) throws Exception {
+	public boolean batchSend(String pluginName, String subject, String content, String[] receivers, String url, String jpushType) throws Exception {
 
-		messageSenderPlugin = getMessageSenderPlugin(messageSender);
+		messageSenderPlugin = getMessageSenderPlugin(pluginName);
 
 		return messageSenderPlugin.batchSend(subject, content, receivers, url, jpushType);
 	}
 
-	private MessageSenderPlugin getMessageSenderPlugin(MessageSender messageSender) {
-		MessageSenderPlugin messageSenderPlugin = mapper.get(messageSender.name());
+	public MessageSenderPlugin getMessageSenderPlugin(String pluginName) {
+		MessageSenderPlugin messageSenderPlugin = mapper.get(pluginName);
 
 		if (messageSenderPlugin == null) {
-			throw new ThirdpartyException("消息提供方:{}不存在", messageSender.name());
+			throw new ThirdpartyException("消息提供方:{}不存在", pluginName);
 		}
 
 		return messageSenderPlugin;

+ 8 - 7
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/message/provider/JiguangPushPlugin.java

@@ -16,7 +16,6 @@ import com.keao.edu.thirdparty.exception.ThirdpartyException;
 import com.keao.edu.thirdparty.message.MessageSenderPlugin;
 import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
 import com.keao.edu.thirdparty.message.SendMode;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext.MessageSender;
 import com.keao.edu.util.http.HttpUtil;
 
 /**
@@ -48,14 +47,16 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
 
 	@Value("${push.jiguang.reqURL:https://api.jpush.cn/v3/push}")
 	private String reqURL = "https://api.jpush.cn/v3/push";// 请求极光地址
+	
+	public final static String PLUGIN_NAME = "JiGuang";
 
 	@Override
 	public String getName() {
-		return MessageSender.JIGUANG.name();
+		return PLUGIN_NAME;
 	}
 
 	@Override
-	public SendMode sendMode() {
+	public SendMode getSendMode() {
 		return SendMode.PUSH;
 	}
 
@@ -126,9 +127,9 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
 	 * @param alert 推送消息
 	 * @param content 推送内容
 	 */
-	private String push(String[] alias, String alert, String content, String url,String type) {
+	private String push(String[] alias, String alert, String content, String url,String appClient) {
 		String base64_auth_string = "";
-		switch (type){
+		switch (appClient){
 			case "STUDENT":
 				base64_auth_string = encryptBASE64(this.studentAppKey + ":" + this.studentMasterSecret);
 				break;
@@ -187,9 +188,9 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
 	}
 
 	@Override
-	public boolean send(String subject, String content, String receiver, String url, String type) throws IOException {
+	public boolean send(String subject, String content, String receiver, String url, String appClient) throws IOException {
 		String[] alias = { receiver };
-		String result = this.push(alias, subject, content, url,type);
+		String result = this.push(alias, subject, content, url,appClient);
 		JSONObject json = JSONObject.parseObject(result);
 		if (json.containsKey("error")) {
 			JSONObject jsonObject = json.getJSONObject("error");

+ 4 - 3
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/message/provider/MOxintongSMSPlugin.java

@@ -15,7 +15,6 @@ import com.keao.edu.thirdparty.exception.ThirdpartyException;
 import com.keao.edu.thirdparty.message.MessageSenderPlugin;
 import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
 import com.keao.edu.thirdparty.message.SendMode;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext.MessageSender;
 import com.keao.edu.util.http.HttpUtil;
 
 /**
@@ -32,14 +31,16 @@ public class MOxintongSMSPlugin implements MessageSenderPlugin, InitializingBean
 	
 	@Value("${Moxintong.reqUrl:1}")
 	private String reqUrl;
+	
+	public final static String PLUGIN_NAME = "MoXingTong";
 
 	@Override
 	public String getName() {
-		return MessageSender.MOXINGTONG.name();
+		return PLUGIN_NAME;
 	}
 
 	@Override
-	public SendMode sendMode() {
+	public SendMode getSendMode() {
 		return SendMode.SMS;
 	}
 

+ 4 - 3
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/message/provider/ShiyuanSMSPlugin.java

@@ -14,7 +14,6 @@ import com.keao.edu.thirdparty.exception.ThirdpartyException;
 import com.keao.edu.thirdparty.message.MessageSenderPlugin;
 import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
 import com.keao.edu.thirdparty.message.SendMode;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext.MessageSender;
 import com.keao.edu.util.http.HttpUtil;
 
 /**
@@ -37,6 +36,8 @@ public class ShiyuanSMSPlugin implements MessageSenderPlugin, InitializingBean {
 	 */
 	@Value("${sms.shiyuan.pwd:1}")
 	private String pswd;
+	
+	public final static String PLUGIN_NAME = "ShiYuan";
 
 	// private boolean needstatus = true;//是否需要状态报告,需要true,不需要false
 	// private String product = "";//产品ID(不用填写)
@@ -44,11 +45,11 @@ public class ShiyuanSMSPlugin implements MessageSenderPlugin, InitializingBean {
 
 	@Override
 	public String getName() {
-		return MessageSender.SHIYUAN.name();
+		return PLUGIN_NAME;
 	}
 
 	@Override
-	public SendMode sendMode() {
+	public SendMode getSendMode() {
 		return SendMode.SMS;
 	}
 

+ 4 - 3
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/message/provider/YimeiSmsPlugin.java

@@ -17,7 +17,6 @@ import com.keao.edu.thirdparty.exception.ThirdpartyException;
 import com.keao.edu.thirdparty.message.MessageSenderPlugin;
 import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
 import com.keao.edu.thirdparty.message.SendMode;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext.MessageSender;
 import com.keao.edu.util.date.DateUtil;
 import com.keao.edu.util.http.HttpUtil;
 
@@ -35,14 +34,16 @@ public class YimeiSmsPlugin implements MessageSenderPlugin, InitializingBean {
 	private String secretKey;
 	@Value("${com.properties.sms-host-dev:http://bjmtn.b2m.cn}")
 	private String host;
+	
+	public final static String PLUGIN_NAME = "YiMei";
 
 	@Override
 	public String getName() {
-		return MessageSender.YIMEI.name();
+		return PLUGIN_NAME;
 	}
 
 	@Override
-	public SendMode sendMode() {
+	public SendMode getSendMode() {
 		return SendMode.SMS;
 	}
 

+ 23 - 17
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamOrganizationRelationServiceImpl.java

@@ -1,5 +1,23 @@
 package com.keao.edu.user.service.impl;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
 import com.keao.edu.auth.api.client.SysMessageFeignService;
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.entity.SysMessageParams;
@@ -9,11 +27,12 @@ import com.keao.edu.common.entity.SysConfig;
 import com.keao.edu.common.enums.MessageTypeEnum;
 import com.keao.edu.common.exception.BizException;
 import com.keao.edu.common.page.PageInfo;
-import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
 import com.keao.edu.common.tenant.TenantContextHolder;
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
-import com.keao.edu.user.dao.*;
+import com.keao.edu.user.dao.ExamOrganizationRelationDao;
+import com.keao.edu.user.dao.ExaminationBasicDao;
+import com.keao.edu.user.dao.OrganizationDao;
+import com.keao.edu.user.dao.TenantInfoDao;
 import com.keao.edu.user.dto.ExamOrganizationRelationExtraDto;
 import com.keao.edu.user.entity.ExamOrganizationRelation;
 import com.keao.edu.user.entity.ExaminationBasic;
@@ -28,19 +47,6 @@ import com.keao.edu.user.service.ShortUrlService;
 import com.keao.edu.user.service.SysConfigService;
 import com.keao.edu.util.collection.MapUtil;
 import com.keao.edu.util.date.DateUtil;
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Isolation;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
-
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.stream.Collectors;
 
 @Service
 public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, ExamOrganizationRelation> implements ExamOrganizationRelationService {
@@ -213,7 +219,7 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 			Map<Integer, String> userPhoneMap = new HashMap<>();
 			userPhoneMap.put(examOrgan.getOrganId(), student.getPhone());
 
-			SysMessageParams sysMessageParams=new SysMessageParams(MessageSenderPluginContext.MessageSender.YIMEI, MessageTypeEnum.EXAM_REGISTRATION_URL_PUSH,
+			SysMessageParams sysMessageParams=new SysMessageParams(MessageTypeEnum.EXAM_REGISTRATION_URL_PUSH,
 					userPhoneMap, null, 0, null, null,
 					tenantInfo.getName(), examinationBasic.getName(), expectRegistTime.toString(), examOrgan.getUrl());
 			sysMessageFeignService.batchSendMessage(sysMessageParams);