直播间接口修改,查询列表增加点赞数据,点赞接口修改
This commit is contained in:
parent
a966de9e4a
commit
67afdcc372
|
|
@ -24,7 +24,7 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private static final long serialVersionUID = -4747733838201318438L;
|
||||
private static final long serialVersionUID = 4271035874866910990L;
|
||||
|
||||
/**
|
||||
* 直播间Id
|
||||
|
|
@ -58,8 +58,7 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
private String roomDesc;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
* */
|
||||
@Column(name = "room_img", nullable = true, length = 100)
|
||||
private String roomImg;
|
||||
|
||||
|
|
@ -75,6 +74,12 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
@Column(name = "popularity_value", nullable = false, length = 10)
|
||||
private Integer popularityValue;
|
||||
|
||||
/**
|
||||
* 点赞数量
|
||||
*/
|
||||
@Column(name = "zanNum", nullable = true, length = 10)
|
||||
private Integer zanNum;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
|
@ -85,7 +90,7 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
* 是否推荐
|
||||
*/
|
||||
@Column(name = "is_tuijian", nullable = false, length = 1)
|
||||
private String isTuijian;
|
||||
private Integer isTuijian;
|
||||
|
||||
/**
|
||||
* 推荐排序
|
||||
|
|
@ -97,7 +102,7 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
* 首次分享
|
||||
*/
|
||||
@Column(name = "first_share", nullable = false, length = 1)
|
||||
private String firstShare;
|
||||
private Integer firstShare;
|
||||
|
||||
/**
|
||||
* 获取直播间Id
|
||||
|
|
@ -244,6 +249,24 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
this.popularityValue = popularityValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取点赞数量
|
||||
*
|
||||
* @return 点赞数量
|
||||
*/
|
||||
public Integer getZanNum() {
|
||||
return this.zanNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置点赞数量
|
||||
*
|
||||
* @param zanNum 点赞数量
|
||||
*/
|
||||
public void setZanNum(Integer zanNum) {
|
||||
this.zanNum = zanNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
|
|
@ -267,7 +290,7 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
*
|
||||
* @return 是否推荐
|
||||
*/
|
||||
public String getIsTuijian() {
|
||||
public Integer getIsTuijian() {
|
||||
return this.isTuijian;
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +299,7 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
*
|
||||
* @param isTuijian 是否推荐
|
||||
*/
|
||||
public void setIsTuijian(String isTuijian) {
|
||||
public void setIsTuijian(Integer isTuijian) {
|
||||
this.isTuijian = isTuijian;
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +326,7 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
*
|
||||
* @return 首次分享
|
||||
*/
|
||||
public String getFirstShare() {
|
||||
public Integer getFirstShare() {
|
||||
return this.firstShare;
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +335,7 @@ public class Tbl_Live_Room implements java.io.Serializable {
|
|||
*
|
||||
* @param firstShare 首次分享
|
||||
*/
|
||||
public void setFirstShare(String firstShare) {
|
||||
public void setFirstShare(Integer firstShare) {
|
||||
this.firstShare = firstShare;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* 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.bean;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 用户观看直播记录(tbl_live_watch)
|
||||
*
|
||||
* @author bianj
|
||||
* @version 1.0.0 2017-07-14
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "tbl_live_watch")
|
||||
public class Tbl_Live_Watch {
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private static final long serialVersionUID = -3178390426587691302L;
|
||||
|
||||
/**
|
||||
* 直播间ID
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "room_id", unique = true, nullable = false, length = 10)
|
||||
private Integer roomId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "user_id", unique = true, nullable = false, length = 10)
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(name = "update_time", nullable = true)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "create_time", nullable = false)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 获取直播间ID
|
||||
*
|
||||
* @return 直播间ID
|
||||
*/
|
||||
public Integer getRoomId() {
|
||||
return this.roomId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置直播间ID
|
||||
*
|
||||
* @param roomId 直播间ID
|
||||
*/
|
||||
public void setRoomId(Integer roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*
|
||||
* @return 用户id
|
||||
*/
|
||||
public Integer getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取修改时间
|
||||
*
|
||||
* @return 修改时间
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return this.updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置修改时间
|
||||
*
|
||||
* @param updateTime 修改时间
|
||||
*/
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ public class LiveRoom {
|
|||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/liveRoomZan/{roomId}/{userId}", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/liveRoomZan/{roomId}/{userId}", method = RequestMethod.GET)
|
||||
public Object liveRoomsZan(@PathVariable Integer roomId, @PathVariable Integer userId) {
|
||||
try {
|
||||
return liveRoomHelperI.liveRoomsZan(roomId, userId);
|
||||
|
|
@ -59,6 +59,18 @@ public class LiveRoom {
|
|||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改人气值
|
||||
*
|
||||
* @param roomId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/liveRoom/v3/popularityValue.do", method = RequestMethod.POST)
|
||||
public Object popularityValue(Integer roomId, Integer userId) {
|
||||
return liveRoomHelperI.popularityValue(roomId, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间留言
|
||||
*
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.ifish.bean.LiveRoomPageInfo;
|
|||
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_Live_Watch;
|
||||
import com.ifish.bean.Tbl_User;
|
||||
import com.ifish.enums.ResultEnum;
|
||||
import com.ifish.mapper.Tbl_Live_Room_Mapper;
|
||||
|
|
@ -102,13 +103,14 @@ 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) {
|
||||
if (cameraChange) {
|
||||
deviceHelperI.updateDeviceUser(cameraUser);
|
||||
}
|
||||
redisKeyHelperI.deleteRedisByTbl_Live_Room(liveRoom);
|
||||
Map map = new HashMap();
|
||||
map.put("cameraId", cameraId);
|
||||
map.put("isLive", cameraUser.getIsLive());
|
||||
|
|
@ -196,37 +198,54 @@ public class LiveRoomHelper implements LiveRoomHelperI {
|
|||
@Override
|
||||
public Object liveRoomsZan(Integer roomId, Integer userId) {
|
||||
try {
|
||||
//点赞和人气值不一样,人气值只此直播间点击数,点赞指观看此直播并点赞的人数
|
||||
Tbl_Live_Room room = getTbl_Live_RoomById(roomId);
|
||||
if (room == null) {
|
||||
throw new IfishException(ResultEnum.error402);
|
||||
//以前的方式,每人每个直播间只能点赞一次,这里不采用这种方式
|
||||
// //点赞和人气值不一样,人气值只此直播间点击数,点赞指观看此直播并点赞的人数
|
||||
// Tbl_Live_Room room = getTbl_Live_RoomById(roomId);
|
||||
// if (room == null) {
|
||||
// throw new IfishException(ResultEnum.error402);
|
||||
// }
|
||||
// Tbl_User user = userHelperI.getUserById(userId);
|
||||
// if (user == null) {
|
||||
// throw new IfishException(ResultEnum.error402);
|
||||
// }
|
||||
// //点赞数量
|
||||
// Integer zanNum = tbl_Live_Room_Mapper.getLiveRoomZanCountByRoomId(roomId);
|
||||
// //是否点过赞
|
||||
// int i = tbl_Live_Room_Mapper.IsZan(roomId, userId);
|
||||
// Map map = new HashMap();
|
||||
// //点赞过,取消点赞
|
||||
// if (i > 0) {
|
||||
// int j = tbl_Live_Room_Mapper.cancelZan(roomId, userId);
|
||||
// //成功取消
|
||||
// if (j > 0) {
|
||||
// zanNum--;
|
||||
// map.put("isZan", 0);
|
||||
// map.put("zanNum", zanNum);
|
||||
// return IfishUtil.returnJson(ResultEnum.success.getKey(), map);
|
||||
// }
|
||||
// } //没有点赞,点赞一次
|
||||
// else {
|
||||
// int j = tbl_Live_Room_Mapper.ImplementZan(roomId, userId);
|
||||
// if (j > 0) {
|
||||
// zanNum++;
|
||||
// map.put("isZan", 1);
|
||||
// map.put("zanNum", zanNum);
|
||||
// return IfishUtil.returnJson(ResultEnum.success.getKey(), map);
|
||||
// }
|
||||
// }
|
||||
Tbl_Live_Room live = getLive_RoomById(roomId);
|
||||
if (live != null) {
|
||||
if (live.getZanNum() != null && live.getZanNum() >= 0) {
|
||||
live.setZanNum(live.getZanNum() + 1);
|
||||
} else {
|
||||
live.setZanNum(1);
|
||||
}
|
||||
Tbl_User user = userHelperI.getUserById(userId);
|
||||
if (user == null) {
|
||||
throw new IfishException(ResultEnum.error402);
|
||||
}
|
||||
//点赞数量
|
||||
Integer zanNum = tbl_Live_Room_Mapper.getLiveRoomZanCountByRoomId(roomId);
|
||||
//是否点过赞
|
||||
int i = tbl_Live_Room_Mapper.IsZan(roomId, userId);
|
||||
Map map = new HashMap();
|
||||
//点赞过,取消点赞
|
||||
int i = tbl_Live_Room_Mapper.updateLiveRoom(live);
|
||||
if (i > 0) {
|
||||
int j = tbl_Live_Room_Mapper.cancelZan(roomId, userId);
|
||||
//成功取消
|
||||
if (j > 0) {
|
||||
zanNum--;
|
||||
map.put("isZan", 0);
|
||||
map.put("zanNum", zanNum);
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), map);
|
||||
}
|
||||
} //没有点赞,点赞一次
|
||||
else {
|
||||
int j = tbl_Live_Room_Mapper.ImplementZan(roomId, userId);
|
||||
if (j > 0) {
|
||||
zanNum++;
|
||||
redisKeyHelperI.deleteRedisByTbl_Live_Room(live);
|
||||
Map map = new HashMap();
|
||||
map.put("isZan", 1);
|
||||
map.put("zanNum", zanNum);
|
||||
map.put("zanNum", live.getZanNum());
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), map);
|
||||
}
|
||||
}
|
||||
|
|
@ -367,14 +386,24 @@ public class LiveRoomHelper implements LiveRoomHelperI {
|
|||
if (firstResult != null && pageSize != null) {
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
List<LiveRoomPageInfo> timeList = new ArrayList<LiveRoomPageInfo>();
|
||||
String key = redisKeyHelperI.getListTbl_Live_Room_RedisKey(firstResult, pageSize, orders);
|
||||
String redisString = redisHelperI.getRedis(key);
|
||||
if (StringUtils.isNotBlank(redisString)) {
|
||||
timeList = (List<LiveRoomPageInfo>) IfishUtil.JsonToList(redisString, LiveRoomPageInfo.class);
|
||||
} else {
|
||||
if (orders != null && orders.equals("2")) {
|
||||
timeList = tbl_Live_Room_Mapper.getLiveRoomListByRenqi(pageSize, firstResult);
|
||||
} else {
|
||||
timeList = tbl_Live_Room_Mapper.getLiveRoomListByCreateTime(pageSize, firstResult);
|
||||
}
|
||||
if (timeList != null && timeList.size() > 0) {
|
||||
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(timeList));
|
||||
}
|
||||
}
|
||||
|
||||
Integer count = 0;
|
||||
String key = redisKeyHelperI.getTbl_Live_Room_CountRedisKey();
|
||||
String redisString = redisHelperI.getRedis(key);
|
||||
key = redisKeyHelperI.getTbl_Live_Room_CountRedisKey();
|
||||
redisString = redisHelperI.getRedis(key);
|
||||
if (StringUtils.isNotBlank(redisString)) {
|
||||
count = Integer.parseInt(redisString);
|
||||
} else {
|
||||
|
|
@ -420,4 +449,56 @@ public class LiveRoomHelper implements LiveRoomHelperI {
|
|||
}
|
||||
return IfishUtil.toJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间人气值加1
|
||||
*
|
||||
* @param roomId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object popularityValue(Integer roomId, Integer userId) {
|
||||
try {
|
||||
if (roomId != null && userId != null) {
|
||||
//浏览直播间记录
|
||||
Tbl_Live_Watch browseRoom = tbl_Live_Room_Mapper.getTbl_Live_WatchByRoomIdAndUserId(roomId, userId);
|
||||
Date date = new Date();
|
||||
//新增浏览记录
|
||||
if (browseRoom != null) {
|
||||
browseRoom.setUpdateTime(date);
|
||||
tbl_Live_Room_Mapper.updateTbl_Live_Watch(browseRoom);
|
||||
} else {
|
||||
//更新浏览记录
|
||||
browseRoom = new Tbl_Live_Watch();
|
||||
browseRoom.setRoomId(roomId);
|
||||
browseRoom.setUserId(userId);
|
||||
browseRoom.setUpdateTime(date);
|
||||
browseRoom.setCreateTime(date);
|
||||
tbl_Live_Room_Mapper.insertTbl_Live_Watch(browseRoom);
|
||||
}
|
||||
//查找直播间信息
|
||||
Tbl_Live_Room curLiveRoom = getLive_RoomById(roomId);
|
||||
if (curLiveRoom != null) {
|
||||
Integer popularityValue = null;
|
||||
if (curLiveRoom.getPopularityValue() == null) {
|
||||
popularityValue = 0;
|
||||
} else {
|
||||
popularityValue = curLiveRoom.getPopularityValue();
|
||||
}
|
||||
//人气值加一
|
||||
popularityValue++;
|
||||
curLiveRoom.setPopularityValue(popularityValue);
|
||||
tbl_Live_Room_Mapper.updateLiveRoomPopularityValue(curLiveRoom);
|
||||
redisKeyHelperI.deleteRedisByTbl_Live_Room(curLiveRoom);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("roomId", roomId);
|
||||
map.put("popularityValue", popularityValue);
|
||||
return IfishUtil.toJson(ResultEnum.success.getKey(), popularityValue);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return IfishUtil.toJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,4 +76,13 @@ public interface LiveRoomHelperI {
|
|||
* @return
|
||||
*/
|
||||
Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom);
|
||||
|
||||
/**
|
||||
* 直播间人气值加1
|
||||
*
|
||||
* @param roomId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Object popularityValue(Integer roomId, Integer userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,12 +193,26 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
return RedisKey.LIVEROOM_USERID + User;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分页和排序条件获取直播间列表缓存key键值
|
||||
*
|
||||
* @param first
|
||||
* @param pageSize
|
||||
* @param orders
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getListTbl_Live_Room_RedisKey(Integer first, Integer pageSize, String orders) {
|
||||
return RedisKey.LIVEROMM_LIST + "f_" + first + "_p_" + pageSize + "_o_" + orders;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有开启直播间总数量的redis缓存key键值
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
||||
public String getTbl_Live_Room_CountRedisKey() {
|
||||
return RedisKey.LIVEROOM_COUNT;
|
||||
}
|
||||
|
|
@ -300,6 +314,16 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
if (live_Room.getUserId() != null && live_Room.getUserId() > 0) {
|
||||
redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByUserId(live_Room.getUserId()));
|
||||
}
|
||||
redisHelperI.deleteRedis(getTbl_Live_Room_CountRedisKey());
|
||||
redisHelperI.delRedisByTagKey(RedisKey.LIVEROMM_LIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除redis中有直播间总数缓存
|
||||
*/
|
||||
@Override
|
||||
public void deleteRedisByLiveRoomListCount() {
|
||||
redisHelperI.deleteRedis(getTbl_Live_Room_CountRedisKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,6 +140,16 @@ public interface RedisKeyHelperI {
|
|||
*/
|
||||
public String getTbl_Live_RoomRedisKeyByUserId(Integer User);
|
||||
|
||||
/**
|
||||
* 根据分页和排序条件获取直播间列表缓存key键值
|
||||
*
|
||||
* @param first
|
||||
* @param pageSize
|
||||
* @param orders
|
||||
* @return
|
||||
*/
|
||||
public String getListTbl_Live_Room_RedisKey(Integer first, Integer pageSize, String orders);
|
||||
|
||||
/**
|
||||
* 获取所有开启直播间总数量的redis缓存key键值
|
||||
*
|
||||
|
|
@ -199,4 +209,10 @@ public interface RedisKeyHelperI {
|
|||
* @param live_Room
|
||||
*/
|
||||
public void deleteRedisByTbl_Live_Room(Tbl_Live_Room live_Room);
|
||||
|
||||
/**
|
||||
* 删除redis中有直播间总数缓存
|
||||
*/
|
||||
public void deleteRedisByLiveRoomListCount();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -422,8 +422,10 @@ public class UserHelper implements UserHelperI {
|
|||
//如果有手机用手机号注册,否则用用户ID注册
|
||||
if (StringUtils.isBlank(tmpUser.getPhoneNumber())) {
|
||||
code = tmpUser.getUserId() + "";
|
||||
} else {
|
||||
} else if (StringUtils.isNotBlank(tmpUser.getPhoneNumber())) {
|
||||
code = tmpUser.getPhoneNumber();
|
||||
} else if (StringUtils.isNotBlank(tmpUser.getUserEmail())) {
|
||||
code = tmpUser.getUserEmail().replace(".com", "").replace(".cn", "");
|
||||
}
|
||||
//注册技威
|
||||
Map<String, String> map = GwellApi.Register(code);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ package com.ifish.mapper;
|
|||
import com.ifish.bean.LiveRoomPageInfo;
|
||||
import com.ifish.bean.Tbl_Live_Message;
|
||||
import com.ifish.bean.Tbl_Live_Room;
|
||||
import com.ifish.bean.Tbl_Live_Watch;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
|
|
@ -15,6 +16,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.Update;
|
||||
import org.apache.ibatis.annotations.UpdateProvider;
|
||||
|
||||
/**
|
||||
|
|
@ -47,7 +49,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,room_Img 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,zanNum FROM TBL_LIVE_ROOM WHERE user_id = #{userid}")
|
||||
Tbl_Live_Room getLive_RoomByUserId(@Param("userid") Integer UserId);
|
||||
|
||||
/**
|
||||
|
|
@ -95,7 +97,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,room_Img 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,zanNum FROM TBL_LIVE_ROOM WHERE ROOM_ID = #{roomid}")
|
||||
Tbl_Live_Room getTbl_Live_RoomById(@Param("roomid") Integer roomid);
|
||||
|
||||
/**
|
||||
|
|
@ -107,7 +109,7 @@ public interface Tbl_Live_Room_Mapper {
|
|||
*/
|
||||
@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,l.room_Img AS roomImg,"
|
||||
+ "(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,count(lm.message_id) AS pinglunNum "
|
||||
+ "(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,count(lm.message_id) AS pinglunNum,l.zanNum "
|
||||
+ "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 "
|
||||
|
|
@ -125,7 +127,7 @@ public interface Tbl_Live_Room_Mapper {
|
|||
*/
|
||||
@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,l.room_Img AS roomImg,"
|
||||
+ "(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,count(lm.message_id) AS pinglunNum "
|
||||
+ "(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,count(lm.message_id) AS pinglunNum,l.zanNum "
|
||||
+ "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 "
|
||||
|
|
@ -155,6 +157,15 @@ public interface Tbl_Live_Room_Mapper {
|
|||
@UpdateProvider(type = Tbl_Live_Room_MapperSql.class, method = "updateLiveRoom")
|
||||
Integer updateLiveRoom(@Param("live") Tbl_Live_Room live_Room);
|
||||
|
||||
/**
|
||||
* 修改人气值
|
||||
*
|
||||
* @param live_Room
|
||||
* @return
|
||||
*/
|
||||
@Update("UPDATE TBL_LIVE_ROOM SET popularity_value = #{live.popularityValue} WHERE room_id = #{live.roomId}")
|
||||
Integer updateLiveRoomPopularityValue(@Param("live") Tbl_Live_Room live_Room);
|
||||
|
||||
/**
|
||||
* 根据直播间ID获取此直播间评论列表
|
||||
*
|
||||
|
|
@ -168,4 +179,33 @@ public interface Tbl_Live_Room_Mapper {
|
|||
+ "LEFT JOIN tbl_user uu ON l.as_user_id=uu.user_id "
|
||||
+ "WHERE room_id = #{roomid} LIMIT ${first},${page} ")
|
||||
List<Map> getLive_MessagesListByRoomId(@Param("roomid") Integer roomid, @Param("first") Integer firstResult, @Param("page") Integer pageSize);
|
||||
|
||||
/**
|
||||
* 根据直播间和用户ID获取观看记录
|
||||
*
|
||||
* @param roomId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Select("SELECT ROOM_ID,USER_ID,UPDATE_TIME,CREATE_TIME FROM TBL_LIVE_WATCH WHERE ROOM_ID=#{roomid} AND USER_ID=#{userid}")
|
||||
Tbl_Live_Watch getTbl_Live_WatchByRoomIdAndUserId(@Param("roomid") Integer roomId, @Param("userid") Integer userId);
|
||||
|
||||
/**
|
||||
* 修改用户直播观看记录
|
||||
*
|
||||
* @param live
|
||||
* @return
|
||||
*/
|
||||
@Update("UPDATE TBL_LIVE_WATCH SET UPDATE_TIME=#{live.updateTime} WHERE room_id=#{live.roomId} AND user_id=#{live.userId}")
|
||||
Integer updateTbl_Live_Watch(@Param("live") Tbl_Live_Watch live);
|
||||
|
||||
/**
|
||||
* 插入一条用户观看记录
|
||||
*
|
||||
* @param live
|
||||
* @return
|
||||
*/
|
||||
@Insert("INSERT INTO TBL_LIVE_WATCH(room_id,user_id,update_time,create_time) VALUES (#{live.roomId},#{live.userId},#{live.updateTime},#{live.createTime})")
|
||||
Integer insertTbl_Live_Watch(@Param("live") Tbl_Live_Watch live);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class Tbl_Live_Room_MapperSql {
|
|||
if (StringUtils.isNotBlank(live_Room.getCameraId())) {
|
||||
sb.append("camera_id = #{live.cameraId}, ");
|
||||
}
|
||||
if (StringUtils.isNotBlank(live_Room.getFirstShare())) {
|
||||
if (live_Room.getFirstShare() != null && live_Room.getFirstShare() >= 0) {
|
||||
sb.append("first_share = #{live.firstShare}, ");
|
||||
}
|
||||
if (StringUtils.isNotBlank(live_Room.getRoomDesc())) {
|
||||
|
|
@ -44,7 +44,7 @@ public class Tbl_Live_Room_MapperSql {
|
|||
if (StringUtils.isNotBlank(live_Room.getRoomStatus())) {
|
||||
sb.append("room_status = #{live.roomStatus}, ");
|
||||
}
|
||||
if (StringUtils.isNotBlank(live_Room.getIsTuijian())) {
|
||||
if (live_Room.getIsTuijian() != null && live_Room.getIsTuijian() >= 0) {
|
||||
sb.append("is_tuijian = #{live.isTuijian}, ");
|
||||
}
|
||||
if (live_Room.getPopularityValue() != null && live_Room.getPopularityValue() >= 0) {
|
||||
|
|
@ -53,6 +53,9 @@ public class Tbl_Live_Room_MapperSql {
|
|||
if (live_Room.getTuijianNum() != null && live_Room.getTuijianNum() >= 0) {
|
||||
sb.append("tuijian_num = #{live.tuijianNum}, ");
|
||||
}
|
||||
if (live_Room.getZanNum() != null && live_Room.getZanNum() >= 0) {
|
||||
sb.append("zanNum = #{live.zanNum}, ");
|
||||
}
|
||||
if (sb.lastIndexOf(",") == sb.length() - 2) {
|
||||
sb.deleteCharAt(sb.length() - 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,11 @@ public class RedisKey {
|
|||
*/
|
||||
public static final String LIVEROOM_USERID = "liveroomE:uid_";
|
||||
|
||||
/**
|
||||
* 直播间列表缓存前缀,以分页和排序条件进行存储
|
||||
*/
|
||||
public static final String LIVEROMM_LIST = "liveroomlistE:";
|
||||
|
||||
/**
|
||||
* 所有开启的直播间缓存总数
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue