use of com.itrus.portal.db.Smsserver in project portal by ixinportal.
the class SMSServiceAsync method sendDR.
public Object sendDR(Map param, Integer flag) {
if (QueueThread.ASYNC_ON == flag) {
QueueThread.buildTask(sqlSession, this, param);
return null;
}
String authHmac = (String) param.get("authHmac");
String appid = (String) param.get("appid");
String mphone = (String) param.get("mphone");
String content = (String) param.get("content");
HttpServletRequest request = (HttpServletRequest) param.get("request");
Map<String, Object> result = new HashMap<String, Object>(2);
// 验证参数是否完整
if (StringUtils.isBlank(authHmac) || StringUtils.isBlank(appid) || StringUtils.isBlank(mphone) || StringUtils.isBlank(content)) {
result.put("retCode", 0);
result.put("retMsg", "提交的参数信息不完整");
return result;
}
if (content.length() >= 70) {
result.put("retCode", -1);
result.put("retMsg", "短信内容过长");
return result;
}
AppConfigExample ace = new AppConfigExample();
AppConfigExample.Criteria acc = ace.createCriteria();
acc.andAppIdEqualTo(appid);
AppConfig ac = sqlSession.selectOne("com.itrus.portal.db.AppConfigMapper.selectByExample", ace);
if (null == ac) {
result.put("retCode", -3);
result.put("retMsg", "没有此应用");
return result;
}
Smsserver smsserver = sqlSession.selectOne("com.itrus.portal.db.SmsserverMapper.selectByPrimaryKey", ac.getSmsId());
if (!content.startsWith(smsserver.getSmsSignature())) {
// 判断短信签名
result.put("retCode", -2);
result.put("retMsg", "短信签名错误");
return result;
}
if (ac.getAppStatus() == 1 || !ac.getAppip().contains(request.getRemoteAddr())) {
LogUtil.syslog(sqlSession, "短信服务", appid + "没有此服务权限,访问ip:" + request.getRemoteAddr());
result.put("retCode", -4);
result.put("retMsg", "没有此服务权限");
return result;
}
MessageLog ml;
String send = "-8";
// 验证hmac有效性
try {
String macVal = Base64.encode(HMACSHA1.getHmacSHA1(appid + content + mphone, ac.getSecretKey()), false);
if (!authHmac.equals(macVal)) {
result.put("retCode", -5);
result.put("retMsg", "服务密钥错误");
return result;
}
ml = new MessageLog();
ml.setAppId(ac.getId());
ml.setCellPhone(mphone);
ml.setContent(content);
ml.setSendTime(new Date());
ml.setGate(smsserver.getSmsport());
// 0亿美 1未来无线
smsService = SpringContextHolder.getBean("smsClientService" + smsserver.getSmsport());
// send = smsService.sendSms(smsserver,mphone,content);
if ("0".equals(send)) {
ml.setStatus(1);
// ml.setErrorInfo();
sqlSession.insert("com.itrus.portal.db.MessageLogMapper.insert", ml);
result.put("retCode", 1000);
return result;
}
} catch (NoSuchAlgorithmException e) {
result.put("retCode", -6);
result.put("retMsg", "Hmac验证错误");
e.printStackTrace();
return result;
} catch (UnsupportedEncodingException e) {
result.put("retCode", -6);
result.put("retMsg", "Hmac验证错误");
e.printStackTrace();
return result;
} catch (Exception e) {
result.put("retCode", -7);
result.put("retMsg", e.toString());
e.printStackTrace();
return result;
}
if (null != ml) {
ml.setStatus(0);
ml.setErrorInfo("短信接口发送错误,返回" + send);
sqlSession.insert("com.itrus.portal.db.MessageLogMapper.insert", ml);
}
result.put("retCode", send);
result.put("retMsg", "短信接口发送错误");
return result;
}
use of com.itrus.portal.db.Smsserver in project portal by ixinportal.
the class SmsserverController method updateForm.
// 返回修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) throws Exception {
Smsserver smsserver = sqlSession.selectOne("com.itrus.portal.db.SmsserverMapper.selectByPrimaryKey", id);
uiModel.addAttribute("smsserver", smsserver);
return "smsserver/update";
}
use of com.itrus.portal.db.Smsserver in project portal by ixinportal.
the class SmsserverController method delete.
// 删除
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) throws Exception {
Smsserver smsserver = sqlSession.selectOne("com.itrus.portal.db.SmsserverMapper.selectByPrimaryKey", id);
String message = null;
if (smsserver == null) {
message = "未找到要删除短信服务配置";
} else {
try {
sqlSession.delete("com.itrus.portal.db.SmsserverMapper.deleteByPrimaryKey", id);
String oper = "删除短信服务";
String info = "短信服务名称: " + smsserver.getName();
LogUtil.adminlog(sqlSession, oper, info);
} catch (Exception e) {
message = "要删除短信服务配置【" + smsserver.getName() + "】存在关联,无法删除";
}
}
return getReferer(request, "redirect:/smsserver" + (message == null ? "" : "?message=1"), true);
}
use of com.itrus.portal.db.Smsserver in project portal by ixinportal.
the class SmsserverController method show.
// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) throws Exception {
Smsserver smsserver = sqlSession.selectOne("com.itrus.portal.db.SmsserverMapper.selectByPrimaryKey", id);
uiModel.addAttribute("smsserver", smsserver);
return "smsserver/show";
}
Aggregations