| @@ -189,7 +189,10 @@ public enum ErrorCode{ | |||||
| MSG_SIGNATURE_CONTENT_ERROR(12102,"短信签名或内容错误"), | MSG_SIGNATURE_CONTENT_ERROR(12102,"短信签名或内容错误"), | ||||
| MSG_TEMPLATE_CREATE_ERROR(12103,"创建模板失败"), | MSG_TEMPLATE_CREATE_ERROR(12103,"创建模板失败"), | ||||
| MSG_VERIFY_CODE_NOT_FOUND(12104,"短信验证码不存在或失效"), | MSG_VERIFY_CODE_NOT_FOUND(12104,"短信验证码不存在或失效"), | ||||
| MSG_TEMPLATE_NOT_FOUND(12105,"短信模板不存在"), | |||||
| MSG_REQUEST_PARAMS_ERROR(12106,"参数错误"), | |||||
| MSG_SEND_ERROR(12107,"发送短信失败"), | |||||
| MSG_METHOD_REQUEST_ERROR(12108,"接口请求错误") | |||||
| ; | ; | ||||
| private int code; | private int code; | ||||
| @@ -23,8 +23,8 @@ import java.util.*; | |||||
| @Service | @Service | ||||
| public class WxMsgModelServiceImpl implements WxMsgModelService { | public class WxMsgModelServiceImpl implements WxMsgModelService { | ||||
| @Autowired | |||||
| @Autowired | |||||
| WxMsgModelMapper wxMsgModelMapper; | WxMsgModelMapper wxMsgModelMapper; | ||||
| @Autowired | @Autowired | ||||
| @@ -47,11 +47,13 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | WxMsgConfig wxMsgConfig = new WxMsgConfig(); | ||||
| wxMsgConfig.setTenantId(wxMsgModel.getTenantId()); | wxMsgConfig.setTenantId(wxMsgModel.getTenantId()); | ||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | ||||
| if(wxMsgConfigs.size()==0)return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND.getCode(), "您还未接入短信运营商,请联系平台管理员"); | |||||
| if (wxMsgConfigs.size() == 0) | |||||
| return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND.getCode(), "您还未接入短信运营商,请联系平台管理员"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | wxMsgConfig = wxMsgConfigs.get(0); | ||||
| String secret = wxMsgConfig.getSecret(); | String secret = wxMsgConfig.getSecret(); | ||||
| String bid = wxMsgConfig.getBid(); | String bid = wxMsgConfig.getBid(); | ||||
| String signature = wxMsgModel.getSignature(); | String signature = wxMsgModel.getSignature(); | ||||
| String content = wxMsgModel.getContent(); | String content = wxMsgModel.getContent(); | ||||
| //查看用户最新数据是否存在 | //查看用户最新数据是否存在 | ||||
| @@ -61,7 +63,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| } | } | ||||
| if (wxMsgModel.getId() != null && wxMsgModels.size() == 1) { | if (wxMsgModel.getId() != null && wxMsgModels.size() == 1) { | ||||
| WxMsgModel wxmsgmodel = wxMsgModels.get(0); | WxMsgModel wxmsgmodel = wxMsgModels.get(0); | ||||
| if(wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { | |||||
| if (wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { | |||||
| return new ResultData(ResultData.SUCCESS, "修改成功"); | return new ResultData(ResultData.SUCCESS, "修改成功"); | ||||
| } | } | ||||
| } | } | ||||
| @@ -71,7 +73,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| message.put("bid", bid); | message.put("bid", bid); | ||||
| message.put("signature", signature); | message.put("signature", signature); | ||||
| message.put("content", content); | message.put("content", content); | ||||
| message.put("notify_url",wxMsgConfig.getModelnotifyurl()); | |||||
| message.put("notify_url", wxMsgConfig.getModelnotifyurl()); | |||||
| StringBuilder sb = new StringBuilder(); | StringBuilder sb = new StringBuilder(); | ||||
| Set<Map.Entry<String, String>> entries = message.entrySet(); | Set<Map.Entry<String, String>> entries = message.entrySet(); | ||||
| @@ -94,7 +96,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| params.put("data", data); | params.put("data", data); | ||||
| params.put("sc", sc); | params.put("sc", sc); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| e.printStackTrace(); | |||||
| throw new RuntimeException("创建模板失败"); | |||||
| } | } | ||||
| String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | ||||
| @@ -115,7 +117,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | ||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "创建模板成功"); | return new ResultData(Result.SUCCESS, "创建模板成功"); | ||||
| }else if(ret.equals("-6")){ | |||||
| } else if (ret.equals("-6")) { | |||||
| if (wxMsgModel.getId() == null) { | if (wxMsgModel.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsgModel.setId(idWorker.nextId()); | wxMsgModel.setId(idWorker.nextId()); | ||||
| @@ -126,8 +128,16 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| } else { | } else { | ||||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | ||||
| } | } | ||||
| }else if (ret == "-4") { | |||||
| } else if (ret.equals("-4")) { | |||||
| return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | ||||
| } else if (ret.equals("-5")) { | |||||
| return new ResultData(ErrorCode.MSG_TEMPLATE_NOT_FOUND.getCode(), "短信模板不存在"); | |||||
| } else if (ret.equals("-3")) { | |||||
| return new ResultData(ErrorCode.MSG_REQUEST_PARAMS_ERROR.getCode(), "参数错误"); | |||||
| } else if (ret.equals("-2")) { | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "发送短信失败"); | |||||
| } else if (ret.equals("-1")) { | |||||
| return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(), "接口请求错误"); | |||||
| } | } | ||||
| return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | ||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ErrorCode; | |||||
| import com.simple.common.IdWorker; | import com.simple.common.IdWorker; | ||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| @@ -196,7 +197,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| params.put("data", data); | params.put("data", data); | ||||
| params.put("sc", sc); | params.put("sc", sc); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| e.printStackTrace(); | |||||
| throw new RuntimeException("发送短信失败"); | |||||
| } | } | ||||
| String requestUrl = "https://webapp.wiwide.com/apisms/send"; | String requestUrl = "https://webapp.wiwide.com/apisms/send"; | ||||
| @@ -222,7 +223,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| if (ret.equals("1")) { | if (ret.equals("1")) { | ||||
| return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态"); | return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态"); | ||||
| } else { | } else { | ||||
| return new ResultData(Result.SUCCESS, "短信发送发败"); | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "短信发送发败"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -54,6 +54,7 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||||
| String secret = wxMsgConfig.getSecret(); | String secret = wxMsgConfig.getSecret(); | ||||
| String bid = wxMsgConfig.getBid(); | String bid = wxMsgConfig.getBid(); | ||||
| String signature = wxMsgModel.getSignature(); | String signature = wxMsgModel.getSignature(); | ||||
| String content = wxMsgModel.getContent(); | String content = wxMsgModel.getContent(); | ||||
| //查看用户最新数据是否存在 | //查看用户最新数据是否存在 | ||||
| @@ -100,7 +101,7 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||||
| params.put("data", data); | params.put("data", data); | ||||
| params.put("sc", sc); | params.put("sc", sc); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| e.printStackTrace(); | |||||
| throw new RuntimeException("创建模板失败"); | |||||
| } | } | ||||
| String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | ||||
| @@ -132,8 +133,16 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||||
| } else { | } else { | ||||
| wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | ||||
| } | } | ||||
| }else if (ret == "-4") { | |||||
| }else if (ret.equals("-4")) { | |||||
| return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | ||||
| }else if (ret.equals("-5")) { | |||||
| return new ResultData(ErrorCode.MSG_TEMPLATE_NOT_FOUND.getCode(), "短信模板不存在"); | |||||
| }else if (ret.equals("-3")) { | |||||
| return new ResultData(ErrorCode.MSG_REQUEST_PARAMS_ERROR.getCode(), "参数错误"); | |||||
| }else if (ret.equals("-2")) { | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "发送短信失败"); | |||||
| }else if (ret.equals("-1")) { | |||||
| return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(), "接口请求错误"); | |||||
| } | } | ||||
| return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | ||||
| @@ -97,7 +97,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | WxMsgConfig wxMsgConfig = new WxMsgConfig(); | ||||
| wxMsgConfig.setAppid(wxMsgValidationcode.getAppid()); | wxMsgConfig.setAppid(wxMsgValidationcode.getAppid()); | ||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | ||||
| if (wxMsgConfigs.size() == 0) new ResultData(500,"发送失败"); | |||||
| if (wxMsgConfigs.size() == 0) new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | wxMsgConfig = wxMsgConfigs.get(0); | ||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | ||||
| @@ -150,7 +150,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| params.put("data", data); | params.put("data", data); | ||||
| params.put("sc", sc); | params.put("sc", sc); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException("发送失败"); | |||||
| throw new RuntimeException("发送验证码失败"); | |||||
| } | } | ||||
| String requestUrl = "https://webapp.wiwide.com/apisms/send"; | String requestUrl = "https://webapp.wiwide.com/apisms/send"; | ||||
| @@ -171,7 +171,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | ||||
| return new ResultData(Result.SUCCESS,"发送成功"); | return new ResultData(Result.SUCCESS,"发送成功"); | ||||
| } | } | ||||
| return new ResultData(500,"发送失败"); | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); | |||||
| } | } | ||||
| @@ -31,17 +31,17 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != name "> | <if test=" null != name "> | ||||
| and `name` like concat('%', #{name},'%') | |||||
| and `name` = #{name} | |||||
| </if> | </if> | ||||
| <if test=" null != signature "> | <if test=" null != signature "> | ||||
| and `signature` like concat('%', #{signature},'%') | |||||
| and `signature` = #{signature} | |||||
| </if> | </if> | ||||
| <if test=" null != content "> | <if test=" null != content "> | ||||
| and `content` like concat('%', #{content},'%') | |||||
| and `content` = #{content} | |||||
| </if> | </if> | ||||