diff --git a/src/main/java/com/ifish/bean/LiveRoomPageInfo.java b/src/main/java/com/ifish/bean/LiveRoomPageInfo.java index a4687e1..e76fd56 100644 --- a/src/main/java/com/ifish/bean/LiveRoomPageInfo.java +++ b/src/main/java/com/ifish/bean/LiveRoomPageInfo.java @@ -48,6 +48,8 @@ public class LiveRoomPageInfo implements Serializable { private Integer pinglunNum; //点赞数量 private Integer zanNum; + //直播间展示图 + private String roomImg; public Integer getRoomId() { return roomId; @@ -177,4 +179,18 @@ public class LiveRoomPageInfo implements Serializable { this.zanNum = zanNum; } + /** + * @return the roomImg + */ + public String getRoomImg() { + return roomImg; + } + + /** + * @param roomImg the roomImg to set + */ + public void setRoomImg(String roomImg) { + this.roomImg = roomImg; + } + } diff --git a/src/main/java/com/ifish/bean/Tbl_Live_Room.java b/src/main/java/com/ifish/bean/Tbl_Live_Room.java index 723b43b..038861b 100644 --- a/src/main/java/com/ifish/bean/Tbl_Live_Room.java +++ b/src/main/java/com/ifish/bean/Tbl_Live_Room.java @@ -58,8 +58,9 @@ public class Tbl_Live_Room implements java.io.Serializable { private String roomDesc; /** - * */ - @Column(name = "room_img", nullable = true, length = 50) + * + */ + @Column(name = "room_img", nullable = true, length = 100) private String roomImg; /** @@ -84,7 +85,7 @@ public class Tbl_Live_Room implements java.io.Serializable { * 是否推荐 */ @Column(name = "is_tuijian", nullable = false, length = 1) - private Integer isTuijian; + private String isTuijian; /** * 推荐排序 @@ -96,7 +97,7 @@ public class Tbl_Live_Room implements java.io.Serializable { * 首次分享 */ @Column(name = "first_share", nullable = false, length = 1) - private Integer firstShare; + private String firstShare; /** * 获取直播间Id @@ -266,7 +267,7 @@ public class Tbl_Live_Room implements java.io.Serializable { * * @return 是否推荐 */ - public Integer getIsTuijian() { + public String getIsTuijian() { return this.isTuijian; } @@ -275,7 +276,7 @@ public class Tbl_Live_Room implements java.io.Serializable { * * @param isTuijian 是否推荐 */ - public void setIsTuijian(Integer isTuijian) { + public void setIsTuijian(String isTuijian) { this.isTuijian = isTuijian; } @@ -302,7 +303,7 @@ public class Tbl_Live_Room implements java.io.Serializable { * * @return 首次分享 */ - public Integer getFirstShare() { + public String getFirstShare() { return this.firstShare; } @@ -311,7 +312,7 @@ public class Tbl_Live_Room implements java.io.Serializable { * * @param firstShare 首次分享 */ - public void setFirstShare(Integer firstShare) { + public void setFirstShare(String firstShare) { this.firstShare = firstShare; } } diff --git a/src/main/java/com/ifish/bean/Tbl_Vender.java b/src/main/java/com/ifish/bean/Tbl_Vender.java index da691c8..c0a1010 100644 --- a/src/main/java/com/ifish/bean/Tbl_Vender.java +++ b/src/main/java/com/ifish/bean/Tbl_Vender.java @@ -24,7 +24,7 @@ public class Tbl_Vender implements java.io.Serializable { /** * 版本号 */ - private static final long serialVersionUID = -487543106603936914L; + private static final long serialVersionUID = 2462685903502867014L; /** * 鱼缸厂编号 @@ -33,13 +33,6 @@ public class Tbl_Vender implements java.io.Serializable { @Column(name = "brand_code", unique = true, nullable = false, length = 20) private String brandCode; - /** - * 电子厂代码 - */ - @Id - @Column(name = "factory_code", unique = true, nullable = false, length = 20) - private String factoryCode; - /** * logo */ @@ -106,24 +99,6 @@ public class Tbl_Vender implements java.io.Serializable { this.brandCode = brandCode; } - /** - * 获取电子厂代码 - * - * @return 电子厂代码 - */ - public String getFactoryCode() { - return this.factoryCode; - } - - /** - * 设置电子厂代码 - * - * @param factoryCode 电子厂代码 - */ - public void setFactoryCode(String factoryCode) { - this.factoryCode = factoryCode; - } - /** * 获取logo * diff --git a/src/main/java/com/ifish/controller/LiveRoom.java b/src/main/java/com/ifish/controller/LiveRoom.java index 74fdad5..2c9bb88 100644 --- a/src/main/java/com/ifish/controller/LiveRoom.java +++ b/src/main/java/com/ifish/controller/LiveRoom.java @@ -104,4 +104,21 @@ public class LiveRoom { } return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); } + + /** + * 修改直播间 + * + * @param fileUpload + * @param liveRoom + * @return + */ + @RequestMapping(value = "/liveRoom/v3/updateLiveRoom.do", method = RequestMethod.GET) + public Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom) { + try { + return liveRoomHelperI.updateLiveRoom(fileUpload, liveRoom); + } catch (Exception e) { + } + return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); + } + } diff --git a/src/main/java/com/ifish/helper/DeviceHelper.java b/src/main/java/com/ifish/helper/DeviceHelper.java index 17181d1..83f2f76 100644 --- a/src/main/java/com/ifish/helper/DeviceHelper.java +++ b/src/main/java/com/ifish/helper/DeviceHelper.java @@ -14,7 +14,6 @@ import com.ifish.enums.PushTypeEnum; import com.ifish.enums.ResultEnum; import com.ifish.mapper.Tbl_Device_Mapper; import com.ifish.util.IfishUtil; -import com.ifish.util.RedisKey; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -33,6 +32,9 @@ public class DeviceHelper implements DeviceHelperI { @Autowired private RedisHelperI redisHelperI; + @Autowired + private RedisKeyHelperI redisKeyHelperI; + @Autowired private Tbl_Device_Mapper tbl_Device_Mapper; @@ -48,7 +50,7 @@ public class DeviceHelper implements DeviceHelperI { @Override public List getDeviceUsersByUserId(Integer userId) throws Exception { List deviceUserList = null; - String key = RedisKey.DeviceUser_Key + userId; + String key = redisKeyHelperI.getListTbl_Device_UserKeyByUserId(userId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { deviceUserList = (List) IfishUtil.JsonToList(redisString, Tbl_Device_User.class); @@ -71,7 +73,7 @@ public class DeviceHelper implements DeviceHelperI { */ public Tbl_Device_User getDeviceUserByUserId_DeviceId(Integer userId, Integer deviceId) throws Exception { Tbl_Device_User device = null; - String key = RedisKey.DeviceUser_Key + "d" + deviceId + "_u" + userId; + String key = redisKeyHelperI.getTbl_Device_UserRedisKeyByDeviceIdAndUserId(userId, deviceId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { device = (Tbl_Device_User) IfishUtil.JsonToBean(redisString, Tbl_Device_User.class); @@ -111,7 +113,7 @@ public class DeviceHelper implements DeviceHelperI { @Override public Tbl_Device getDeviceById(Integer deviceId) throws Exception { Tbl_Device device = null; - String key = RedisKey.Device_key + deviceId; + String key = redisKeyHelperI.getTbl_DeviceRedisKeyByDeviceId(deviceId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class); @@ -134,7 +136,7 @@ public class DeviceHelper implements DeviceHelperI { @Override public Tbl_Device getDeviceByCameraId(String cameraId) throws Exception { Tbl_Device device = null; - String key = RedisKey.Camera_key + cameraId; + String key = redisKeyHelperI.getTbl_CameraRedisKeyByCameraId(cameraId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class); @@ -157,7 +159,7 @@ public class DeviceHelper implements DeviceHelperI { @Override public Tbl_Device getDeviceByMacAddress(String macAddress) throws Exception { Tbl_Device device = null; - String key = RedisKey.Device_key + macAddress; + String key = redisKeyHelperI.getTbl_DeviceRedisKeyByMacAddress(macAddress); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class); @@ -179,7 +181,7 @@ public class DeviceHelper implements DeviceHelperI { */ public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception { Tbl_Device_Statistics device = null; - String key = RedisKey.DeviceStatistic_key + deviceId; + String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByDeviceId(deviceId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { device = (Tbl_Device_Statistics) IfishUtil.JsonToBean(redisString, Tbl_Device_Statistics.class); @@ -461,15 +463,13 @@ public class DeviceHelper implements DeviceHelperI { try { Tbl_Device_User olDevice_User = getDeviceUserByUserId_DeviceId(device.getUserId(), device.getDeviceId()); - String key = RedisKey.DeviceUser_Key + device.getUserId(); - String key2 = RedisKey.DeviceUser_Key + "d" + device.getDeviceId() + "_u" + device.getUserId(); + if (device != null) { if (olDevice_User != null) { device.setId(olDevice_User.getId()); int i = tbl_Device_Mapper.updateTblDeviceUser(device); if (i > 0) { - redisHelperI.deleteRedis(key); - redisHelperI.deleteRedis(key2); + redisKeyHelperI.deleteRedisByTbl_Device_User(device); Tbl_Device device1 = getDeviceById(device.getDeviceId()); return IfishUtil.returnJson(ResultEnum.success.getKey(), userHelperI.getDeviceInfo(device1, device)); } @@ -496,13 +496,11 @@ public class DeviceHelper implements DeviceHelperI { Tbl_Device_User olDevice_User = getDeviceUserByUserId_CameraId(device_User.getUserId(), cameraId.toString()); if (olDevice_User != null) { if (olDevice_User != null) { - String key = RedisKey.DeviceUser_Key + device_User.getUserId(); - String key2 = RedisKey.DeviceUser_Key + "d" + olDevice_User.getDeviceId() + "_u" + device_User.getUserId(); + device_User.setId(olDevice_User.getId()); int i = tbl_Device_Mapper.updateTblDeviceUser(device_User); if (i > 0) { - redisHelperI.deleteRedis(key); - redisHelperI.deleteRedis(key2); + redisKeyHelperI.deleteRedisByTbl_Device_User(device_User); Map dataMap = new HashMap(); dataMap.put("cameraId", cameraId); dataMap.put("showName", device_User.getShowName()); @@ -536,10 +534,7 @@ public class DeviceHelper implements DeviceHelperI { if (device_User != null) { int i = tbl_Device_Mapper.deleteDeviceUserById(device_User.getId()); if (i > 0) { - String key = RedisKey.DeviceUser_Key + device_User.getUserId(); - String key2 = RedisKey.DeviceUser_Key + "d" + device_User.getDeviceId() + "_u" + device_User.getUserId(); - redisHelperI.deleteRedis(key); - redisHelperI.deleteRedis(key2); + redisKeyHelperI.deleteRedisByTbl_Device_User(device_User); return IfishUtil.returnJson(ResultEnum.success.getKey(), ""); } } @@ -562,12 +557,9 @@ public class DeviceHelper implements DeviceHelperI { if (device_User != null) { int i = tbl_Device_Mapper.deleteDeviceUserById(device_User.getId()); if (i > 0) { - String key = RedisKey.DeviceUser_Key + device_User.getUserId(); - String key2 = RedisKey.DeviceUser_Key + "d" + device_User.getDeviceId() + "_u" + device_User.getUserId(); - String key3 = RedisKey.Camera_key + cameraId; - redisHelperI.deleteRedis(key); - redisHelperI.deleteRedis(key2); - redisHelperI.deleteRedis(key3); + Tbl_Device device = getDeviceByCameraId(cameraId); + redisKeyHelperI.deleteRedisByTbl_Device(device); + redisKeyHelperI.deleteRedisByTbl_Device_User(device_User); return IfishUtil.returnJson(ResultEnum.success.getKey(), ""); } } diff --git a/src/main/java/com/ifish/helper/HardWareTypeHelper.java b/src/main/java/com/ifish/helper/HardWareTypeHelper.java index c293548..7216357 100644 --- a/src/main/java/com/ifish/helper/HardWareTypeHelper.java +++ b/src/main/java/com/ifish/helper/HardWareTypeHelper.java @@ -9,7 +9,6 @@ import com.ifish.bean.Tbl_HardWare_Type; import com.ifish.bean.Tbl_Vender; import com.ifish.mapper.Tbl_Hardware_Type_Mapper; import com.ifish.util.IfishUtil; -import com.ifish.util.RedisKey; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -33,10 +32,13 @@ public class HardWareTypeHelper implements HardWareTypeHelperI { @Autowired private RedisHelperI redisHelperI; + @Autowired + private RedisKeyHelperI redisKeyHelperI; + @Override public Tbl_HardWare_Type getHardwareTypeByTypeCode(String code) throws Exception { Tbl_HardWare_Type hardwareType = null; - String key = RedisKey.HardWareType_key + code; + String key = redisKeyHelperI.getTbl_HardWare_TypeRedisKeyByTypeCode(code); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { hardwareType = (Tbl_HardWare_Type) IfishUtil.JsonToBean(redisString, Tbl_HardWare_Type.class); @@ -52,7 +54,7 @@ public class HardWareTypeHelper implements HardWareTypeHelperI { @Override public Tbl_Vender getVenderListByBrandCode(String code) throws Exception { Tbl_Vender venderList = new Tbl_Vender(); - String key = RedisKey.VenderList_key + code; + String key = redisKeyHelperI.getTbl_Vender_ListRedisKeyByCode(code); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { venderList = (Tbl_Vender) IfishUtil.JsonToBean(redisString, Tbl_Vender.class); @@ -63,4 +65,3 @@ public class HardWareTypeHelper implements HardWareTypeHelperI { return venderList; } } - diff --git a/src/main/java/com/ifish/helper/LiveRoomHelper.java b/src/main/java/com/ifish/helper/LiveRoomHelper.java index 17bfd88..684ebe5 100644 --- a/src/main/java/com/ifish/helper/LiveRoomHelper.java +++ b/src/main/java/com/ifish/helper/LiveRoomHelper.java @@ -7,7 +7,6 @@ package com.ifish.helper; import com.ifish.Interceptor.IfishException; import com.ifish.bean.LiveRoomPageInfo; -import com.ifish.bean.PageResult; import com.ifish.bean.Tbl_Device_User; import com.ifish.bean.Tbl_Live_Message; import com.ifish.bean.Tbl_Live_Room; @@ -15,7 +14,6 @@ import com.ifish.bean.Tbl_User; import com.ifish.enums.ResultEnum; import com.ifish.mapper.Tbl_Live_Room_Mapper; import com.ifish.util.IfishUtil; -import com.ifish.util.RedisKey; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -48,6 +46,9 @@ public class LiveRoomHelper implements LiveRoomHelperI { @Autowired private RedisHelperI redisHelperI; + @Autowired + private RedisKeyHelperI redisKeyHelperI; + /** * 新增直播间 * @@ -73,7 +74,7 @@ public class LiveRoomHelper implements LiveRoomHelperI { throw new IfishException(ResultEnum.error401); } if (fileUpload == null || fileUpload.getSize() > 1048576) { - //throw new IfishException(ResultEnum.warn206); + throw new IfishException(ResultEnum.warn205); } String file = fastDFSClientI.uploadFileToFastDFS(fileUpload); if (StringUtils.isNotBlank(file)) { @@ -101,7 +102,7 @@ public class LiveRoomHelper implements LiveRoomHelperI { } //新增直播间 liveRoom.setCreateTime(new Date()); - liveRoom.setFirstShare(0); + liveRoom.setFirstShare("0"); liveRoom.setPopularityValue(0); int i = tbl_Live_Room_Mapper.insertLiveRoom(liveRoom); if (i > 0) { @@ -112,6 +113,7 @@ public class LiveRoomHelper implements LiveRoomHelperI { map.put("cameraId", cameraId); map.put("isLive", cameraUser.getIsLive()); map.put("roomId", liveRoom.getRoomId()); + map.put("roomImg", liveRoom.getRoomImg()); return IfishUtil.returnJson(ResultEnum.success.getKey(), map); } return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); @@ -129,7 +131,7 @@ public class LiveRoomHelper implements LiveRoomHelperI { */ public Tbl_Live_Room getLive_RoomById(Integer roomId) throws Exception { Tbl_Live_Room live_Room = null; - String key = RedisKey.LiveRoom_key + roomId; + String key = redisKeyHelperI.getTbl_Live_RoomRedisKeyByRoomId(roomId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { live_Room = (Tbl_Live_Room) IfishUtil.JsonToBean(redisString, Tbl_Live_Room.class); @@ -150,7 +152,7 @@ public class LiveRoomHelper implements LiveRoomHelperI { */ public Tbl_Live_Room getLive_RoomByUserId(Integer userId) throws Exception { Tbl_Live_Room live_Room = null; - String key = RedisKey.LiveRoom_key + "u_" + userId; + String key = redisKeyHelperI.getTbl_Live_RoomRedisKeyByUserId(userId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { live_Room = (Tbl_Live_Room) IfishUtil.JsonToBean(redisString, Tbl_Live_Room.class); @@ -171,7 +173,7 @@ public class LiveRoomHelper implements LiveRoomHelperI { */ public Tbl_Live_Room getTbl_Live_RoomById(Integer roomId) throws Exception { Tbl_Live_Room device = null; - String key = RedisKey.LiveRoom_key + roomId; + String key = redisKeyHelperI.getTbl_Live_RoomRedisKeyByRoomId(roomId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { device = (Tbl_Live_Room) IfishUtil.JsonToBean(redisString, Tbl_Live_Room.class); @@ -307,6 +309,7 @@ public class LiveRoomHelper implements LiveRoomHelperI { map.put("roomDesc", curLiveRoom.getRoomDesc()); map.put("popularityValue", curLiveRoom.getPopularityValue()); map.put("roomStatus", curLiveRoom.getRoomStatus()); + map.put("roomImg", curLiveRoom.getRoomImg()); return IfishUtil.toJson(ResultEnum.success.getKey(), map); } } @@ -332,13 +335,13 @@ public class LiveRoomHelper implements LiveRoomHelperI { if (firstResult != null && pageSize != null) { Map returnMap = new HashMap(); List timeList = new ArrayList(); - if (orders.equals("renqi")) { - timeList = tbl_Live_Room_Mapper.getLiveRoomListByCreateTime(pageSize, firstResult); + if (orders != null && orders.equals("renqi")) { + timeList = tbl_Live_Room_Mapper.getLiveRoomListByRenqi(pageSize, firstResult); } else { timeList = tbl_Live_Room_Mapper.getLiveRoomListByCreateTime(pageSize, firstResult); } Integer count = 0; - String key = RedisKey.LIVEROOM_COUNT_KEY; + String key = redisKeyHelperI.getTbl_Live_Room_CountRedisKey(); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { count = Integer.parseInt(redisString); @@ -357,4 +360,32 @@ public class LiveRoomHelper implements LiveRoomHelperI { } } + + /** + * 修改直播间 + * + * @param fileUpload + * @param liveRoom + * @return + */ + @Override + public Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom) { + + try { + if (fileUpload != null && fileUpload.getSize() <= 1048576) { + String file = fastDFSClientI.uploadFileToFastDFS(fileUpload); + if (StringUtils.isNotBlank(file)) { + liveRoom.setRoomImg(file); + } + } + int i = tbl_Live_Room_Mapper.updateLiveRoom(liveRoom); + if (i > 0) { + redisKeyHelperI.deleteRedisByTbl_Live_Room(liveRoom); + Tbl_Live_Room live = getLive_RoomById(liveRoom.getRoomId()); + return IfishUtil.toJson(ResultEnum.success.getKey(), live); + } + } catch (Exception e) { + } + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } } diff --git a/src/main/java/com/ifish/helper/LiveRoomHelperI.java b/src/main/java/com/ifish/helper/LiveRoomHelperI.java index d2cf60e..c8bf5ff 100644 --- a/src/main/java/com/ifish/helper/LiveRoomHelperI.java +++ b/src/main/java/com/ifish/helper/LiveRoomHelperI.java @@ -59,4 +59,13 @@ public interface LiveRoomHelperI { * @return */ Object getLiveRooms(Integer firstResult, Integer pageSize, String orders); + + /** + * 修改直播间 + * + * @param fileUpload + * @param liveRoom + * @return + */ + Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom); } diff --git a/src/main/java/com/ifish/helper/PushMessageHelper.java b/src/main/java/com/ifish/helper/PushMessageHelper.java index 93e3e9b..5b40f0b 100644 --- a/src/main/java/com/ifish/helper/PushMessageHelper.java +++ b/src/main/java/com/ifish/helper/PushMessageHelper.java @@ -10,7 +10,6 @@ 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 com.ifish.util.RedisKey; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -29,6 +28,9 @@ public class PushMessageHelper implements PushMessageHelperI { @Autowired private RedisHelperI redisHelperI; + @Autowired + private RedisKeyHelperI redisKeyHelperI; + /** * 根据条件获取推送列表 * @@ -95,7 +97,7 @@ public class PushMessageHelper implements PushMessageHelperI { */ public Tbl_Push_List getPush_ListById(Integer pushId) throws Exception { Tbl_Push_List list = null; - String key = RedisKey.PUSHLIST_KEY + pushId; + String key = redisKeyHelperI.getTbl_Push_List_RedisByPushId(pushId); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { list = (Tbl_Push_List) IfishUtil.JsonToBean(redisString, Tbl_Push_List.class); diff --git a/src/main/java/com/ifish/helper/RedisKeyHelper.java b/src/main/java/com/ifish/helper/RedisKeyHelper.java new file mode 100644 index 0000000..6471ee5 --- /dev/null +++ b/src/main/java/com/ifish/helper/RedisKeyHelper.java @@ -0,0 +1,272 @@ +/* + * 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.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_Room; +import com.ifish.bean.Tbl_User; +import com.ifish.util.RedisKey; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * + * @author Administrator + */ +@Component +public class RedisKeyHelper implements RedisKeyHelperI { + + @Autowired + private RedisHelperI redisHelperI; + + /** + * 根据userId获取Tbl_User用户信息的Redis缓存key键值 + * + * @param userId + * @return + */ + @Override + public String getTbl_UserRedisKeyByUserId(Integer userId) { + return RedisKey.USER_ID_KEY + userId; + } + + /** + * 根据mac地址获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_DeviceRedisKeyByMacAddress(String macAddress) { + return RedisKey.DEVICE_KEY_MACADDRESS + macAddress; + } + + /** + * 根据摄像头Id获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_CameraRedisKeyByCameraId(String CameraId) { + return RedisKey.DEVICE_KEY_CAMERAID + CameraId; + } + + /** + * 根据Id获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_DeviceRedisKeyByDeviceId(Integer deviceId) { + return RedisKey.DEVICE_KEY_DEVICEID + deviceId; + } + + /** + * 根据设备ID和用户ID获取Tbl_Device_User的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + @Override + public String getTbl_Device_UserRedisKeyByDeviceIdAndUserId(Integer userId, Integer deviceId) { + return RedisKey.DEVICE_USER_DEVICEID_AND_USERID + "u_" + userId + "_d_" + deviceId; + } + + /** + * 根据设备ID获取Tbl_Device_User(列表)的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + @Override + public String getListTbl_Device_UserKeyByDeviceId(Integer deviceId) { + return RedisKey.DEVICE_USER_LIST_DEVICEID + deviceId; + } + + /** + * 根据用户ID获取Tbl_Device_User(列表)的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + @Override + public String getListTbl_Device_UserKeyByUserId(Integer userId) { + return RedisKey.DEVICE_USER_LIST_USERID + userId; + } + + /** + * 根据mac地址获取Tbl_Device_Statistics的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_Device_StatisticsRedisKeyByMacAddress(String macAddress) { + return RedisKey.DEVICE_STATISTICS_MACADDRESS + macAddress; + } + + /** + * 根据Id获取Tbl_Device_Statistics的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_Device_StatisticsRedisKeyByDeviceId(Integer deviceId) { + return RedisKey.DEVICE_STATISTICS_DEVICEID + deviceId; + } + + /** + * 根据typeCode获取Tbl_HardWare_Type的redis缓存key键值 + * + * @param typeCode + * @return + */ + @Override + public String getTbl_HardWare_TypeRedisKeyByTypeCode(String typeCode) { + return RedisKey.HARD_WARE_TYPE + typeCode; + } + + /** + * 根据brandCode获取Tbl_Vender_list的redis缓存key键值 + * + * @param brandCode + * @return + */ + @Override + public String getTbl_Vender_ListRedisKeyByCode(String brandCode) { + return RedisKey.VENDER_CODE + brandCode; + } + + /** + * 根据直播间Id获取Tbl_Live_Room的redis缓存key键值 + * + * @param roomId + * @return + */ + @Override + public String getTbl_Live_RoomRedisKeyByRoomId(Integer roomId) { + return RedisKey.LIVEROOM_ROOMID + roomId; + } + + /** + * 根据用户Id获取Tbl_Live_Room的redis缓存key键值 + * + * @param roomId + * @return + */ + @Override + public String getTbl_Live_RoomRedisKeyByUserId(Integer User) { + return RedisKey.LIVEROOM_USERID + User; + } + + /** + * 获取所有开启直播间总数量的redis缓存key键值 + * + * @return + */ + @Override + public String getTbl_Live_Room_CountRedisKey() { + return RedisKey.LIVEROOM_COUNT; + } + + /** + * 根据pushId获取Tbl_push_list的redis缓存key键值 + * + * @param pushId + * @return + */ + @Override + public String getTbl_Push_List_RedisByPushId(Integer pushId) { + return RedisKey.PUSHLIST_PUSHID + pushId; + } + + /** + * 删除redis中某个设备详情Tbl_Device的缓存 + * + * @param device + * @return + */ + @Override + public void deleteRedisByTbl_Device(Tbl_Device 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())); + } + if (StringUtils.isNotBlank(device.getCameraId())) { + redisHelperI.deleteRedis(getTbl_CameraRedisKeyByCameraId(device.getCameraId())); + } + } + + /** + * 删除redis中某个设备统计信息Tbl_Device_Statistics的缓存 + * + * @param device + * @return + */ + @Override + public void deleteRedisByTbl_Device_Statistics(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())); + } + } + + /** + * 删除redis中某个设备和用户关系Tbl_Device_User的缓存 + * + * @param tbl_Device_User + */ + @Override + public void deleteRedisByTbl_Device_User(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())); + } + } + + /** + * 删除redis中某个用户Tbl_User的缓存 + * + * @param tbl_User + */ + @Override + public void deleteRedisByTbl_User(Tbl_User tbl_User) { + if (tbl_User.getUserId() != null && tbl_User.getUserId() > 0) { + redisHelperI.deleteRedis(getTbl_UserRedisKeyByUserId(tbl_User.getUserId())); + } + } + + /** + * 删除redis中某个直播间Tbl_Live_Room的缓存 + * + * @param live_Room + */ + @Override + public void deleteRedisByTbl_Live_Room(Tbl_Live_Room live_Room) { + if (live_Room.getRoomId() != null && live_Room.getRoomId() > 0) { + redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByRoomId(live_Room.getRoomId())); + } + if (live_Room.getUserId() != null && live_Room.getUserId() > 0) { + redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByUserId(live_Room.getUserId())); + } + } + +} diff --git a/src/main/java/com/ifish/helper/RedisKeyHelperI.java b/src/main/java/com/ifish/helper/RedisKeyHelperI.java new file mode 100644 index 0000000..446e268 --- /dev/null +++ b/src/main/java/com/ifish/helper/RedisKeyHelperI.java @@ -0,0 +1,178 @@ +/* + * 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.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_Room; +import com.ifish.bean.Tbl_User; + +/** + * + * @author Administrator + */ +public interface RedisKeyHelperI { + + /** + * 根据userId获取Tbl_User用户信息的Redis缓存key键值 + * + * @param userId + * @return + */ + public String getTbl_UserRedisKeyByUserId(Integer userId); + + /** + * 根据mac地址获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_DeviceRedisKeyByMacAddress(String macAddress); + + /** + * 根据摄像头Id获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_CameraRedisKeyByCameraId(String CameraId); + + /** + * 根据Id获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_DeviceRedisKeyByDeviceId(Integer deviceId); + + /** + * 根据mac地址获取Tbl_Device_Statistics的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_Device_StatisticsRedisKeyByMacAddress(String macAddress); + + /** + * 根据Id获取Tbl_Device_Statistics的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_Device_StatisticsRedisKeyByDeviceId(Integer deviceId); + + /** + * 根据设备ID和用户ID获取Tbl_Device_User的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + public String getTbl_Device_UserRedisKeyByDeviceIdAndUserId(Integer userId, Integer deviceId); + + /** + * 根据设备ID获取Tbl_Device_User(列表)的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + public String getListTbl_Device_UserKeyByDeviceId(Integer deviceId); + + /** + * 根据用户ID获取Tbl_Device_User(列表)的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + public String getListTbl_Device_UserKeyByUserId(Integer userId); + + /** + * 根据typeCode获取Tbl_HardWare_Type的redis缓存key键值 + * + * @param typeCode + * @return + */ + public String getTbl_HardWare_TypeRedisKeyByTypeCode(String typeCode); + + /** + * 根据brandCode获取Tbl_Vender_list的redis缓存key键值 + * + * @param brandCode + * @return + */ + public String getTbl_Vender_ListRedisKeyByCode(String brandCode); + + /** + * 根据直播间Id获取Tbl_Live_Room的redis缓存key键值 + * + * @param roomId + * @return + */ + public String getTbl_Live_RoomRedisKeyByRoomId(Integer roomId); + + /** + * 根据用户Id获取Tbl_Live_Room的redis缓存key键值 + * + * @param roomId + * @return + */ + public String getTbl_Live_RoomRedisKeyByUserId(Integer User); + + /** + * 获取所有开启直播间总数量的redis缓存key键值 + * + * @return + */ + public String getTbl_Live_Room_CountRedisKey(); + + /** + * 根据pushId获取Tbl_push_list的redis缓存key键值 + * + * @param pushId + * @return + */ + public String getTbl_Push_List_RedisByPushId(Integer pushId); + + /** + * 删除redis中某个设备详情的缓存 + * + * @param device + * @return + */ + public void deleteRedisByTbl_Device(Tbl_Device device); + + /** + * 删除redis中某个设备统计信息Tbl_Device_Statistics的缓存 + * + * @param device + * @return + */ + public void deleteRedisByTbl_Device_Statistics(Tbl_Device_Statistics device); + + /** + * 删除redis中某个设备和用户关系Tbl_Device_User的缓存 + * + * @param tbl_Device_User + */ + public void deleteRedisByTbl_Device_User(Tbl_Device_User tbl_Device_User); + + /** + * 删除redis中某个用户Tbl_User的缓存 + * + * @param tbl_User + */ + public void deleteRedisByTbl_User(Tbl_User tbl_User); + + /** + * 删除redis中某个直播间Tbl_Live_Room的缓存 + * + * @param live_Room + */ + public void deleteRedisByTbl_Live_Room(Tbl_Live_Room live_Room); +} diff --git a/src/main/java/com/ifish/helper/UserHelper.java b/src/main/java/com/ifish/helper/UserHelper.java index 703f4e8..c83cdb0 100644 --- a/src/main/java/com/ifish/helper/UserHelper.java +++ b/src/main/java/com/ifish/helper/UserHelper.java @@ -16,7 +16,6 @@ import com.ifish.enums.ResultEnum; import com.ifish.mapper.Tbl_Hardware_Type_Mapper; import com.ifish.mapper.Tbl_User_Mapper; import com.ifish.util.IfishUtil; -import com.ifish.util.RedisKey; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -50,6 +49,9 @@ public class UserHelper implements UserHelperI { @Autowired private HardWareTypeHelperI hardWareTypeHelperI; + @Autowired + private RedisKeyHelperI redisKeyHelperI; + /** * 登陆接口 * @@ -90,7 +92,7 @@ public class UserHelper implements UserHelperI { @Override public Tbl_User getUserById(Integer userId) throws Exception { Tbl_User tmpUser = null; - String userKey = RedisKey.User_Key + userId; + String userKey = redisKeyHelperI.getTbl_UserRedisKeyByUserId(userId); String userString = redisHelperI.getRedis(userKey); //1.从数据库或缓存中读取用户对象 if (StringUtils.isNotBlank(userString)) { @@ -466,7 +468,7 @@ public class UserHelper implements UserHelperI { * @param user */ private void saveUserToRedis(Tbl_User user) throws Exception { - String key = RedisKey.User_Key + user.getUserId(); + String key = redisKeyHelperI.getTbl_UserRedisKeyByUserId(user.getUserId()); redisHelperI.setRedis(key, IfishUtil.ObjectToJson(user)); } diff --git a/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java index 4096535..975a74e 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java +++ b/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java @@ -121,6 +121,16 @@ public interface Tbl_Device_Mapper { + "upgrade_time,authorize_time,create_code,MCU_count,module_count,router_count,server_count,server_try_count,software_version,hardware_type,factory_code,brand_code FROM tbl_device_statistics WHERE device_id=#{deviceid}") Tbl_Device_Statistics getDevStatisticsByDeviceId(@Param("deviceid") Integer deviceid); + /** + * 根据设备ID查询设备统计信息 + * + * @param deviceid + * @return + */ + @Select("SELECT id,device_id,mac_address,login_count,login_time,first_activate,create_time,is_charge,sdk_version,sdk_time,create_date,is_upgrade,upgrade_version," + + "upgrade_time,authorize_time,create_code,MCU_count,module_count,router_count,server_count,server_try_count,software_version,hardware_type,factory_code,brand_code FROM tbl_device_statistics WHERE mac_address=#{mac}") + Tbl_Device_Statistics getDevStatisticsByMacAddress(@Param("mac") String macAddress); + /** * 插入一条设备统计信息 * @@ -195,5 +205,5 @@ public interface Tbl_Device_Mapper { */ @Update("UPDATE tbl_activa_code set is_used='1' WHERE active_code = #{code}") Integer updateTblActivaCodeIsUse(@Param("code") String activa_Code); - + } diff --git a/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java b/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java index 77eb599..8e60486 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java +++ b/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java @@ -87,13 +87,13 @@ public class Tbl_Device_MapperSql { sb.append("UPDATE tbl_device_statistics SET "); - if (device_Statistics.getDeviceId() > 0) { + if (device_Statistics.getDeviceId() != null && device_Statistics.getDeviceId() > 0) { sb.append("device_id = #{deviceStatistics.deviceId}, "); } if (StringUtils.isNotBlank(device_Statistics.getMacAddress())) { sb.append("mac_address = #{deviceStatistics.macAddress}, "); } - if (device_Statistics.getLoginCount() > 0) { + if (device_Statistics.getLoginCount() != null && device_Statistics.getLoginCount() > 0) { sb.append("login_count = #{deviceStatistics.loginCount}, "); } if (device_Statistics.getLoginTime() != null && StringUtils.isNotBlank(device_Statistics.getLoginTime().toString())) { diff --git a/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java index df026b8..c28dd9c 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java +++ b/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java @@ -14,6 +14,7 @@ import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.SelectKey; +import org.apache.ibatis.annotations.UpdateProvider; /** * @@ -24,8 +25,8 @@ public interface Tbl_Live_Room_Mapper { /** * 建立一个直播间 */ - @Insert("INSERT INTO tbl_live_room (user_id,camera_id,room_name,room_desc,room_status,popularity_value,create_time,is_tuijian,tuijian_num,first_share) VALUES(" - + "#{liveroom.userId},#{liveroom.cameraId},#{liveroom.roomName},#{liveroom.roomDesc},#{liveroom.roomStatus},#{liveroom.popularityValue},now(),#{liveroom.isTuijian},#{liveroom.tuijianNum},#{liveroom.firstShare})") + @Insert("INSERT INTO tbl_live_room (user_id,camera_id,room_name,room_desc,room_status,popularity_value,create_time,is_tuijian,tuijian_num,first_share,room_Img) VALUES(" + + "#{liveroom.userId},#{liveroom.cameraId},#{liveroom.roomName},#{liveroom.roomDesc},#{liveroom.roomStatus},#{liveroom.popularityValue},now(),#{liveroom.isTuijian},#{liveroom.tuijianNum},#{liveroom.firstShare},#{liveroom.roomImg})") @SelectKey(statement = "select @@IDENTITY as room_id", keyProperty = "liveroom.roomId", keyColumn = "room_id", before = false, resultType = int.class) Integer insertLiveRoom(@Param("liveroom") Tbl_Live_Room liveRoom); @@ -45,7 +46,7 @@ public interface Tbl_Live_Room_Mapper { * @param UserId * @return */ - @Select("SELECT room_id,user_id,camera_id,room_name,room_desc,room_status,popularity_value,is_tuijian,tuijian_num,first_share FROM TBL_LIVE_ROOM WHERE user_id = #{userid}") + @Select("SELECT room_id,user_id,camera_id,room_name,room_desc,room_status,popularity_value,is_tuijian,tuijian_num,first_share,room_Img FROM TBL_LIVE_ROOM WHERE user_id = #{userid}") Tbl_Live_Room getLive_RoomByUserId(@Param("userid") Integer UserId); /** @@ -93,7 +94,7 @@ public interface Tbl_Live_Room_Mapper { * @param roomid * @return */ - @Select("SELECT ROOM_ID,USER_ID,CAMERA_ID,ROOM_NAME,ROOM_DESC,ROOM_STATUS,POPULARITY_VALUE,CREATE_TIME,IS_TUIJIAN,TUIJIAN_NUM,FIRST_SHARE FROM TBL_LIVE_ROOM WHERE ROOM_ID = #{roomid}") + @Select("SELECT ROOM_ID,USER_ID,CAMERA_ID,ROOM_NAME,ROOM_DESC,ROOM_STATUS,POPULARITY_VALUE,CREATE_TIME,IS_TUIJIAN,TUIJIAN_NUM,FIRST_SHARE,room_Img FROM TBL_LIVE_ROOM WHERE ROOM_ID = #{roomid}") Tbl_Live_Room getTbl_Live_RoomById(@Param("roomid") Integer roomid); /** @@ -104,12 +105,13 @@ public interface Tbl_Live_Room_Mapper { * @return */ @Select("select l.room_id AS roomId,u.user_id AS userId,u.user_type AS userType,u.nick_name AS nickName,u.user_img AS userImg,u.login_time AS loginTime,l.create_time AS createTime," - + "td.camera_id AS cameraId,l.room_name AS roomName,l.room_desc AS roomDesc,l.popularity_value AS popularityValue,\n" - + "(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays " + + "td.camera_id AS cameraId,l.room_name AS roomName,l.room_desc AS roomDesc,l.popularity_value AS popularityValue,l.room_Img AS roomImg," + + "(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,count(lm.message_id) AS pinglunNum " + "from tbl_user u " + "LEFT JOIN tbl_device_user c ON u.user_id=c.user_id " + "LEFT JOIN tbl_device td ON c.device_id = td.device_id " + "LEFT JOIN tbl_live_room l ON u.user_id=l.user_id " + + "LEFT JOIN tbl_live_message lm ON l.room_id = lm.room_id " + "where td.is_camera = '1' ORDER BY l.create_time DESC LIMIT ${first},${pagesize}") List getLiveRoomListByCreateTime(@Param("pagesize") Integer pageSize, @Param("first") Integer FirstResult); @@ -121,12 +123,13 @@ public interface Tbl_Live_Room_Mapper { * @return */ @Select("select l.room_id AS roomId,u.user_id AS userId,u.user_type AS userType,u.nick_name AS nickName,u.user_img AS userImg,u.login_time AS loginTime,l.create_time AS createTime," - + "td.camera_id AS cameraId,l.room_name AS roomName,l.room_desc AS roomDesc,l.popularity_value AS popularityValue,\n" - + "(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays " + + "td.camera_id AS cameraId,l.room_name AS roomName,l.room_desc AS roomDesc,l.popularity_value AS popularityValue,l.room_Img AS roomImg," + + "(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,count(lm.message_id) AS pinglunNum " + "from tbl_user u " + "LEFT JOIN tbl_device_user c ON u.user_id=c.user_id " + "LEFT JOIN tbl_device td ON c.device_id = td.device_id " + "LEFT JOIN tbl_live_room l ON u.user_id=l.user_id " + + "LEFT JOIN tbl_live_message lm ON l.room_id = lm.room_id " + "where td.is_camera = '1' ORDER BY l.popularity_value DESC LIMIT ${first},${pagesize}") List getLiveRoomListByRenqi(@Param("pagesize") Integer pageSize, @Param("first") Integer FirstResult); @@ -142,4 +145,12 @@ public interface Tbl_Live_Room_Mapper { + "where td.is_camera = '1'") Integer getLiveRoomListCount(); + /** + * 修改直播间信息 + * + * @param live_Room + * @return + */ + @UpdateProvider(type = Tbl_Live_Room_MapperSql.class, method = "updateLiveRoom") + Integer updateLiveRoom(@Param("live") Tbl_Live_Room live_Room); } diff --git a/src/main/java/com/ifish/mapper/Tbl_Live_Room_MapperSql.java b/src/main/java/com/ifish/mapper/Tbl_Live_Room_MapperSql.java new file mode 100644 index 0000000..aff324c --- /dev/null +++ b/src/main/java/com/ifish/mapper/Tbl_Live_Room_MapperSql.java @@ -0,0 +1,64 @@ +/* + * 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.mapper; + +import com.ifish.bean.Tbl_Live_Room; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.annotations.Param; + +/** + * + * @author Administrator + */ +public class Tbl_Live_Room_MapperSql { + + /** + * 修改直播间信息 + * + * @param live_Room + * @return + */ + public String updateLiveRoom(@Param("live") Tbl_Live_Room live_Room) { + StringBuilder sb = new StringBuilder(); + + sb.append("UPDATE TBL_LIVE_ROOM SET "); + + if (StringUtils.isNotBlank(live_Room.getCameraId())) { + sb.append("camera_id = #{live.cameraId}, "); + } + if (StringUtils.isNotBlank(live_Room.getFirstShare())) { + sb.append("first_share = #{live.firstShare}, "); + } + if (StringUtils.isNotBlank(live_Room.getRoomDesc())) { + sb.append("room_desc = #{live.roomDesc}, "); + } + if (StringUtils.isNotBlank(live_Room.getRoomImg())) { + sb.append("room_img = #{live.roomImg}, "); + } + if (StringUtils.isNotBlank(live_Room.getRoomName())) { + sb.append("room_name = #{live.roomName}, "); + } + if (StringUtils.isNotBlank(live_Room.getRoomStatus())) { + sb.append("room_status = #{live.roomStatus}, "); + } + if (StringUtils.isNotBlank(live_Room.getIsTuijian())) { + sb.append("is_tuijian = #{live.isTuijian}, "); + } + if (live_Room.getPopularityValue() != null && live_Room.getPopularityValue() >= 0) { + sb.append("popularity_value = #{live.popularityValue}, "); + } + if (live_Room.getTuijianNum() != null && live_Room.getTuijianNum() >= 0) { + sb.append("tuijian_num = #{live.tuijianNum}, "); + } + if (sb.lastIndexOf(",") == sb.length() - 2) { + sb.deleteCharAt(sb.length() - 2); + } + sb.append(" WHERE room_id=#{live.roomId} "); + + return sb.toString(); + } + +} diff --git a/src/main/java/com/ifish/mapper/Tbl_User_MapperSql.java b/src/main/java/com/ifish/mapper/Tbl_User_MapperSql.java index ec264cd..a161bd1 100644 --- a/src/main/java/com/ifish/mapper/Tbl_User_MapperSql.java +++ b/src/main/java/com/ifish/mapper/Tbl_User_MapperSql.java @@ -40,10 +40,6 @@ public class Tbl_User_MapperSql { if (user.getUserSex() != null && StringUtils.isNotBlank(user.getUserSex())) { sb.append("user_sex = #{user.userSex}, "); } - //登陆次数有另外的Sql语句 - if (user.getUpdateTime() != null) { - sb.append("update_time = #{user.updateTime}, "); - } if (user.getLoginTime() != null) { sb.append("login_time = #{user.loginTime}, "); } @@ -78,9 +74,7 @@ public class Tbl_User_MapperSql { if (user.getLongitude() != null && user.getLongitude() > 0) { sb.append("longitude = #{iser.longitude}, "); } - if (sb.lastIndexOf(",") == sb.length() - 2) { - sb.deleteCharAt(sb.length() - 2); - } + sb.append("update_time = NOW() "); sb.append(" WHERE user_id = #{user.userId}"); return sb.toString(); } diff --git a/src/main/java/com/ifish/util/RedisKey.java b/src/main/java/com/ifish/util/RedisKey.java index 331f03a..e5c6b81 100644 --- a/src/main/java/com/ifish/util/RedisKey.java +++ b/src/main/java/com/ifish/util/RedisKey.java @@ -12,67 +12,77 @@ package com.ifish.util; public class RedisKey { /** - * 用户缓存前缀 + * 用户缓存前缀,以id进行存储 */ - public static final String User_Key = "userE:"; + public static final String USER_ID_KEY = "userE:id_"; /** - * 商家信息缓存前缀 + * 设备用户关系缓存前缀,以设备ID和用户ID进行存储 */ - public static final String ShopsInfo_Key = "shopsInfoE:"; + public static final String DEVICE_USER_DEVICEID_AND_USERID = "deviceUserE:"; /** - * 用户绑定设备缓存前缀 + * 设备用户关系缓存前缀(列表),以设备ID进行存储 */ - public static final String DeviceUser_Key = "deviceUserE:"; + public static final String DEVICE_USER_LIST_DEVICEID = "deviceUserlistE:id_"; /** - * 设备绑定摄像头缓存前缀 + * 设备用户关系缓存前缀(列表),以用户ID进行存储 */ - public static final String DeviceCamera_key = "deviceCameraE:"; + public static final String DEVICE_USER_LIST_USERID = "deviceUserlistE:u_"; /** - * 设备详情缓存前缀 + * 设备详情缓存前缀,以macAddress进行存储 */ - public static final String Device_key = "deviceE:"; + public static final String DEVICE_KEY_MACADDRESS = "deviceE:mac_"; + + /** + * 设备详情缓存前缀,以deviceId进行存储 + */ + public static final String DEVICE_KEY_DEVICEID = "deviceE:id_"; + + /** + * 设备详情缓存前缀,以摄像头ID进行存储 + */ + public static final String DEVICE_KEY_CAMERAID = "deviceE:cid_"; + + /** + * 设备统计信息表缓存前缀,以deviceId为前缀 + */ + public static final String DEVICE_STATISTICS_DEVICEID = "devicestatiE:id_"; + + /** + * 设备统计信息表缓存前缀,以mac地址为前缀 + */ + public static final String DEVICE_STATISTICS_MACADDRESS = "devicestatiE:mac_"; /** * 设备类型缓存前缀 */ - public static final String HardWareType_key = "hardwaretypeE:"; + public static final String HARD_WARE_TYPE = "hardwaretypeE:"; /** - * 厂家列表缓存前缀 + * 鱼缸厂统计表缓存前缀,以鱼缸场代码进行存储 */ - public static final String VenderList_key = "venderlistE:"; + public static final String VENDER_CODE = "tblvenderE:code_"; /** - * 用户和摄像头的绑定关系存前缀 + * 直播间详情表缓存前缀,以直播间ID进行存储 */ - public static final String CameraUser_key = "cameraUserE:"; + public static final String LIVEROOM_ROOMID = "liveroomE:id_"; /** - * 摄像头详情缓存前缀 + * 直播间详情表缓存前缀,以直播间ID进行存储 */ - public static final String Camera_key = "cameraE:"; + public static final String LIVEROOM_USERID = "liveroomE:uid_"; /** - * 设备统计信息表缓存前缀 + * 所有开启的直播间缓存总数 */ - public static final String DeviceStatistic_key = "deviceStaticticsE:"; + public static final String LIVEROOM_COUNT = "liveroomE:num_"; /** - * 直播间详情表缓存前缀 + * 推送信息表缓存前缀,以推送Id进行存储 */ - public static final String LiveRoom_key = "liveroomE:"; - - /** - * 直播间数量缓存前缀 - */ - public static final String LIVEROOM_COUNT_KEY = "liveroomcountE:"; - - /** - * 推送消息缓存前缀 - */ - public static final String PUSHLIST_KEY = "pushlistE:"; + public static final String PUSHLIST_PUSHID = "pushlistE:id_"; }