| | |
| | | if (ToolUtil.isEmpty(kaptcha) || !kaptcha.equalsIgnoreCase(code)) { |
| | | return ResultUtil.error(language == 1 ? "图形验证码错误" : language == 2 ? "The graphic verification code is incorrect" : "Code de vérification graphique incorrect"); |
| | | } |
| | | return userInfoService.queryCaptcha(phone, type); |
| | | return userInfoService.queryCaptcha(phone, type, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "场景类型(1=身份验证,2=登录确认,3=用户注册,4=修改密码)", name = "type", required = true, dataType = "String") |
| | | }) |
| | | public ResultUtil queryCaptcha1(String phone, Integer type){ |
| | | public ResultUtil queryCaptcha1(String phone, Integer type, Integer language){ |
| | | if(ToolUtil.isNotEmpty(phone)){ |
| | | try { |
| | | String substring = phone.substring(0, 1); |
| | |
| | | if(phone.indexOf("233") < 0){ |
| | | phone = "233" + phone; |
| | | } |
| | | return userInfoService.queryCaptcha(phone, type); |
| | | return userInfoService.queryCaptcha(phone, type, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | * @param phone |
| | | * @return |
| | | */ |
| | | ResultUtil queryCaptcha(String phone, Integer type) throws Exception; |
| | | ResultUtil queryCaptcha(String phone, Integer type, Integer language) throws Exception; |
| | | |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultUtil queryCaptcha(String phone, Integer type) throws Exception { |
| | | public ResultUtil queryCaptcha(String phone, Integer type, Integer language) throws Exception { |
| | | Random random = new Random(); |
| | | Object value = redisUtil.getValue(phone); |
| | | if(value==null){ |
| | |
| | | |
| | | //发送验证码短信 |
| | | redisUtil.setStrValue(phone, authCode, 5 * 60);//设置五分钟过期 |
| | | SMSUtil.send_huawei_sms("b793ae3d41a049059197bfe92cf8bc83", "+" + phone, "[\"" + authCode + "\"]"); |
| | | String templateId = ""; |
| | | switch (language){ |
| | | case 1: |
| | | templateId = "b793ae3d41a049059197bfe92cf8bc83"; |
| | | break; |
| | | case 2: |
| | | templateId = "058c7d11ce594d668841cceb49fb5c9a"; |
| | | break; |
| | | case 3: |
| | | templateId = "4edbe604da6546808ffda582085b3c83"; |
| | | break; |
| | | } |
| | | SMSUtil.send_huawei_sms(templateId, "+" + phone, "[\"" + authCode + "\"]"); |
| | | System.out.println(sms); |
| | | } |
| | | return ResultUtil.success(); |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | try { |
| | | SMSUtil.send_huawei_sms("b793ae3d41a049059197bfe92cf8bc83", "+8615828353127", "[\"1234\"]"); |
| | | SMSUtil.send_huawei_sms("b793ae3d41a049059197bfe92cf8bc83", "+233500666666", "[\"1234\"]"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |