| | |
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.push.DeviceActive;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenIOS;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.service.inter.config.SystemService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceActiveService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
|
| | | import com.yeshi.fanli.service.inter.push.IOSPushService;
|
| | | import com.yeshi.fanli.service.inter.push.PushRecordService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping(value = "api/v1/push")
|
| | |
| | |
|
| | | @Resource
|
| | | private DeviceTokenHWService deviceTokenHWService;
|
| | |
|
| | | @Resource
|
| | | private DeviceActiveService deviceActiveService;
|
| | |
|
| | | @RequestMapping(value = "callback", method = RequestMethod.POST)
|
| | | public void callback(AcceptData acceptData, String pushId, PrintWriter out) {
|
| | |
| | | @RequestMapping(value = "/insertDeviceToken", method = RequestMethod.POST)
|
| | | public void insertIOSDeviceToken(AcceptData acceptData, String deviceToken, PrintWriter out) {
|
| | | if (!StringUtil.isNullOrEmpty(acceptData.getDevice()) && !StringUtil.isNullOrEmpty(deviceToken)) {
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDevice(acceptData.getDevice());
|
| | | // 添加设备活跃记录
|
| | | DeviceActive da = new DeviceActive();
|
| | | da.setDeviceToken(deviceToken);
|
| | | da.setPlatform(DeviceActive.PLATFORM_IOS);
|
| | | da.setVersionCode(Integer.parseInt(acceptData.getVersion()));
|
| | | deviceActiveService.addDeviceActive(da);
|
| | |
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
|
| | | if (deviceTokenIOS == null)
|
| | | iosPushService.addDeviceToken(null, deviceToken, acceptData.getDevice());
|
| | | iosPushService.addDeviceToken(null, Integer.parseInt(acceptData.getVersion()), deviceToken,
|
| | | acceptData.getDevice());
|
| | | else {
|
| | | deviceTokenIOS.setDeviceToken(deviceToken);
|
| | | deviceTokenIOS.setDevice(acceptData.getDevice());
|
| | | iosPushService.updateDeviceToken(deviceTokenIOS);
|
| | | }
|
| | | out.print(JsonUtil.loadTrue(0, null, "成功"));
|
| | |
| | | * @param deviceToken
|
| | | */
|
| | |
|
| | | // 传一个device 如果存在device 根据device执行update操作 , 如果不存在 都执行insert操作三个参数
|
| | | @RequestMapping(value = "/uidBindDeviceToken", method = RequestMethod.POST)
|
| | | public void uidBindIOSDeviceToken(AcceptData acceptData, Long uid, String deviceToken, PrintWriter out) {
|
| | | if (uid != null && uid != 0 && !StringUtil.isNullOrEmpty(deviceToken)) {
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDevice(acceptData.getDevice());
|
| | | // 添加设备活跃记录
|
| | | DeviceActive da = new DeviceActive();
|
| | | da.setDeviceToken(deviceToken);
|
| | | da.setPlatform(DeviceActive.PLATFORM_IOS);
|
| | | da.setVersionCode(Integer.parseInt(acceptData.getVersion()));
|
| | | deviceActiveService.addDeviceActive(da);
|
| | | // 添加token
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(acceptData.getDevice());
|
| | | if (deviceTokenIOS != null) {
|
| | | if (!StringUtil.isNullOrEmpty(deviceToken))
|
| | | deviceTokenIOS.setDeviceToken(deviceToken);
|
| | | deviceTokenIOS.setUid(uid);
|
| | | deviceTokenIOS.setDevice(acceptData.getDevice());
|
| | | deviceTokenIOS.setVersion(Integer.parseInt(acceptData.getVersion()));
|
| | | iosPushService.updateDeviceToken(deviceTokenIOS);
|
| | | } else {
|
| | | iosPushService.addDeviceToken(uid, deviceToken, acceptData.getDevice());
|
| | | iosPushService.addDeviceToken(uid, Integer.parseInt(acceptData.getVersion()), deviceToken,
|
| | | acceptData.getDevice());
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | */
|
| | | @RequestMapping(value = "/unBind", method = RequestMethod.POST)
|
| | | public void unBind(AcceptData acceptData, String deviceToken, PrintWriter out) {
|
| | | if (deviceToken != null && !"".equals(deviceToken)) {
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDevice(acceptData.getDevice());
|
| | | if (!StringUtil.isNullOrEmpty(deviceToken)) {
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
|
| | | if (deviceTokenIOS != null) {
|
| | | deviceTokenIOS.setUid(null);
|
| | | iosPushService.updateDeviceToken(deviceTokenIOS);
|