diff --git a/src/main/java/com/ifish/controller/Device.java b/src/main/java/com/ifish/controller/Device.java new file mode 100644 index 0000000..e69ac7a --- /dev/null +++ b/src/main/java/com/ifish/controller/Device.java @@ -0,0 +1,76 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.controller; + +import com.ifish.bean.Tbl_Device_User; +import com.ifish.helper.DeviceHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * + * @author Administrator + */ +@Controller +public class Device { + + @Autowired + private DeviceHelper deviceHelper; + + /** + * 用户详情页面绑定设备 + * + * @param userId + * @param deviceMac + * @return + */ + @RequestMapping(value = "/bindDevice", method = RequestMethod.POST) + @ResponseBody + public Object bindDevice(Integer userId, String deviceMac) { + return deviceHelper.bindDevice(userId, deviceMac); + } + + /** + * 用户详情页面绑定摄像头 + * + * @param userId + * @param cameraId + * @return + */ + @RequestMapping(value = "/bindCamera", method = RequestMethod.POST) + @ResponseBody + public Object bindCamera(Integer userId, String cameraId) { + return deviceHelper.bindCamera(userId, cameraId); + } + + /** + * 用户详情页解除绑定设备 + * + * @param userId + * @param deviceMac + * @return + */ + @RequestMapping(value = "/deleteDeviceUser", method = RequestMethod.POST) + @ResponseBody + public Object deleteDeviceUser(Tbl_Device_User deviceUser) { + return deviceHelper.deleteDeviceUser(deviceUser); + } + + /** + * 删除绑定的摄像头 + * + * @param deviceUser + * @return + */ + @RequestMapping(value = "/deleteCameraUser", method = RequestMethod.POST) + @ResponseBody + public Object deleteCameraUser(Integer userId, String cameraId) { + return deviceHelper.bindDevice(userId, cameraId); + } +} diff --git a/src/main/java/com/ifish/controller/PushMessage.java b/src/main/java/com/ifish/controller/PushMessage.java new file mode 100644 index 0000000..e016084 --- /dev/null +++ b/src/main/java/com/ifish/controller/PushMessage.java @@ -0,0 +1,57 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.controller; + +import com.ifish.helper.PushMessageHelperI; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.ModelAndView; + +/** + * + * @author Administrator + */ +@Controller +public class PushMessage { + + @Autowired + private PushMessageHelperI pushMessageHelperI; + + /** + * 消息推送页面 + * + * @return + */ + @RequestMapping(value = {"/pushlist"}, method = RequestMethod.GET) + public ModelAndView getPushList() { + return pushMessageHelperI.getPushListView(); + } + + /** + * 根据条件查询消息推送数据 + * + * @param draw + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + @RequestMapping(value = {"/pushlistdata"}, method = RequestMethod.POST) + @ResponseBody + public Object getPushListData(String draw, Integer start, Integer length, String sdkVersion, String phoneNumber, String mac, String phoneType, String pushType, String sortField, String sortMode) { + return pushMessageHelperI.getPushListData(draw, start, length, sdkVersion, phoneNumber, mac, phoneType, pushType, sortField, sortMode); + } + +} diff --git a/src/main/java/com/ifish/controller/User.java b/src/main/java/com/ifish/controller/User.java index 7dd8acb..89f6070 100644 --- a/src/main/java/com/ifish/controller/User.java +++ b/src/main/java/com/ifish/controller/User.java @@ -24,6 +24,11 @@ public class User { @Autowired private UserHelper userHelper; + /** + * 注册用户页面 + * + * @return + */ @RequestMapping(value = {"/userlist"}, method = RequestMethod.GET) public ModelAndView getUserList() { ModelAndView mv = new ModelAndView(); @@ -48,17 +53,52 @@ public class User { return mv; } + /** + * 用户详情页面 + * + * @param userId + * @return + */ @RequestMapping(value = {"/userDetail"}, method = RequestMethod.GET) public ModelAndView getUserDetail(String userId) { return (ModelAndView) userHelper.getUserDetail(userId); } + /** + * 注册用户页面根据条件查询用户列表 + * + * @param draw + * @param start + * @param length + * @param userId + * @param phoneNumber + * @param userEmail + * @param phoneType + * @param isRegisterGwell + * @param isRegisterJiguang + * @param sortField + * @param sortMode + * @param nickName + * @param remarks + * @param loginTime1 + * @param loginTime2 + * @param createTime1 + * @param createTime2 + * @return + */ @RequestMapping(value = "/getUserList", method = RequestMethod.POST) @ResponseBody public Object getlist(String draw, Integer start, Integer length, String userId, String phoneNumber, String userEmail, String phoneType, String isRegisterGwell, String isRegisterJiguang, String sortField, String sortMode, String nickName, String remarks, String loginTime1, String loginTime2, String createTime1, String createTime2) { return userHelper.getlist(draw, start, length, userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2); } + /** + * 注册用户页面修改用户备注 + * + * @param userId + * @param remarks + * @return + */ @RequestMapping(value = "/updateRemarks", method = RequestMethod.POST) @ResponseBody public Object updateRemarks(String userId, String remarks) { diff --git a/src/main/java/com/ifish/helper/DeviceHelper.java b/src/main/java/com/ifish/helper/DeviceHelper.java index d33b54f..919c462 100644 --- a/src/main/java/com/ifish/helper/DeviceHelper.java +++ b/src/main/java/com/ifish/helper/DeviceHelper.java @@ -41,6 +41,16 @@ public interface DeviceHelper { */ Tbl_Device getDeviceById(Integer deviceId) throws Exception; + /** + * 根据用户ID和设备ID获取此设备和此用户的关系 + * + * @param userId + * @param deviceId + * @return + * @throws Exception + */ + Tbl_Device_User getDeviceUserByUserId_DeviceId(Integer userId, Integer deviceId) throws Exception; + /** * 根据设备MacAddress获取设备详情 * diff --git a/src/main/java/com/ifish/helper/DeviceHelperI.java b/src/main/java/com/ifish/helper/DeviceHelperI.java index 914ad19..1cfad69 100644 --- a/src/main/java/com/ifish/helper/DeviceHelperI.java +++ b/src/main/java/com/ifish/helper/DeviceHelperI.java @@ -79,6 +79,7 @@ public class DeviceHelperI implements DeviceHelper { * @return * @throws Exception */ + @Override public Tbl_Device_User getDeviceUserByUserId_DeviceId(Integer userId, Integer deviceId) throws Exception { Tbl_Device_User device = null; String key = redisKeyHelperI.getTbl_Device_UserRedisKeyByDeviceIdAndUserId(userId, deviceId); @@ -356,14 +357,16 @@ public class DeviceHelperI implements DeviceHelper { deviceUser.setUpdateTime(date); deviceUser.setCreateTime(date); tbl_Device_Mapper.insertDeviceUser(deviceUser); + redisKeyHelperI.deleteRedisByTbl_Device(device); + redisKeyHelperI.deleteRedisByTbl_Device_User(deviceUser); } //封装设备返回信息 - return IfishUtil.returnJson(ResultEnum.success.getKey(), ""); + return IfishUtil.returnJson(ResultEnum.success.getKey(), "绑定成功"); } else { - return IfishUtil.returnJson(ResultEnum.warn202.getKey(), ""); + return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "绑定出错"); } } catch (Exception e) { - return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); + return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "绑定失败"); } } @@ -417,12 +420,12 @@ public class DeviceHelperI implements DeviceHelper { dataMap.put("isLook", device_User.getIsLook()); dataMap.put("isLive", device_User.getIsLive()); dataMap.put("isActive", camera.getActiveCode() != null && !camera.getActiveCode().equals("") ? "1" : "0"); - return IfishUtil.returnJson(ResultEnum.success.getKey(), dataMap); + return IfishUtil.returnJson(ResultEnum.success.getKey(), "绑定成功"); } else { - return IfishUtil.returnJson(ResultEnum.warn202.getKey(), ""); + return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "绑定出错"); } } catch (Exception e) { - return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); + return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "绑定失败"); } } diff --git a/src/main/java/com/ifish/helper/PushMessageHelper.java b/src/main/java/com/ifish/helper/PushMessageHelper.java index 573c3d6..21f41bf 100644 --- a/src/main/java/com/ifish/helper/PushMessageHelper.java +++ b/src/main/java/com/ifish/helper/PushMessageHelper.java @@ -10,10 +10,14 @@ import com.ifish.bean.Tbl_Push_List; import com.ifish.enums.ResultEnum; import com.ifish.mapper.Tbl_Push_List_Mapper; import com.ifish.util.IfishUtil; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.web.servlet.ModelAndView; /** * @@ -123,4 +127,107 @@ public class PushMessageHelper implements PushMessageHelperI { return null; } } + + /** + * 推送列表首页 + * + * @return + */ + @Override + public ModelAndView getPushListView() { + ModelAndView mv = new ModelAndView(); + mv.setViewName("pushlist"); + mv.addObject("title", "消息推送列表"); + mv.addObject("myjs", "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + "" + + " \n" + + " \n" + + " \n" + + " \n" + + " "); + return mv; + } + + /** + * 根据条件获取推送列表 + * + * @param draw + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + @Override + public Object getPushListData(String draw, Integer start, Integer length, String sdkVersion, String phoneNumber, String mac, String phoneType, String pushType, String sortField, String sortMode) { + List list = null; + String key = redisKeyHelperI.getAdmin_Tbl_Push_List_BySelect(start, length, sdkVersion, phoneNumber, mac, phoneType, pushType, sortField, sortMode); + String redisString = redisHelperI.getRedis(key); + try { + if (StringUtils.isNotBlank(redisString)) { + list = (List) IfishUtil.JsonToList(redisString, Map.class); + } else { + list = tbl_Push_List_Mapper.getPushListData(start, length, sdkVersion, phoneNumber, mac, phoneType, pushType, sortField, sortMode); + if (list != null && list.size() > 0) { + for (Map map : list) { + if (map.get("createTime") != null) { + String createTime = IfishUtil.format((Date) map.get("createTime")); + map.put("createTime", createTime); + } + } + redisHelperI.setRedis(key, IfishUtil.ObjectToJson(list)); + } + } + } catch (Exception e) { + } + Integer count = 0; + key = redisKeyHelperI.getAdmin_Tbl_Push_List_Count_BySelect(sdkVersion, phoneNumber, mac, phoneType, pushType, sortField, sortMode); + redisString = redisHelperI.getRedis(key); + try { + if (StringUtils.isNotBlank(redisString)) { + count = Integer.parseInt(redisString); + } else { + count = tbl_Push_List_Mapper.getPushListDataCount(sdkVersion, phoneNumber, mac, phoneType, pushType, sortField, sortMode); + if (count != null && count > 0) { + redisHelperI.setRedis(key, count.toString()); + } + } + } catch (Exception e) { + } + + Integer allCount = 0; + key = redisKeyHelperI.getAdmin_Tbl_Push_List_AllCount(); + redisString = redisHelperI.getRedis(key); + try { + if (StringUtils.isNotBlank(redisString)) { + allCount = Integer.parseInt(redisString); + } else { + allCount = tbl_Push_List_Mapper.getPushListDataAllCount(); + if (allCount != null && allCount > 0) { + redisHelperI.setRedis(key, allCount.toString()); + } + } + } catch (Exception e) { + } + + Map map = new HashMap(); + map.put("data", list); + map.put("draw", draw); + map.put("recordsTotal", allCount); + map.put("recordsFiltered", count); + return map; + } } diff --git a/src/main/java/com/ifish/helper/PushMessageHelperI.java b/src/main/java/com/ifish/helper/PushMessageHelperI.java index e73cd40..34e2790 100644 --- a/src/main/java/com/ifish/helper/PushMessageHelperI.java +++ b/src/main/java/com/ifish/helper/PushMessageHelperI.java @@ -6,6 +6,7 @@ package com.ifish.helper; import com.ifish.bean.Tbl_Push_List; +import org.springframework.web.servlet.ModelAndView; /** * @@ -34,4 +35,28 @@ public interface PushMessageHelperI { Object deletePushList(Integer userId, Integer pushId); Tbl_Push_List save(Tbl_Push_List pushList); + + /** + * 推送列表首页 + * + * @return + */ + ModelAndView getPushListView(); + + /** + * 根据条件获取推送列表 + * + * @param draw + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + Object getPushListData(String draw, Integer start, Integer length, String sdkVersion, String phoneNumber, String mac, String phoneType, String pushType, String sortField, String sortMode); } diff --git a/src/main/java/com/ifish/helper/RedisKeyHelper.java b/src/main/java/com/ifish/helper/RedisKeyHelper.java index 64ca4f1..9ddda14 100644 --- a/src/main/java/com/ifish/helper/RedisKeyHelper.java +++ b/src/main/java/com/ifish/helper/RedisKeyHelper.java @@ -8,7 +8,9 @@ package com.ifish.helper; import com.ifish.bean.Tbl_Device; import com.ifish.bean.Tbl_Device_Statistics; import com.ifish.bean.Tbl_Device_User; +import com.ifish.bean.Tbl_Live_Message; import com.ifish.bean.Tbl_Live_Room; +import com.ifish.bean.Tbl_Push_List; import com.ifish.bean.Tbl_User; import com.ifish.util.RedisKey; import org.apache.commons.lang3.StringUtils; @@ -21,10 +23,13 @@ import org.springframework.stereotype.Component; */ @Component public class RedisKeyHelper implements RedisKeyHelperI { - + @Autowired private RedisHelperI redisHelperI; + @Autowired + private DeviceHelper deviceHelper; + /** * 根据phoneNumber获取Tbl_User用户信息的Redis缓存key键值 * @@ -264,6 +269,17 @@ public class RedisKeyHelper implements RedisKeyHelperI { return RedisKey.LIVEROOM_ROOMID + roomId; } + /** + * 根据摄像头Id获取Tbl_Live_Room的redis缓存key键值 + * + * @param roomId + * @return + */ + @Override + public String getTbl_Live_RoomRedisKeyByCameraId(String cameraId) { + return RedisKey.LIVEROOM_CAMERAID + cameraId; + } + /** * 根据用户Id获取Tbl_Live_Room的redis缓存key键值 * @@ -294,7 +310,7 @@ public class RedisKeyHelper implements RedisKeyHelperI { * @return */ @Override - + public String getTbl_Live_Room_CountRedisKey() { return RedisKey.LIVEROOM_COUNT; } @@ -310,6 +326,17 @@ public class RedisKeyHelper implements RedisKeyHelperI { return RedisKey.LIVEMESSAGE_ROOMID + roomId + "_f_" + firstResult + "_p_" + pageSize; } + /** + * 获取直播间评论总数的redis缓存key键值 + * + * @param roomId + * @return + */ + @Override + public String getTbl_Live_MessageCount(Integer roomId) { + return RedisKey.LIVEMESSAGE_COUNT + roomId; + } + /** * 根据pushId获取Tbl_push_list的redis缓存key键值 * @@ -332,6 +359,16 @@ public class RedisKeyHelper implements RedisKeyHelperI { return RedisKey.EMAIL_REGIESTER + md5; } + /** + * 根据MD5值获取redis缓存key键值(修改密码用) + * + * @param md5 + * @return + */ + public String getEmailUpdatePasswordRedisKey(String md5) { + return RedisKey.EMAIL_UPDATEPASSWORD + md5; + } + /** * 删除redis中某个设备详情Tbl_Device的缓存 * @@ -340,6 +377,15 @@ public class RedisKeyHelper implements RedisKeyHelperI { */ @Override public void deleteRedisByTbl_Device(Tbl_Device device) { + deleteTbl_DeviceInfo(device); + try { + Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId()); + deleteTbl_Device_StatisticsInfo(device_Statistics); + } catch (Exception e) { + } + } + + public void deleteTbl_DeviceInfo(Tbl_Device device) { if (device.getDeviceId() != null && device.getDeviceId() > 0) { redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId())); } @@ -359,12 +405,22 @@ public class RedisKeyHelper implements RedisKeyHelperI { */ @Override public void deleteRedisByTbl_Device_Statistics(Tbl_Device_Statistics device) { + deleteTbl_Device_StatisticsInfo(device); + try { + Tbl_Device device1 = deviceHelper.getDeviceById(device.getDeviceId()); + deleteTbl_DeviceInfo(device1); + } catch (Exception e) { + } + } + + public void deleteTbl_Device_StatisticsInfo(Tbl_Device_Statistics device) { if (device.getDeviceId() != null && device.getDeviceId() > 0) { redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId())); } if (StringUtils.isNotBlank(device.getMacAddress())) { redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByMacAddress(device.getMacAddress())); } + } /** @@ -374,12 +430,26 @@ public class RedisKeyHelper implements RedisKeyHelperI { */ @Override public void deleteRedisByTbl_Device_User(Tbl_Device_User tbl_Device_User) { + deleteTbl_Device_UserInfo(tbl_Device_User); + try { + Tbl_Device device1 = deviceHelper.getDeviceById(tbl_Device_User.getDeviceId()); + deleteTbl_DeviceInfo(device1); + Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(tbl_Device_User.getDeviceId()); + deleteTbl_Device_StatisticsInfo(device_Statistics); + } catch (Exception e) { + } + } + + public void deleteTbl_Device_UserInfo(Tbl_Device_User tbl_Device_User) { if (tbl_Device_User.getDeviceId() != null && tbl_Device_User.getUserId() != null && tbl_Device_User.getDeviceId() > 0 && tbl_Device_User.getUserId() > 0) { redisHelperI.deleteRedis(getTbl_Device_UserRedisKeyByDeviceIdAndUserId(tbl_Device_User.getUserId(), tbl_Device_User.getDeviceId())); } if (tbl_Device_User.getDeviceId() != null && tbl_Device_User.getDeviceId() > 0) { redisHelperI.deleteRedis(getListTbl_Device_UserKeyByDeviceId(tbl_Device_User.getDeviceId())); } + if (tbl_Device_User.getUserId() != null) { + redisHelperI.delRedisByTagKey(getListTbl_Device_UserKeyByUserId(tbl_Device_User.getUserId())); + } } /** @@ -416,6 +486,9 @@ public class RedisKeyHelper implements RedisKeyHelperI { if (live_Room.getRoomId() != null && live_Room.getRoomId() > 0) { redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByRoomId(live_Room.getRoomId())); } + if (StringUtils.isNotBlank(live_Room.getCameraId())) { + redisHelperI.deleteRedis(live_Room.getCameraId()); + } if (live_Room.getUserId() != null && live_Room.getUserId() > 0) { redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByUserId(live_Room.getUserId())); } @@ -430,5 +503,91 @@ public class RedisKeyHelper implements RedisKeyHelperI { public void deleteRedisByLiveRoomListCount() { redisHelperI.deleteRedis(getTbl_Live_Room_CountRedisKey()); } - + + /** + * 删除redis中某个直播间评论列表缓存 + * + * @param tbl_Live_Message + */ + @Override + public void deleteRedisByTbl_Live_Message(Tbl_Live_Message tbl_Live_Message) { + redisHelperI.delRedisByTagKey(RedisKey.LIVEMESSAGE_ROOMID + tbl_Live_Message.getRoomId()); + redisHelperI.deleteRedis(RedisKey.LIVEMESSAGE_COUNT + tbl_Live_Message.getRoomId()); + } + + /** + * 后台推送消息列表缓存 + * + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + @Override + public String getAdmin_Tbl_Push_List_BySelect(Integer start, Integer length, String sdkVersion, String phoneNumber, String mac, String phoneType, String pushType, String sortField, String sortMode) { + return RedisKey.PUSHLIST_SELECT + start + "_" + length + "_" + sdkVersion + "_" + phoneNumber + "_" + mac + "_" + phoneType + "_" + pushType + "_" + sortField + "_" + sortMode; + } + + /** + * 后台推送消息列表查询数量缓存 + * + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + @Override + public String getAdmin_Tbl_Push_List_Count_BySelect(String sdkVersion, String phoneNumber, String mac, String phoneType, String pushType, String sortField, String sortMode) { + return RedisKey.PUSHLIST_SELECT + "count_" + sdkVersion + "_" + phoneNumber + "_" + mac + "_" + phoneType + "_" + pushType + "_" + sortField + "_" + sortMode; + } + + /** + * 后台推送消息列表总数缓存 + * + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + @Override + public String getAdmin_Tbl_Push_List_AllCount() { + return RedisKey.PUSHLIST_SELECT; + } + + /** + * 根据条件删除推送列表缓存 + * + * @param pushId + */ + public void deleteRedisByTbl_Push_List(Tbl_Push_List tbl_Push_List) { + if (tbl_Push_List.getPushId() != null) { + redisHelperI.deleteRedis(getTbl_Push_List_RedisByPushId(tbl_Push_List.getPushId())); + } + deleteRedisByTbl_Push_ListToAllRedisList(); + } + + /** + * 删除推送列表类缓存 + */ + public void deleteRedisByTbl_Push_ListToAllRedisList() { + redisHelperI.delRedisByTagKey(RedisKey.PUSHLIST_SELECT); + } } diff --git a/src/main/java/com/ifish/helper/RedisKeyHelperI.java b/src/main/java/com/ifish/helper/RedisKeyHelperI.java index 9ca8acf..de5cbf0 100644 --- a/src/main/java/com/ifish/helper/RedisKeyHelperI.java +++ b/src/main/java/com/ifish/helper/RedisKeyHelperI.java @@ -8,7 +8,9 @@ package com.ifish.helper; import com.ifish.bean.Tbl_Device; import com.ifish.bean.Tbl_Device_Statistics; import com.ifish.bean.Tbl_Device_User; +import com.ifish.bean.Tbl_Live_Message; import com.ifish.bean.Tbl_Live_Room; +import com.ifish.bean.Tbl_Push_List; import com.ifish.bean.Tbl_User; /** @@ -199,6 +201,14 @@ public interface RedisKeyHelperI { */ public String getTbl_Live_RoomRedisKeyByRoomId(Integer roomId); + /** + * 根据摄像头Id获取Tbl_Live_Room的redis缓存key键值 + * + * @param roomId + * @return + */ + public String getTbl_Live_RoomRedisKeyByCameraId(String cameraId); + /** * 根据用户Id获取Tbl_Live_Room的redis缓存key键值 * @@ -232,6 +242,14 @@ public interface RedisKeyHelperI { */ public String getTbl_Live_Message(Integer firstResult, Integer pageSize, Integer roomId); + /** + * 获取直播间评论总数的redis缓存key键值 + * + * @param roomId + * @return + */ + public String getTbl_Live_MessageCount(Integer roomId); + /** * 根据pushId获取Tbl_push_list的redis缓存key键值 * @@ -241,13 +259,69 @@ public interface RedisKeyHelperI { public String getTbl_Push_List_RedisByPushId(Integer pushId); /** - * 根据MD5值获取redis缓存key键值 + * 后台推送消息列表缓存 + * + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + public String getAdmin_Tbl_Push_List_BySelect(Integer start, Integer length, String sdkVersion, String phoneNumber, String mac, String phoneType, String pushType, String sortField, String sortMode); + + /** + * 后台推送消息列表查询数量缓存 + * + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + public String getAdmin_Tbl_Push_List_Count_BySelect(String sdkVersion, String phoneNumber, String mac, String phoneType, String pushType, String sortField, String sortMode); + + /** + * 后台推送消息列表总数缓存 + * + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + public String getAdmin_Tbl_Push_List_AllCount(); + + /** + * 根据MD5值获取redis缓存key键值(注册账号用) * * @param md5 * @return */ public String getEmailRedisKey(String md5); + /** + * 根据MD5值获取redis缓存key键值(修改密码用) + * + * @param md5 + * @return + */ + public String getEmailUpdatePasswordRedisKey(String md5); + /** * 删除redis中某个设备详情的缓存 * @@ -290,4 +364,23 @@ public interface RedisKeyHelperI { */ public void deleteRedisByLiveRoomListCount(); + /** + * 删除redis中某个直播间评论列表缓存 + * + * @param tbl_Live_Message + */ + public void deleteRedisByTbl_Live_Message(Tbl_Live_Message tbl_Live_Message); + + /** + * 根据条件删除推送列表缓存 + * + * @param pushId + */ + public void deleteRedisByTbl_Push_List(Tbl_Push_List tbl_Push_List); + + /** + * 删除推送列表类缓存 + */ + public void deleteRedisByTbl_Push_ListToAllRedisList(); + } diff --git a/src/main/java/com/ifish/mapper/Tbl_Push_List_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Push_List_Mapper.java index 7bc62b5..a6b03d9 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Push_List_Mapper.java +++ b/src/main/java/com/ifish/mapper/Tbl_Push_List_Mapper.java @@ -7,6 +7,7 @@ package com.ifish.mapper; import com.ifish.bean.Tbl_Push_List; import java.util.List; +import java.util.Map; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; @@ -71,4 +72,44 @@ public interface Tbl_Push_List_Mapper { + "#{push.pushType},#{push.pushTitle},#{push.pushContext},NOW(),#{push.pushLink},#{push.jpushStatus},#{push.googleStatus},#{push.reportId},#{push.mcuCount},#{push.modularCount},#{push.routerCount},#{push.serverCount},#{push.serverTryCount})") Integer saveTbl_Push_List(@Param("push") Tbl_Push_List tbl_Push_List); + /** + * 根据条件搜索推送列表数据 + * + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + @SelectProvider(type = Tbl_Push_List_MapperSql.class, method = "getPushListData") + List getPushListData(@Param("start") Integer start, @Param("length") Integer length, @Param("sdkversion") String sdkVersion, @Param("phoneNumber") String phoneNumber, @Param("mac") String mac, @Param("phoneType") String phoneType, @Param("pushType") String pushType, @Param("sortField") String sortField, @Param("sortMode") String sortMode); + + /** + * 根据条件搜索推送列表数据数量 + * + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + @SelectProvider(type = Tbl_Push_List_MapperSql.class, method = "getPushListDataCount") + Integer getPushListDataCount(@Param("sdkversion") String sdkVersion, @Param("phoneNumber") String phoneNumber, @Param("mac") String mac, @Param("phoneType") String phoneType, @Param("pushType") String pushType, @Param("sortField") String sortField, @Param("sortMode") String sortMode); + + /** + * 获取推送列表总数 + * + * @return + */ + @SelectProvider(type = Tbl_Push_List_MapperSql.class, method = "getPushListDataAllCount") + Integer getPushListDataAllCount(); + } diff --git a/src/main/java/com/ifish/mapper/Tbl_Push_List_MapperSql.java b/src/main/java/com/ifish/mapper/Tbl_Push_List_MapperSql.java index 7a58097..3beecca 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Push_List_MapperSql.java +++ b/src/main/java/com/ifish/mapper/Tbl_Push_List_MapperSql.java @@ -39,4 +39,112 @@ public class Tbl_Push_List_MapperSql { return sb.toString(); } + /** + * 根据条件搜索推送列表数据 + * + * @param start + * @param length + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + public String getPushListData(@Param("start") Integer start, @Param("length") Integer length, @Param("sdkversion") String sdkVersion, @Param("phoneNumber") String phoneNumber, @Param("mac") String mac, @Param("phoneType") String phoneType, @Param("pushType") String pushType, @Param("sortField") String sortField, @Param("sortMode") String sortMode) { + StringBuilder sb = new StringBuilder(); + + sb.append("SELECT a.push_id pushId,e.phone_number phoneNumber,e.user_email userEmail,e.user_id userId,b.mac_address macAddress,b.device_id deviceId,c.sdk_version sdkVersion,c.MCU_count mcuCount,"); + sb.append(" c.module_count moduleCount,c.router_count routerCount,c.server_count serverCount,c.server_try_count serverTryCount,"); + sb.append(" a.phone_type phoneType,a.jpush_status jpushStatus,a.push_type pushType,a.push_title pushTitle,a.push_context pushContext,a.create_time createTime"); + sb.append(" from tbl_push_list a"); + sb.append(" LEFT JOIN tbl_device b ON a.device_id = b.device_id"); + sb.append(" LEFT JOIN tbl_device_statistics c ON a.device_id=c.device_id"); + sb.append(" LEFT JOIN tbl_user e ON a.user_id =e.user_id"); + sb.append(" WHERE 1=1 "); + if (StringUtils.isNotBlank(phoneType)) { + sb.append(" AND a.phone_type = #{phoneType}"); + } + if (StringUtils.isNotBlank(pushType)) { + sb.append(" AND a.push_type = #{pushType}"); + } + if (StringUtils.isNotBlank(sdkVersion)) { + sb.append(" AND c.sdk_version = #{sdkversion}"); + } + if (StringUtils.isNotBlank(phoneNumber)) { + sb.append(" AND e.phone_number = #{phoneNumber}"); + } + if (StringUtils.isNotBlank(mac)) { + sb.append(" AND b.mac_address = #{mac}"); + } + if (StringUtils.isBlank(sortField)) { + sortField = "push_id"; + } + if (StringUtils.isBlank(sortMode)) { + sortMode = "DESC"; + } + sb.append("ORDER BY a." + sortField + " " + sortMode); + sb.append(" limit " + start + "," + length); + return sb.toString(); + } + + /** + * 根据条件搜索推送列表数据数量 + * + * @param sdkVersion + * @param phoneNumber + * @param mac + * @param phoneType + * @param pushType + * @param sortField + * @param sortMode + * @return + */ + public String getPushListDataCount(@Param("sdkversion") String sdkVersion, @Param("phoneNumber") String phoneNumber, @Param("mac") String mac, @Param("phoneType") String phoneType, @Param("pushType") String pushType, @Param("sortField") String sortField, @Param("sortMode") String sortMode) { + StringBuilder sb = new StringBuilder(); + sb.append("SELECT COUNT(1) "); + sb.append(" from tbl_push_list a"); + sb.append(" LEFT JOIN tbl_device b ON a.device_id = b.device_id"); + sb.append(" LEFT JOIN tbl_device_statistics c ON a.device_id=c.device_id"); + sb.append(" LEFT JOIN tbl_user e ON a.user_id =e.user_id"); + sb.append(" WHERE 1=1 "); + if (StringUtils.isNotBlank(phoneType)) { + sb.append(" AND a.phone_type = #{phoneType}"); + } + if (StringUtils.isNotBlank(pushType)) { + sb.append(" AND a.push_type = #{pushType}"); + } + if (StringUtils.isNotBlank(sdkVersion)) { + sb.append(" AND c.sdk_version = #{sdkversion}"); + } + if (StringUtils.isNotBlank(phoneNumber)) { + sb.append(" AND e.phone_number = #{phoneNumber}"); + } + if (StringUtils.isNotBlank(mac)) { + sb.append(" AND b.mac_address = #{mac}"); + } + if (StringUtils.isBlank(sortField)) { + sortField = "push_id"; + } + if (StringUtils.isBlank(sortMode)) { + sortMode = "DESC"; + } + sb.append("ORDER BY a." + sortField + " " + sortMode); + return sb.toString(); + } + + /** + * 获取推送列表总数 + * + * @return + */ + public String getPushListDataAllCount() { + StringBuilder sb = new StringBuilder(); + sb.append("SELECT COUNT(1) "); + sb.append(" from tbl_push_list a"); + return sb.toString(); + } + } diff --git a/src/main/java/com/ifish/util/RedisKey.java b/src/main/java/com/ifish/util/RedisKey.java index 91a7269..0a98111 100644 --- a/src/main/java/com/ifish/util/RedisKey.java +++ b/src/main/java/com/ifish/util/RedisKey.java @@ -134,6 +134,11 @@ public class RedisKey { */ public static final String PUSHLIST_PUSHID = "pushlistE:id_"; + /** + * 后台推送列表缓存条件 + */ + public static final String PUSHLIST_SELECT = "pushlistE:se_"; + /** * 邮箱验证有效缓存key */ diff --git a/src/main/webapp/WEB-INF/layout/IndexPage.jsp b/src/main/webapp/WEB-INF/layout/IndexPage.jsp index c8ec031..0c34231 100644 --- a/src/main/webapp/WEB-INF/layout/IndexPage.jsp +++ b/src/main/webapp/WEB-INF/layout/IndexPage.jsp @@ -96,7 +96,7 @@