From c06b04869b961e3442a61ed1b2aef9bfd6609c6e Mon Sep 17 00:00:00 2001 From: Peanut Date: Sun, 19 Jul 2026 12:21:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(server):=20=E7=9F=AD=E7=AF=87=E5=B0=8F?= =?UTF-8?q?=E8=AF=B4=20SSE=20=E4=BB=A3=E7=90=86=20Controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ShortNovelController.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 server/src/main/java/com/emotion/controller/ShortNovelController.java diff --git a/server/src/main/java/com/emotion/controller/ShortNovelController.java b/server/src/main/java/com/emotion/controller/ShortNovelController.java new file mode 100644 index 0000000..d46e799 --- /dev/null +++ b/server/src/main/java/com/emotion/controller/ShortNovelController.java @@ -0,0 +1,42 @@ +package com.emotion.controller; + +import com.emotion.dto.request.ShortNovelFollowupRequest; +import com.emotion.dto.request.ShortNovelStreamRequest; +import com.emotion.service.ShortNovelService; +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.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; + +import javax.validation.Valid; + +/** + * 短篇小说外部服务代理 Controller + * + * @author huazhongmin + * @date 2026-07-19 + */ +@Tag(name = "短篇小说管理", description = "短篇小说生成 SSE 代理接口") +@RestController +@RequestMapping("/shortNovel") +public class ShortNovelController { + + @Autowired + private ShortNovelService shortNovelService; + + @Operation(summary = "首次发起短篇小说生成", description = "用户输入心愿文本,发起流式生成") + @PostMapping("/stream") + public SseEmitter stream(@Valid @RequestBody ShortNovelStreamRequest request) { + return shortNovelService.stream(request); + } + + @Operation(summary = "短篇小说后续轮次", description = "处理澄清回答、大纲确认/修改、重试等") + @PostMapping("/followup") + public SseEmitter followup(@Valid @RequestBody ShortNovelFollowupRequest request) { + return shortNovelService.followup(request); + } +} \ No newline at end of file