完善批量设置

This commit is contained in:
2024-11-27 18:06:15 +08:00
parent ad84c71a30
commit 38854993d0
5 changed files with 22 additions and 14 deletions

View File

@@ -25,7 +25,7 @@ public class FollowLive extends BaseBean {
private String roomId;
@JSONField(name = "uid")
private int uid;
private String uid;
@JSONField(name = "online")
private int online;

View File

@@ -140,13 +140,20 @@ public class LiveConfigController {
@RequestMapping(value = "set/array", method = RequestMethod.POST)
@ResponseBody
public JSONObject addArrayConfig(@RequestBody JSONObject jsonObject) {
LiveConfigDatabaseBean bean = jsonObject.getJSONObject("config").to(LiveConfigDatabaseBean.class);
JSONObject config=jsonObject.getJSONObject("config");
LiveConfigDatabaseBean bean = config.to(LiveConfigDatabaseBean.class);
if (!bean.verifyLiveTimer()) {
return ResultData.fail(ReturnCode.RC999.getCode(), "视频录制时间格式错误");
}
if (!bean.verifyDanmuTimer()) {
return ResultData.fail(ReturnCode.RC999.getCode(), "弹幕录制时间格式错误");
}
if("on".equals(config.getString("recordDanmu"))){
bean.setRecordDanmu(true);
}
if("on".equals(config.getString("recordLive"))){
bean.setRecordLive(true);
}
JSONArray jsonArray = jsonObject.getJSONArray("array");
List<LiveConfigDatabaseBean> list = jsonArray.stream().map(roomId -> configService.addConfig(roomId.toString(), bean)).toList();
int countNull = list.stream().filter(Objects::isNull).toList().size();
@@ -160,16 +167,17 @@ public class LiveConfigController {
int countNull = list.stream().filter(it -> !it).toList().size();
return ResultData.success("成功删除" + (list.size() - countNull) + "个直播间");
}
@RequestMapping(value = "delete/all", method = RequestMethod.GET)
@ResponseBody
public JSONObject deleteAllConfig() {
for (LiveConfigDatabaseBean bean : configService.getAllConfig()) {
configService.deleteConfig(bean.getRoomId());
}
if(configService.getAllConfig().isEmpty()) {
if (configService.getAllConfig().isEmpty()) {
return ResultData.success("成功删除");
}else{
return ResultData.fail(-1,"删除失败,剩余:"+configService.getAllConfig().size()+"个直播间");
} else {
return ResultData.fail(-1, "删除失败,剩余:" + configService.getAllConfig().size() + "个直播间");
}
}