56 lines
1.9 KiB
Java
56 lines
1.9 KiB
Java
package com.yutou.bilibili.Controllers;
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.yutou.bilibili.datas.ResultData;
|
|
import com.yutou.bilibili.services.LiveDanmuService;
|
|
import com.yutou.bilibili.services.LiveService;
|
|
import com.yutou.bilibili.services.LiveVideoDownloadService;
|
|
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
|
|
LiveVideoDownloadService videoService;
|
|
@Resource
|
|
LiveDanmuService danmuService;
|
|
@Resource
|
|
LiveService liveService;
|
|
|
|
|
|
@RequestMapping("/live/list")
|
|
@ResponseBody
|
|
public JSONObject getLiveList(int page, int limit) {
|
|
List<JSONObject> list = liveService.getLiveList(page, limit).stream().map(it -> {
|
|
JSONObject json = JSONObject.parseObject(JSON.toJSONString(it));
|
|
if (videoService.isUserStopList(it.getRoomId())) {
|
|
json.put("videoListen", "已暂停");
|
|
} else if (it.isDownloadVideo()) {
|
|
json.put("videoListen", "录制中");
|
|
} else {
|
|
json.put("videoListen", "待机中");
|
|
}
|
|
if (danmuService.isUserStopList(it.getRoomId())) {
|
|
json.put("danmuListen", "已暂停");
|
|
} else if (it.isDanmu()) {
|
|
json.put("danmuListen", "录制中");
|
|
} else {
|
|
json.put("danmuListen", "待机中");
|
|
}
|
|
return json;
|
|
}).toList();
|
|
return ResultData.success(list, liveService.getConfigCount());
|
|
}
|
|
|
|
@RequestMapping("/live/gift/info")
|
|
@ResponseBody
|
|
public JSONObject download(String roomId, String videoId) {
|
|
return ResultData.success(liveService.getGiftInfo(roomId, videoId));
|
|
}
|
|
}
|