SendWeChatHandle.java 855 B

12345678910111213141516171819202122232425262728
  1. package cn.com.ctop.notice.handler;
  2. import cn.com.ctop.common.module.mapper.MailLogMapper;
  3. import cn.com.ctop.common.module.utils.CorpWexinUtils;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. @Slf4j
  8. @Service
  9. public class SendWeChatHandle {
  10. @Autowired
  11. MailLogMapper mailLogMapper;
  12. public boolean SendWeChatByMail(String mail,String message){
  13. boolean result=true;
  14. String weChatId=mailLogMapper.getWeChatByMail(mail);
  15. if(weChatId.isEmpty()){
  16. log.error(String.format("mail's WeChat not found. mail =%s", mail));
  17. //TODO 通知管理员添加邮箱
  18. result=false;
  19. }else{
  20. CorpWexinUtils.sendMessageByWeChatId(weChatId,message);
  21. }
  22. return result;
  23. }
  24. }