xiangpei
2025-04-18 0aa739db8268b442ab74634289ffed00124a976a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.monkeylessey.controller;
 
import com.monkeylessey.domain.form.ChatForm;
import com.monkeylessey.domain.form.SessionForm;
import com.monkeylessey.group.Add;
import com.monkeylessey.response.Result;
import com.monkeylessey.service.ChatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
 
import javax.servlet.http.HttpServletResponse;
 
/**
 * @author:xp
 * @date:2025/4/18 13:59
 */
@Validated
@RequiredArgsConstructor
@Api(value = "chat对话", tags = "chat对话管理")
@RestController
@RequestMapping("/chat")
public class ChatController {
 
    private final ChatService chatService;
 
    @PostMapping(value = "/send/msg", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    @ApiOperation(value = "问问题/对话", notes = "问问题/对话")
    public SseEmitter sendMsg(@RequestBody @Validated ChatForm form) {
        return chatService.sendMsg(form);
    }
 
}