Commit 5e3cfb5497db5b37b421fe7c9c5e103dc5e0a588

Authored by liwei2917
1 parent 877f22a0

将邮件需要的常量提到配置文件中,修改邮件发送列表的获取参数

src/main/java/com/cnlive/shenhe/job/LiveApplyJob.java
@@ -23,6 +23,7 @@ import com.cnlive.shenhe.utils.InfoUtil; @@ -23,6 +23,7 @@ import com.cnlive.shenhe.utils.InfoUtil;
23 import com.cnlive.shenhe.utils.OpenUtil; 23 import com.cnlive.shenhe.utils.OpenUtil;
24 24
25 import tk.mybatis.mapper.entity.Example; 25 import tk.mybatis.mapper.entity.Example;
  26 +import tk.mybatis.mapper.entity.Example.Criteria;
26 27
27 import org.slf4j.Logger; 28 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory; 29 import org.slf4j.LoggerFactory;
@@ -40,6 +41,12 @@ public class LiveApplyJob { @@ -40,6 +41,12 @@ public class LiveApplyJob {
40 private static Logger logger = LoggerFactory.getLogger(LiveApplyJob.class); 41 private static Logger logger = LoggerFactory.getLogger(LiveApplyJob.class);
41 @Value("${spring.localhost.url}") 42 @Value("${spring.localhost.url}")
42 private String localhost_url;//本机地址 43 private String localhost_url;//本机地址
  44 + @Value("${email_app_id}")
  45 + private String email_app_id;//开发者对应的id,与app_key相对应
  46 + @Value("${email_app_key}")
  47 + private String email_app_key;//开发者帐号对应的key. 请开发者谨慎保管此值。
  48 + @Value("${email_send_URL}")
  49 + private String email_send_URL;//调用邮件发送服务器的地址
43 50
44 @Autowired 51 @Autowired
45 SitesServiceImpl sitesService; 52 SitesServiceImpl sitesService;
@@ -78,16 +85,16 @@ public class LiveApplyJob { @@ -78,16 +85,16 @@ public class LiveApplyJob {
78 @Scheduled(fixedRate = 60 * 1000) 85 @Scheduled(fixedRate = 60 * 1000)
79 public void liveApplyNotice() { 86 public void liveApplyNotice() {
80 Example example = new Example(ShyLiveapply.class); 87 Example example = new Example(ShyLiveapply.class);
81 - Example.Criteria criteria = example.createCriteria(); 88 + Criteria criteria = example.createCriteria();
82 criteria.andEqualTo("shenhe_state", CommonConst.AUDIT_SUCCESS); 89 criteria.andEqualTo("shenhe_state", CommonConst.AUDIT_SUCCESS);
83 - criteria.andNotEqualTo("notice_jishu", CommonConst.NOTICE_SUCCESS);//状态不等于已通知 90 + criteria.andNotEqualTo("email_notice_state", CommonConst.NOTICE_SUCCESS);//状态不等于已通知
84 List<ShyLiveapply> shyLiveApplyList = shyLiveApplyMapper.selectByExample(example); 91 List<ShyLiveapply> shyLiveApplyList = shyLiveApplyMapper.selectByExample(example);
85 if (shyLiveApplyList.size() > 0) { 92 if (shyLiveApplyList.size() > 0) {
86 - logger.info("直播申请邮件通知开始,共"+shyLiveApplyList.size()+"个");  
87 - String app_id = "769_jetja50p18"; //开发者对应的id,与app_key相对应  
88 - String app_key = "ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba"; //开发者帐号对应的key. 请开发者谨慎保管此值。  
89 - String URL = "http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action";//调用邮件发送服务器的地址 93 + String app_id = email_app_id; //开发者对应的id,与app_key相对应
  94 + String app_key = email_app_key; //开发者帐号对应的key. 请开发者谨慎保管此值。
  95 + String URL = email_send_URL;//调用邮件发送服务器的地址
90 List<String> shyEmailList=emailServiceImpl.getEmailSendList(CommonConst.EMAIL_LIVEAPPLY); 96 List<String> shyEmailList=emailServiceImpl.getEmailSendList(CommonConst.EMAIL_LIVEAPPLY);
  97 + logger.info("直播申请邮件通知开始,共"+shyLiveApplyList.size()+"个申请,每个申请通知"+shyEmailList.size()+"个邮箱");
91 for(ShyLiveapply liveApply : shyLiveApplyList){ 98 for(ShyLiveapply liveApply : shyLiveApplyList){
92 Integer notice_state = liveApply.getEmail_notice_state();//初始化通知状态 99 Integer notice_state = liveApply.getEmail_notice_state();//初始化通知状态
93 String notice_msg = liveApply.getEmail_notice_msg();//初始化通知消息 100 String notice_msg = liveApply.getEmail_notice_msg();//初始化通知消息
src/main/java/com/cnlive/shenhe/serviceImpl/EmailServiceImpl.java
@@ -120,15 +120,17 @@ public class EmailServiceImpl { @@ -120,15 +120,17 @@ public class EmailServiceImpl {
120 * @return 120 * @return
121 */ 121 */
122 public List<String> getEmailSendList(Integer emailSendType) { 122 public List<String> getEmailSendList(Integer emailSendType) {
123 -  
124 - List<ShyEmail> shyEmailList = shyEmailMapper.selectAll(); 123 + ShyEmail shyEmail= new ShyEmail();
  124 + shyEmail.setIs_delete(false);
  125 + shyEmail.setIs_enable(true);
  126 + List<ShyEmail> shyEmailList = shyEmailMapper.select(shyEmail);
125 List<String> emailList = new ArrayList<String>(); 127 List<String> emailList = new ArrayList<String>();
126 - for (ShyEmail shyEmail : shyEmailList) {  
127 - if (CommonUtils.isNotEmpty(shyEmail.getNotice_type())) {  
128 - String[] business = shyEmail.getNotice_type().split(","); 128 + for (ShyEmail shyEmail2 : shyEmailList) {
  129 + if (CommonUtils.isNotEmpty(shyEmail2.getNotice_type())) {
  130 + String[] business = shyEmail2.getNotice_type().split(",");
129 List<String> asList = Arrays.asList(business); 131 List<String> asList = Arrays.asList(business);
130 if (asList.contains(emailSendType + "")) { 132 if (asList.contains(emailSendType + "")) {
131 - emailList.add(shyEmail.getEmail()); 133 + emailList.add(shyEmail2.getEmail());
132 } 134 }
133 } 135 }
134 } 136 }
src/main/resources/application.properties
@@ -64,6 +64,11 @@ avsmple_callback=http://test.shen.cnlive.com/api/avsample/callback @@ -64,6 +64,11 @@ avsmple_callback=http://test.shen.cnlive.com/api/avsample/callback
64 #\u540c\u6b65\u76f4\u64ad\u4e91\u4fe1\u606f 64 #\u540c\u6b65\u76f4\u64ad\u4e91\u4fe1\u606f
65 live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe 65 live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe
66 66
  67 +#\u90ae\u4ef6\u4f7f\u7528\u5e38\u91cf
  68 +email_app_id=769_jetja50p18
  69 +email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
  70 +email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action
  71 +
67 #\u62bd\u5e27\u5b58\u653ebucket\u548c\u57df\u540d 72 #\u62bd\u5e27\u5b58\u653ebucket\u548c\u57df\u540d
68 qn_bucket=cnlivetest 73 qn_bucket=cnlivetest
69 qn_domain=http://test.qnvod.cnlive.com 74 qn_domain=http://test.qnvod.cnlive.com