上周部分接口
This commit is contained in:
parent
c56f07a617
commit
e6d2646644
5
pom.xml
5
pom.xml
|
|
@ -148,11 +148,6 @@
|
|||
</dependency>
|
||||
|
||||
<!-- For log4j -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
|
|
|
|||
|
|
@ -48,12 +48,6 @@ public class LiveRoomPageInfo implements Serializable {
|
|||
private Integer pinglunNum;
|
||||
//点赞数量
|
||||
private Integer zanNum;
|
||||
//是否点过赞
|
||||
private String isZan;
|
||||
//打赏金币数量
|
||||
private BigDecimal totalGoldValue;
|
||||
//等级
|
||||
private Integer gradeNum;
|
||||
|
||||
public Integer getRoomId() {
|
||||
return roomId;
|
||||
|
|
@ -175,22 +169,6 @@ public class LiveRoomPageInfo implements Serializable {
|
|||
this.pinglunNum = pinglunNum;
|
||||
}
|
||||
|
||||
public String getIsZan() {
|
||||
return isZan;
|
||||
}
|
||||
|
||||
public void setIsZan(String isZan) {
|
||||
this.isZan = isZan;
|
||||
}
|
||||
|
||||
public Integer getGradeNum() {
|
||||
return gradeNum;
|
||||
}
|
||||
|
||||
public void setGradeNum(Integer gradeNum) {
|
||||
this.gradeNum = gradeNum;
|
||||
}
|
||||
|
||||
public Integer getZanNum() {
|
||||
return zanNum;
|
||||
}
|
||||
|
|
@ -199,11 +177,4 @@ public class LiveRoomPageInfo implements Serializable {
|
|||
this.zanNum = zanNum;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalGoldValue() {
|
||||
return totalGoldValue;
|
||||
}
|
||||
|
||||
public void setTotalGoldValue(BigDecimal totalGoldValue) {
|
||||
this.totalGoldValue = totalGoldValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* 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_factory_list)
|
||||
*
|
||||
* @author bianj
|
||||
* @version 1.0.0 2017-07-03
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "tbl_factory_list")
|
||||
public class Tbl_Factory_List implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private static final long serialVersionUID = -8290320819344778436L;
|
||||
|
||||
/**
|
||||
* 电子厂代码
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "factory_code", unique = true, nullable = false, length = 20)
|
||||
private String factoryCode;
|
||||
|
||||
/**
|
||||
* 电子厂名称
|
||||
*/
|
||||
@Column(name = "factory_name", nullable = false, length = 20)
|
||||
private String factoryName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "create_time", nullable = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否收税:1收、0不收
|
||||
*/
|
||||
@Column(name = "is_tax", nullable = true, length = 1)
|
||||
private String isTax;
|
||||
|
||||
/**
|
||||
* 获取电子厂代码
|
||||
*
|
||||
* @return 电子厂代码
|
||||
*/
|
||||
public String getFactoryCode() {
|
||||
return this.factoryCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置电子厂代码
|
||||
*
|
||||
* @param factoryCode 电子厂代码
|
||||
*/
|
||||
public void setFactoryCode(String factoryCode) {
|
||||
this.factoryCode = factoryCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电子厂名称
|
||||
*
|
||||
* @return 电子厂名称
|
||||
*/
|
||||
public String getFactoryName() {
|
||||
return this.factoryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置电子厂名称
|
||||
*
|
||||
* @param factoryName 电子厂名称
|
||||
*/
|
||||
public void setFactoryName(String factoryName) {
|
||||
this.factoryName = factoryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否收税:1收、0不收
|
||||
*
|
||||
* @return 是否收税
|
||||
*/
|
||||
public String getIsTax() {
|
||||
return this.isTax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否收税:1收、0不收
|
||||
*
|
||||
* @param isTax 是否收税:1收、0不收
|
||||
*/
|
||||
public void setIsTax(String isTax) {
|
||||
this.isTax = isTax;
|
||||
}
|
||||
}
|
||||
|
|
@ -97,9 +97,9 @@ public class LiveRoom {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/liveRoom/v3/getLiveRooms.do", method = RequestMethod.GET)
|
||||
public Object getLiveRooms(Integer firstResult, Integer pageSize, Integer userId, String orders) {
|
||||
public Object getLiveRooms(Integer firstResult, Integer pageSize, String orders) {
|
||||
try {
|
||||
return liveRoomHelperI.getLiveRooms(firstResult, pageSize, userId, orders);
|
||||
return liveRoomHelperI.getLiveRooms(firstResult, pageSize, orders);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ 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;
|
||||
|
|
@ -18,12 +19,10 @@ import com.ifish.util.RedisKey;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import static org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.json;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
|
@ -327,103 +326,35 @@ public class LiveRoomHelper implements LiveRoomHelperI {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object getLiveRooms(Integer firstResult, Integer pageSize, Integer userId, String orders) {
|
||||
public Object getLiveRooms(Integer firstResult, Integer pageSize, String orders) {
|
||||
|
||||
try {
|
||||
if (firstResult != null && pageSize != null && userId != null) {
|
||||
if (firstResult != null && pageSize != null) {
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Map<Integer, LiveRoomPageInfo> map = new HashMap<Integer, Tbl_Live_Room>();
|
||||
if (firstResult == 0) {
|
||||
Tbl_User user = userHelperI.getUserById(userId);
|
||||
if (user != null) {
|
||||
//经度
|
||||
Double longitude = user.getLongitude();
|
||||
//纬度
|
||||
Double latitude = user.getLatitude();
|
||||
//距离用户最近的前5条记录
|
||||
List<LiveRoomPageInfo> distanceList = tbl_Live_Room_Mapper.getLiveRoomListByLongLat(longitude, latitude);
|
||||
for (LiveRoomPageInfo liveRoomInfo : distanceList) {
|
||||
Integer roomId = liveRoomInfo.getRoomId();
|
||||
map.put(roomId, liveRoomInfo);
|
||||
}
|
||||
//获取用户最近浏览的5条记录
|
||||
List<LiveRoomPageInfo> browseList = this.liveRoomDao.findByBrowse(userId);
|
||||
for (LiveRoomPageInfo liveRoomInfo : browseList) {
|
||||
Integer roomId = liveRoomInfo.getRoomId();
|
||||
map.put(roomId, liveRoomInfo);
|
||||
}
|
||||
//获取人气值最高的5条记录
|
||||
List<LiveRoomPageInfo> popularityList = this.liveRoomDao.findByPopularityValue();
|
||||
for (LiveRoomPageInfo liveRoomInfo : popularityList) {
|
||||
Integer roomId = liveRoomInfo.getRoomId();
|
||||
map.put(roomId, liveRoomInfo);
|
||||
}
|
||||
//去重条件
|
||||
orders = StringUtils.join(map.keySet().toArray(), ",");
|
||||
//根据开播时间倒序排列
|
||||
Pagination<LiveRoomPageInfo> page = this.liveRoomDao.findByTime(firstResult, pageSize, orders);
|
||||
List<LiveRoomPageInfo> timeList = page.getList();
|
||||
for (LiveRoomPageInfo liveRoomInfo : timeList) {
|
||||
Integer roomId = liveRoomInfo.getRoomId();
|
||||
map.put(roomId, liveRoomInfo);
|
||||
}
|
||||
List<LiveRoomPageInfo> list = new ArrayList<LiveRoomPageInfo>();
|
||||
Long curTime = new Date().getTime();
|
||||
//计算活跃值
|
||||
for (LiveRoomPageInfo liveRoomInfo : map.values()) {
|
||||
Long loginTime = liveRoomInfo.getLoginTime().getTime();
|
||||
//最近登录天数
|
||||
Integer days = (int) ((curTime - loginTime) / (1000 * 60 * 60 * 24));
|
||||
//小于一周
|
||||
if (days <= 7) {
|
||||
liveRoomInfo.setLiveness("优");
|
||||
} //一周至半个月
|
||||
else if (days > 7 && days <= 15) {
|
||||
liveRoomInfo.setLiveness("良");
|
||||
} //半个月至一个月
|
||||
else if (days > 15 && days <= 30) {
|
||||
liveRoomInfo.setLiveness("中");
|
||||
List<LiveRoomPageInfo> timeList = new ArrayList<LiveRoomPageInfo>();
|
||||
if (orders.equals("renqi")) {
|
||||
timeList = tbl_Live_Room_Mapper.getLiveRoomListByCreateTime(pageSize, firstResult);
|
||||
} else {
|
||||
liveRoomInfo.setLiveness("差");
|
||||
timeList = tbl_Live_Room_Mapper.getLiveRoomListByCreateTime(pageSize, firstResult);
|
||||
}
|
||||
list.add(liveRoomInfo);
|
||||
Integer count = 0;
|
||||
String key = RedisKey.LIVEROOM_COUNT_KEY;
|
||||
String redisString = redisHelperI.getRedis(key);
|
||||
if (StringUtils.isNotBlank(redisString)) {
|
||||
count = Integer.parseInt(redisString);
|
||||
} else {
|
||||
count = tbl_Live_Room_Mapper.getLiveRoomListCount();
|
||||
redisHelperI.setRedis(key, count.toString());
|
||||
}
|
||||
returnMap.put("orders", orders);
|
||||
returnMap.put("total", page.getTotalCount());
|
||||
returnMap.put("liveRoomInfo", list);
|
||||
return IfishUtil.toJson(ResultEnum.success.getKey(), returnMap);
|
||||
}
|
||||
} else {
|
||||
//根据开播时间倒序排列
|
||||
Pagination<LiveRoomPageInfo> page = this.liveRoomDao.findByTime(firstResult, pageSize, orders);
|
||||
List<LiveRoomPageInfo> timeList = page.getList();
|
||||
Long curTime = new Date().getTime();
|
||||
//计算活跃值
|
||||
for (LiveRoomPageInfo liveRoomInfo : timeList) {
|
||||
Long loginTime = liveRoomInfo.getLoginTime().getTime();
|
||||
//最近登录天数
|
||||
Integer days = (int) ((curTime - loginTime) / (1000 * 60 * 60 * 24));
|
||||
//小于一周
|
||||
if (days <= 7) {
|
||||
liveRoomInfo.setLiveness("优");
|
||||
} //一周至半个月
|
||||
else if (days > 7 && days <= 15) {
|
||||
liveRoomInfo.setLiveness("良");
|
||||
} //半个月至一个月
|
||||
else if (days > 15 && days <= 30) {
|
||||
liveRoomInfo.setLiveness("中");
|
||||
} else {
|
||||
liveRoomInfo.setLiveness("差");
|
||||
}
|
||||
}
|
||||
returnMap.put("orders", orders);
|
||||
returnMap.put("total", page.getTotalCount());
|
||||
returnMap.put("total", count);
|
||||
returnMap.put("liveRoomInfo", timeList);
|
||||
return IfishUtil.toJson(ResultEnum.success.getKey(), returnMap);
|
||||
}
|
||||
}
|
||||
return IfishUtil.toJson(ResultEnum.fail101.getKey(), "");
|
||||
} catch (Exception e) {
|
||||
return IfishUtil.toJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,5 +58,5 @@ public interface LiveRoomHelperI {
|
|||
* @param orders
|
||||
* @return
|
||||
*/
|
||||
Object getLiveRooms(Integer firstResult, Integer pageSize, Integer userId, String orders);
|
||||
Object getLiveRooms(Integer firstResult, Integer pageSize, String orders);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,16 +97,49 @@ public interface Tbl_Live_Room_Mapper {
|
|||
Tbl_Live_Room getTbl_Live_RoomById(@Param("roomid") Integer roomid);
|
||||
|
||||
/**
|
||||
* 根据经纬度获取直播间集合
|
||||
* 根据开播时间来查询直播间
|
||||
*
|
||||
* @param pageSize
|
||||
* @param FirstResult
|
||||
* @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 "
|
||||
+ "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 "
|
||||
+ "where td.is_camera = '1' ORDER BY l.create_time DESC LIMIT ${first},${pagesize}")
|
||||
List<LiveRoomPageInfo> getLiveRoomListByCreateTime(@Param("pagesize") Integer pageSize, @Param("first") Integer FirstResult);
|
||||
|
||||
/**
|
||||
* 根据开播时间来查询直播间
|
||||
*
|
||||
* @param pageSize
|
||||
* @param FirstResult
|
||||
* @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 "
|
||||
+ "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 "
|
||||
+ "where td.is_camera = '1' ORDER BY l.popularity_value DESC LIMIT ${first},${pagesize}")
|
||||
List<LiveRoomPageInfo> getLiveRoomListByRenqi(@Param("pagesize") Integer pageSize, @Param("first") Integer FirstResult);
|
||||
|
||||
/**
|
||||
* 查询所有直播间数量
|
||||
*
|
||||
* @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,c.camera_id AS cameraId,"
|
||||
+ "l.room_name AS roomName,l.room_desc AS roomDesc,l.popularity_value AS popularityValue,(TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,"
|
||||
+ "round(6378.138*2*asin(sqrt(pow(sin((${lat}*pi()/180-u.latitude*pi()/180)/2),2)+cos(${lat}*pi()/180)*cos(u.latitude*pi()/180)* pow(sin((${long}*pi()/180-u.longitude*pi()/180)/2),2)))*1000) AS distance "
|
||||
+ "from tbl_user u LEFT JOIN tbl_camera_user c ON u.user_id=c.user_id "
|
||||
+ "LEFT JOIN tbl_live_room l on c.user_id=l.user_id "
|
||||
+ "WHERE c.is_live=1 AND l.room_status=1 HAVING distance IS NOT NULL"
|
||||
+ " ORDER BY distance ASC LIMIT 5")
|
||||
List<LiveRoomPageInfo> getLiveRoomListByLongLat(@Param("long") Double longitude, @Param("lat") Double latitude);
|
||||
@Select("select count(1) 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 "
|
||||
+ "where td.is_camera = '1'")
|
||||
Integer getLiveRoomListCount();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@ public class RedisKey {
|
|||
*/
|
||||
public static final String LiveRoom_key = "liveroomE:";
|
||||
|
||||
/**
|
||||
* 直播间数量缓存前缀
|
||||
*/
|
||||
public static final String LIVEROOM_COUNT_KEY = "liveroomcountE:";
|
||||
|
||||
/**
|
||||
* 推送消息缓存前缀
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue