You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.6 KiB
64 lines
2.6 KiB
|
3 weeks ago
|
package com.ruoyi.web.controller;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
||
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
import com.ruoyi.common.core.controller.BaseController;
|
||
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||
|
|
import com.ruoyi.websocket.service.WhiteboardRoomService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 白板 Controller:房间维度的白板 CRUD,数据存 Redis
|
||
|
|
*/
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/room")
|
||
|
|
public class WhiteboardController extends BaseController {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private WhiteboardRoomService whiteboardRoomService;
|
||
|
|
|
||
|
|
/** 获取房间下所有白板列表 */
|
||
|
|
@GetMapping("/{roomId}/whiteboards")
|
||
|
|
public AjaxResult list(@PathVariable Long roomId) {
|
||
|
|
List<Object> list = whiteboardRoomService.listWhiteboards(roomId);
|
||
|
|
return success(list);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取单个白板详情 */
|
||
|
|
@GetMapping("/{roomId}/whiteboard/{whiteboardId}")
|
||
|
|
public AjaxResult get(@PathVariable Long roomId, @PathVariable String whiteboardId) {
|
||
|
|
Object wb = whiteboardRoomService.getWhiteboard(roomId, whiteboardId);
|
||
|
|
if (wb == null) return error("白板不存在");
|
||
|
|
return success(wb);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 创建白板 */
|
||
|
|
@PostMapping("/{roomId}/whiteboard")
|
||
|
|
public AjaxResult create(@PathVariable Long roomId, @RequestBody Object whiteboard) {
|
||
|
|
Object created = whiteboardRoomService.createWhiteboard(roomId, whiteboard);
|
||
|
|
return success(created);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 更新白板 */
|
||
|
|
@PutMapping("/{roomId}/whiteboard/{whiteboardId}")
|
||
|
|
public AjaxResult update(@PathVariable Long roomId, @PathVariable String whiteboardId,
|
||
|
|
@RequestBody Object whiteboard) {
|
||
|
|
boolean ok = whiteboardRoomService.updateWhiteboard(roomId, whiteboardId, whiteboard);
|
||
|
|
return ok ? success() : error("更新失败");
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 删除白板 */
|
||
|
|
@DeleteMapping("/{roomId}/whiteboard/{whiteboardId}")
|
||
|
|
public AjaxResult delete(@PathVariable Long roomId, @PathVariable String whiteboardId) {
|
||
|
|
boolean ok = whiteboardRoomService.deleteWhiteboard(roomId, whiteboardId);
|
||
|
|
return ok ? success() : error("删除失败");
|
||
|
|
}
|
||
|
|
}
|