| | |
| | | import com.yami.trading.common.http.HttpHelper; |
| | | import com.yami.trading.common.manager.BlacklistIpTimeWindow; |
| | | import com.yami.trading.common.manager.SendCountTimeWindow; |
| | | import com.yami.trading.common.manager.sms.BUKASmsUtils; |
| | | import com.yami.trading.common.manager.sms.GoToneSmsUtils; |
| | | import com.yami.trading.service.EmailSendService; |
| | | import com.yami.trading.service.IdentifyingCodeService; |
| | |
| | | import com.yami.trading.service.syspara.SysparaService; |
| | | import com.yami.trading.service.system.CodeLogService; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.apache.commons.lang3.StringEscapeUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | GoToneSmsUtils goToneSmsUtils; |
| | | |
| | | @Autowired |
| | | BUKASmsUtils bukasmsUtils; |
| | | |
| | | @Override |
| | | public void send(String target, String ip) throws IOException { |
| | | String code = null; |
| | |
| | | // String smsbao_sign = sysparaService.find("smsbao_sign").getValue(); |
| | | |
| | | // 短信发送文本[TEST]code is :{0} |
| | | String send_code_text = this.sysparaService.find("send_code_text").getSvalue(); |
| | | if (StringUtils.isNullOrEmpty(send_code_text)) { |
| | | logger.error("send_code_text 未配置"); |
| | | return; |
| | | } |
| | | String send_code_text; |
| | | |
| | | /** |
| | | * 是否每次发送的code都不一样 |
| | |
| | | } |
| | | // log.info(MessageFormat.format("target:{0},code:{1},ip:{2}", target, code, ip)); |
| | | |
| | | String content = MessageFormat.format("code is :{0}", new Object[] { code }); |
| | | String content = "[BingX]"; |
| | | if (target.indexOf("@") == -1) { |
| | | |
| | | send_code_text = this.sysparaService.find("send_code_text").getSvalue(); |
| | | if (StringUtils.isNullOrEmpty(send_code_text)) { |
| | | logger.error("send_code_text 未配置"); |
| | | return; |
| | | } |
| | | /** |
| | | * 发送的短信接口类型 tiantian---天天---smsSendService--->>>>-- |
| | | * moduyun---摩杜云---smsSingleSender |
| | |
| | | return; |
| | | } |
| | | |
| | | if ("buka".equals(send_code_type)) { |
| | | bukasmsUtils.sendSms(target, MessageFormat.format(send_code_text, new Object[] { code })); |
| | | logger.info(MessageFormat.format("buka--target:{0},code:{1},ip:{2}", target, code, ip)); |
| | | } |
| | | |
| | | if ("GoTone".equals(send_code_type)) { |
| | | goToneSmsUtils.sendSms(target, MessageFormat.format(send_code_text, new Object[] { code })); |
| | | String response = goToneSmsUtils.sendSms(target, MessageFormat.format(send_code_text, new Object[] { code })); |
| | | logger.info(MessageFormat.format("GoTone--target:{0},code:{1},ip:{2}", target, code, ip)); |
| | | String responseWithChinese = StringEscapeUtils.unescapeJava(response); |
| | | System.out.println("中文发送结果: " + responseWithChinese); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | } else { |
| | | send_code_text = this.sysparaService.find("email_send_code_text").getSvalue(); |
| | | if (StringUtils.isNullOrEmpty(send_code_text)) { |
| | | logger.error("email_send_code_text 未配置"); |
| | | return; |
| | | } |
| | | /** |
| | | * 邮件 |
| | | */ |
| | | emailSendService.sendEmail(target, MessageFormat.format(send_code_text, new Object[] { code }), content); |
| | | //emailSendService.sendEmail(target, content, MessageFormat.format(send_code_text, new Object[] { code })); |
| | | // 调用示例 |
| | | Map<String, Object> model = new HashMap<>(); |
| | | model.put("code", code); |
| | | emailSendService.sendEmail(target, content, "verification_email.ftl", model); |
| | | logger.info(MessageFormat.format("email--target:{0},code:{1},ip:{2}", target, code, ip)); |
| | | } |
| | | |