package cn.com.ctop.notice.handler; import cn.com.ctop.common.module.mapper.MailLogMapper; import cn.com.ctop.common.module.utils.CorpWexinUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.List; @Slf4j @Service public class SendWeChatHandle { @Autowired MailLogMapper mailLogMapper; public void sendWeChatByMail(String mail,String message){ String weChatId=mailLogMapper.getWeChatByMail(mail); if(weChatId.isEmpty()){ log.error(String.format("mail's WeChat not found. mail =%s", mail)); //TODO 通知管理员添加邮箱 }else{ CorpWexinUtils.sendMessageByWeChatId(weChatId,message); } } /** * 发送多人,邮箱逗号隔开 * @param mails * @param message */ public void sendWeChatByMails(String mails,String message){ List mail= Arrays.asList(mails.split(",")); mail.forEach(m->{ this.sendWeChatByMail(m,message); }); } }