|
|
|
@@ -3,6 +3,7 @@ package com.simple.service.impl; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.simple.common.ErrorCode; |
|
|
|
import com.simple.common.IdWorker; |
|
|
|
import com.simple.common.Result; |
|
|
|
import com.simple.common.ResultData; |
|
|
|
@@ -58,13 +59,16 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM |
|
|
|
//查看用户最新数据是否存在 |
|
|
|
List<WxMsgValidationcodeModel> wxMsgModels = wxMsgValidationcodeModelMapper.findList(wxMsgModel); |
|
|
|
if (wxMsgModel.getId() == null && wxMsgModels.size() == 1) { |
|
|
|
return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); |
|
|
|
return new ResultData(ErrorCode.MSG_TEMPLATE_REPEAT.getCode(), "您添加的短信模板已存在"); |
|
|
|
} |
|
|
|
|
|
|
|
if (wxMsgModel.getId() != null && wxMsgModels.size() == 1) { |
|
|
|
//ID相同 内容相同 不发送短信 不做修改 |
|
|
|
WxMsgValidationcodeModel wxmsgmodel = wxMsgModels.get(0); |
|
|
|
if(wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { |
|
|
|
return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); |
|
|
|
return new ResultData(Result.SUCCESS, "修改成功"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//请求api数据排序 |
|
|
|
@@ -103,7 +107,7 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM |
|
|
|
String result = HttpUtil.doPost(requestUrl, params); |
|
|
|
JSONObject jsonObjectResult = JSONObject.parseObject(result); |
|
|
|
String ret = jsonObjectResult.get("ret").toString(); |
|
|
|
if (ret.equals("1") || ret.equals("-6")) { |
|
|
|
if (ret.equals("1")) { |
|
|
|
if (wxMsgModel.getId() == null) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
wxMsgModel.setId(idWorker.nextId()); |
|
|
|
@@ -117,10 +121,23 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM |
|
|
|
wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); |
|
|
|
} |
|
|
|
return new ResultData(Result.SUCCESS, "创建模板成功"); |
|
|
|
}else if(ret.equals("-6")){ |
|
|
|
if (wxMsgModel.getId() == null) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
wxMsgModel.setId(idWorker.nextId()); |
|
|
|
wxMsgModel.setTenantId(wxMsgModel.getTenantId()); |
|
|
|
String data = jsonObjectResult.get("data").toString(); |
|
|
|
wxMsgModel.setModelId(Integer.valueOf(data)); |
|
|
|
wxMsgModel.setCreatetime(new Date()); |
|
|
|
wxMsgModel.setStatus(1); |
|
|
|
wxMsgValidationcodeModelMapper.insertSelective(wxMsgModel); |
|
|
|
} else { |
|
|
|
wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); |
|
|
|
} |
|
|
|
}else if (ret == "-4") { |
|
|
|
return new ResultData(Result.SUCCESS, "短信签名或内容错误"); |
|
|
|
return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); |
|
|
|
} |
|
|
|
return new ResultData(Result.SUCCESS, "创建模板失败"); |
|
|
|
return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|