feat: 新增 ScriptChatController 统一流式接口

This commit is contained in:
2026-06-28 18:09:09 +08:00
parent 8537c27015
commit 3b9a8222de
2 changed files with 41 additions and 1 deletions
@@ -124,8 +124,18 @@ public class MessageController {
/**
* 删除消息
*/
@Operation(summary = "删除消息", description = "删除指定的消息。")
@DeleteMapping(value = "/delete")
public Result<Void> delete(@Parameter(description = "消息 ID") @RequestParam String id) {
boolean deleted = messageService.deleteMessage(id);
if (!deleted) {
return Result.error("删除失败");
}
return Result.success();
}
@Operation(summary = "删除版本消息", description = "删除指定的剧本版本消息,不能删除当前生效版本。")
@DeleteMapping(value = "/version")
@DeleteMapping(value = "/deleteVersion")
public Result<Void> deleteVersion(@Parameter(description = "消息 ID") @RequestParam String id) {
boolean deleted = scriptMessageService.deleteVersion(id);
if (!deleted) {
@@ -0,0 +1,30 @@
package com.emotion.controller;
import com.emotion.dto.request.ScriptChatStreamRequest;
import com.emotion.service.ScriptChatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import javax.validation.Valid;
/**
* 剧本对话流式控制器
*/
@RestController
@RequestMapping("/chat")
@Tag(name = "剧本对话", description = "剧本改写、续写、聊天的统一流式接口")
public class ScriptChatController {
@Autowired
private ScriptChatService scriptChatService;
@Operation(summary = "流式对话", description = "统一的剧本改写/续写/聊天流式接口。")
@PostMapping(value = "/stream", produces = "text/event-stream")
public SseEmitter stream(@Valid @RequestBody ScriptChatStreamRequest request) {
return scriptChatService.streamChat(request);
}
}