Authored by 胡古飞

去除无效代码

... ... @@ -36,8 +36,8 @@ import com.yoho.yhmessage.inbox.service.model.CouponInBox;
* @author CaoQi
* @Time 2015/11/11
*/
@Controller
@RequestMapping("/InBoxRest")
//@Controller
//@RequestMapping("/InBoxRest")
public class InBoxRest {
private static Logger logger = LoggerFactory.getLogger(InBoxRest.class);
... ...
package com.yoho.yhmessage.push.restapi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.core.rest.annotation.ServiceDesc;
import com.yoho.service.model.push.RecycleTaskUserBO;
import com.yoho.service.model.push.RecyleTaskForbidUserBO;
import com.yoho.service.model.push.request.RecycleTaskDefineReqBO;
import com.yoho.service.model.push.response.RecycleTaskDefineRspBO;
import com.yoho.service.model.response.CommonRspBO;
import com.yoho.yhmessage.push.service.IRecycleTaskDefineService;
import com.yoho.yhmessage.push.service.IRecycleTaskUserService;
@Controller
@RequestMapping("/RecycleTaskRest")
@ServiceDesc("push")
public class RecycleTaskRest {
private final Logger logger = LoggerFactory.getLogger(RecycleTaskRest.class);
@Autowired
private IRecycleTaskUserService recycleTaskUserService;
@Autowired
private IRecycleTaskDefineService recycleTaskDefineService;
/**
* 获取推送任务定义
*
* @param recycleTaskDefineReqBO
* @return
*/
@RequestMapping(value = "/getRecycleTaskDefine")
@ResponseBody
public RecycleTaskDefineRspBO getRecycleTaskDefine(@RequestBody RecycleTaskDefineReqBO recycleTaskDefineReqBO) {
logger.info("enter getRecycleTaskDefine param taskKey is {}", recycleTaskDefineReqBO.getTaskKey());
return recycleTaskDefineService.getRecycleTaskDefine(recycleTaskDefineReqBO.getTaskKey());
}
/**
* 更改推送标识
*
* @param recycleTaskUserBO
* @return
*/
@RequestMapping(value = "/changeRecycleTaskPushFlag")
@ResponseBody
public CommonRspBO changeRecycleTaskPushFlag(@RequestBody RecycleTaskUserBO recycleTaskUserBO) {
logger.info("enter changeTaskPushFlag param recycleTaskUserBO is {}", recycleTaskUserBO);
return recycleTaskUserService.changeTaskPushFlag(recycleTaskUserBO);
}
/**
* 获取推送标识
*
* @param recycleTaskUserBO
* @return
*/
@RequestMapping(value = "/getRecycleTaskPushFlag")
@ResponseBody
public RecycleTaskUserBO getRecycleTaskPushFlag(@RequestBody RecycleTaskUserBO recycleTaskUserBO) {
String taskKey = recycleTaskUserBO.getTaskKey();
int userId = recycleTaskUserBO.getUserId();
logger.info("enter getRecycleTaskUser param taskKey is {},userId is{}", taskKey, userId);
return recycleTaskUserService.getRecycleTaskUser(taskKey, userId);
}
/**
* 增加不推送的人
*
* @场景:已经签到的人就不发推送,在用户签到的时候,调一下这个接口,到点时不会给这个用户发推送
* @param recycleTaskUserBO
* @return
*/
@RequestMapping(value = "/addRecycleTaskForbidUser")
@ResponseBody
public CommonRspBO addRecycleTaskForbidUser(@RequestBody RecyleTaskForbidUserBO recyleTaskForbidUserBO) {
logger.info("enter addRecycleTaskForbidUser param recyleTaskForbidUserBO is {}", recyleTaskForbidUserBO);
return recycleTaskUserService.addRecycleTaskForbidUser(recyleTaskForbidUserBO);
}
}
package com.yoho.yhmessage.push.restapi;
import com.yoho.message.dal.SendTaskMapper;
import com.yoho.message.dal.model.SendTaskWithBLOBs;
import com.yoho.service.model.push.request.OpenCountReqBO;
import com.yoho.service.model.push.request.SendTaskReqBO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Created by ming on 16/3/23.
*/
@Controller
@RequestMapping("/SendTask")
public class SendTaskRest {
private final Logger logger = LoggerFactory.getLogger(SendTaskRest.class);
@Autowired
private SendTaskMapper sendTaskMapper;
@RequestMapping(value = "/addPushTask")
@ResponseBody
public void addPushTask(@RequestBody SendTaskReqBO sendTaskReqBO) {
logger.info("AddPushTask: {}", sendTaskReqBO);
SendTaskWithBLOBs sendTask = new SendTaskWithBLOBs();
BeanUtils.copyProperties(sendTaskReqBO, sendTask);
sendTaskMapper.insertSelective(sendTask);
}
@RequestMapping(value = "/addOpenCount")
@ResponseBody
public void addOpenCount(@RequestBody OpenCountReqBO openCountReqBO ){
logger.info("addOpenCount: {}", openCountReqBO);
sendTaskMapper.updateOpenCount(openCountReqBO.getId());
}
}
package com.yoho.yhmessage.push.restapi;
import com.yoho.message.dal.model.GetuiToken;
import com.yoho.message.dal.model.IosToken;
import com.yoho.service.model.push.GetuiTokenBO;
import com.yoho.service.model.push.IosTokenBO;
import com.yoho.yhmessage.push.service.ITokenService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 更新及添加 ios 和 android token
*
* Created by ming on 16/2/17.
*/
@Controller
@RequestMapping("/TokenRest")
public class TokenBindingRest {
private static Logger logger = LoggerFactory.getLogger(TokenBindingRest.class);
@Autowired
private ITokenService tokenService;
/**
* 根据 token 查找 ios 设备表
*
* @param token
* @return
*/
@RequestMapping("/getIosByToken")
@ResponseBody
public IosTokenBO getIosByToken(@RequestBody String token) {
logger.info("Begin getIosByToken. Token is {}", token);
IosToken iosToken = tokenService.getIosByToken(token);
if (null == iosToken) {
return null;
}
IosTokenBO iosTokenBO = new IosTokenBO();
BeanUtils.copyProperties(iosToken, iosTokenBO);
logger.info("End getIosByToken. Token is {}", token);
return iosTokenBO;
}
/**
* 新增 token
*
* @param iosTokenBO
*/
@RequestMapping("/setIosToken")
@ResponseBody
public void setIosToken(@RequestBody IosTokenBO iosTokenBO) {
logger.info("Begin setIosUser. IosTokenBO is {}", iosTokenBO);
IosToken iosToken = new IosToken();
BeanUtils.copyProperties(iosTokenBO, iosToken);
tokenService.insertIosToken(iosToken);
logger.info("End setIosUser. IosTokenBO is {}", iosTokenBO);
}
/**
* 更新已有 token
*
* @param iosTokenBO
*/
@RequestMapping("/updateIosToken")
@ResponseBody
public void updateIosToken(@RequestBody IosTokenBO iosTokenBO) {
logger.info("Begin updateIosUser. IosTokenBO is {}", iosTokenBO);
IosToken iosToken = new IosToken();
BeanUtils.copyProperties(iosTokenBO, iosToken);
tokenService.updateIosToken(iosToken);
logger.info("End updateIosUser. IosTokenBO is {}", iosTokenBO);
}
@RequestMapping("/publishIosUser")
@ResponseBody
public Integer publishIosUser(@RequestBody IosTokenBO iosTokenBO) {
logger.info("Begin publishIosUser. IosTokenBO is {}", iosTokenBO);
IosToken iosToken = new IosToken();
BeanUtils.copyProperties(iosTokenBO, iosToken);
try {
tokenService.updateIosTokenStatus(iosToken);
logger.info("End publishIosUser. IosTokenBO is {}", iosTokenBO);
return 1;
} catch (Exception e) {
logger.warn("Exception in publishIosToken: {} IosTokenBO is {}", e, iosTokenBO);
logger.info("End publishIosUser. IosTokenBO is {}", iosTokenBO);
return 0;
}
}
@RequestMapping("/getGetuiByToken")
@ResponseBody
public GetuiTokenBO getGetuiByToken(@RequestBody String token) {
logger.info("Begin getGetuiByToken. Token is {}", token);
GetuiToken getuiToken = tokenService.getGetuiByToken(token);
if (null == getuiToken) {
return null;
}
GetuiTokenBO getuiTokenBO = new GetuiTokenBO();
BeanUtils.copyProperties(getuiToken, getuiTokenBO);
logger.info("End getGetuiByToken. Token is {}", token);
return getuiTokenBO;
}
@RequestMapping("/setGetuiToken")
@ResponseBody
public void setGetuiToken(@RequestBody GetuiTokenBO getuiTokenBO) {
logger.info("Begin setGetuiToken. GetuiTokenBO is {}", getuiTokenBO);
GetuiToken getuiToken = new GetuiToken();
BeanUtils.copyProperties(getuiTokenBO, getuiToken);
tokenService.insertGetuiToken(getuiToken);
logger.info("End setGetuiToken. GetuiTokenBO is {}", getuiTokenBO);
}
@RequestMapping("/updateGetuiToken")
@ResponseBody
public void updateGetuiToken(@RequestBody GetuiTokenBO getuiTokenBO) {
logger.info("Begin updateGetuiToken. GetuiTokenBO is {}", getuiTokenBO);
GetuiToken getuiToken = new GetuiToken();
BeanUtils.copyProperties(getuiTokenBO, getuiToken);
tokenService.updateGetuiToken(getuiToken);
logger.info("End updateGetuiToken. GetuiTokenBO is {}", getuiTokenBO);
}
@RequestMapping("/publishGetuiUser")
@ResponseBody
public Integer publishGetuiUser(@RequestBody GetuiTokenBO getuiTokenBO) {
logger.info("Begin publishGetuiUser. GetuiTokenBO is {}", getuiTokenBO);
GetuiToken getuiToken = new GetuiToken();
BeanUtils.copyProperties(getuiTokenBO, getuiToken);
try {
tokenService.updateGetuiTokenStatus(getuiToken);
logger.info("End publishGetuiUser. GetuiTokenBO is {}", getuiTokenBO);
return 1;
} catch (Exception e) {
logger.warn("Exception in publishGetuiToken: {} GetuiTokenBO is {}", e, getuiTokenBO);
logger.info("End publishGetuiUser. GetuiTokenBO is {}", getuiTokenBO);
return 0;
}
}
}
... ... @@ -19,7 +19,7 @@ import com.yoho.yhmessage.push.service.IUserPushService;
@ServiceDesc("push")
public class UserPushRest {
private final Logger logger = LoggerFactory.getLogger(RecycleTaskRest.class);
private final Logger logger = LoggerFactory.getLogger(UserPushRest.class);
@Autowired
private IUserPushService addPushService;
... ...
package com.yoho.yhmessage.push.service;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.push.response.RecycleTaskDefineRspBO;
public interface IRecycleTaskDefineService {
/**
* 获取循环任务定义
* @param recycleTaskDefineReqBO
* @return
* @throws ServiceException
*/
public RecycleTaskDefineRspBO getRecycleTaskDefine(String taskKey) throws ServiceException;
}
package com.yoho.yhmessage.push.service;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.push.RecycleTaskUserBO;
import com.yoho.service.model.push.RecyleTaskForbidUserBO;
import com.yoho.service.model.response.CommonRspBO;
public interface IRecycleTaskUserService {
/**
* 更新用户某个任务的推送状态
*
* @param recycleTaskUserBO
* @return
* @throws ServiceException
*/
public CommonRspBO changeTaskPushFlag(RecycleTaskUserBO recycleTaskUserBO) throws ServiceException;
/**
* 获取某个用户的某个任务的推送状态
*
* @param taskkey
* @param userId
* @return
* @throws ServiceException
*/
public RecycleTaskUserBO getRecycleTaskUser(String taskKey, int userId) throws ServiceException;
/**
* 增加某次推送不推送的人
*
* @param taskKey
* @param userId
* @return
*/
public CommonRspBO addRecycleTaskForbidUser(RecyleTaskForbidUserBO recyleTaskForbidUserBO ) throws ServiceException;
}
package com.yoho.yhmessage.push.service.impl;
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.message.dal.IRecycleTaskDefineDao;
import com.yoho.message.dal.model.RecycleTaskDefine;
import com.yoho.service.model.push.response.RecycleTaskDefineRspBO;
import com.yoho.yhmessage.push.service.IRecycleTaskDefineService;
import com.yoho.yhmessage.push.utils.CronUtil;
@Service
public class RecycleTaskDefineServiceImpl implements IRecycleTaskDefineService {
private static final Logger logger = LoggerFactory.getLogger(RecycleTaskDefineServiceImpl.class);
@Autowired
private IRecycleTaskDefineDao recycleTaskDefineDao;
@Override
public RecycleTaskDefineRspBO getRecycleTaskDefine(String taskKey) throws ServiceException {
logger.info(" enter getRecycleTaskDefine param taskKey is {}", taskKey);
// 1)参数校验
if (StringUtils.isBlank(taskKey)) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_EMPTY);
}
// 2)获取循环任务定义
RecycleTaskDefine recycleTaskDefine = recycleTaskDefineDao.selectByTaskKey(taskKey, 1);
if (recycleTaskDefine == null) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_NOTEXIST);
}
logger.info(" getRecycleTaskDefine from db RecycleTask id is {}", recycleTaskDefine.getId());
// 3)生成返回结果
RecycleTaskDefineRspBO response = new RecycleTaskDefineRspBO();
response.setTaskKey(recycleTaskDefine.getTaskKey());
response.setClients(Arrays.asList(recycleTaskDefine.getClients().split(",")));
response.setAndroidTitle(recycleTaskDefine.getAndroidTitle());
response.setAndroidContent(recycleTaskDefine.getAndroidContent());
response.setIosAlert(recycleTaskDefine.getIosAlert());
response.setAppendParams(recycleTaskDefine.getAppendParams());
response.setCronExpression(recycleTaskDefine.getCronExpression());
response.setMinAppVersion(recycleTaskDefine.getMinAppVersion());
response.setBeginTime(recycleTaskDefine.getBeginTime());
response.setEndTime(recycleTaskDefine.getEndTime());
response.setNextSendTime(CronUtil.getNextRunTime(recycleTaskDefine.getCronExpression(), recycleTaskDefine.getBeginTime(), recycleTaskDefine.getEndTime()));
return response;
}
}
package com.yoho.yhmessage.push.service.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yoho.core.redis.YHListOperations;
import com.yoho.core.redis.YHRedisTemplate;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.message.dal.IRecycleTaskDefineDao;
import com.yoho.message.dal.IRecycleTaskUserDao;
import com.yoho.message.dal.model.RecycleTaskDefine;
import com.yoho.message.dal.model.RecycleTaskUser;
import com.yoho.service.model.push.RecycleTaskUserBO;
import com.yoho.service.model.push.RecyleTaskForbidUserBO;
import com.yoho.service.model.response.CommonRspBO;
import com.yoho.yhmessage.push.service.IRecycleTaskUserService;
import com.yoho.yhmessage.push.utils.CronUtil;
import com.yoho.yhmessage.push.utils.RedisKeyUtils;
import javax.annotation.Resource;
@Service
public class RecycleTaskUserServiceImpl implements IRecycleTaskUserService {
private static final Logger logger = LoggerFactory.getLogger(RecycleTaskUserServiceImpl.class);
@Autowired
private IRecycleTaskDefineDao recycleTaskDefineDao;
@Autowired
private IRecycleTaskUserDao recycleTaskUserDao;
@Resource(name = "yhListOperations")
private YHListOperations<String, String> listOperations;
@Resource(name = "yhRedisTemplate")
private YHRedisTemplate<String, String> redisTemplate;
@Override
public CommonRspBO changeTaskPushFlag(RecycleTaskUserBO recycleTaskUserBO) throws ServiceException {
// 1)参数验证
String taskKey = recycleTaskUserBO.getTaskKey();
int userId = recycleTaskUserBO.getUserId();
if (StringUtils.isEmpty(taskKey)) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_EMPTY);
}
if (userId <= 0) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_UID_EMPTY);
}
// 2)检查task_key是否存在
RecycleTaskDefine recycleTaskDefine = recycleTaskDefineDao.selectByTaskKey(taskKey, 1);
if (recycleTaskDefine == null) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_NOTEXIST);
}
// 3)根据task_key和uid取数据
int currenSecond = this.getCurrentSecond();
RecycleTaskUser recycleTaskUser = recycleTaskUserDao.selectByUniqueKey(taskKey, userId);
// 4)如果记录不存在,则直接插入
if (recycleTaskUser == null) {
recycleTaskUser = new RecycleTaskUser();
recycleTaskUser.setTaskKey(taskKey);
recycleTaskUser.setUserId(userId);
recycleTaskUser.setStatus(recycleTaskUserBO.getPushFlag());
recycleTaskUser.setCreateTime(currenSecond);
recycleTaskUser.setUpdateTime(currenSecond);
recycleTaskUserDao.insertSelective(recycleTaskUser);
} else {
// 否则直接更新状态
recycleTaskUserDao.updateStatusByPrimaryKey(recycleTaskUser.getId(), recycleTaskUserBO.getPushFlag(), currenSecond);
}
return new CommonRspBO(200, "更新成功");
}
private int getCurrentSecond() {
long nowTs = System.currentTimeMillis();
return (int) (nowTs / 1000L);
}
@Override
public RecycleTaskUserBO getRecycleTaskUser(String taskKey, int userId) throws ServiceException {
// 1)参数验证
if (StringUtils.isEmpty(taskKey)) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_EMPTY);
}
if (userId <= 0) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_UID_EMPTY);
}
// 2)取数据
RecycleTaskUser recycleTaskUser = recycleTaskUserDao.selectByUniqueKey(taskKey, userId);
// 3)不存在则直接返回pushFlag = 0的数据
if (recycleTaskUser == null) {
return new RecycleTaskUserBO(taskKey, userId, 0);
}
// 4)根据recycleTaskUser生成RecycleTaskUserBO
return new RecycleTaskUserBO(taskKey, userId, recycleTaskUser.getStatus());
}
@Override
public CommonRspBO addRecycleTaskForbidUser(RecyleTaskForbidUserBO recyleTaskForbidUserBO) throws ServiceException {
// 1)参数验证
String taskKey = recyleTaskForbidUserBO.getTaskKey();
if (StringUtils.isEmpty(recyleTaskForbidUserBO.getTaskKey())) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_EMPTY);
}
int userId = recyleTaskForbidUserBO.getUserId();
if (userId <= 0) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_UID_EMPTY);
}
// 2)检查task_key是否存在
RecycleTaskDefine recycleTaskDefine = recycleTaskDefineDao.selectByTaskKey(taskKey, 1);
if (recycleTaskDefine == null) {
throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_NOTEXIST);
}
// 3)如果该任务下次发送时间为空,表明任务无效,则直接返回成功
Date nextSendTime = CronUtil.getNextRunTime(recycleTaskDefine.getCronExpression(), recycleTaskDefine.getBeginTime(), recycleTaskDefine.getEndTime());
if (nextSendTime == null) {
return new CommonRspBO(200, "成功");
}
// 4)如果跨天无效,则直接返回
boolean clearWhenDifferDay = recyleTaskForbidUserBO.isClearWhenDifferDay();
if(clearWhenDifferDay && !isSameDay(nextSendTime, new Date())){
return new CommonRspBO(200, "成功");
}
// 5)将forbidUserId插入redis,并设置sendTime的一个小时后过期(重复设置过期时间也没关系的)
String redisKey = RedisKeyUtils.genRecycleTaskForbidUserKey(taskKey, nextSendTime);
listOperations.rightPush(redisKey, String.valueOf(userId));
long expired = nextSendTime.getTime() - System.currentTimeMillis() + DateUtils.MILLIS_PER_HOUR;
redisTemplate.longExpire(redisKey, expired , TimeUnit.MILLISECONDS);
logger.info("add recycleTaskForbidUser to redis , redisKey is{}, uid is {}",redisKey,userId);
// List<String> allForbidUserIds = listOperations.range(redisKey, 0, -1);
// logger.info("add recycleTaskForbidUser to redis , redisKey is{}, uid is {},allForbidUserIds is {}",redisKey,userId,allForbidUserIds);
return new CommonRspBO(200, "成功");
}
private boolean isSameDay(Date d1,Date d2){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String d1DayStr = sdf.format(d1);
String d2DayStr = sdf.format(d2);
if(d1DayStr.equals(d2DayStr)){
return true;
}
return false;
}
}
package com.yoho.yhmessage.sms.restapi;
import java.io.UnsupportedEncodingException;
import com.yoho.error.exception.ServiceException;
import com.yoho.yhmessage.sms.helper.SMSLogHelper;
import com.yoho.yhmessage.sms.service.INoticeSMSService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.service.model.sms.request.SMSTemplateReqBO;
import com.yoho.service.model.sms.response.CommonRspBO;
import com.yoho.yhmessage.sms.service.ISmsSendService;
@Controller
@RequestMapping("/SMSDispatcherRest")
public class SMSDispatcherRest {
@Autowired
private ISmsSendService smsSendService;
@Autowired
private INoticeSMSService noticeSMSService;
private static final Logger logger = LoggerFactory.getLogger(SMSDispatcherRest.class);
@RequestMapping(value = "/smsSend")
@ResponseBody
public CommonRspBO smsSend(@RequestBody SMSTemplateReqBO[] boList) throws UnsupportedEncodingException {
CommonRspBO commonRspBO = new CommonRspBO();
try {
//(1)关闭当前的Thread线程
SMSLogHelper.remove();
//(2)发送短信
commonRspBO = smsSendService.smsSend(boList);
}catch (Exception e){
if(e instanceof ServiceException){
throw e;
}else {
//eat all other exceptions
logger.warn("Send sms failed. errorMsg is {}", e.getMessage(), e);
}
}finally {
SMSLogHelper.remove();
}
return commonRspBO;
}
@RequestMapping(value = "/noticeSMSSend")
@ResponseBody
public CommonRspBO noticeSMSSend(@RequestBody SMSTemplateReqBO smsTemplateReqBO) throws UnsupportedEncodingException {
CommonRspBO commonRspBO = new CommonRspBO();
try {
//(1)关闭当前的Thread线程
SMSLogHelper.remove();
//(2)发送短信
commonRspBO = noticeSMSService.noticeSMSSend(smsTemplateReqBO);
}catch (Exception e){
if(e instanceof ServiceException){
throw e;
}else {
//eat all other exceptions
logger.warn("Send notice sms failed. errorMsg is {}", e.getMessage(), e);
}
}finally {
SMSLogHelper.remove();
}
return commonRspBO;
}
}
package com.yoho.yhmessage.sms.restapi;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.yhmessage.sms.client.DIYClientExample;
import com.yoho.yhmessage.sms.service.model.ResultInfo;
@Controller
public class SMSReportReceptRest {
@RequestMapping(value = "hlReportReceive")
@ResponseBody
public ResultInfo hlReportRecept(@RequestParam("PlatForm") String PlatForm,
@RequestParam("FUnikey") String FUnikey,
@RequestParam("FOrgAddr") String FOrgAddr,
@RequestParam("FDestAddr") String FDestAddr,
@RequestParam("FSubmitTime") String FSubmitTime,
@RequestParam("FFeeTerminal") String FFeeTerminal,
@RequestParam("FServiceUPID") String FServiceUPID,
@RequestParam("FReportCode") String FReportCode,
@RequestParam("FLinkID") String FLinkID,
@RequestParam("FAckStatus") String FAckStatus) {
return null;
}
@RequestMapping(value = "rlReportReceive")
@ResponseBody
public ResultInfo rlReportRecept() {
return null;
}
@RequestMapping(value = "xwReportReceive")
@ResponseBody
public ResultInfo xwReportRecept() {
return null;
}
@RequestMapping(value = "ytReportReceive")
@ResponseBody
public String ytReportRecept(HttpServletRequest request) {
String spid = request.getParameter("spid");
String mtmsgid = request.getParameter("mtmsgid");
String mtstat = request.getParameter("mtstat");
String mterrorcode = request.getParameter("mterrorcode");
// 获取状态报告参数后,请即刻返回响应信息
String output = "command=RT_RESPONSE&spid=" + spid + "&mtmsgid="
+ mtmsgid + "&rtstat=ACCEPTD&rterrcode=000";
return output;
}
@RequestMapping(value = "ytMsgReceive")
@ResponseBody
public String ytMsgReceive(HttpServletRequest request) {
String spid = request.getParameter("spid");
String momsgid = request.getParameter("momsgid");
String da = request.getParameter("da");
String sa = request.getParameter("sa");
String dc = request.getParameter("dc");
String sm = request.getParameter("sm");
// 将Hex编码的上行内容还原成普通字符串
// 在jdk1.4版本环境下,请使用DIYClientExample.decodeHexStr(Integer.parseInt(dc),sm)
String moContent = DIYClientExample.decodeHexStr(Integer.parseInt(dc),
sm);
// 获取上行参数后,请即刻返回响应信息
String output = "command=MO_RESPONSE&spid=" + spid + "&momsgid="
+ momsgid + "&mostat=ACCEPTD&moerrcode=000";
return output;
}
}
package com.yoho.yhmessage.sms.restapi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yoho.yhmessage.sms.service.ISmsSendService;
@Controller
@RequestMapping("/SmsSendRest")
public class SmsSendRest {
@Autowired
private ISmsSendService smsSendService;
private static final Logger logger = LoggerFactory.getLogger(SMSDispatcherRest.class);
// @RequestMapping(value = "/baseSmsSend")
// @ResponseBody
// public CommonRspBO baseSmsSend(@RequestBody BaseSmsSendReqBO req) throws UnsupportedEncodingException {
// CommonRspBO commonRspBO = new CommonRspBO();
// try {
// //(1)关闭当前的Thread线程
// SMSLogHelper.remove();
// //(2)发送短信
// commonRspBO = smsSendService.baseSmsSend(req);
// }catch (Exception e){
// if(e instanceof ServiceException){
// throw e;
// }else {
// //eat all other exceptions
// logger.warn("Send sms failed. errorMsg is {}", e.getMessage(), e);
// }
// }finally {
// SMSLogHelper.remove();
// }
// return commonRspBO;
// }
}
#zookeeper address
zkAddress=192.168.102.205:2181
# web context
web.context=message
\ No newline at end of file
web.context=messagesender
\ No newline at end of file
... ...
... ... @@ -8,6 +8,9 @@ redis.readonly.proxy.address=${redis.readonly.proxy.address}
redis.readonly.proxy.port=${redis.readonly.proxy.port}
redis.readonly.proxy.auth=${redis.readonly.proxy.auth}
redis.notsync.twemproxy.addresses=${redis.notsync.twemproxy.addresses}
redis.notsync.twemproxy.auth=${redis.notsync.twemproxy.auth}
redis.timeout=50
mobile.limit.sendTimes=50
... ... @@ -15,9 +18,8 @@ mobile.limit.sendTimes=50
rabbit.cacheclean.producer.host=${rabbit.cacheclean.producer.host}
rabbit.cacheclean.consumer.host=${rabbit.cacheclean.consumer.host}
rabbit_host=${rabbit_host}
rabbit_user=${rabbit_user}
rabbit_password =${rabbit_password}
rabbit_host=${rabbit_message_center}
rabbit_user=${rabbit_message_center_user}
rabbit_password =${rabbit_message_center_password}
redis.notsync.twemproxy.addresses=${redis.notsync.twemproxy.addresses}
redis.notsync.twemproxy.auth=${redis.notsync.twemproxy.auth}
... ...