直播间修改图片修改

This commit is contained in:
谢洪龙 2017-08-02 13:17:03 +08:00
parent c2c29af6d0
commit 2c4f2eef65
6 changed files with 133 additions and 15 deletions

View File

@ -155,12 +155,27 @@ public class LiveRoom {
* @return
*/
@RequestMapping(value = "/liveRoom/v3/updateLiveRoom.do", method = RequestMethod.POST)
public Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom) {
public Object updateLiveRoom(Tbl_Live_Room liveRoom) {
try {
return liveRoomHelperI.updateLiveRoom(liveRoom);
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 修改直播间展示图片
*
* @param fileUpload
* @param liveRoom
* @return
*/
@RequestMapping(value = "/liveRoom/v3/updateLiveRoomImg.do", method = RequestMethod.POST)
public Object updateLiveRoomImg(MultipartFile fileUpload, Tbl_Live_Room liveRoom) {
try {
return liveRoomHelperI.updateLiveRoom(fileUpload, liveRoom);
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
}

View File

@ -200,6 +200,29 @@ public class DeviceHelper implements DeviceHelperI {
return device;
}
/**
* 根据设备ID获取设备统计信息
*
* @param deviceId
* @return
* @throws Exception
*/
@Override
public Tbl_Device_Statistics getDeviceStatisticsByMacAddress(String mackAddress) throws Exception {
Tbl_Device_Statistics device = null;
String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByMacAddress(mackAddress);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device_Statistics) IfishUtil.JsonToBean(redisString, Tbl_Device_Statistics.class);
} else {
device = tbl_Device_Mapper.getDevStatisticsByMacAddress(mackAddress);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 绑定设备
*

View File

@ -42,6 +42,15 @@ public interface DeviceHelperI {
*/
public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception;
/**
* 根据设备ID获取设备统计信息
*
* @param deviceId
* @return
* @throws Exception
*/
public Tbl_Device_Statistics getDeviceStatisticsByMacAddress(String macAddress) throws Exception;
/**
* 根据设备Id获取设备详情
*
@ -61,6 +70,14 @@ public interface DeviceHelperI {
*/
Tbl_Device getDeviceByMacAddress(String macAddress) throws Exception;
/**
* 根据摄像头ID获取设备信息
*
* @param cameraId
* @return
*/
Tbl_Device getDeviceByCameraId(String cameraId) throws Exception;
/**
* 绑定设备
*
@ -88,14 +105,6 @@ public interface DeviceHelperI {
*/
Object bindCamera(Integer userId, String cameraId);
/**
* 根据摄像头ID获取设备信息
*
* @param cameraId
* @return
*/
Tbl_Device getDeviceByCameraId(String cameraId) throws Exception;
/**
* 修改设备信息
*

View File

@ -396,8 +396,10 @@ public class LiveRoomHelper implements LiveRoomHelperI {
//查找直播间信息
Tbl_Live_Room curLiveRoom = getTbl_Live_RoomByRoomId(roomId);
if (curLiveRoom != null) {
Tbl_User user = userHelperI.getUserById(curLiveRoom.getUserId());
Map<String, Object> map = new HashMap<String, Object>();
map.put("roomId", roomId);
map.put("userImg", user.getUserImg());
map.put("userId", curLiveRoom.getUserId());
map.put("cameraId", curLiveRoom.getCameraId());
map.put("roomName", curLiveRoom.getRoomName());
@ -429,8 +431,10 @@ public class LiveRoomHelper implements LiveRoomHelperI {
//查找直播间信息
Tbl_Live_Room curLiveRoom = getTbl_Live_RoomByCameraId(cameraId);
if (curLiveRoom != null) {
Tbl_User user = userHelperI.getUserById(curLiveRoom.getUserId());
Map<String, Object> map = new HashMap<String, Object>();
map.put("roomId", curLiveRoom.getRoomId());
map.put("userImg", user.getUserImg());
map.put("cameraId", curLiveRoom.getCameraId());
map.put("userId", curLiveRoom.getUserId());
map.put("roomName", curLiveRoom.getRoomName());
@ -510,12 +514,44 @@ public class LiveRoomHelper implements LiveRoomHelperI {
public Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom) {
try {
if (StringUtils.isNotBlank(liveRoom.getRoomName())) {
String roomName = new String(liveRoom.getRoomName().getBytes("iso-8859-1"), "UTF-8");
liveRoom.setRoomName(roomName);
}
if (StringUtils.isNotBlank(liveRoom.getRoomDesc())) {
String roomDesc = new String(liveRoom.getRoomDesc().getBytes("iso-8859-1"), "UTF-8");
liveRoom.setRoomDesc(roomDesc);
}
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 = getTbl_Live_RoomByRoomId(liveRoom.getRoomId());
return IfishUtil.toJson(ResultEnum.success.getKey(), live);
}
} catch (Exception e) {
}
return IfishUtil.toJson(ResultEnum.fail101.getKey(), "");
}
/**
* 修改直播间
*
* @param fileUpload
* @param liveRoom
* @return
*/
@Override
public Object updateLiveRoom(Tbl_Live_Room liveRoom) {
try {
int i = tbl_Live_Room_Mapper.updateLiveRoom(liveRoom);
if (i > 0) {
redisKeyHelperI.deleteRedisByTbl_Live_Room(liveRoom);

View File

@ -85,6 +85,15 @@ public interface LiveRoomHelperI {
*/
Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom);
/**
* 修改直播间
*
* @param fileUpload
* @param liveRoom
* @return
*/
Object updateLiveRoom(Tbl_Live_Room liveRoom);
/**
* 直播间人气值加1
*

View File

@ -26,9 +26,10 @@ public class RedisKeyHelper implements RedisKeyHelperI {
@Autowired
private RedisHelperI redisHelperI;
@Autowired
private DeviceHelperI deviceHelper;
@Autowired
private UserHelperI userHelperI;
/**
* 根据phoneNumber获取Tbl_User用户信息的Redis缓存key键值
@ -376,8 +377,18 @@ public class RedisKeyHelper implements RedisKeyHelperI {
*/
@Override
public void deleteRedisByTbl_Device(Tbl_Device device) {
deleteTbl_DeviceInfo(device);
try {
if (device.getDeviceId() != null && device.getDeviceId() != 0 && StringUtils.isBlank(device.getMacAddress())) {
device = deviceHelper.getDeviceById(device.getDeviceId());
}
if (StringUtils.isNotBlank(device.getMacAddress()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
device = deviceHelper.getDeviceByMacAddress(device.getMacAddress());
}
if (StringUtils.isNotBlank(device.getCameraId()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
device = deviceHelper.getDeviceByCameraId(device.getCameraId());
}
deleteTbl_DeviceInfo(device);
Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId());
deleteTbl_Device_StatisticsInfo(device_Statistics);
} catch (Exception e) {
@ -404,8 +415,15 @@ public class RedisKeyHelper implements RedisKeyHelperI {
*/
@Override
public void deleteRedisByTbl_Device_Statistics(Tbl_Device_Statistics device) {
deleteTbl_Device_StatisticsInfo(device);
try {
if (device.getDeviceId() != null && device.getDeviceId() != 0 && StringUtils.isBlank(device.getMacAddress())) {
device = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId());
}
if (StringUtils.isNotBlank(device.getMacAddress()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
device = deviceHelper.getDeviceStatisticsByMacAddress(device.getMacAddress());
}
deleteTbl_Device_StatisticsInfo(device);
Tbl_Device device1 = deviceHelper.getDeviceById(device.getDeviceId());
deleteTbl_DeviceInfo(device1);
} catch (Exception e) {
@ -414,10 +432,10 @@ public class RedisKeyHelper implements RedisKeyHelperI {
public void deleteTbl_Device_StatisticsInfo(Tbl_Device_Statistics device) {
if (device.getDeviceId() != null && device.getDeviceId() > 0) {
redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId()));
redisHelperI.deleteRedis(getTbl_Device_StatisticsRedisKeyByDeviceId(device.getDeviceId()));
}
if (StringUtils.isNotBlank(device.getMacAddress())) {
redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByMacAddress(device.getMacAddress()));
redisHelperI.deleteRedis(getTbl_Device_StatisticsRedisKeyByMacAddress(device.getMacAddress()));
}
}
@ -437,6 +455,7 @@ public class RedisKeyHelper implements RedisKeyHelperI {
deleteTbl_Device_StatisticsInfo(device_Statistics);
} catch (Exception e) {
}
}
public void deleteTbl_Device_UserInfo(Tbl_Device_User tbl_Device_User) {
@ -458,6 +477,12 @@ public class RedisKeyHelper implements RedisKeyHelperI {
*/
@Override
public void deleteRedisByTbl_User(Tbl_User tbl_User) {
try {
if (tbl_User.getUserId() != null && tbl_User.getUserId() > 0) {
tbl_User = userHelperI.getUserById(tbl_User.getUserId());
}
} catch (Exception e) {
}
if (tbl_User.getUserId() != null && tbl_User.getUserId() > 0) {
redisHelperI.deleteRedis(getTbl_UserRedisKeyByUserId(tbl_User.getUserId()));
}
@ -482,6 +507,7 @@ public class RedisKeyHelper implements RedisKeyHelperI {
*/
@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()));
}