This commit is contained in:
2024-10-31 18:23:39 +08:00
parent 4b04c1863b
commit 34a41f50ac
31 changed files with 561 additions and 223 deletions

View File

@@ -37,9 +37,9 @@ public class LiveAnchorInfo {
@JSONField(name = "title")
private String title;
@JSONField(name = "room_id")
private BigInteger roomId;
private String roomId;
@JSONField(name = "uid")
private BigInteger uid;
private String uid;
@JSONField(name = "online")
private int online;
@JSONField(name = "live_time")

View File

@@ -11,7 +11,7 @@ import java.util.Objects;
@Data
public class LiveRoomConfig {
String loginUid;
BigInteger roomId;
String roomId;
String anchorName;
boolean isLogin;
String rootPath="live";
@@ -44,7 +44,7 @@ public class LiveRoomConfig {
public static LiveRoomConfig buildConfig(String roomId){
BiliLiveConfigDatabase database = new BiliLiveConfigDatabase();
LiveConfigDatabaseBean bean = database.getConfig(new BigInteger(roomId));
LiveConfigDatabaseBean bean = database.getConfig(new String(roomId));
LiveRoomConfig config = new LiveRoomConfig();
config.setLoginUid(bean.getRecordUid());

View File

@@ -9,10 +9,10 @@ import java.util.List;
@Data
public class LiveRoomInfo {
@JSONField(name = "uid")
private BigInteger uid;
private String uid;
@JSONField(name = "room_id")
private BigInteger roomId;
private String roomId;
@JSONField(name = "short_id")
private int shortId;

View File

@@ -12,13 +12,13 @@ import java.util.List;
@Data
public class LiveRoomPlayInfo extends BaseBean {
@JSONField(name = "room_id")
private BigInteger roomId;
private String roomId;
@JSONField(name = "short_id")
private int shortId;
@JSONField(name = "uid")
private BigInteger uid;
private String uid;
@JSONField(name = "is_hidden")
private boolean isHidden;

View File

@@ -29,7 +29,7 @@ public class LiveRoomStatus {
private int online;
@JSONField(name = "roomid")
private BigInteger roomid;
private String roomid;
@JSONField(name = "broadcast_type")
private int broadcastType;

View File

@@ -41,7 +41,7 @@ public class MasterInfoBean extends BaseBean {
@Data
public static class Info {
@JSONField(name = "uid")
private BigInteger uid;
private String uid;
@JSONField(name = "uname")
private String uname;

View File

@@ -2,12 +2,17 @@ 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.common.databases.AbsDatabasesBean;
import com.yutou.common.utils.Log;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.File;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -18,9 +23,9 @@ import static com.alibaba.fastjson2.util.DateUtils.DateTimeFormatPattern.DATE_FO
@Data
public class LiveConfigDatabaseBean extends AbsDatabasesBean {
@JSONField(name = "live_room_id")
private BigInteger roomId;
private String roomId;
@JSONField(name = "anchorUid")
private BigInteger anchorUid;
private String anchorUid;
@JSONField(name = "anchorName")
private String anchorName;
@JSONField(name = "anchorFace")
@@ -31,6 +36,8 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
private boolean isRecordDanmu;
@JSONField(name = "keyword")
private List<String> keywordList;
@JSONField(name = "week")
private List<String> weeks;
@JSONField(name = "recordPath")
private String recordPath = "live";
@JSONField(name = "recordUid")
@@ -38,9 +45,9 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
@JSONField(name = "recordLiveModel")
private int recordLiveModel;//0 - ffmpeg 1 - java
@JSONField(name = "recordDanmuDate")
private String recordDanmuDate = "* * *";// * * * 分 时 星期 | 周日是1
private String recordDanmuDate = null;// 时间范围 20:00:00 - 23:59:59
@JSONField(name = "recordLiveDate")
private String recordLiveDate = "* * *";// * * * 分 时 星期 | 周日是1
private String recordLiveDate = null;// 时间范围 20:00:00 - 23:59:59
public LiveConfigDatabaseBean() {
@@ -64,55 +71,42 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
}
private boolean verifyTimer(String val) {
int _length = val.length();
boolean isFullDate = (_length - val.replace("*", "").length()) == 3
&& (_length - val.replace("*", "").trim().length()) == 0;
String[] split = val.split(" ");
if (isFullDate) {
return true;
}
String minute = split[0];
String hour = split[1];
String day = split[2];
String t = "20:00:00 - 23:59:59";
try {
Integer.parseInt(minute);
Integer.parseInt(hour);
Integer.parseInt(day);
String[] time = val.split(" - ");
Date start = DateFormatUtils.parseTimer(time[0]);
Date end = DateFormatUtils.parseTimer(time[1]);
if (start != null && end != null) {
return true;
}
} catch (Exception e) {
return false;
Log.e(e);
}
return true;
return false;
}
private boolean checkRecordTime(String recordDate) {
int _length = recordDate.length();
boolean isFullDate = (_length - recordDate.replace("*", "").length()) == 3;
if (isFullDate) {
return true;
}
String[] split = recordDate.split(" ");
String minute = split[0];
String hour = split[1];
String day = split[2];
boolean isFullMinute = "*".equals(minute);
boolean isFullHour = "*".equals(hour);
boolean isFullDay = "*".equals(day);
Calendar today = Calendar.getInstance();
if (!isFullDay) {
if (today.get(Calendar.DAY_OF_WEEK) != Integer.parseInt(day) + 1) {
return false;
}
}
if (!isFullHour) {
if (today.get(Calendar.HOUR_OF_DAY) != Integer.parseInt(hour)) {
return false;
}
}
if (!isFullMinute) {
if (today.get(Calendar.MINUTE) != Integer.parseInt(minute)) {
return false;
}
}
return true;
//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;
}
}

View File

@@ -25,7 +25,7 @@ public class LiveDanmuDatabaseBean extends AbsDatabasesBean {
@JSONField(name = "time")
private long time;
@JSONField(name = "uid")
private BigInteger uid;
private String uid;
@JSONField(name = "uname")
private String uname;

View File

@@ -18,9 +18,9 @@ public class LiveInfoDatabaseBean extends AbsDatabasesBean {
@JSONField(name = "id")
int id;
@JSONField(name = "roomId")
private BigInteger roomId;
private String roomId;
@JSONField(name = "anchorUid")
private BigInteger anchorUid;
private String anchorUid;
@JSONField(name = "title")
private String title;
@JSONField(name = "record_time_start")

View File

@@ -32,7 +32,7 @@ public class UserInfoBean extends BaseBean {
private LevelInfo levelInfo;
@JSONField(name = "mid")
private BigInteger mid;
private String mid;
@JSONField(name = "mobile_verified")
private int mobileVerified;

View File

@@ -23,7 +23,7 @@ public class WSDanmuData extends WSData {
private long time;
private String uCode;
private String danmu;
private BigInteger uid;
private String uid;
private String uname;
private WSUserMedal medal;
@@ -36,7 +36,7 @@ public class WSDanmuData extends WSData {
setTime(infoData.getJSONArray(0).getLong(4));
setUCode(infoData.getJSONArray(0).getString(7));
setDanmu(infoData.getString(1));
setUid(infoData.getJSONArray(2).getBigInteger(0));
setUid(infoData.getJSONArray(2).getFirst().toString());
setUname(infoData.getJSONArray(2).getString(1));
try {
medal = WSUserMedal.create(infoData.getJSONArray(3));

View File

@@ -61,7 +61,7 @@ public class BiliBiliLoginDatabase extends SQLiteManager {
return list.getFirst();
}
for (LoginUserDatabaseBean bean : list) {
if (bean.getUserInfo().getMid().equals(new BigInteger(userId))) {
if (bean.getUserInfo().getMid().equals(new String(userId))) {
return bean;
}
}

View File

@@ -41,7 +41,7 @@ public class BiliLiveConfigDatabase extends SQLiteManager {
update(bean);
}
public LiveConfigDatabaseBean getConfig(BigInteger roomId) {
public LiveConfigDatabaseBean getConfig(String roomId) {
List<LiveConfigDatabaseBean> list = get(getDataBean().get(0).getTableName(), LiveConfigDatabaseBean.class);
if (list.isEmpty()) {
return null;
@@ -54,7 +54,7 @@ public class BiliLiveConfigDatabase extends SQLiteManager {
return null;
}
public boolean deleteConfig(BigInteger roomId) {
public boolean deleteConfig(String roomId) {
LiveConfigDatabaseBean config = getConfig(roomId);
if (config == null) {
return false;

View File

@@ -44,18 +44,18 @@ public class BiliLiveNetApiManager extends BaseApi {
return createApi(LiveApi.class);
}
public Map<BigInteger, LiveAnchorInfo> getAnchorInfos(String loginUid,List<BigInteger> anchorIds) {
public Map<String, LiveAnchorInfo> getAnchorInfos(String loginUid,List<BigInteger> anchorIds) {
JSONObject json = new JSONObject();
json.put("uids", anchorIds);
try {
String src = getApi(loginUid).getLiveRoomStatus(json).execute().body().getSrc();
json = JSONObject.parseObject(src);
if (json.getInteger("code") == 0) {
Map<BigInteger, LiveAnchorInfo> map = new HashMap<>();
Map<String, LiveAnchorInfo> map = new HashMap<>();
JSONObject data = json.getJSONObject("data");
for (String key : data.keySet()) {
LiveAnchorInfo info = JSONObject.parseObject(data.getString(key), LiveAnchorInfo.class);
map.put(new BigInteger(key), info);
map.put(key, info);
}
return map;
}

View File

@@ -85,7 +85,7 @@ public class WebSocketManager {
public void stopRoom(String roomId, boolean isUser) {
LiveRoomConfig roomConfig = new LiveRoomConfig();
roomConfig.setRoomId(new BigInteger(roomId));
roomConfig.setRoomId(new String(roomId));
if (checkRoom(roomConfig)) {
roomMap.get(roomConfig).close();
roomMap.remove(roomConfig);
@@ -278,7 +278,7 @@ public class WebSocketManager {
String buvid = BiliUserUtils.getBuvid(BiliBiliLoginDatabase.getInstance().getCookie(roomConfig.getLoginUid()));
if (buvid != null) {
try {
json.put("roomid", roomConfig.getRoomId());
json.put("roomid", new BigInteger(roomConfig.getRoomId()));
json.put("protover", 3);
json.put("buvid", buvid);
json.put("platform", "web");

View File

@@ -56,7 +56,7 @@ public class LiveConfigController {
return ResultData.fail(ReturnCode.RC999.getCode(),"弹幕录制时间格式错误");
}
LiveConfigDatabaseBean config = configService.updateConfig(new BigInteger(roomId), bean);
LiveConfigDatabaseBean config = configService.updateConfig(new String(roomId), bean);
if (config != null) {
return ResultData.success(config.toJson());
}
@@ -69,7 +69,7 @@ public class LiveConfigController {
if ("0".equals(roomId) || !StringUtils.hasText(roomId)) {
return ResultData.fail(ReturnCode.RC999);
}
LiveConfigDatabaseBean config = configService.getConfig(new BigInteger(roomId));
LiveConfigDatabaseBean config = configService.getConfig(new String(roomId));
if (config != null) {
return ResultData.success(config.toJson());
}
@@ -88,8 +88,8 @@ public class LiveConfigController {
@RequestMapping(value = "delete", method = RequestMethod.GET)
@ResponseBody
public JSONObject deleteConfig(BigInteger roomId) {
if (roomId.equals(BigInteger.ZERO)) {
public JSONObject deleteConfig(String roomId) {
if ("0".equals(roomId)|| !StringUtils.hasText(roomId)) {
return ResultData.fail(ReturnCode.RC999);
}
boolean flag = configService.deleteConfig(roomId);

View File

@@ -0,0 +1,32 @@
package com.yutou.bilibili.Controllers;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.bilibili.datas.ResultData;
import com.yutou.bilibili.datas.VideoFilePath;
import com.yutou.bilibili.services.LiveDanmuService;
import com.yutou.bilibili.services.LiveService;
import com.yutou.bilibili.services.LiveVideoService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
public class LiveController {
@Resource
LiveVideoService videoService;
@Resource
LiveDanmuService danmuService;
@Resource
LiveService liveService;
@RequestMapping("/live/list")
@ResponseBody
public JSONObject getLiveList(){
return ResultData.success(liveService.getLiveList());
}
}

View File

@@ -1,5 +1,6 @@
package com.yutou.bilibili.Controllers;
import com.yutou.common.okhttp.HttpLoggingInterceptor;
import com.yutou.common.utils.FFmpegUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -12,4 +13,10 @@ public class TestControllers {
public String test(){
return "hello world";
}
@ResponseBody
@RequestMapping("/root/log")
public String log(boolean flag){
HttpLoggingInterceptor.setLog(flag);
return flag+"";
}
}

View File

@@ -1,22 +1,41 @@
package com.yutou.bilibili.Tools;
import com.yutou.common.utils.Log;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateFormatUtils {
public static String format(Date date,String format){
public static String format(Date date, String format) {
return new SimpleDateFormat(format).format(date);
}
public static String format(long time,String format){
public static String format(long time, String format) {
return new SimpleDateFormat(format).format(new Date(time));
}
public static String format(long time){
public static String format(long time) {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(time));
}
public static String format(Date date){
public static String format(Date date) {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(date);
}
public static String format(){
public static String format() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
}
public static Date parseTimer(String date) {
return parse(date, "HH:mm:ss");
}
public static Date parse(String date, String format) {
try {
return new SimpleDateFormat(format).parse(date);
} catch (Exception e) {
Log.e(e);
return null;
}
}
}

View File

@@ -0,0 +1,21 @@
package com.yutou.bilibili.datas.web;
import com.yutou.common.okhttp.BaseBean;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class LiveData extends BaseBean {
private String roomId;
private String anchorName;
private String anchorUid;
private String anchorFace;
private String title;
private String cover;
private boolean isLive;
private boolean isDanmu;
private boolean isDownloadVideo;
}

View File

@@ -27,7 +27,7 @@ public class LiveConfigService {
if (!StringUtils.hasText(roomId)) {
return null;
}
bean.setRoomId(new BigInteger(roomId));
bean.setRoomId(new String(roomId));
try {
LiveRoomInfo body = BiliLiveNetApiManager.getInstance().getApi(null).getRoomInfo(String.valueOf(bean.getRoomId())).execute().body().getData();
MasterInfoBean infoBean = BiliLiveNetApiManager.getInstance().getApi(null).getMasterInfo(String.valueOf(body.getUid())).execute().body().getData();
@@ -36,14 +36,13 @@ public class LiveConfigService {
bean.setAnchorFace(infoBean.getInfo().getFace());
bean.setAnchorName(infoBean.getInfo().getUname());
database.setConfig(bean);
downloadFace(bean);
return bean;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public LiveConfigDatabaseBean updateConfig(BigInteger roomId, LiveConfigDatabaseBean bean) {
public LiveConfigDatabaseBean updateConfig(String roomId, LiveConfigDatabaseBean bean) {
LiveConfigDatabaseBean config = database.getConfig(roomId);
if (config == null) {
return null;
@@ -51,11 +50,10 @@ public class LiveConfigService {
bean.setRoomId(roomId);
bean.setSql_time(config.getSql_time());
database.setConfig(bean);
downloadFace(bean);
return bean;
}
public boolean deleteConfig(BigInteger roomId) {
public boolean deleteConfig(String roomId) {
LiveConfigDatabaseBean config = database.getConfig(roomId);
if (config == null) {
return false;
@@ -68,32 +66,23 @@ public class LiveConfigService {
return database.getAllConfig();
}
public LiveConfigDatabaseBean getConfig(BigInteger roomId) {
public LiveConfigDatabaseBean getConfig(String roomId) {
return database.getConfig(roomId);
}
public File getFace(String roomId) {
LiveConfigDatabaseBean config = database.getConfig(new BigInteger(roomId));
LiveConfigDatabaseBean config = database.getConfig(new String(roomId));
if (config == null) {
return null;
}
return new File(config.getRecordPath() + File.separator + config.getAnchorName() + File.separator + config.getAnchorFace());
}
private void downloadFace(LiveConfigDatabaseBean bean) {
HttpDownloadUtils.download(
new HttpDownloadUtils.Builder()
.setPath(bean.getRecordPath() + File.separator + bean.getAnchorName())
.setUrl(bean.getAnchorFace())
.setFileName("face.jpg")
);
bean.setAnchorFace(bean.getRecordPath() + File.separator + bean.getAnchorName() + File.separator + "face.jpg");
}
public boolean checkUrl(String url) {
if (!url.startsWith("https://live.bilibili.com/")) {
try {
new BigInteger(url);
new String(url);
} catch (Exception e) {
return false;
}

View File

@@ -25,6 +25,11 @@ public class LiveDanmuService {
public void start(String roomId,boolean isUser) {
WebSocketManager.getInstance().addRoom(LiveRoomConfig.buildConfig(roomId), isUser);
}
public boolean check(String roomId) {
LiveRoomConfig roomConfig = new LiveRoomConfig();
roomConfig.setRoomId(roomId);
return WebSocketManager.getInstance().checkRoom(roomConfig);
}
public void stop(String roomId,boolean isUser) {
WebSocketManager.getInstance().stopRoom(roomId, isUser);
@@ -37,7 +42,7 @@ public class LiveDanmuService {
public List<File> getDanmuFileList(String roomId) {
BiliLiveConfigDatabase configDatabase=new BiliLiveConfigDatabase();
LiveConfigDatabaseBean bean = configDatabase.getConfig(new BigInteger(roomId));
LiveConfigDatabaseBean bean = configDatabase.getConfig(new String(roomId));
configDatabase.close();
return Tools.scanFile(new File(bean.getRecordPath() + File.separator + bean.getAnchorName()));
}

View File

@@ -0,0 +1,62 @@
package com.yutou.bilibili.services;
import com.yutou.biliapi.api.LiveApi;
import com.yutou.biliapi.bean.live.LiveRoomInfo;
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
import com.yutou.biliapi.databases.BiliLiveConfigDatabase;
import com.yutou.biliapi.net.BiliLiveNetApiManager;
import com.yutou.bilibili.datas.web.LiveData;
import com.yutou.common.okhttp.HttpBody;
import com.yutou.common.utils.AppTools;
import com.yutou.common.utils.Log;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Service
public class LiveService {
BiliLiveConfigDatabase liveConfigDatabase;
@Resource
LiveVideoService videoService;
@Resource
LiveDanmuService danmuService;
LiveApi api;
public LiveService() {
liveConfigDatabase = new BiliLiveConfigDatabase();
api = BiliLiveNetApiManager.getInstance().getApi(null);
}
public List<LiveData> getLiveList() {
List<LiveConfigDatabaseBean> allConfig = liveConfigDatabase.getAllConfig();
List<LiveData> liveDataList = new ArrayList<>();
for (LiveConfigDatabaseBean config : allConfig) {
LiveData liveData = new LiveData();
liveData.setRoomId(config.getRoomId());
liveData.setAnchorUid(config.getAnchorUid());
liveData.setAnchorName(config.getAnchorName());
liveData.setAnchorFace(config.getAnchorFace());
liveData.setDownloadVideo(videoService.checkDownload(config.getRoomId()));
liveData.setDanmu(danmuService.check(config.getRoomId()));
try {
LiveRoomInfo body = api.getRoomInfo(config.getRoomId()).execute().body().getData();
if (body != null) {
liveData.setTitle(body.getTitle());
liveData.setLive(body.getLiveStatus() == 1);
if (body.getLiveStatus() == 1) {
liveData.setCover(body.getKeyframe());
} else {
liveData.setCover(body.getUserCover());
}
}
liveDataList.add(liveData);
} catch (IOException e) {
Log.e(e);
}
}
return liveDataList;
}
}

View File

@@ -47,16 +47,20 @@ import static com.alibaba.fastjson2.util.DateUtils.DateTimeFormatPattern.DATE_FO
@Service
public class LiveVideoService {
ThreadPoolExecutor executor;
private final ThreadPoolExecutor executor;
private final List<String> userStopList = new ArrayList<>();//手动停止列表
AbsVideoRecord videoRecord;
private final AbsVideoRecord videoRecord;
public LiveVideoService() {
Log.i("初始化下载服务");
videoRecord=new FFmpegUtils();
videoRecord = new FFmpegUtils();
executor = new ThreadPoolExecutor(2, 4, Long.MAX_VALUE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100));
}
public boolean checkDownload(String roomId) {
return videoRecord.check(roomId);
}
public void start(LiveConfigDatabaseBean bean, boolean isUser) {
if (!isUser && userStopList.contains(bean.getRoomId().toString())) {
return;
@@ -240,15 +244,17 @@ public class LiveVideoService {
cookie = ck.toCookieString();
}
FFmpegUtils command = new FFmpegUtils.Builder()
FFmpegUtils.Builder builder = new FFmpegUtils.Builder()
.withParam("-user_agent", ConfigTools.getUserAgent())
.withParam("-cookies", cookie)
.withParam("-headers", "Referer: https://live.bilibili.com")
// .withNotSymbolParam("-progress", "-")
.withNotSymbolParam("-threads", "8")
.withNotSymbolParam("-c:v", "copy")
.withNotSymbolParam("-y", "")
.build(config.getRoomId().toString(), ffmpegPath, url, savePath);
.withNotSymbolParam("-y", "");
if (ck != null) {
builder = builder.withParam("-cookies", cookie);
}
FFmpegUtils command = builder.build(config.getRoomId(), ffmpegPath, url, savePath);
Log.i(command.getCommand());
try {
command.start(new DownloadInterface() {
@@ -306,7 +312,7 @@ public class LiveVideoService {
public List<VideoFilePath> getVideoPath(String roomId) {
BiliLiveConfigDatabase configDatabase = new BiliLiveConfigDatabase();
LiveConfigDatabaseBean bean = configDatabase.getConfig(new BigInteger(roomId));
LiveConfigDatabaseBean bean = configDatabase.getConfig(new String(roomId));
configDatabase.close();
return new ArrayList<>(getVideoFilePath(bean));
}

View File

@@ -54,7 +54,7 @@ public abstract class SQLiteManager {
type = BuildSqlItem.TYPE_BOOLEAN;
} else if (field.getType() == ISqlDatabaseBean.class) {
type = BuildSqlItem.TYPE_TEXT;
} else if (field.getType() == BigInteger.class) {
} else if (field.getType() == String.class) {
type = BuildSqlItem.TYPE_INT;
}
items.add(BuildSqlItem.create().setName(name).setType(type).setNull(!"id".equals(name)).setKey("id".equals(name)));
@@ -136,7 +136,7 @@ public abstract class SQLiteManager {
statement.setInt(i++, json.getInteger(key));
} else if (json.get(key) instanceof Long) {
statement.setLong(i++, json.getLong(key));
} else if (json.get(key) instanceof BigInteger) {
} else if (json.get(key) instanceof String) {
statement.setObject(i++, json.get(key));
} else if (json.get(key) instanceof Boolean) {
statement.setBoolean(i++, json.getBoolean(key));
@@ -353,7 +353,7 @@ public abstract class SQLiteManager {
public static void main(String[] args) {
LiveConfigDatabaseBean bean = new LiveConfigDatabaseBean();
bean.setRoomId(new BigInteger("123"));
bean.setRoomId(new String("123"));
bean.setRecordLive(true);
bean.setKeywordList(List.of("111", "22"));
JSONObject json = bean.toJson();