Browse Source

fengji 教材, 邮件发送

yanite 3 years ago
parent
commit
71c2601ade

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysEmailDao.java

@@ -0,0 +1,20 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ym.mec.biz.dal.entity.SysEmail;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * (SysEmail)表数据库访问层
+ *
+ * @author makejava
+ * @since 2022-01-04 17:07:43
+ */
+public interface SysEmailDao extends BaseMapper<SysEmail> {
+
+   int insertBatch(@Param("entities") List<SysEmail> entities);
+   
+}
+

+ 120 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysEmail.java

@@ -0,0 +1,120 @@
+package com.ym.mec.biz.dal.entity;
+
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+
+/**
+ * (SysEmail)表实体类
+ *
+ * @author makejava
+ * @since 2022-01-04 17:07:43
+ */
+@ApiModel(value = "sys_email-${tableInfo.comment}")
+public class SysEmail implements Serializable {
+   @TableId(value = "id_", type = IdType.AUTO)
+     @ApiModelProperty(value = "${column.comment}")
+    private Integer id;
+    
+  @TableField("host_name_")
+     @ApiModelProperty(value = "SMTP服务器")
+    private String hostName;
+    
+  @TableField("smtp_port_")
+     @ApiModelProperty(value = "SMTP服务器端口")
+    private Integer smtpPort;
+    
+  @TableField("user_name_")
+     @ApiModelProperty(value = "SMTP服务器认证用户名")
+    private String userName;
+    
+  @TableField("password_")
+     @ApiModelProperty(value = "SMTP服务器认证密码")
+    private String password;
+    
+  @TableField("from_")
+     @ApiModelProperty(value = "发件人邮箱")
+    private String from;
+    
+  @TableField("from_name_")
+     @ApiModelProperty(value = "落款")
+    private String fromName;
+    
+  @TableField("tenant_id_")
+     @ApiModelProperty(value = "${column.comment}")
+    private Integer tenantId;
+    
+    private static final long serialVersionUID = 1L;
+    
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public Integer getSmtpPort() {
+        return smtpPort;
+    }
+
+    public void setSmtpPort(Integer smtpPort) {
+        this.smtpPort = smtpPort;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getFrom() {
+        return from;
+    }
+
+    public void setFrom(String from) {
+        this.from = from;
+    }
+
+    public String getFromName() {
+        return fromName;
+    }
+
+    public void setFromName(String fromName) {
+        this.fromName = fromName;
+    }
+
+    public Integer getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Integer tenantId) {
+        this.tenantId = tenantId;
+    }
+
+
+}
+

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMusicScoreCategories.java

@@ -41,6 +41,8 @@ public class SysMusicScoreCategories {
 	private Integer order;
 
 	private Integer musicScoreNum;
+
+	private Integer musicScoreNumSum;
 	
 	private String soundResource;
 
@@ -171,4 +173,11 @@ public class SysMusicScoreCategories {
 		return ToStringBuilder.reflectionToString(this);
 	}
 
+	public Integer getMusicScoreNumSum() {
+		return musicScoreNumSum;
+	}
+
+	public void setMusicScoreNumSum(Integer musicScoreNumSum) {
+		this.musicScoreNumSum = musicScoreNumSum;
+	}
 }

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysEmailService.java

@@ -0,0 +1,15 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.SysEmail;
+
+/**
+ * (SysEmail)表服务接口
+ *
+ * @author makejava
+ * @since 2022-01-04 17:07:43
+ */
+public interface SysEmailService extends IService<SysEmail> {
+
+}
+

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/AppRedemptionCodeServiceImpl.java

@@ -120,7 +120,7 @@ public class AppRedemptionCodeServiceImpl extends ServiceImpl<RedemptionCodeDao,
     @Override
     public void checkLowVolume() {
         Integer volume = redemptionCodeDao.findNull();
-        if (volume == null || volume < 10) {
+        if (volume == null || volume < 10000) {
             Map<Integer, String> receivers = new HashMap<>(1);
             receivers.put(0, "13512341234");
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS,

+ 25 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysEmailServiceImpl.java

@@ -0,0 +1,25 @@
+package com.ym.mec.biz.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.biz.dal.dao.SysEmailDao;
+import com.ym.mec.biz.dal.entity.SysEmail;
+import com.ym.mec.biz.service.SysEmailService;
+import org.springframework.stereotype.Service;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * (SysEmail)表服务实现类
+ *
+ * @author makejava
+ * @since 2022-01-04 17:07:43
+ */
+@Service("sysEmailService")
+public class SysEmailServiceImpl extends ServiceImpl<SysEmailDao, SysEmail> implements SysEmailService {
+
+    private final static Logger logger = LoggerFactory.getLogger(SysEmailServiceImpl.class);
+
+
+}
+

+ 45 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMessageServiceImpl.java

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.dao.SysMessageDao;
 import com.ym.mec.biz.dal.dao.WaitSendMessageDao;
 import com.ym.mec.biz.dal.dto.Mapper;
 import com.ym.mec.biz.dal.dto.SysMessageDto;
+import com.ym.mec.biz.dal.entity.SysEmail;
 import com.ym.mec.biz.dal.entity.SysMessage;
 import com.ym.mec.biz.dal.entity.SysMessageConfig;
 import com.ym.mec.biz.dal.entity.WaitSendMessage;
@@ -24,6 +25,7 @@ import com.ym.mec.common.entity.ImTxtMessage;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.redis.service.RedisCache;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
@@ -44,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.enums.MessageTypeEnum.STUDENT_PUSH_VIP_BUY;
 
@@ -64,6 +67,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
 
+
 	@Autowired
 	private WaitSendMessageDao waitSendMessageDao;
 
@@ -76,6 +80,9 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 	@Autowired
 	private RedisCache<String, Object> redisCache;
 
+	@Autowired
+	private SysEmailServiceImpl sysEmailService;
+
 	// 验证码有效期
 	public static final int CODE_EXPIRE = 60 * 5;
 
@@ -305,6 +312,9 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 		if (receivers == null || receivers.size() == 0) {
 			throw new BizException("接收地址不能为空");
 		}
+		// email data from database load, 使用接收者 tenantId, 假设发送者和接收者为同一机构
+		Integer tenantId = getTenantIdByUser(null, String.valueOf(receivers.keySet().stream().findFirst()));
+		loadEmailInfo(messageSender, tenantId);
 		if(StringUtils.isNotEmpty(jpushType) && jpushType == "STUDENT"){
 			//如果不是缴费信息
 			if(type != STUDENT_PUSH_VIP_BUY){
@@ -367,6 +377,8 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 				url, messageConfig.getGroup(),jpushType);
 	}
 
+
+
 	@Override
 	@Async
 	public void batchPushMessage(MessageTypeEnum type, Map<Integer, String> receivers, Date triggerTime, Integer readStatus,
@@ -432,11 +444,13 @@ 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,
-			String url, String group,String jpushType) {
+	public void sendMessage(MessageSender messageSender, 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("接收地址不能为空");
 		}
+		// email data from database load
+		Integer tenantId = getTenantIdByUser(userId, receiver);
+		loadEmailInfo(messageSender, tenantId);
 		Date date = new Date();
 		SendStatusEnum status = SendStatusEnum.WAIT;
 		String errorMsg = null;
@@ -466,6 +480,35 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 		addMessage(receivers, title, content, triggerTime, mode, status, errorMsg, readStatus, url, null,jpushType);
 	}
 
+	private Integer getTenantIdByUser(Integer userId, String receiver) throws BizException {
+		SysUser user;
+		if (userId == null) {
+			user = sysUserFeignService.queryUserByMobile(receiver);
+			if (user != null) {
+				return user.getTenantId();
+			} // user query null using receiver query
+		}
+
+		user = sysUserFeignService.queryUserByMobile(receiver);
+		if (user != null) {
+			return user.getTenantId();
+		} else {
+			throw new BizException("找不到发送者用户 id: " + userId.toString() + " 接收者 " + receiver);
+		}
+	}
+
+	private void loadEmailInfo(MessageSender messageSender, Integer tenantId) {
+		if (Objects.equals(messageSender.getSendMode(), "EMAIL")) {
+			SysEmail email1 = sysEmailService.getOne(new WrapperUtil<SysEmail>().hasEq("tenant_id_", tenantId).queryWrapper());
+			messageSenderPluginContext.sysEmail.setHostName(email1.getHostName());
+			messageSenderPluginContext.sysEmail.setSmtpPort(email1.getSmtpPort());
+			messageSenderPluginContext.sysEmail.setUserName(email1.getUserName());
+			messageSenderPluginContext.sysEmail.setPassword(email1.getPassword());
+			messageSenderPluginContext.sysEmail.setFromName(email1.getFromName());
+			messageSenderPluginContext.sysEmail.setFrom(email1.getFrom());
+		}
+	}
+
 	@Override
 	public boolean sendSecurityCode(MessageSender messageSender, Integer userId, MessageTypeEnum messageType, String receiver) {
 		String key1 = getVerificationCode1CacheKey(messageType, receiver);

+ 2 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreCategoriesServiceImpl.java

@@ -41,11 +41,7 @@ public class SysMusicScoreCategoriesServiceImpl extends BaseServiceImpl<Integer,
 		List<SysMusicScoreCategories> scoreCategoriesAllList = sysMusicScoreCategoriesDao.findByParentId(null,menuQueryInfo.getOrganId(),menuQueryInfo.getEnable());
 		for (SysMusicScoreCategories categories : scoreCategories) {
 			getTree(categories, scoreCategoriesAllList);
-			if (categories.getSysMusicScoreCategoriesList() != null) {
-				categories.setMusicScoreNum(categories.getSysMusicScoreCategoriesList().size());
-			} else {
-				categories.setMusicScoreNum(0);
-			}
+			categories.setMusicScoreNum(categories.getMusicScoreNumSum());
 		}
 		return scoreCategories;
 	}
@@ -209,11 +205,7 @@ public class SysMusicScoreCategoriesServiceImpl extends BaseServiceImpl<Integer,
 			//遍历子节点....
 			for (SysMusicScoreCategories score : scoreCategories) {
 				getTree(score, scoreCategoriesAllList);
-				if (score.getSysMusicScoreCategoriesList() != null) {
-					score.setMusicScoreNum(score.getSysMusicScoreCategoriesList().size());
-				} else {
-					score.setMusicScoreNum(0);
-				}
+				score.setMusicScoreNum(score.getMusicScoreNumSum());
 			}
 		}
 		return categories;

+ 28 - 0
mec-biz/src/main/resources/config/mybatis/SysEmailMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ym.mec.biz.dal.dao.SysEmailDao">
+  <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.SysEmail">
+                       <id column="id_" jdbcType="INTEGER" property="id"/>
+                                  <result column="host_name_" jdbcType="VARCHAR" property="hostName"/>
+                                  <result column="smtp_port_" jdbcType="INTEGER" property="smtpPort"/>
+                                  <result column="user_name_" jdbcType="VARCHAR" property="userName"/>
+                                  <result column="password_" jdbcType="VARCHAR" property="password"/>
+                                  <result column="from_" jdbcType="VARCHAR" property="from"/>
+                                  <result column="from_name_" jdbcType="VARCHAR" property="fromName"/>
+                                  <result column="tenant_id_" jdbcType="INTEGER" property="tenantId"/>
+                </resultMap>
+  
+  <sql id="Base_Column_List">    
+                                            id_, host_name_, smtp_port_, user_name_, password_, from_, from_name_, tenant_id_
+  </sql>
+  
+   <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
+            parameterType="com.ym.mec.biz.dal.entity.SysEmail">
+       insert into sys_email(host_name_, smtp_port_, user_name_, password_, from_, from_name_, tenant_id_)
+       values
+       <foreach collection="entities" item="entity" separator=",">
+       (#{entity.hostName}, #{entity.smtpPort}, #{entity.userName}, #{entity.password}, #{entity.from}, #{entity.fromName}, #{entity.tenantId})
+       </foreach>
+   </insert>
+
+</mapper>

+ 11 - 7
mec-biz/src/main/resources/config/mybatis/SysMusicScoreCategoriesMapper.xml

@@ -17,6 +17,7 @@
 		<result column="order_" property="order" />
 		<result column="organ_name_" property="organNames" />
 		<result column="music_score_num_" property="musicScoreNum" />
+		<result column="music_score_num_sum_" property="musicScoreNumSum" />
 		<result column="sound_resource_" property="soundResource" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
@@ -24,12 +25,16 @@
 	
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="SysMusicScoreCategories" >
-		SELECT * FROM sys_music_score_categories WHERE id_ = #{id} 
+		SELECT categ.*,
+		(select count(1) from sys_music_score ms where categ.id_ = ms.music_score_categories_id_) as music_score_num_sum_
+		FROM sys_music_score_categories categ WHERE categ.id_ = #{id}
 	</select>
 	
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="SysMusicScoreCategories">
-		SELECT * FROM sys_music_score_categories ORDER BY id_
+		SELECT categ.*,
+			   (select count(1) from sys_music_score ms where categ.id_ = ms.music_score_categories_id_) as music_score_num_sum_
+		       FROM sys_music_score_categories categ ORDER BY categ.id_
 	</select>
 	
 	<!-- 向数据库增加一条记录 -->
@@ -136,7 +141,6 @@
 				AND (sm.id_ = #{search} OR sm.name_ LIKE CONCAT('%',#{search},'%'))
 			</if>
 		</where>
-		GROUP BY sm.id_
 		ORDER BY sm.order_
 		<include refid="global.limit"/>
 	</select>
@@ -160,11 +164,11 @@
 		</where>
 	</select>
 	<select id="findByParentId" resultMap="SysMusicScoreCategories">
-		SELECT count(score.id_) AS musicScoreNum, sm.* FROM sys_music_score_categories sm
-		LEFT JOIN sys_music_score score ON sm.id_ = score.music_score_categories_id_
+		SELECT sm.*,
+		(select count(1) from sys_music_score sms where sm.id_ = sms.music_score_categories_id_) as music_score_num_sum_
+        FROM sys_music_score_categories sm
 		<include refid="queryTree"/>
-		group by score.music_score_categories_id_
-# 		ORDER BY sm.order_
+ 		ORDER BY sm.order_
 	</select>
 	<select id="findByCategoriesIds" resultType="java.lang.String">
 		SELECT GROUP_CONCAT(id_) FROM sys_music_score_categories

+ 96 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/entity/SysEmail.java

@@ -0,0 +1,96 @@
+package com.ym.mec.thirdparty.entity;
+
+import java.io.Serializable;
+
+/**
+ * (SysEmail)表实体类
+ *
+ * @author makejava
+ * @since 2022-01-04 17:07:43
+ */
+public class SysEmail implements Serializable {
+    private Integer id;
+    
+    private String hostName;
+    
+    private Integer smtpPort;
+    
+    private String userName;
+    
+    private String password;
+    
+    private String from;
+    
+    private String fromName;
+    
+    private Integer tenantId;
+    
+    private static final long serialVersionUID = 1L;
+    
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public Integer getSmtpPort() {
+        return smtpPort;
+    }
+
+    public void setSmtpPort(Integer smtpPort) {
+        this.smtpPort = smtpPort;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getFrom() {
+        return from;
+    }
+
+    public void setFrom(String from) {
+        this.from = from;
+    }
+
+    public String getFromName() {
+        return fromName;
+    }
+
+    public void setFromName(String fromName) {
+        this.fromName = fromName;
+    }
+
+    public Integer getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Integer tenantId) {
+        this.tenantId = tenantId;
+    }
+
+
+}
+

+ 20 - 12
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/MessageSenderPluginContext.java

@@ -4,7 +4,8 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import com.ym.mec.thirdparty.message.provider.YimeiSmsPlugin;
+import com.ym.mec.thirdparty.entity.SysEmail;
+import com.ym.mec.thirdparty.message.provider.*;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeansException;
@@ -13,17 +14,15 @@ import org.springframework.context.ApplicationContextAware;
 import org.springframework.stereotype.Component;
 
 import com.ym.mec.thirdparty.exception.ThirdpartyException;
-import com.ym.mec.thirdparty.message.provider.AwSmsPlugin;
-import com.ym.mec.thirdparty.message.provider.JiguangPushPlugin;
-import com.ym.mec.thirdparty.message.provider.MOxintongSMSPlugin;
-import com.ym.mec.thirdparty.message.provider.ShiyuanSMSPlugin;
 
 @Component
 public class MessageSenderPluginContext implements ApplicationContextAware {
 
+	public SysEmail sysEmail = new SysEmail();
+
 	public enum MessageSender {
 
-		JIGUANG("PUSH"), MOXINGTONG("SMS"), SHIYUAN("SMS"), YIMEI("SMS"), AWSMS("SMS");
+		JIGUANG("PUSH"), MOXINGTONG("SMS"), SHIYUAN("SMS"), YIMEI("SMS"), AWSMS("SMS"), EMAIL("EMAIL");
 
 		/**
 		 * 发送模式(SMS,PUSH,EMAIL)
@@ -44,18 +43,14 @@ public class MessageSenderPluginContext implements ApplicationContextAware {
 	private ApplicationContext applicationContext;
 
 	private final Map<String, String> mapper = new HashMap<String, String>() {
-
-		/**
-		 * 
-		 */
 		private static final long serialVersionUID = -3964872523891264522L;
-
 		{
 			put(StringUtils.lowerCase(JiguangPushPlugin.getName()), StringUtils.uncapitalize(JiguangPushPlugin.class.getSimpleName()));
 			put(StringUtils.lowerCase(MOxintongSMSPlugin.getName()), StringUtils.uncapitalize(MOxintongSMSPlugin.class.getSimpleName()));
 			put(StringUtils.lowerCase(ShiyuanSMSPlugin.getName()), StringUtils.uncapitalize(ShiyuanSMSPlugin.class.getSimpleName()));
 			put(StringUtils.lowerCase(YimeiSmsPlugin.getName()), StringUtils.uncapitalize(YimeiSmsPlugin.class.getSimpleName()));
 			put(StringUtils.lowerCase(AwSmsPlugin.getName()), StringUtils.uncapitalize(AwSmsPlugin.class.getSimpleName()));
+			put(StringUtils.lowerCase(CommEmailPlugin.getName()), StringUtils.uncapitalize(CommEmailPlugin.class.getSimpleName()));
 		}
 	};
 
@@ -104,8 +99,21 @@ public class MessageSenderPluginContext implements ApplicationContextAware {
 		if (StringUtils.isBlank(beanId)) {
 			throw new ThirdpartyException("消息提供方:{}不存在", beanId);
 		}
+		MessageSenderPlugin messageSenderPlugin = applicationContext.getBean(beanId, MessageSenderPlugin.class);
+		injectEmailAttribute(messageSenderPlugin);
+		return messageSenderPlugin;
+	}
 
-		return applicationContext.getBean(beanId, MessageSenderPlugin.class);
+	private void injectEmailAttribute(MessageSenderPlugin messageSenderPlugin) {
+		if (messageSenderPlugin.getClass() == CommEmailPlugin.class) {
+			CommEmailPlugin commEmailPlugin = (CommEmailPlugin) messageSenderPlugin;
+			commEmailPlugin.setHostName(sysEmail.getHostName());
+			commEmailPlugin.setSmtpPort(sysEmail.getSmtpPort());
+			commEmailPlugin.setUserName(sysEmail.getUserName());
+			commEmailPlugin.setPassword(sysEmail.getPassword());
+			commEmailPlugin.setFrom(sysEmail.getFrom());
+			commEmailPlugin.setFromName(sysEmail.getFromName());
+		}
 	}
 
 }

+ 11 - 2
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/CommEmailPlugin.java

@@ -12,7 +12,7 @@ import com.ym.mec.thirdparty.message.MessageSenderPlugin;
 
 //@Service
 public class CommEmailPlugin implements MessageSenderPlugin, InitializingBean {
-	
+
 	private String hostName;
 
 	private int smtpPort;
@@ -49,6 +49,10 @@ public class CommEmailPlugin implements MessageSenderPlugin, InitializingBean {
 		this.fromName = fromName;
 	}
 
+	public static String getName() {
+		return "EMAIL";
+	}
+
 	@Override
 	public void afterPropertiesSet() throws Exception {
 		if (StringUtils.isBlank(hostName)) {
@@ -71,6 +75,7 @@ public class CommEmailPlugin implements MessageSenderPlugin, InitializingBean {
 			throw new RuntimeException("发件人邮箱没有配置");
 		}
 
+		// 落款名字
 		if (StringUtils.isBlank(fromName)) {
 			fromName = from;
 		}
@@ -98,7 +103,11 @@ public class CommEmailPlugin implements MessageSenderPlugin, InitializingBean {
 	@Override
 	public boolean batchSend(String subject, String content, String[] receivers, String url, String jpushType, String sound, String channelId) throws Exception {
 		for (String rev : receivers) {
-			send(subject, content, rev, url, jpushType, sound, channelId);
+			try {
+				send(subject, content, rev, url, jpushType, sound, channelId);
+			} catch(EmailException e) {
+				throw new RuntimeException("发送邮件出现异常", e);
+			}
 		}
 		return true;
 	}

+ 9 - 0
mec-web/src/main/java/com/ym/mec/web/controller/AppRedemptionCodeController.java

@@ -44,5 +44,14 @@ public class AppRedemptionCodeController extends BaseController {
         }
         return succeed(appRedemptionCodeService.allocation(userId));
     }
+
+    @ApiOperation(value = "使用量检测")
+    @GetMapping(value = "checkLowVolume")
+    // @PreAuthorize("@pcs.hasPermissions('appRedemptionCode/checkLowVolume')")
+    public Object checkLowVolume() {
+        appRedemptionCodeService.checkLowVolume();
+        return null;
+    }
+
 }
 

+ 28 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SysEmailController.java

@@ -0,0 +1,28 @@
+package com.ym.mec.web.controller;
+
+
+
+import com.ym.mec.biz.dal.entity.SysEmail;
+import com.ym.mec.biz.service.SysEmailService;
+import org.springframework.web.bind.annotation.*;
+import com.ym.mec.common.controller.BaseController;
+
+import javax.annotation.Resource;
+
+/**
+ * (SysEmail)表控制层
+ *
+ * @author makejava
+ * @since 2022-01-04 17:07:43
+ */
+@RestController
+@RequestMapping("/sysEmail")
+public class SysEmailController extends BaseController {
+    /**
+     * 服务对象
+     */
+    @Resource
+    private SysEmailService sysEmailService;
+
+}
+