update
This commit is contained in:
@@ -3,10 +3,12 @@ package com.yutou.biliapi.bean.live.database;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.util.DateUtils;
|
||||
import com.yutou.bilibili.Tools.DateFormatUtils;
|
||||
import com.yutou.bilibili.Tools.Tools;
|
||||
import com.yutou.common.databases.AbsDatabasesBean;
|
||||
import com.yutou.common.utils.Log;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigInteger;
|
||||
@@ -37,7 +39,7 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
private boolean isRecordDanmu;
|
||||
@JSONField(name = "keyword")
|
||||
private List<String> keywordList;
|
||||
@JSONField(name = "week")
|
||||
@JSONField(name = "weeks")
|
||||
private List<String> weeks;
|
||||
@JSONField(name = "recordPath")
|
||||
private String recordPath = "live";
|
||||
@@ -56,11 +58,11 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
}
|
||||
|
||||
public boolean checkRecordDanmuTime() {
|
||||
return checkRecordTime(recordDanmuDate);
|
||||
return DateFormatUtils.checkTime(weeks,recordDanmuDate);
|
||||
}
|
||||
|
||||
public boolean checkRecordLiveTime() {
|
||||
return checkRecordTime(recordLiveDate);
|
||||
return DateFormatUtils.checkTime(weeks,recordLiveDate);
|
||||
}
|
||||
|
||||
public boolean verifyDanmuTimer() {
|
||||
@@ -85,36 +87,13 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkRecordTime(String recordDate) {
|
||||
//TODO 待测试
|
||||
String[] parts = recordDate.split(" - ");
|
||||
LocalTime startTime = LocalTime.parse(parts[0], DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
LocalTime endTime = LocalTime.parse(parts[1], DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
|
||||
|
||||
// 获取当前时间
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
|
||||
// 获取当前日期对应的星期几(1-7分别对应周一到周日)
|
||||
int currentWeekDay = currentDate.getDayOfWeek().getValue();
|
||||
|
||||
// 判断当前日期是否在指定的星期列表中
|
||||
boolean isSpecifiedWeekDay = weeks.contains(String.valueOf(currentWeekDay));
|
||||
|
||||
|
||||
// 判断当前时间是否在指定的时间范围内
|
||||
boolean isWithinRange = (currentTime.isAfter(startTime) || currentTime.equals(startTime)) &&
|
||||
(currentTime.isBefore(endTime) || currentTime.equals(endTime));
|
||||
return isWithinRange && isSpecifiedWeekDay;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String t = "18:00:00 - 23:59:59";
|
||||
List<String> weeks = Arrays.asList("1", "2", "3", "9", "5", "6", "7");
|
||||
String t = "18:00:00 - 19:59:59";
|
||||
t=null;
|
||||
List<String> weeks = Arrays.asList("1", "2", "3", "4", "5", "6", "7");
|
||||
LiveConfigDatabaseBean bean=new LiveConfigDatabaseBean();
|
||||
bean.setWeeks(weeks);
|
||||
System.out.println(bean.checkRecordTime(t));
|
||||
System.out.println(DateFormatUtils.checkTime(weeks,t));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class BiliLiveConfigDatabase extends SQLiteManager {
|
||||
}
|
||||
|
||||
public LiveConfigDatabaseBean getConfig(String roomId) {
|
||||
List<LiveConfigDatabaseBean> list = get(getDataBean().get(0).getTableName(), LiveConfigDatabaseBean.class);
|
||||
List<LiveConfigDatabaseBean> list = get(getDataBean().getFirst().getTableName(), LiveConfigDatabaseBean.class);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -61,14 +61,23 @@ public class BiliLiveConfigDatabase extends SQLiteManager {
|
||||
}
|
||||
return delete(config);
|
||||
}
|
||||
|
||||
public List<LiveConfigDatabaseBean> getAllConfig() {
|
||||
List<LiveConfigDatabaseBean> list = get(getDataBean().get(0).getTableName(), LiveConfigDatabaseBean.class);
|
||||
public List<LiveConfigDatabaseBean> getConfigs(int page,int limit) {
|
||||
int offset = (page - 1) * limit;
|
||||
List<LiveConfigDatabaseBean> list = get(getDataBean().getFirst().getTableName(),"`sql_time` >0 limit "+limit+" offset "+offset, LiveConfigDatabaseBean.class);
|
||||
if (list.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<LiveConfigDatabaseBean> getAllConfig() {
|
||||
List<LiveConfigDatabaseBean> list = get(getDataBean().getFirst().getTableName(), LiveConfigDatabaseBean.class);
|
||||
if (list.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public int getConfigCount() {
|
||||
return getCount(getDataBean().getFirst().getTableName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ public class WebSocketManager {
|
||||
array.addAll(roomMap.keySet());
|
||||
return array;
|
||||
}
|
||||
public void clearUserStopList() {
|
||||
userStopList.clear();
|
||||
}
|
||||
|
||||
public void addRoom(LiveRoomConfig roomConfig, boolean isUser) {
|
||||
if (!isUser && userStopList.contains(roomConfig.getRoomId().toString())) {
|
||||
|
||||
Reference in New Issue
Block a user