fix: 修复视频接口中错误引用 ChatResponse 导致的编译失败
This commit is contained in:
@@ -3,12 +3,13 @@ package com.chat.controller;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.chat.model.VideoStream;
|
||||
import com.chat.service.VideoStreamService;
|
||||
import com.chat.model.dto.ChatResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 视频流控制器
|
||||
@@ -24,25 +25,30 @@ public class VideoStreamController {
|
||||
* 获取视频列表,可根据分类筛选
|
||||
*/
|
||||
@GetMapping
|
||||
public ChatResponse<List<VideoStream>> listVideos(@RequestParam(required = false) String category) {
|
||||
public ResponseEntity<?> listVideos(@RequestParam(required = false) String category) {
|
||||
LambdaQueryWrapper<VideoStream> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (category != null && !category.isEmpty() && !"全部".equals(category)) {
|
||||
queryWrapper.eq(VideoStream::getCategory, category);
|
||||
}
|
||||
queryWrapper.orderByDesc(VideoStream::getId);
|
||||
return ChatResponse.success(videoStreamService.list(queryWrapper));
|
||||
List<VideoStream> list = videoStreamService.list(queryWrapper);
|
||||
return ResponseEntity.ok(Map.of("code", 200, "data", list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收爬虫提交的视频并保存
|
||||
*/
|
||||
@PostMapping
|
||||
public ChatResponse<Boolean> addVideo(@RequestBody VideoStream videoStream) {
|
||||
public ResponseEntity<?> addVideo(@RequestBody VideoStream videoStream) {
|
||||
if (videoStream.getCreatedAt() == null) {
|
||||
videoStream.setCreatedAt(LocalDateTime.now());
|
||||
videoStream.setUpdatedAt(LocalDateTime.now());
|
||||
}
|
||||
boolean saved = videoStreamService.save(videoStream);
|
||||
return saved ? ChatResponse.success(true) : ChatResponse.error(500, "保存失败");
|
||||
if (saved) {
|
||||
return ResponseEntity.ok(Map.of("code", 200, "data", true));
|
||||
} else {
|
||||
return ResponseEntity.status(500).body(Map.of("code", 500, "message", "保存失败"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user