This commit is contained in:
Yutousama 2024-11-01 00:15:12 +08:00
parent 526cf7e25f
commit 45c38f56fd
24 changed files with 508 additions and 239 deletions

View File

@ -14,7 +14,7 @@
<script src="/js/jquery-3.2.1.js"></script> <script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script> <script src="/js/CommonConfig.js"></script>
<script> <script>
headerModel=2; headerModel=3;
$('#header').load("/html/header.html"); $('#header').load("/html/header.html");
</script> </script>

164
Web/html/body/live.html Normal file
View File

@ -0,0 +1,164 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>视频管理</title>
<link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body>
<div id="header"></div>
<table class="layui-hide" id="roomList" lay-filter="roomTable"></table>
</body>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" onclick="createRoom()">添加新房间</button>
<button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
</div>
</script>
<script type="text/html" id="toolDemo">
<div class="layui-clear-space">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-xs" lay-event="more">
更多
<i class="layui-icon layui-icon-down"></i>
</a>
</div>
</script>
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script>
<script src="/js/httpUtils.js"></script>
<script>
headerModel = 1;
$('#header').load("/html/header.html");
</script>
<script>
function createRoom(roomId) {
layer.open({
type: 2,
title: "添加新房间",
area: ['600px', '500px'],
content: '/html/ui/createConfig.html?roomId=' + roomId
});
}
</script>
<script>
layui.use(['table', 'dropdown'], function () {
var table = layui.table;
var dropdown = layui.dropdown;
// 创建渲染实例
table.render({
elem: '#roomList',
url: '/live/config/all',
toolbar: '#toolbarDemo',
totalRow: true, // 开启合计行
page: true,
response: {
statusCode: 100 // 重新规定成功的状态码为 200table 组件默认为 0
},
parseData: function (res) {
return {
"code": res.status, //解析接口状态
"msg": res.message, //解析提示文本
"data": res.data, //解析数据列表
"count": res.count
};
},
cols: [[
{ type: 'checkbox', fixed: 'left' },
{ field: 'anchorUid', title: 'UID', width: 100, sort: true, fixed: 'left', templet: '<div><a href="https://space.bilibili.com/{{= d.anchorUid}}" target="_blank">{{= d.anchorUid}}</a>' },
{ field: 'anchorName', title: '用户名', width: 100, fixed: 'left' },
{ field: 'anchorFace', title: '头像', width: 80, templet: '<div><image src="" onerror="showImage(\'{{= d.anchorFace }}\',this);" style="width: 30px;height: 30px;"></div>' },
{ field: 'live_room_id', title: '房间号', width: 80, templet: '<div><a href="https://live.bilibili.com/{{= d.live_room_id}}" target="_blank">{{= d.live_room_id}}</a>' },
{ field: 'recordPath', title: '保存路径', width: 120 },
{ field: 'recordDanmu', title: '录制弹幕', width: 120, sort: true },
{ field: 'recordLive', title: '录制视频', width: 120, sort: true },
{ field: 'recordDanmuDate', title: '弹幕录制预定时间', width: 100, sort: true },
{ field: 'recordLiveDate', title: '视频录制预定时间', width: 100, sort: true },
{ field: 'recordUid', title: '录制账号', width: 120, sort: true, templet: '<div><a href="https://space.bilibili.com/{{= d.recordUid}}" target="_blank">{{= d.recordUid}}</a>' },
{ field: 'recordDanmu', title: '录制弹幕', width: 120, sort: true },
{ field: 'sql_time', title: '添加时间', width: 100 },
{ fixed: "right", title: "操作", width: 190, align: "center", toolbar: "#toolDemo" }
]],
done: function () {
done();
},
error: function (res, msg) {
console.log(res, msg)
}
});
function done() {
// 工具栏事件
table.on('toolbar(roomTable)', function (obj) {
var id = obj.config.id;
var checkStatus = table.checkStatus(id);
var othis = lay(this);
switch (obj.event) {
case 'getCheckData':
var data = checkStatus.data;
layer.alert(layui.util.escape(JSON.stringify(data)));
break;
};
});
// 触发单元格工具事件
table.on('tool(roomTable)', function (obj) { // 双击 toolDouble
var data = obj.data; // 获得当前行数据
console.log(obj)
if (obj.event === 'edit') {
createRoom(obj.data.live_room_id)
} else if (obj.event === 'more') {
// 更多 - 下拉菜单
dropdown.render({
elem: this, // 触发事件的 DOM 对象
show: true, // 外部事件触发即显示
data: [{
title: '查看',
id: 'detail'
}, {
title: '删除',
id: 'del'
}],
click: function (menudata) {
if (menudata.id === 'detail') {
layer.msg('查看操作,当前行 ID:' + data.live_room_id);
} else if (menudata.id === 'del') {
layer.confirm('真的删除行 [' + data.anchorName + '] 么', function (index) {
deleteRoomConfig(data.live_room_id)
.then(data => {
layer.msg(data.message)
if (data.status == 100) {
obj.del(); // 删除对应行tr的DOM结构
layer.close(index);
}
})
// 向服务端发送删除指令
});
}
},
align: 'right', // 右对齐弹出
style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' // 设置额外样式
})
}
});
}
});
</script>
<style>
</style>
</html>

View File

@ -38,7 +38,7 @@
<script src="/js/jquery-3.2.1.js"></script> <script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script> <script src="/js/CommonConfig.js"></script>
<script> <script>
headerModel=3; headerModel=4;
$('#header').load("/html/header.html"); $('#header').load("/html/header.html");
layui.use(['form', 'laytpl'], function () { layui.use(['form', 'laytpl'], function () {

View File

@ -1,164 +1,65 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>视频管理</title> <title>视频中心</title>
<link rel="stylesheet" href="/layui/css/layui.css"> <link rel="stylesheet" href="/layui/css/layui.css">
</head> </head>
<body> <body>
<div id="header"></div> <div id="header"></div>
<table class="layui-hide" id="roomList" lay-filter="roomTable"></table> <body>
<div id="view"></div>
</body> </body>
<script type="text/html" id="toolbarDemo"> <script id="demo" type="text/html">
<div class="layui-btn-container"> <h3>{{ d.title }}</h3>
<button class="layui-btn layui-btn-sm" onclick="createRoom()">添加新房间</button> <ul>
<button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button> {{# layui.each(d.list, function(index, item){ }}
</div> <li>
</script> <span>{{ item.modname }}</span>
<script type="text/html" id="toolDemo"> <span>{{ item.alias }}</span>
<div class="layui-clear-space"> <span>{{ item.site || '' }}</span>
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> </li>
<a class="layui-btn layui-btn-xs" lay-event="more"> {{# }); }}
更多 {{# if(d.list.length === 0){ }}
<i class="layui-icon layui-icon-down"></i> 无数据
</a> {{# } }}
</div> </ul>
</script> </script>
<script src="/layui/layui.js"></script> <script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script> <script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script> <script src="/js/CommonConfig.js"></script>
<script src="/js/httpUtils.js"></script>
<script> <script>
headerModel = 1; headerModel=2;
$('#header').load("/html/header.html"); $('#header').load("/html/header.html");
layui.use(['form', 'laytpl'], function () {
var form = layui.form;
var layer = layui.layer;
var laytpl = layui.laytpl
var data = { //数据
"title":"Layui常用模块"
,"list":[{"modname":"弹层","alias":"layer","site":"layer.layui99.com"},{"modname":"表单","alias":"form"}]
}
var getTpl = $("#demo").get(0).innerHTML
,view = document.getElementById('view');
laytpl(getTpl).render(data, function(html){
view.innerHTML = html;
console.log(html)
});
})
</script> </script>
<script>
function createRoom(roomId) {
layer.open({
type: 2,
title: "添加新房间",
area: ['500px', '400px'],
content: '/html/ui/createConfig.html?roomId=' + roomId
});
}
</script>
<script>
layui.use(['table', 'dropdown'], function () {
var table = layui.table;
var dropdown = layui.dropdown;
// 创建渲染实例
table.render({
elem: '#roomList',
url: '/live/config/all',
toolbar: '#toolbarDemo',
totalRow: true, // 开启合计行
page: true,
response: {
statusCode: 100 // 重新规定成功的状态码为 200table 组件默认为 0
},
parseData: function (res) {
return {
"code": res.status, //解析接口状态
"msg": res.message, //解析提示文本
"data": res.data, //解析数据列表
"count": res.count
};
},
cols: [[
{ type: 'checkbox', fixed: 'left' },
{ field: 'anchorUid', title: 'UID', width: 100, sort: true, fixed: 'left', templet: '<div><a href="https://space.bilibili.com/{{= d.anchorUid}}" target="_blank">{{= d.anchorUid}}</a>' },
{ field: 'anchorName', title: '用户名', width: 100, fixed: 'left' },
{ field: 'anchorFace', title: '头像', width: 80, templet: '<div><image src="" onerror="showImage(\'{{= d.anchorFace }}\',this);" style="width: 30px;height: 30px;"></div>' },
{ field: 'live_room_id', title: '房间号', width: 80, templet: '<div><a href="https://live.bilibili.com/{{= d.live_room_id}}" target="_blank">{{= d.live_room_id}}</a>' },
{ field: 'recordPath', title: '保存路径', width: 120 },
{ field: 'recordDanmu', title: '录制弹幕', width: 120, sort: true },
{ field: 'recordLive', title: '录制视频', width: 120, sort: true },
{ field: 'recordDanmuDate', title: '弹幕录制预定时间', width: 100, sort: true },
{ field: 'recordLiveDate', title: '视频录制预定时间', width: 100, sort: true },
{ field: 'recordUid', title: '录制账号', width: 120, sort: true, templet: '<div><a href="https://space.bilibili.com/{{= d.recordUid}}" target="_blank">{{= d.recordUid}}</a>' },
{ field: 'recordDanmu', title: '录制弹幕', width: 120, sort: true },
{ field: 'sql_time', title: '添加时间', width: 100 },
{ fixed: "right", title: "操作", width: 190, align: "center", toolbar: "#toolDemo" }
]],
done: function () {
done();
},
error: function (res, msg) {
console.log(res, msg)
}
});
function done() {
// 工具栏事件
table.on('toolbar(roomTable)', function (obj) {
var id = obj.config.id;
var checkStatus = table.checkStatus(id);
var othis = lay(this);
switch (obj.event) {
case 'getCheckData':
var data = checkStatus.data;
layer.alert(layui.util.escape(JSON.stringify(data)));
break;
};
});
// 触发单元格工具事件
table.on('tool(roomTable)', function (obj) { // 双击 toolDouble
var data = obj.data; // 获得当前行数据
console.log(obj)
if (obj.event === 'edit') {
createRoom(obj.data.live_room_id)
} else if (obj.event === 'more') {
// 更多 - 下拉菜单
dropdown.render({
elem: this, // 触发事件的 DOM 对象
show: true, // 外部事件触发即显示
data: [{
title: '查看',
id: 'detail'
}, {
title: '删除',
id: 'del'
}],
click: function (menudata) {
if (menudata.id === 'detail') {
layer.msg('查看操作,当前行 ID:' + data.live_room_id);
} else if (menudata.id === 'del') {
layer.confirm('真的删除行 [' + data.anchorName + '] 么', function (index) {
deleteRoomConfig(data.live_room_id)
.then(data => {
layer.msg(data.message)
if (data.status == 100) {
obj.del(); // 删除对应行tr的DOM结构
layer.close(index);
}
})
// 向服务端发送删除指令
});
}
},
align: 'right', // 右对齐弹出
style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' // 设置额外样式
})
}
});
}
});
</script>
<style> <style>
</style> </style>
</html> </html>

View File

@ -1,6 +1,7 @@
<body> <body>
<ul class="layui-nav"> <ul class="layui-nav">
<li class="layui-nav-item index"><a href="/index.html">监控大厅</a></li> <li class="layui-nav-item index"><a href="/index.html">监控大厅</a></li>
<li class="layui-nav-item live"><a href="/html/body/live.html">直播管理</a></li>
<li class="layui-nav-item video"><a href="/html/body/video.html">视频管理</a></li> <li class="layui-nav-item video"><a href="/html/body/video.html">视频管理</a></li>
<li class="layui-nav-item data" ><a href="/html/body/data.html">数据中心</a></li> <li class="layui-nav-item data" ><a href="/html/body/data.html">数据中心</a></li>
<li class="layui-nav-item user"><a href="/html/body/user.html">用户中心</a></li> <li class="layui-nav-item user"><a href="/html/body/user.html">用户中心</a></li>
@ -10,13 +11,15 @@
<script> <script>
$(".index").removeClass("layui-this") $(".index").removeClass("layui-this")
$(".live").removeClass("layui-this")
$(".video").removeClass("layui-this") $(".video").removeClass("layui-this")
$(".data").removeClass("layui-this") $(".data").removeClass("layui-this")
$(".user").removeClass("layui-this") $(".user").removeClass("layui-this")
switch(headerModel){ switch(headerModel){
case 0:$(".index").addClass('layui-this');break; case 0:$(".index").addClass('layui-this');break;
case 1:$(".video").addClass('layui-this');break; case 1:$(".live").addClass('layui-this');break;
case 2:$(".data").addClass('layui-this');break; case 2:$(".video").addClass('layui-this');break;
case 3:$(".user").addClass('layui-this');break; case 3:$(".data").addClass('layui-this');break;
case 4:$(".user").addClass('layui-this');break;
} }
</script> </script>

View File

@ -32,20 +32,20 @@
<div class="layui-form-item" pane> <div class="layui-form-item" pane>
<label class="layui-form-label">录制日期</label> <label class="layui-form-label">录制日期</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="checkbox" name="2" title="周一" lay-skin="tag"> <input type="checkbox" checked name="week_1" title="周一" lay-skin="tag">
<input type="checkbox" name="3" title="周二" lay-skin="tag"> <input type="checkbox" checked name="week_2" title="周二" lay-skin="tag">
<input type="checkbox" name="4" title="周三" lay-skin="tag"> <input type="checkbox" checked name="week_3" title="周三" lay-skin="tag">
<input type="checkbox" name="5" title="周四" lay-skin="tag"> <input type="checkbox" checked name="week_4" title="周四" lay-skin="tag">
<input type="checkbox" name="6" title="周五" lay-skin="tag"> <input type="checkbox" checked name="week_5" title="周五" lay-skin="tag">
<input type="checkbox" name="7" title="周六" lay-skin="tag"> <input type="checkbox" checked name="week_6" title="周六" lay-skin="tag">
<input type="checkbox" name="1" title="周日" lay-skin="tag"> <input type="checkbox" checked name="week_7" title="周日" lay-skin="tag">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">弹幕录制时间</label> <label class="layui-form-label">弹幕录制时间</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="recordDanmuDate" id="recordDanmuDate" lay-verify="required" autocomplete="off" <input type="text" name="recordDanmuDate" id="recordDanmuDate" value="00:00:00 - 23:59:59"
class="layui-input"> lay-verify="required" autocomplete="off" class="layui-input">
</div> </div>
<div class="layui-form-mid layui-text-em" onclick="timeTips(this)"><i <div class="layui-form-mid layui-text-em" onclick="timeTips(this)"><i
class="layui-icon layui-icon-help"></i> </div> class="layui-icon layui-icon-help"></i> </div>
@ -53,8 +53,8 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">视频录制时间</label> <label class="layui-form-label">视频录制时间</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="recordLiveDate" id="recordLiveDate" lay-verify="required" <input type="text" name="recordLiveDate" id="recordLiveDate" value="00:00:00 - 23:59:59"
autocomplete="off" class="layui-input"> lay-verify="required" autocomplete="off" class="layui-input">
</div> </div>
<div class="layui-form-mid layui-text-em" onclick="timeTips(this)"><i <div class="layui-form-mid layui-text-em" onclick="timeTips(this)"><i
class="layui-icon layui-icon-help"></i> </div> class="layui-icon layui-icon-help"></i> </div>
@ -90,7 +90,7 @@
<script src="/js/CommonConfig.js"></script> <script src="/js/CommonConfig.js"></script>
<script> <script>
function timeTips(that) { function timeTips(that) {
layer.tips('填写[分钟][小时][星期],空格分割,例如预定每周6晚上8点之后才开始录制则填写:* 8 6', that); layer.tips('是从开始到结束时间范围内,主播开播会启动录制,超过结束范围不会中断正在录制的任务', that);
} }
var roomId = getParam("roomId"); var roomId = getParam("roomId");
@ -109,16 +109,24 @@
// 此处可执行 Ajax 等操作 // 此处可执行 Ajax 等操作
// … // …
var weeks = [
]
for (let i = 1; i <= 7; i++) {
if (field[`week_${i}`] === 'on') {
weeks.push(i.toString());
}
}
field.weeks = weeks;
console.log(field) console.log(field)
// addRoomConfig(field) addRoomConfig(field)
// .then(json => { .then(json => {
// layer.msg(json.message, function () { layer.msg(json.message, function () {
// if (json.status == 100) { if (json.status == 100) {
// close() close()
// } }
// }) })
// }) })
return false; // 阻止默认 form 跳转 return false; // 阻止默认 form 跳转
}); });
@ -159,13 +167,19 @@
.then(data => { .then(data => {
if (data.status === 100) { if (data.status === 100) {
var json = data.data; var json = data.data;
form.val('form-filter', { var result = {
'url': 'https://live.bilibili.com/' + json.live_room_id, 'url': 'https://live.bilibili.com/' + json.live_room_id,
'recordLive': json.recordLive, 'recordLive': json.recordLive,
'recordDanmu': json.recordDanmu, 'recordDanmu': json.recordDanmu,
'recordDanmuDate': json.recordDanmuDate, 'recordDanmuDate': json.recordDanmuDate,
'recordLiveDate': json.recordLiveDate 'recordLiveDate': json.recordLiveDate,
}); };
for (let i = 0; i < json.weeks.length; i++) {
result[`week_${json.weeks[i]}`] = true;
}
form.val('form-filter',result);
$('#url').get(0).disabled = true; $('#url').get(0).disabled = true;
} }
}) })

View File

@ -10,17 +10,16 @@
<body> <body>
<div id="header"></div> <div id="header"></div>
<button id="btn" type="button" class="layui-btn" onclick="onButton()">默认按钮</button>
<div class="layui-row layui-col-space15"> <div class="layui-row layui-col-space15">
<div id="card"></div> <div id="card"></div>
</div> </div><br>
<div id="page"></div>
</body> </body>
<script id="liveCard" type="text/html"> <script id="liveCard" type="text/html">
{{# layui.each(d.data, function(index, item){ }} {{# layui.each(d.data, function(index, item){ }}
<div class="layui-col-xs3"> <div class="layui-col-xs3 layui-col-sm3 layui-col-md3">
<div class="layui-bg-gray" style="padding: 16px;"> <div class="layui-bg-gray" style="padding: 16px;">
<div class="layui-row layui-col-space15"> <div class="layui-row layui-col-space15">
<div class="layui-card"> <div class="layui-card">
@ -34,7 +33,8 @@
</span> </span>
</div> </div>
<div class="layui-card-body"> <div class="layui-card-body">
<img src="#" onerror="showImage('{{= item.cover}}',this)" style="width: 100%; height: 100%;"/><br> <img src="#" onerror="showTmpImage('{{= item.cover}}',this)" onclick="toLive('{{= item.roomId}}')" style="width: 100%; height: 100%;"/><br>
<!-- <img src="#" onerror="showImage('{{= item.cover}}',this)" onclick="toLive('{{= item.roomId}}')" style="width: 100%; height: 100%;"/><br> -->
{{= item.title}}<br> {{= item.title}}<br>
直播录制状态: 直播录制状态:
{{# if(item.downloadVideo){ }} {{# if(item.downloadVideo){ }}
@ -64,20 +64,24 @@
<script> <script>
headerModel = 0; headerModel = 0;
$('#header').load("/html/header.html"); $('#header').load("/html/header.html");
function toLive(roomId){
console.log(roomId)
window.open("https://live.bilibili.com/"+roomId,'_blank')
}
function clickVideo(roomId, status) { function clickVideo(roomId, status) {
const title = "是否" + (status ? "停止" : "启动") + "录制视频?" const title = "是否" + (status ? "停止" : "启动") + "录制视频?"
layer.confirm(title, { icon: 3 }, function () { layer.confirm(title, { icon: 3 }, function () {
if (status) { if (status) {
stopLiveVideo(roomId) stopLiveVideo(roomId)
.then(data => { .then(data => {
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) },function(){ layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) }, function () {
location.reload(); location.reload();
}); });
}) })
} else { } else {
startLiveVideo(roomId) startLiveVideo(roomId)
.then(data => { .then(data => {
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) },function(){ layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) }, function () {
location.reload(); location.reload();
}); });
}) })
@ -93,7 +97,7 @@
if (status) { if (status) {
stopLiveDanmu(roomId) stopLiveDanmu(roomId)
.then(data => { .then(data => {
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) },function(){ layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) }, function () {
location.reload(); location.reload();
}); });
@ -101,7 +105,7 @@
} else { } else {
startLiveDanmu(roomId) startLiveDanmu(roomId)
.then(data => { .then(data => {
layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) },function(){ layer.msg(data.message, { icon: (data.status == 100 ? 1 : 0) }, function () {
location.reload(); location.reload();
}); });
}) })
@ -112,22 +116,55 @@
} }
</script> </script>
<script> <script>
layui.use(['laytpl'], function () { layui.use(['laytpl', 'laypage'], function () {
var laytpl = layui.laytpl; var laytpl = layui.laytpl;
var laypage = layui.laypage;
var pageIndex = 0;
var pageMax = 8;
var listCount=10;
var listMax=pageMax;
var initPage=true;
function initCard() { function initCard() {
getAllLive() var loadIndex = layer.msg('加载中', {
icon: 16,
shade: 0.4
});
getAllLive(pageIndex, pageMax)
.then(data => { .then(data => {
console.log(data) listCount=data.count;
if(initPage){
initPage=false;
initPageView();
}
var view = $("#card").get(0); var view = $("#card").get(0);
laytpl($('#liveCard').get(0).innerHTML).render(data, function (html) { laytpl($('#liveCard').get(0).innerHTML).render(data, function (html) {
view.innerHTML = html view.innerHTML = html;
layer.close(loadIndex)
}); });
}) })
} }
function init() { function init() {
initCard() initCard()
} }
function initPageView(){
laypage.render({
elem: 'page',
limit: 8,
curr: pageIndex + 1,
limits: [4, 8, 16, 24, 32, 40],
layout: ['prev', 'page', 'next', 'limit'],
count: listCount, // 数据总数
jump: function (obj, first) {
listMax=obj.limit
if (!first) {
pageIndex =obj.curr;
pageMax = obj.limit;
initCard()
}
}
});
}
init() init()
}) })
function onButton() { function onButton() {

View File

@ -26,3 +26,13 @@ function showImage(url, imgElement) {
// 可以在这里设置一个默认图片或者显示错误信息 // 可以在这里设置一个默认图片或者显示错误信息
}); });
} }
function showTmpImage(url, imgElement) {
getHttpTmpImage(url)
.then(blob => {
imgElement.src ="data:image/jpeg;base64,"+blob;
})
.catch(error => {
console.log("Error loading image:", error);
// 可以在这里设置一个默认图片或者显示错误信息
});
}

View File

@ -32,7 +32,6 @@ function post(url,formData,isJSON) {
return blob; return blob;
} }
const imageUrl = URL.createObjectURL(blob); const imageUrl = URL.createObjectURL(blob);
console.log("Image URL:", imageUrl);
return imageUrl; return imageUrl;
}) })
.catch(error => { .catch(error => {
@ -40,6 +39,27 @@ function post(url,formData,isJSON) {
throw error; // 重新抛出错误以便外部捕获 throw error; // 重新抛出错误以便外部捕获
}); });
} }
function post2blob(url,formData) {
return fetch(url, {
method: "POST",
body: formData
})
.then(response => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.text();
})
.then(blob => {
return blob;
})
.catch(error => {
console.error("There was a problem with the fetch operation:", error);
throw error; // 重新抛出错误以便外部捕获
});
}
function buildFormData(json){ function buildFormData(json){
const formData = new FormData(); const formData = new FormData();
@ -73,6 +93,15 @@ function getHttpImage(url) {
return blob; return blob;
}) })
} }
function getHttpTmpImage(url) {
const encode = encodeURI(url);
const formData = new FormData();
formData.append("url", encode);
return post2blob("/file/imgTmp",formData)
.then(blob=>{
return blob;
})
}
function getBiliAllUser(){ function getBiliAllUser(){
return get("/user/list") return get("/user/list")
} }
@ -89,8 +118,8 @@ function deleteRoomConfig(roomId){
//----------------直播配置相关接口end //----------------直播配置相关接口end
//----------------首页相关接口 //----------------首页相关接口
function getAllLive(){ function getAllLive(page,limit){
return get("/live/list") return get("/live/list?page="+page+"&limit="+limit)
} }
//----------------首页相关接口end //----------------首页相关接口end
//----------------视频相关接口 //----------------视频相关接口

View File

@ -11,7 +11,7 @@
<groupId>com.yutou</groupId> <groupId>com.yutou</groupId>
<artifactId>bilibili</artifactId> <artifactId>bilibili</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <!-- <packaging>pom</packaging>-->
<name>bilibili</name> <name>bilibili</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<properties> <properties>
@ -136,7 +136,7 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId> <artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version> <version>1.8</version>
<executions> <!--<executions>
<execution> <execution>
<phase>test</phase> <phase>test</phase>
<goals> <goals>
@ -149,7 +149,7 @@
</tasks> </tasks>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>-->
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -3,10 +3,12 @@ package com.yutou.biliapi.bean.live.database;
import com.alibaba.fastjson2.annotation.JSONField; import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.util.DateUtils; import com.alibaba.fastjson2.util.DateUtils;
import com.yutou.bilibili.Tools.DateFormatUtils; import com.yutou.bilibili.Tools.DateFormatUtils;
import com.yutou.bilibili.Tools.Tools;
import com.yutou.common.databases.AbsDatabasesBean; import com.yutou.common.databases.AbsDatabasesBean;
import com.yutou.common.utils.Log; import com.yutou.common.utils.Log;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springframework.util.StringUtils;
import java.io.File; import java.io.File;
import java.math.BigInteger; import java.math.BigInteger;
@ -37,7 +39,7 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
private boolean isRecordDanmu; private boolean isRecordDanmu;
@JSONField(name = "keyword") @JSONField(name = "keyword")
private List<String> keywordList; private List<String> keywordList;
@JSONField(name = "week") @JSONField(name = "weeks")
private List<String> weeks; private List<String> weeks;
@JSONField(name = "recordPath") @JSONField(name = "recordPath")
private String recordPath = "live"; private String recordPath = "live";
@ -56,11 +58,11 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
} }
public boolean checkRecordDanmuTime() { public boolean checkRecordDanmuTime() {
return checkRecordTime(recordDanmuDate); return DateFormatUtils.checkTime(weeks,recordDanmuDate);
} }
public boolean checkRecordLiveTime() { public boolean checkRecordLiveTime() {
return checkRecordTime(recordLiveDate); return DateFormatUtils.checkTime(weeks,recordLiveDate);
} }
public boolean verifyDanmuTimer() { public boolean verifyDanmuTimer() {
@ -85,36 +87,13 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
return false; 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) { public static void main(String[] args) {
String t = "18:00:00 - 23:59:59"; String t = "18:00:00 - 19:59:59";
List<String> weeks = Arrays.asList("1", "2", "3", "9", "5", "6", "7"); t=null;
List<String> weeks = Arrays.asList("1", "2", "3", "4", "5", "6", "7");
LiveConfigDatabaseBean bean=new LiveConfigDatabaseBean(); LiveConfigDatabaseBean bean=new LiveConfigDatabaseBean();
bean.setWeeks(weeks); bean.setWeeks(weeks);
System.out.println(bean.checkRecordTime(t)); System.out.println(DateFormatUtils.checkTime(weeks,t));
} }
} }

View File

@ -42,7 +42,7 @@ public class BiliLiveConfigDatabase extends SQLiteManager {
} }
public LiveConfigDatabaseBean getConfig(String roomId) { 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()) { if (list.isEmpty()) {
return null; return null;
} }
@ -61,14 +61,23 @@ public class BiliLiveConfigDatabase extends SQLiteManager {
} }
return delete(config); return delete(config);
} }
public List<LiveConfigDatabaseBean> getConfigs(int page,int limit) {
public List<LiveConfigDatabaseBean> getAllConfig() { int offset = (page - 1) * limit;
List<LiveConfigDatabaseBean> list = get(getDataBean().get(0).getTableName(), LiveConfigDatabaseBean.class); List<LiveConfigDatabaseBean> list = get(getDataBean().getFirst().getTableName(),"`sql_time` >0 limit "+limit+" offset "+offset, LiveConfigDatabaseBean.class);
if (list.isEmpty()) { if (list.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
return list; 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());
}
} }

View File

@ -66,6 +66,9 @@ public class WebSocketManager {
array.addAll(roomMap.keySet()); array.addAll(roomMap.keySet());
return array; return array;
} }
public void clearUserStopList() {
userStopList.clear();
}
public void addRoom(LiveRoomConfig roomConfig, boolean isUser) { public void addRoom(LiveRoomConfig roomConfig, boolean isUser) {
if (!isUser && userStopList.contains(roomConfig.getRoomId().toString())) { if (!isUser && userStopList.contains(roomConfig.getRoomId().toString())) {

View File

@ -8,6 +8,7 @@ import com.yutou.bilibili.datas.ResultData;
import com.yutou.bilibili.datas.ReturnCode; import com.yutou.bilibili.datas.ReturnCode;
import com.yutou.bilibili.services.LiveConfigService; import com.yutou.bilibili.services.LiveConfigService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.val;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Controller @Controller
@ -69,19 +71,19 @@ public class LiveConfigController {
if ("0".equals(roomId) || !StringUtils.hasText(roomId)) { if ("0".equals(roomId) || !StringUtils.hasText(roomId)) {
return ResultData.fail(ReturnCode.RC999); return ResultData.fail(ReturnCode.RC999);
} }
LiveConfigDatabaseBean config = configService.getConfig(new String(roomId)); LiveConfigDatabaseBean config = configService.getConfig(roomId);
if (config != null) { if (config != null) {
return ResultData.success(config.toJson()); return ResultData.success(config);
} }
return ResultData.fail(ReturnCode.RC999); return ResultData.fail(ReturnCode.RC999);
} }
@RequestMapping(value = "all", method = RequestMethod.GET) @RequestMapping(value = "all", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public JSONObject getAllConfig() { public JSONObject getAllConfig(int page,int limit) {
List<LiveConfigDatabaseBean> config = configService.getAllConfig(); List<LiveConfigDatabaseBean> config = configService.getConfigs(page, limit);
if (config != null) { if (config != null) {
return ResultData.success(config); return ResultData.success(config,configService.getConfigCount());
} }
return ResultData.fail(ReturnCode.RC999); return ResultData.fail(ReturnCode.RC999);
} }

View File

@ -7,6 +7,7 @@ import com.yutou.bilibili.services.LiveDanmuService;
import com.yutou.bilibili.services.LiveService; import com.yutou.bilibili.services.LiveService;
import com.yutou.bilibili.services.LiveVideoService; import com.yutou.bilibili.services.LiveVideoService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.val;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@ -25,8 +26,7 @@ public class LiveController {
@RequestMapping("/live/list") @RequestMapping("/live/list")
@ResponseBody @ResponseBody
public JSONObject getLiveList(){ public JSONObject getLiveList(int page,int limit) {
return ResultData.success(liveService.getLiveList(page,limit), liveService.getConfigCount());
return ResultData.success(liveService.getLiveList());
} }
} }

View File

@ -11,6 +11,7 @@ import com.yutou.common.utils.AppTools;
import com.yutou.common.utils.Base64Tools; import com.yutou.common.utils.Base64Tools;
import com.yutou.common.utils.Log; import com.yutou.common.utils.Log;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.val;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -21,9 +22,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List; import java.util.List;
@Controller @Controller
@ -72,5 +77,35 @@ public class VideoFileController {
} }
return null; return null;
} }
@RequestMapping(value = "/file/imgTmp", method = RequestMethod.POST)
@ResponseBody
public String getTmpImg(String url) {
try {
// 获取图片流
InputStream inputStream = new URL(url).openStream();
// 将输入流转换为字节数组
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, length);
}
byte[] imageBytes = byteArrayOutputStream.toByteArray();
// 关闭输入流
inputStream.close();
byteArrayOutputStream.close();
// 将字节数组编码为 Base64 字符串
String base64Image = Base64.getEncoder().encodeToString(imageBytes);
// 返回带有 MIME 类型的数据 URI
return base64Image;
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
} }

View File

@ -1,9 +1,14 @@
package com.yutou.bilibili.Tools; package com.yutou.bilibili.Tools;
import com.yutou.common.utils.Log; import com.yutou.common.utils.Log;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.List;
public class DateFormatUtils { public class DateFormatUtils {
public static String format(Date date, String format) { public static String format(Date date, String format) {
@ -38,4 +43,37 @@ public class DateFormatUtils {
return null; return null;
} }
} }
public static boolean checkTime(List<String> weeks, String recordDate) {
if (!StringUtils.hasText(recordDate)) {
recordDate = "00:00:00 - 23:59:59";
}
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;
if (weeks == null) {
isSpecifiedWeekDay = true;
} else {
isSpecifiedWeekDay = weeks.contains(String.valueOf(currentWeekDay));
}
// 判断当前时间是否在指定的时间范围内
boolean isWithinRange = (currentTime.isAfter(startTime) || currentTime.equals(startTime)) &&
(currentTime.isBefore(endTime) || currentTime.equals(endTime));
return isWithinRange && isSpecifiedWeekDay;
}
} }

View File

@ -19,8 +19,11 @@ public class ResultData<T> {
this.timestamp = System.currentTimeMillis(); this.timestamp = System.currentTimeMillis();
} }
public static <T> JSONObject success(T data) { public static <T> JSONObject success(T data) {
return success(data, -1);
}
public static <T> JSONObject success(T data, int count) {
ResultData<T> resultData = new ResultData<>(); ResultData<T> resultData = new ResultData<>();
resultData.setStatus(ReturnCode.RC100.getCode()); resultData.setStatus(ReturnCode.RC100.getCode());
resultData.setMessage(ReturnCode.RC100.getMessage()); resultData.setMessage(ReturnCode.RC100.getMessage());
@ -28,6 +31,9 @@ public class ResultData<T> {
if (data instanceof Collection<?>) { if (data instanceof Collection<?>) {
resultData.count = ((Collection<?>) data).size(); resultData.count = ((Collection<?>) data).size();
} }
if (count != -1) {
resultData.count = count;
}
return JSONObject.parseObject(JSONObject.toJSONString(resultData)); return JSONObject.parseObject(JSONObject.toJSONString(resultData));
} }

View File

@ -65,6 +65,9 @@ public class LiveConfigService {
public List<LiveConfigDatabaseBean> getAllConfig() { public List<LiveConfigDatabaseBean> getAllConfig() {
return database.getAllConfig(); return database.getAllConfig();
} }
public List<LiveConfigDatabaseBean> getConfigs(int page,int limit) {
return database.getConfigs(page, limit);
}
public LiveConfigDatabaseBean getConfig(String roomId) { public LiveConfigDatabaseBean getConfig(String roomId) {
return database.getConfig(roomId); return database.getConfig(roomId);
@ -97,4 +100,8 @@ public class LiveConfigService {
} }
} }
public int getConfigCount() {
return database.getConfigCount();
}
} }

View File

@ -38,7 +38,9 @@ public class LiveDanmuService {
public JSONArray getLiveRoomList() { public JSONArray getLiveRoomList() {
return WebSocketManager.getInstance().getLiveRoomList(); return WebSocketManager.getInstance().getLiveRoomList();
} }
public void clearUserList(){
WebSocketManager.getInstance().clearUserStopList();
}
public List<File> getDanmuFileList(String roomId) { public List<File> getDanmuFileList(String roomId) {
BiliLiveConfigDatabase configDatabase=new BiliLiveConfigDatabase(); BiliLiveConfigDatabase configDatabase=new BiliLiveConfigDatabase();

View File

@ -10,6 +10,7 @@ import com.yutou.common.okhttp.HttpBody;
import com.yutou.common.utils.AppTools; import com.yutou.common.utils.AppTools;
import com.yutou.common.utils.Log; import com.yutou.common.utils.Log;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.val;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException; import java.io.IOException;
@ -29,9 +30,11 @@ public class LiveService {
liveConfigDatabase = new BiliLiveConfigDatabase(); liveConfigDatabase = new BiliLiveConfigDatabase();
api = BiliLiveNetApiManager.getInstance().getApi(null); api = BiliLiveNetApiManager.getInstance().getApi(null);
} }
public int getConfigCount(){
public List<LiveData> getLiveList() { return liveConfigDatabase.getAllConfig().size();
List<LiveConfigDatabaseBean> allConfig = liveConfigDatabase.getAllConfig(); }
public List<LiveData> getLiveList(int page,int limit) {
List<LiveConfigDatabaseBean> allConfig = liveConfigDatabase.getConfigs(page,limit);
List<LiveData> liveDataList = new ArrayList<>(); List<LiveData> liveDataList = new ArrayList<>();
for (LiveConfigDatabaseBean config : allConfig) { for (LiveConfigDatabaseBean config : allConfig) {
LiveData liveData = new LiveData(); LiveData liveData = new LiveData();

View File

@ -60,6 +60,9 @@ public class LiveVideoService {
public boolean checkDownload(String roomId) { public boolean checkDownload(String roomId) {
return videoRecord.check(roomId); return videoRecord.check(roomId);
} }
public void clearUserStopList() {
userStopList.clear();
}
public void start(LiveConfigDatabaseBean bean, boolean isUser) { public void start(LiveConfigDatabaseBean bean, boolean isUser) {
if (!isUser && userStopList.contains(bean.getRoomId().toString())) { if (!isUser && userStopList.contains(bean.getRoomId().toString())) {

View File

@ -7,6 +7,7 @@ import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
import com.yutou.biliapi.databases.BiliLiveConfigDatabase; import com.yutou.biliapi.databases.BiliLiveConfigDatabase;
import com.yutou.biliapi.net.BiliLiveNetApiManager; import com.yutou.biliapi.net.BiliLiveNetApiManager;
import com.yutou.biliapi.net.WebSocketManager; import com.yutou.biliapi.net.WebSocketManager;
import com.yutou.bilibili.Tools.DateFormatUtils;
import com.yutou.bilibili.databases.SystemConfigDatabases; import com.yutou.bilibili.databases.SystemConfigDatabases;
import com.yutou.bilibili.datas.SystemConfigDatabaseBean; import com.yutou.bilibili.datas.SystemConfigDatabaseBean;
import com.yutou.common.okhttp.HttpBody; import com.yutou.common.okhttp.HttpBody;
@ -45,6 +46,8 @@ public class SystemService {
return config.getTimerLoop(); return config.getTimerLoop();
} }
private final String resetTimer = "00:00:00 - 00:01:00";
public void start() { public void start() {
if (timer == null) { if (timer == null) {
timer = Executors.newScheduledThreadPool(1); timer = Executors.newScheduledThreadPool(1);
@ -56,6 +59,10 @@ public class SystemService {
scheduled = timer.scheduleAtFixedRate(() -> { scheduled = timer.scheduleAtFixedRate(() -> {
List<LiveConfigDatabaseBean> list = liveConfigDatabase.getAllConfig(); List<LiveConfigDatabaseBean> list = liveConfigDatabase.getAllConfig();
Log.i("循环任务:" + list.size()); Log.i("循环任务:" + list.size());
if(DateFormatUtils.checkTime(null,resetTimer)){
videoService.clearUserStopList();
danmuService.clearUserList();
}
for (LiveConfigDatabaseBean bean : list) { for (LiveConfigDatabaseBean bean : list) {
try { try {
if (bean.isRecordDanmu() && bean.checkRecordDanmuTime()) { if (bean.isRecordDanmu() && bean.checkRecordDanmuTime()) {

View File

@ -234,6 +234,22 @@ public abstract class SQLiteManager {
return get(table, null, tClass); return get(table, null, tClass);
} }
protected int getCount(String table) {
try (PreparedStatement preparedStatement = conn.prepareStatement("SELECT count(*) FROM "+table)) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
if (resultSet.next()) {
return resultSet.getInt(1);
}
}
} catch (SQLException e) {
Log.e(e);
throw new RuntimeException("Error executing SQL query", e);
}
return 0;
}
protected <T extends AbsDatabasesBean> List<T> get(String table, String where, Class<T> tClass) { protected <T extends AbsDatabasesBean> List<T> get(String table, String where, Class<T> tClass) {
List<T> list = new ArrayList<>(); List<T> list = new ArrayList<>();
try { try {
@ -242,6 +258,7 @@ public abstract class SQLiteManager {
if (where != null) { if (where != null) {
sql += " WHERE " + where; sql += " WHERE " + where;
} }
System.out.println("sql = " + sql);
ResultSet resultSet = statement.executeQuery(sql); ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) { while (resultSet.next()) {
list.add(getSQL(resultSet).to(tClass)); list.add(getSQL(resultSet).to(tClass));