Showing
14 changed files
with
11 additions
and
754 deletions
@@ -36,8 +36,8 @@ import com.yoho.yhmessage.inbox.service.model.CouponInBox; | @@ -36,8 +36,8 @@ import com.yoho.yhmessage.inbox.service.model.CouponInBox; | ||
36 | * @author CaoQi | 36 | * @author CaoQi |
37 | * @Time 2015/11/11 | 37 | * @Time 2015/11/11 |
38 | */ | 38 | */ |
39 | -@Controller | ||
40 | -@RequestMapping("/InBoxRest") | 39 | +//@Controller |
40 | +//@RequestMapping("/InBoxRest") | ||
41 | public class InBoxRest { | 41 | public class InBoxRest { |
42 | 42 | ||
43 | private static Logger logger = LoggerFactory.getLogger(InBoxRest.class); | 43 | private static Logger logger = LoggerFactory.getLogger(InBoxRest.class); |
1 | -package com.yoho.yhmessage.push.restapi; | ||
2 | - | ||
3 | -import org.slf4j.Logger; | ||
4 | -import org.slf4j.LoggerFactory; | ||
5 | -import org.springframework.beans.factory.annotation.Autowired; | ||
6 | -import org.springframework.stereotype.Controller; | ||
7 | -import org.springframework.web.bind.annotation.RequestBody; | ||
8 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
9 | -import org.springframework.web.bind.annotation.ResponseBody; | ||
10 | - | ||
11 | -import com.yoho.core.rest.annotation.ServiceDesc; | ||
12 | -import com.yoho.service.model.push.RecycleTaskUserBO; | ||
13 | -import com.yoho.service.model.push.RecyleTaskForbidUserBO; | ||
14 | -import com.yoho.service.model.push.request.RecycleTaskDefineReqBO; | ||
15 | -import com.yoho.service.model.push.response.RecycleTaskDefineRspBO; | ||
16 | -import com.yoho.service.model.response.CommonRspBO; | ||
17 | -import com.yoho.yhmessage.push.service.IRecycleTaskDefineService; | ||
18 | -import com.yoho.yhmessage.push.service.IRecycleTaskUserService; | ||
19 | - | ||
20 | -@Controller | ||
21 | -@RequestMapping("/RecycleTaskRest") | ||
22 | -@ServiceDesc("push") | ||
23 | -public class RecycleTaskRest { | ||
24 | - | ||
25 | - private final Logger logger = LoggerFactory.getLogger(RecycleTaskRest.class); | ||
26 | - | ||
27 | - @Autowired | ||
28 | - private IRecycleTaskUserService recycleTaskUserService; | ||
29 | - @Autowired | ||
30 | - private IRecycleTaskDefineService recycleTaskDefineService; | ||
31 | - | ||
32 | - /** | ||
33 | - * 获取推送任务定义 | ||
34 | - * | ||
35 | - * @param recycleTaskDefineReqBO | ||
36 | - * @return | ||
37 | - */ | ||
38 | - @RequestMapping(value = "/getRecycleTaskDefine") | ||
39 | - @ResponseBody | ||
40 | - public RecycleTaskDefineRspBO getRecycleTaskDefine(@RequestBody RecycleTaskDefineReqBO recycleTaskDefineReqBO) { | ||
41 | - logger.info("enter getRecycleTaskDefine param taskKey is {}", recycleTaskDefineReqBO.getTaskKey()); | ||
42 | - return recycleTaskDefineService.getRecycleTaskDefine(recycleTaskDefineReqBO.getTaskKey()); | ||
43 | - } | ||
44 | - | ||
45 | - /** | ||
46 | - * 更改推送标识 | ||
47 | - * | ||
48 | - * @param recycleTaskUserBO | ||
49 | - * @return | ||
50 | - */ | ||
51 | - @RequestMapping(value = "/changeRecycleTaskPushFlag") | ||
52 | - @ResponseBody | ||
53 | - public CommonRspBO changeRecycleTaskPushFlag(@RequestBody RecycleTaskUserBO recycleTaskUserBO) { | ||
54 | - logger.info("enter changeTaskPushFlag param recycleTaskUserBO is {}", recycleTaskUserBO); | ||
55 | - return recycleTaskUserService.changeTaskPushFlag(recycleTaskUserBO); | ||
56 | - } | ||
57 | - | ||
58 | - /** | ||
59 | - * 获取推送标识 | ||
60 | - * | ||
61 | - * @param recycleTaskUserBO | ||
62 | - * @return | ||
63 | - */ | ||
64 | - @RequestMapping(value = "/getRecycleTaskPushFlag") | ||
65 | - @ResponseBody | ||
66 | - public RecycleTaskUserBO getRecycleTaskPushFlag(@RequestBody RecycleTaskUserBO recycleTaskUserBO) { | ||
67 | - String taskKey = recycleTaskUserBO.getTaskKey(); | ||
68 | - int userId = recycleTaskUserBO.getUserId(); | ||
69 | - logger.info("enter getRecycleTaskUser param taskKey is {},userId is{}", taskKey, userId); | ||
70 | - return recycleTaskUserService.getRecycleTaskUser(taskKey, userId); | ||
71 | - } | ||
72 | - | ||
73 | - /** | ||
74 | - * 增加不推送的人 | ||
75 | - * | ||
76 | - * @场景:已经签到的人就不发推送,在用户签到的时候,调一下这个接口,到点时不会给这个用户发推送 | ||
77 | - * @param recycleTaskUserBO | ||
78 | - * @return | ||
79 | - */ | ||
80 | - @RequestMapping(value = "/addRecycleTaskForbidUser") | ||
81 | - @ResponseBody | ||
82 | - public CommonRspBO addRecycleTaskForbidUser(@RequestBody RecyleTaskForbidUserBO recyleTaskForbidUserBO) { | ||
83 | - logger.info("enter addRecycleTaskForbidUser param recyleTaskForbidUserBO is {}", recyleTaskForbidUserBO); | ||
84 | - return recycleTaskUserService.addRecycleTaskForbidUser(recyleTaskForbidUserBO); | ||
85 | - } | ||
86 | - | ||
87 | -} |
1 | -package com.yoho.yhmessage.push.restapi; | ||
2 | - | ||
3 | -import com.yoho.message.dal.SendTaskMapper; | ||
4 | -import com.yoho.message.dal.model.SendTaskWithBLOBs; | ||
5 | -import com.yoho.service.model.push.request.OpenCountReqBO; | ||
6 | -import com.yoho.service.model.push.request.SendTaskReqBO; | ||
7 | -import org.slf4j.Logger; | ||
8 | -import org.slf4j.LoggerFactory; | ||
9 | -import org.springframework.beans.BeanUtils; | ||
10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
11 | -import org.springframework.stereotype.Controller; | ||
12 | -import org.springframework.web.bind.annotation.RequestBody; | ||
13 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
14 | -import org.springframework.web.bind.annotation.ResponseBody; | ||
15 | - | ||
16 | -/** | ||
17 | - * Created by ming on 16/3/23. | ||
18 | - */ | ||
19 | -@Controller | ||
20 | -@RequestMapping("/SendTask") | ||
21 | -public class SendTaskRest { | ||
22 | - | ||
23 | - private final Logger logger = LoggerFactory.getLogger(SendTaskRest.class); | ||
24 | - | ||
25 | - @Autowired | ||
26 | - private SendTaskMapper sendTaskMapper; | ||
27 | - | ||
28 | - @RequestMapping(value = "/addPushTask") | ||
29 | - @ResponseBody | ||
30 | - public void addPushTask(@RequestBody SendTaskReqBO sendTaskReqBO) { | ||
31 | - logger.info("AddPushTask: {}", sendTaskReqBO); | ||
32 | - | ||
33 | - SendTaskWithBLOBs sendTask = new SendTaskWithBLOBs(); | ||
34 | - BeanUtils.copyProperties(sendTaskReqBO, sendTask); | ||
35 | - sendTaskMapper.insertSelective(sendTask); | ||
36 | - | ||
37 | - } | ||
38 | - | ||
39 | - @RequestMapping(value = "/addOpenCount") | ||
40 | - @ResponseBody | ||
41 | - public void addOpenCount(@RequestBody OpenCountReqBO openCountReqBO ){ | ||
42 | - logger.info("addOpenCount: {}", openCountReqBO); | ||
43 | - | ||
44 | - sendTaskMapper.updateOpenCount(openCountReqBO.getId()); | ||
45 | - } | ||
46 | - | ||
47 | -} |
1 | -package com.yoho.yhmessage.push.restapi; | ||
2 | - | ||
3 | -import com.yoho.message.dal.model.GetuiToken; | ||
4 | -import com.yoho.message.dal.model.IosToken; | ||
5 | -import com.yoho.service.model.push.GetuiTokenBO; | ||
6 | -import com.yoho.service.model.push.IosTokenBO; | ||
7 | -import com.yoho.yhmessage.push.service.ITokenService; | ||
8 | -import org.slf4j.Logger; | ||
9 | -import org.slf4j.LoggerFactory; | ||
10 | -import org.springframework.beans.BeanUtils; | ||
11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
12 | -import org.springframework.stereotype.Controller; | ||
13 | -import org.springframework.web.bind.annotation.RequestBody; | ||
14 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
15 | -import org.springframework.web.bind.annotation.ResponseBody; | ||
16 | - | ||
17 | -/** | ||
18 | - * 更新及添加 ios 和 android token | ||
19 | - * | ||
20 | - * Created by ming on 16/2/17. | ||
21 | - */ | ||
22 | -@Controller | ||
23 | -@RequestMapping("/TokenRest") | ||
24 | -public class TokenBindingRest { | ||
25 | - | ||
26 | - private static Logger logger = LoggerFactory.getLogger(TokenBindingRest.class); | ||
27 | - | ||
28 | - @Autowired | ||
29 | - private ITokenService tokenService; | ||
30 | - | ||
31 | - /** | ||
32 | - * 根据 token 查找 ios 设备表 | ||
33 | - * | ||
34 | - * @param token | ||
35 | - * @return | ||
36 | - */ | ||
37 | - @RequestMapping("/getIosByToken") | ||
38 | - @ResponseBody | ||
39 | - public IosTokenBO getIosByToken(@RequestBody String token) { | ||
40 | - logger.info("Begin getIosByToken. Token is {}", token); | ||
41 | - IosToken iosToken = tokenService.getIosByToken(token); | ||
42 | - if (null == iosToken) { | ||
43 | - return null; | ||
44 | - } | ||
45 | - IosTokenBO iosTokenBO = new IosTokenBO(); | ||
46 | - BeanUtils.copyProperties(iosToken, iosTokenBO); | ||
47 | - logger.info("End getIosByToken. Token is {}", token); | ||
48 | - return iosTokenBO; | ||
49 | - } | ||
50 | - | ||
51 | - /** | ||
52 | - * 新增 token | ||
53 | - * | ||
54 | - * @param iosTokenBO | ||
55 | - */ | ||
56 | - @RequestMapping("/setIosToken") | ||
57 | - @ResponseBody | ||
58 | - public void setIosToken(@RequestBody IosTokenBO iosTokenBO) { | ||
59 | - logger.info("Begin setIosUser. IosTokenBO is {}", iosTokenBO); | ||
60 | - IosToken iosToken = new IosToken(); | ||
61 | - BeanUtils.copyProperties(iosTokenBO, iosToken); | ||
62 | - tokenService.insertIosToken(iosToken); | ||
63 | - logger.info("End setIosUser. IosTokenBO is {}", iosTokenBO); | ||
64 | - } | ||
65 | - | ||
66 | - /** | ||
67 | - * 更新已有 token | ||
68 | - * | ||
69 | - * @param iosTokenBO | ||
70 | - */ | ||
71 | - @RequestMapping("/updateIosToken") | ||
72 | - @ResponseBody | ||
73 | - public void updateIosToken(@RequestBody IosTokenBO iosTokenBO) { | ||
74 | - logger.info("Begin updateIosUser. IosTokenBO is {}", iosTokenBO); | ||
75 | - IosToken iosToken = new IosToken(); | ||
76 | - BeanUtils.copyProperties(iosTokenBO, iosToken); | ||
77 | - tokenService.updateIosToken(iosToken); | ||
78 | - logger.info("End updateIosUser. IosTokenBO is {}", iosTokenBO); | ||
79 | - } | ||
80 | - | ||
81 | - @RequestMapping("/publishIosUser") | ||
82 | - @ResponseBody | ||
83 | - public Integer publishIosUser(@RequestBody IosTokenBO iosTokenBO) { | ||
84 | - logger.info("Begin publishIosUser. IosTokenBO is {}", iosTokenBO); | ||
85 | - IosToken iosToken = new IosToken(); | ||
86 | - BeanUtils.copyProperties(iosTokenBO, iosToken); | ||
87 | - try { | ||
88 | - tokenService.updateIosTokenStatus(iosToken); | ||
89 | - logger.info("End publishIosUser. IosTokenBO is {}", iosTokenBO); | ||
90 | - return 1; | ||
91 | - } catch (Exception e) { | ||
92 | - logger.warn("Exception in publishIosToken: {} IosTokenBO is {}", e, iosTokenBO); | ||
93 | - logger.info("End publishIosUser. IosTokenBO is {}", iosTokenBO); | ||
94 | - return 0; | ||
95 | - } | ||
96 | - } | ||
97 | - | ||
98 | - @RequestMapping("/getGetuiByToken") | ||
99 | - @ResponseBody | ||
100 | - public GetuiTokenBO getGetuiByToken(@RequestBody String token) { | ||
101 | - logger.info("Begin getGetuiByToken. Token is {}", token); | ||
102 | - GetuiToken getuiToken = tokenService.getGetuiByToken(token); | ||
103 | - if (null == getuiToken) { | ||
104 | - return null; | ||
105 | - } | ||
106 | - GetuiTokenBO getuiTokenBO = new GetuiTokenBO(); | ||
107 | - BeanUtils.copyProperties(getuiToken, getuiTokenBO); | ||
108 | - logger.info("End getGetuiByToken. Token is {}", token); | ||
109 | - return getuiTokenBO; | ||
110 | - } | ||
111 | - | ||
112 | - @RequestMapping("/setGetuiToken") | ||
113 | - @ResponseBody | ||
114 | - public void setGetuiToken(@RequestBody GetuiTokenBO getuiTokenBO) { | ||
115 | - logger.info("Begin setGetuiToken. GetuiTokenBO is {}", getuiTokenBO); | ||
116 | - GetuiToken getuiToken = new GetuiToken(); | ||
117 | - BeanUtils.copyProperties(getuiTokenBO, getuiToken); | ||
118 | - tokenService.insertGetuiToken(getuiToken); | ||
119 | - logger.info("End setGetuiToken. GetuiTokenBO is {}", getuiTokenBO); | ||
120 | - } | ||
121 | - | ||
122 | - @RequestMapping("/updateGetuiToken") | ||
123 | - @ResponseBody | ||
124 | - public void updateGetuiToken(@RequestBody GetuiTokenBO getuiTokenBO) { | ||
125 | - logger.info("Begin updateGetuiToken. GetuiTokenBO is {}", getuiTokenBO); | ||
126 | - GetuiToken getuiToken = new GetuiToken(); | ||
127 | - BeanUtils.copyProperties(getuiTokenBO, getuiToken); | ||
128 | - tokenService.updateGetuiToken(getuiToken); | ||
129 | - logger.info("End updateGetuiToken. GetuiTokenBO is {}", getuiTokenBO); | ||
130 | - } | ||
131 | - | ||
132 | - @RequestMapping("/publishGetuiUser") | ||
133 | - @ResponseBody | ||
134 | - public Integer publishGetuiUser(@RequestBody GetuiTokenBO getuiTokenBO) { | ||
135 | - logger.info("Begin publishGetuiUser. GetuiTokenBO is {}", getuiTokenBO); | ||
136 | - GetuiToken getuiToken = new GetuiToken(); | ||
137 | - BeanUtils.copyProperties(getuiTokenBO, getuiToken); | ||
138 | - try { | ||
139 | - tokenService.updateGetuiTokenStatus(getuiToken); | ||
140 | - logger.info("End publishGetuiUser. GetuiTokenBO is {}", getuiTokenBO); | ||
141 | - return 1; | ||
142 | - } catch (Exception e) { | ||
143 | - logger.warn("Exception in publishGetuiToken: {} GetuiTokenBO is {}", e, getuiTokenBO); | ||
144 | - logger.info("End publishGetuiUser. GetuiTokenBO is {}", getuiTokenBO); | ||
145 | - return 0; | ||
146 | - } | ||
147 | - } | ||
148 | - | ||
149 | -} |
@@ -19,7 +19,7 @@ import com.yoho.yhmessage.push.service.IUserPushService; | @@ -19,7 +19,7 @@ import com.yoho.yhmessage.push.service.IUserPushService; | ||
19 | @ServiceDesc("push") | 19 | @ServiceDesc("push") |
20 | public class UserPushRest { | 20 | public class UserPushRest { |
21 | 21 | ||
22 | - private final Logger logger = LoggerFactory.getLogger(RecycleTaskRest.class); | 22 | + private final Logger logger = LoggerFactory.getLogger(UserPushRest.class); |
23 | 23 | ||
24 | @Autowired | 24 | @Autowired |
25 | private IUserPushService addPushService; | 25 | private IUserPushService addPushService; |
push/src/main/java/com/yoho/yhmessage/push/service/IRecycleTaskDefineService.java
deleted
100644 → 0
1 | -package com.yoho.yhmessage.push.service; | ||
2 | - | ||
3 | -import com.yoho.error.exception.ServiceException; | ||
4 | -import com.yoho.service.model.push.response.RecycleTaskDefineRspBO; | ||
5 | - | ||
6 | -public interface IRecycleTaskDefineService { | ||
7 | - | ||
8 | - /** | ||
9 | - * 获取循环任务定义 | ||
10 | - * @param recycleTaskDefineReqBO | ||
11 | - * @return | ||
12 | - * @throws ServiceException | ||
13 | - */ | ||
14 | - public RecycleTaskDefineRspBO getRecycleTaskDefine(String taskKey) throws ServiceException; | ||
15 | - | ||
16 | -} |
1 | -package com.yoho.yhmessage.push.service; | ||
2 | - | ||
3 | -import com.yoho.error.exception.ServiceException; | ||
4 | -import com.yoho.service.model.push.RecycleTaskUserBO; | ||
5 | -import com.yoho.service.model.push.RecyleTaskForbidUserBO; | ||
6 | -import com.yoho.service.model.response.CommonRspBO; | ||
7 | - | ||
8 | -public interface IRecycleTaskUserService { | ||
9 | - | ||
10 | - /** | ||
11 | - * 更新用户某个任务的推送状态 | ||
12 | - * | ||
13 | - * @param recycleTaskUserBO | ||
14 | - * @return | ||
15 | - * @throws ServiceException | ||
16 | - */ | ||
17 | - public CommonRspBO changeTaskPushFlag(RecycleTaskUserBO recycleTaskUserBO) throws ServiceException; | ||
18 | - | ||
19 | - /** | ||
20 | - * 获取某个用户的某个任务的推送状态 | ||
21 | - * | ||
22 | - * @param taskkey | ||
23 | - * @param userId | ||
24 | - * @return | ||
25 | - * @throws ServiceException | ||
26 | - */ | ||
27 | - public RecycleTaskUserBO getRecycleTaskUser(String taskKey, int userId) throws ServiceException; | ||
28 | - | ||
29 | - /** | ||
30 | - * 增加某次推送不推送的人 | ||
31 | - * | ||
32 | - * @param taskKey | ||
33 | - * @param userId | ||
34 | - * @return | ||
35 | - */ | ||
36 | - public CommonRspBO addRecycleTaskForbidUser(RecyleTaskForbidUserBO recyleTaskForbidUserBO ) throws ServiceException; | ||
37 | - | ||
38 | -} |
push/src/main/java/com/yoho/yhmessage/push/service/impl/RecycleTaskDefineServiceImpl.java
deleted
100644 → 0
1 | -package com.yoho.yhmessage.push.service.impl; | ||
2 | - | ||
3 | -import java.util.Arrays; | ||
4 | - | ||
5 | -import org.apache.commons.lang3.StringUtils; | ||
6 | -import org.slf4j.Logger; | ||
7 | -import org.slf4j.LoggerFactory; | ||
8 | -import org.springframework.beans.factory.annotation.Autowired; | ||
9 | -import org.springframework.stereotype.Service; | ||
10 | - | ||
11 | -import com.yoho.error.ServiceError; | ||
12 | -import com.yoho.error.exception.ServiceException; | ||
13 | -import com.yoho.message.dal.IRecycleTaskDefineDao; | ||
14 | -import com.yoho.message.dal.model.RecycleTaskDefine; | ||
15 | -import com.yoho.service.model.push.response.RecycleTaskDefineRspBO; | ||
16 | -import com.yoho.yhmessage.push.service.IRecycleTaskDefineService; | ||
17 | -import com.yoho.yhmessage.push.utils.CronUtil; | ||
18 | - | ||
19 | -@Service | ||
20 | -public class RecycleTaskDefineServiceImpl implements IRecycleTaskDefineService { | ||
21 | - | ||
22 | - private static final Logger logger = LoggerFactory.getLogger(RecycleTaskDefineServiceImpl.class); | ||
23 | - | ||
24 | - @Autowired | ||
25 | - private IRecycleTaskDefineDao recycleTaskDefineDao; | ||
26 | - | ||
27 | - @Override | ||
28 | - public RecycleTaskDefineRspBO getRecycleTaskDefine(String taskKey) throws ServiceException { | ||
29 | - logger.info(" enter getRecycleTaskDefine param taskKey is {}", taskKey); | ||
30 | - // 1)参数校验 | ||
31 | - if (StringUtils.isBlank(taskKey)) { | ||
32 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_EMPTY); | ||
33 | - } | ||
34 | - // 2)获取循环任务定义 | ||
35 | - RecycleTaskDefine recycleTaskDefine = recycleTaskDefineDao.selectByTaskKey(taskKey, 1); | ||
36 | - if (recycleTaskDefine == null) { | ||
37 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_NOTEXIST); | ||
38 | - } | ||
39 | - logger.info(" getRecycleTaskDefine from db RecycleTask id is {}", recycleTaskDefine.getId()); | ||
40 | - | ||
41 | - // 3)生成返回结果 | ||
42 | - RecycleTaskDefineRspBO response = new RecycleTaskDefineRspBO(); | ||
43 | - response.setTaskKey(recycleTaskDefine.getTaskKey()); | ||
44 | - response.setClients(Arrays.asList(recycleTaskDefine.getClients().split(","))); | ||
45 | - response.setAndroidTitle(recycleTaskDefine.getAndroidTitle()); | ||
46 | - response.setAndroidContent(recycleTaskDefine.getAndroidContent()); | ||
47 | - response.setIosAlert(recycleTaskDefine.getIosAlert()); | ||
48 | - response.setAppendParams(recycleTaskDefine.getAppendParams()); | ||
49 | - response.setCronExpression(recycleTaskDefine.getCronExpression()); | ||
50 | - response.setMinAppVersion(recycleTaskDefine.getMinAppVersion()); | ||
51 | - response.setBeginTime(recycleTaskDefine.getBeginTime()); | ||
52 | - response.setEndTime(recycleTaskDefine.getEndTime()); | ||
53 | - response.setNextSendTime(CronUtil.getNextRunTime(recycleTaskDefine.getCronExpression(), recycleTaskDefine.getBeginTime(), recycleTaskDefine.getEndTime())); | ||
54 | - return response; | ||
55 | - } | ||
56 | - | ||
57 | -} |
push/src/main/java/com/yoho/yhmessage/push/service/impl/RecycleTaskUserServiceImpl.java
deleted
100644 → 0
1 | -package com.yoho.yhmessage.push.service.impl; | ||
2 | - | ||
3 | -import java.text.SimpleDateFormat; | ||
4 | -import java.util.Date; | ||
5 | -import java.util.concurrent.TimeUnit; | ||
6 | - | ||
7 | -import org.apache.commons.lang.time.DateUtils; | ||
8 | -import org.apache.commons.lang3.StringUtils; | ||
9 | -import org.slf4j.Logger; | ||
10 | -import org.slf4j.LoggerFactory; | ||
11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
12 | -import org.springframework.stereotype.Service; | ||
13 | - | ||
14 | -import com.yoho.core.redis.YHListOperations; | ||
15 | -import com.yoho.core.redis.YHRedisTemplate; | ||
16 | -import com.yoho.error.ServiceError; | ||
17 | -import com.yoho.error.exception.ServiceException; | ||
18 | -import com.yoho.message.dal.IRecycleTaskDefineDao; | ||
19 | -import com.yoho.message.dal.IRecycleTaskUserDao; | ||
20 | -import com.yoho.message.dal.model.RecycleTaskDefine; | ||
21 | -import com.yoho.message.dal.model.RecycleTaskUser; | ||
22 | -import com.yoho.service.model.push.RecycleTaskUserBO; | ||
23 | -import com.yoho.service.model.push.RecyleTaskForbidUserBO; | ||
24 | -import com.yoho.service.model.response.CommonRspBO; | ||
25 | -import com.yoho.yhmessage.push.service.IRecycleTaskUserService; | ||
26 | -import com.yoho.yhmessage.push.utils.CronUtil; | ||
27 | -import com.yoho.yhmessage.push.utils.RedisKeyUtils; | ||
28 | - | ||
29 | -import javax.annotation.Resource; | ||
30 | - | ||
31 | -@Service | ||
32 | -public class RecycleTaskUserServiceImpl implements IRecycleTaskUserService { | ||
33 | - | ||
34 | - private static final Logger logger = LoggerFactory.getLogger(RecycleTaskUserServiceImpl.class); | ||
35 | - | ||
36 | - @Autowired | ||
37 | - private IRecycleTaskDefineDao recycleTaskDefineDao; | ||
38 | - @Autowired | ||
39 | - private IRecycleTaskUserDao recycleTaskUserDao; | ||
40 | - @Resource(name = "yhListOperations") | ||
41 | - private YHListOperations<String, String> listOperations; | ||
42 | - @Resource(name = "yhRedisTemplate") | ||
43 | - private YHRedisTemplate<String, String> redisTemplate; | ||
44 | - | ||
45 | - @Override | ||
46 | - public CommonRspBO changeTaskPushFlag(RecycleTaskUserBO recycleTaskUserBO) throws ServiceException { | ||
47 | - // 1)参数验证 | ||
48 | - String taskKey = recycleTaskUserBO.getTaskKey(); | ||
49 | - int userId = recycleTaskUserBO.getUserId(); | ||
50 | - if (StringUtils.isEmpty(taskKey)) { | ||
51 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_EMPTY); | ||
52 | - } | ||
53 | - if (userId <= 0) { | ||
54 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_UID_EMPTY); | ||
55 | - } | ||
56 | - | ||
57 | - // 2)检查task_key是否存在 | ||
58 | - RecycleTaskDefine recycleTaskDefine = recycleTaskDefineDao.selectByTaskKey(taskKey, 1); | ||
59 | - if (recycleTaskDefine == null) { | ||
60 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_NOTEXIST); | ||
61 | - } | ||
62 | - | ||
63 | - // 3)根据task_key和uid取数据 | ||
64 | - int currenSecond = this.getCurrentSecond(); | ||
65 | - RecycleTaskUser recycleTaskUser = recycleTaskUserDao.selectByUniqueKey(taskKey, userId); | ||
66 | - | ||
67 | - // 4)如果记录不存在,则直接插入 | ||
68 | - if (recycleTaskUser == null) { | ||
69 | - recycleTaskUser = new RecycleTaskUser(); | ||
70 | - recycleTaskUser.setTaskKey(taskKey); | ||
71 | - recycleTaskUser.setUserId(userId); | ||
72 | - recycleTaskUser.setStatus(recycleTaskUserBO.getPushFlag()); | ||
73 | - recycleTaskUser.setCreateTime(currenSecond); | ||
74 | - recycleTaskUser.setUpdateTime(currenSecond); | ||
75 | - recycleTaskUserDao.insertSelective(recycleTaskUser); | ||
76 | - } else { | ||
77 | - // 否则直接更新状态 | ||
78 | - recycleTaskUserDao.updateStatusByPrimaryKey(recycleTaskUser.getId(), recycleTaskUserBO.getPushFlag(), currenSecond); | ||
79 | - } | ||
80 | - return new CommonRspBO(200, "更新成功"); | ||
81 | - } | ||
82 | - | ||
83 | - private int getCurrentSecond() { | ||
84 | - long nowTs = System.currentTimeMillis(); | ||
85 | - return (int) (nowTs / 1000L); | ||
86 | - } | ||
87 | - | ||
88 | - @Override | ||
89 | - public RecycleTaskUserBO getRecycleTaskUser(String taskKey, int userId) throws ServiceException { | ||
90 | - // 1)参数验证 | ||
91 | - if (StringUtils.isEmpty(taskKey)) { | ||
92 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_EMPTY); | ||
93 | - } | ||
94 | - if (userId <= 0) { | ||
95 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_UID_EMPTY); | ||
96 | - } | ||
97 | - | ||
98 | - // 2)取数据 | ||
99 | - RecycleTaskUser recycleTaskUser = recycleTaskUserDao.selectByUniqueKey(taskKey, userId); | ||
100 | - | ||
101 | - // 3)不存在则直接返回pushFlag = 0的数据 | ||
102 | - if (recycleTaskUser == null) { | ||
103 | - return new RecycleTaskUserBO(taskKey, userId, 0); | ||
104 | - } | ||
105 | - | ||
106 | - // 4)根据recycleTaskUser生成RecycleTaskUserBO | ||
107 | - return new RecycleTaskUserBO(taskKey, userId, recycleTaskUser.getStatus()); | ||
108 | - } | ||
109 | - | ||
110 | - @Override | ||
111 | - public CommonRspBO addRecycleTaskForbidUser(RecyleTaskForbidUserBO recyleTaskForbidUserBO) throws ServiceException { | ||
112 | - // 1)参数验证 | ||
113 | - String taskKey = recyleTaskForbidUserBO.getTaskKey(); | ||
114 | - if (StringUtils.isEmpty(recyleTaskForbidUserBO.getTaskKey())) { | ||
115 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_EMPTY); | ||
116 | - } | ||
117 | - int userId = recyleTaskForbidUserBO.getUserId(); | ||
118 | - if (userId <= 0) { | ||
119 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_UID_EMPTY); | ||
120 | - } | ||
121 | - // 2)检查task_key是否存在 | ||
122 | - RecycleTaskDefine recycleTaskDefine = recycleTaskDefineDao.selectByTaskKey(taskKey, 1); | ||
123 | - if (recycleTaskDefine == null) { | ||
124 | - throw new ServiceException(ServiceError.PUSH_RECYCLETASK_TASKKEY_NOTEXIST); | ||
125 | - } | ||
126 | - | ||
127 | - // 3)如果该任务下次发送时间为空,表明任务无效,则直接返回成功 | ||
128 | - Date nextSendTime = CronUtil.getNextRunTime(recycleTaskDefine.getCronExpression(), recycleTaskDefine.getBeginTime(), recycleTaskDefine.getEndTime()); | ||
129 | - if (nextSendTime == null) { | ||
130 | - return new CommonRspBO(200, "成功"); | ||
131 | - } | ||
132 | - | ||
133 | - // 4)如果跨天无效,则直接返回 | ||
134 | - boolean clearWhenDifferDay = recyleTaskForbidUserBO.isClearWhenDifferDay(); | ||
135 | - if(clearWhenDifferDay && !isSameDay(nextSendTime, new Date())){ | ||
136 | - return new CommonRspBO(200, "成功"); | ||
137 | - } | ||
138 | - | ||
139 | - // 5)将forbidUserId插入redis,并设置sendTime的一个小时后过期(重复设置过期时间也没关系的) | ||
140 | - String redisKey = RedisKeyUtils.genRecycleTaskForbidUserKey(taskKey, nextSendTime); | ||
141 | - listOperations.rightPush(redisKey, String.valueOf(userId)); | ||
142 | - long expired = nextSendTime.getTime() - System.currentTimeMillis() + DateUtils.MILLIS_PER_HOUR; | ||
143 | - redisTemplate.longExpire(redisKey, expired , TimeUnit.MILLISECONDS); | ||
144 | - | ||
145 | - logger.info("add recycleTaskForbidUser to redis , redisKey is{}, uid is {}",redisKey,userId); | ||
146 | -// List<String> allForbidUserIds = listOperations.range(redisKey, 0, -1); | ||
147 | -// logger.info("add recycleTaskForbidUser to redis , redisKey is{}, uid is {},allForbidUserIds is {}",redisKey,userId,allForbidUserIds); | ||
148 | - return new CommonRspBO(200, "成功"); | ||
149 | - } | ||
150 | - | ||
151 | - private boolean isSameDay(Date d1,Date d2){ | ||
152 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
153 | - String d1DayStr = sdf.format(d1); | ||
154 | - String d2DayStr = sdf.format(d2); | ||
155 | - if(d1DayStr.equals(d2DayStr)){ | ||
156 | - return true; | ||
157 | - } | ||
158 | - return false; | ||
159 | - } | ||
160 | - | ||
161 | -} |
1 | -package com.yoho.yhmessage.sms.restapi; | ||
2 | - | ||
3 | -import java.io.UnsupportedEncodingException; | ||
4 | - | ||
5 | -import com.yoho.error.exception.ServiceException; | ||
6 | -import com.yoho.yhmessage.sms.helper.SMSLogHelper; | ||
7 | -import com.yoho.yhmessage.sms.service.INoticeSMSService; | ||
8 | -import org.slf4j.Logger; | ||
9 | -import org.slf4j.LoggerFactory; | ||
10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
11 | -import org.springframework.stereotype.Controller; | ||
12 | -import org.springframework.web.bind.annotation.RequestBody; | ||
13 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
14 | -import org.springframework.web.bind.annotation.ResponseBody; | ||
15 | - | ||
16 | -import com.yoho.service.model.sms.request.SMSTemplateReqBO; | ||
17 | -import com.yoho.service.model.sms.response.CommonRspBO; | ||
18 | -import com.yoho.yhmessage.sms.service.ISmsSendService; | ||
19 | - | ||
20 | -@Controller | ||
21 | -@RequestMapping("/SMSDispatcherRest") | ||
22 | -public class SMSDispatcherRest { | ||
23 | - | ||
24 | - @Autowired | ||
25 | - private ISmsSendService smsSendService; | ||
26 | - | ||
27 | - @Autowired | ||
28 | - private INoticeSMSService noticeSMSService; | ||
29 | - | ||
30 | - private static final Logger logger = LoggerFactory.getLogger(SMSDispatcherRest.class); | ||
31 | - | ||
32 | - @RequestMapping(value = "/smsSend") | ||
33 | - @ResponseBody | ||
34 | - public CommonRspBO smsSend(@RequestBody SMSTemplateReqBO[] boList) throws UnsupportedEncodingException { | ||
35 | - CommonRspBO commonRspBO = new CommonRspBO(); | ||
36 | - try { | ||
37 | - //(1)关闭当前的Thread线程 | ||
38 | - SMSLogHelper.remove(); | ||
39 | - //(2)发送短信 | ||
40 | - commonRspBO = smsSendService.smsSend(boList); | ||
41 | - }catch (Exception e){ | ||
42 | - if(e instanceof ServiceException){ | ||
43 | - throw e; | ||
44 | - }else { | ||
45 | - //eat all other exceptions | ||
46 | - logger.warn("Send sms failed. errorMsg is {}", e.getMessage(), e); | ||
47 | - } | ||
48 | - }finally { | ||
49 | - SMSLogHelper.remove(); | ||
50 | - } | ||
51 | - return commonRspBO; | ||
52 | - } | ||
53 | - | ||
54 | - @RequestMapping(value = "/noticeSMSSend") | ||
55 | - @ResponseBody | ||
56 | - public CommonRspBO noticeSMSSend(@RequestBody SMSTemplateReqBO smsTemplateReqBO) throws UnsupportedEncodingException { | ||
57 | - CommonRspBO commonRspBO = new CommonRspBO(); | ||
58 | - try { | ||
59 | - //(1)关闭当前的Thread线程 | ||
60 | - SMSLogHelper.remove(); | ||
61 | - //(2)发送短信 | ||
62 | - commonRspBO = noticeSMSService.noticeSMSSend(smsTemplateReqBO); | ||
63 | - }catch (Exception e){ | ||
64 | - if(e instanceof ServiceException){ | ||
65 | - throw e; | ||
66 | - }else { | ||
67 | - //eat all other exceptions | ||
68 | - logger.warn("Send notice sms failed. errorMsg is {}", e.getMessage(), e); | ||
69 | - } | ||
70 | - }finally { | ||
71 | - SMSLogHelper.remove(); | ||
72 | - } | ||
73 | - return commonRspBO; | ||
74 | - } | ||
75 | - | ||
76 | -} |
1 | -package com.yoho.yhmessage.sms.restapi; | ||
2 | - | ||
3 | -import javax.servlet.http.HttpServletRequest; | ||
4 | - | ||
5 | -import org.springframework.stereotype.Controller; | ||
6 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
7 | -import org.springframework.web.bind.annotation.RequestParam; | ||
8 | -import org.springframework.web.bind.annotation.ResponseBody; | ||
9 | - | ||
10 | -import com.yoho.yhmessage.sms.client.DIYClientExample; | ||
11 | -import com.yoho.yhmessage.sms.service.model.ResultInfo; | ||
12 | - | ||
13 | -@Controller | ||
14 | -public class SMSReportReceptRest { | ||
15 | - | ||
16 | - @RequestMapping(value = "hlReportReceive") | ||
17 | - @ResponseBody | ||
18 | - public ResultInfo hlReportRecept(@RequestParam("PlatForm") String PlatForm, | ||
19 | - @RequestParam("FUnikey") String FUnikey, | ||
20 | - @RequestParam("FOrgAddr") String FOrgAddr, | ||
21 | - @RequestParam("FDestAddr") String FDestAddr, | ||
22 | - @RequestParam("FSubmitTime") String FSubmitTime, | ||
23 | - @RequestParam("FFeeTerminal") String FFeeTerminal, | ||
24 | - @RequestParam("FServiceUPID") String FServiceUPID, | ||
25 | - @RequestParam("FReportCode") String FReportCode, | ||
26 | - @RequestParam("FLinkID") String FLinkID, | ||
27 | - @RequestParam("FAckStatus") String FAckStatus) { | ||
28 | - return null; | ||
29 | - } | ||
30 | - | ||
31 | - @RequestMapping(value = "rlReportReceive") | ||
32 | - @ResponseBody | ||
33 | - public ResultInfo rlReportRecept() { | ||
34 | - return null; | ||
35 | - } | ||
36 | - | ||
37 | - @RequestMapping(value = "xwReportReceive") | ||
38 | - @ResponseBody | ||
39 | - public ResultInfo xwReportRecept() { | ||
40 | - return null; | ||
41 | - } | ||
42 | - | ||
43 | - @RequestMapping(value = "ytReportReceive") | ||
44 | - @ResponseBody | ||
45 | - public String ytReportRecept(HttpServletRequest request) { | ||
46 | - String spid = request.getParameter("spid"); | ||
47 | - String mtmsgid = request.getParameter("mtmsgid"); | ||
48 | - String mtstat = request.getParameter("mtstat"); | ||
49 | - String mterrorcode = request.getParameter("mterrorcode"); | ||
50 | - // 获取状态报告参数后,请即刻返回响应信息 | ||
51 | - String output = "command=RT_RESPONSE&spid=" + spid + "&mtmsgid=" | ||
52 | - + mtmsgid + "&rtstat=ACCEPTD&rterrcode=000"; | ||
53 | - return output; | ||
54 | - } | ||
55 | - | ||
56 | - @RequestMapping(value = "ytMsgReceive") | ||
57 | - @ResponseBody | ||
58 | - public String ytMsgReceive(HttpServletRequest request) { | ||
59 | - String spid = request.getParameter("spid"); | ||
60 | - String momsgid = request.getParameter("momsgid"); | ||
61 | - String da = request.getParameter("da"); | ||
62 | - String sa = request.getParameter("sa"); | ||
63 | - String dc = request.getParameter("dc"); | ||
64 | - String sm = request.getParameter("sm"); | ||
65 | - // 将Hex编码的上行内容还原成普通字符串 | ||
66 | - // 在jdk1.4版本环境下,请使用DIYClientExample.decodeHexStr(Integer.parseInt(dc),sm) | ||
67 | - String moContent = DIYClientExample.decodeHexStr(Integer.parseInt(dc), | ||
68 | - sm); | ||
69 | - // 获取上行参数后,请即刻返回响应信息 | ||
70 | - String output = "command=MO_RESPONSE&spid=" + spid + "&momsgid=" | ||
71 | - + momsgid + "&mostat=ACCEPTD&moerrcode=000"; | ||
72 | - return output; | ||
73 | - } | ||
74 | -} |
1 | -package com.yoho.yhmessage.sms.restapi; | ||
2 | - | ||
3 | -import org.slf4j.Logger; | ||
4 | -import org.slf4j.LoggerFactory; | ||
5 | -import org.springframework.beans.factory.annotation.Autowired; | ||
6 | -import org.springframework.stereotype.Controller; | ||
7 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
8 | - | ||
9 | -import com.yoho.yhmessage.sms.service.ISmsSendService; | ||
10 | - | ||
11 | -@Controller | ||
12 | -@RequestMapping("/SmsSendRest") | ||
13 | -public class SmsSendRest { | ||
14 | - | ||
15 | - @Autowired | ||
16 | - private ISmsSendService smsSendService; | ||
17 | - | ||
18 | - private static final Logger logger = LoggerFactory.getLogger(SMSDispatcherRest.class); | ||
19 | -// @RequestMapping(value = "/baseSmsSend") | ||
20 | -// @ResponseBody | ||
21 | -// public CommonRspBO baseSmsSend(@RequestBody BaseSmsSendReqBO req) throws UnsupportedEncodingException { | ||
22 | -// CommonRspBO commonRspBO = new CommonRspBO(); | ||
23 | -// try { | ||
24 | -// //(1)关闭当前的Thread线程 | ||
25 | -// SMSLogHelper.remove(); | ||
26 | -// //(2)发送短信 | ||
27 | -// commonRspBO = smsSendService.baseSmsSend(req); | ||
28 | -// }catch (Exception e){ | ||
29 | -// if(e instanceof ServiceException){ | ||
30 | -// throw e; | ||
31 | -// }else { | ||
32 | -// //eat all other exceptions | ||
33 | -// logger.warn("Send sms failed. errorMsg is {}", e.getMessage(), e); | ||
34 | -// } | ||
35 | -// }finally { | ||
36 | -// SMSLogHelper.remove(); | ||
37 | -// } | ||
38 | -// return commonRspBO; | ||
39 | -// } | ||
40 | -} |
@@ -8,6 +8,9 @@ redis.readonly.proxy.address=${redis.readonly.proxy.address} | @@ -8,6 +8,9 @@ redis.readonly.proxy.address=${redis.readonly.proxy.address} | ||
8 | redis.readonly.proxy.port=${redis.readonly.proxy.port} | 8 | redis.readonly.proxy.port=${redis.readonly.proxy.port} |
9 | redis.readonly.proxy.auth=${redis.readonly.proxy.auth} | 9 | redis.readonly.proxy.auth=${redis.readonly.proxy.auth} |
10 | 10 | ||
11 | +redis.notsync.twemproxy.addresses=${redis.notsync.twemproxy.addresses} | ||
12 | +redis.notsync.twemproxy.auth=${redis.notsync.twemproxy.auth} | ||
13 | + | ||
11 | redis.timeout=50 | 14 | redis.timeout=50 |
12 | 15 | ||
13 | mobile.limit.sendTimes=50 | 16 | mobile.limit.sendTimes=50 |
@@ -15,9 +18,8 @@ mobile.limit.sendTimes=50 | @@ -15,9 +18,8 @@ mobile.limit.sendTimes=50 | ||
15 | rabbit.cacheclean.producer.host=${rabbit.cacheclean.producer.host} | 18 | rabbit.cacheclean.producer.host=${rabbit.cacheclean.producer.host} |
16 | rabbit.cacheclean.consumer.host=${rabbit.cacheclean.consumer.host} | 19 | rabbit.cacheclean.consumer.host=${rabbit.cacheclean.consumer.host} |
17 | 20 | ||
18 | -rabbit_host=${rabbit_host} | ||
19 | -rabbit_user=${rabbit_user} | ||
20 | -rabbit_password =${rabbit_password} | 21 | +rabbit_host=${rabbit_message_center} |
22 | +rabbit_user=${rabbit_message_center_user} | ||
23 | +rabbit_password =${rabbit_message_center_password} | ||
24 | + | ||
21 | 25 | ||
22 | -redis.notsync.twemproxy.addresses=${redis.notsync.twemproxy.addresses} | ||
23 | -redis.notsync.twemproxy.auth=${redis.notsync.twemproxy.auth} |
-
Please register or login to post a comment