package com.custom.webui.controller; import com.custom.webui.dto.resp.Result; import com.custom.webui.security.CurrentUser; import com.custom.webui.service.PendingAttachmentService; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; 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 java.util.HashMap; import java.util.Map; /** * 临时附件文本接口。 * *
存在的唯一理由:SSE 是 GET 请求,参数只能走 query string, * 而图片 OCR 文字达几千字时中文 URL 编码会撑爆 Tomcat 的请求行上限 * (默认 8KB,2000 个汉字约 18KB),得到 * {@code Request header is too large} 这种前端完全看不懂的 400。 * *
所以先 POST 存文本换一个短 id,SSE 只带 id。 */ @Slf4j @RestController @RequestMapping("/api/attachments") @RequiredArgsConstructor public class AttachmentController { private final PendingAttachmentService pendingAttachmentService; /** * 暂存一段附件文本,返回可放入 query 的短 id。 * *
用于图片 OCR 文字:前端识别完成后先存这里, * 发送消息时只传 {@code imageTextId}。 */ @PostMapping("/text") public Result