package com.backendsys.modules.ai.chat.controller; import com.backendsys.modules.ai.chat.entity.Chat; import com.backendsys.modules.ai.chat.service.ChatService; import com.backendsys.modules.common.utils.Result; import io.swagger.v3.oas.annotations.Operation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @Validated @RestController public class ChatController { @Autowired private ChatService chatService; @Operation(summary = "发起对话") @PreAuthorize("@sr.hasPermission('31')") @PostMapping("/api/ai/chat/sendChat") public Result sendChat(@Validated(Chat.Create.class) @RequestBody Chat chat) { return Result.success().put("data", chatService.sendChat(chat)); } @Operation(summary = "获取我的对话") @PreAuthorize("@sr.hasPermission('31')") @GetMapping("/api/ai/chat/getChatList") public Result getChatList(@Validated(Chat.Detail.class) Chat chat) { return Result.success().put("data", chatService.selectChatList(chat.getHistory_code())); } }