diff --git a/src/main/java/cn/teammodel/controller/frontend/AiController.java b/src/main/java/cn/teammodel/controller/frontend/AiController.java index fdda18e..141b7e4 100644 --- a/src/main/java/cn/teammodel/controller/frontend/AiController.java +++ b/src/main/java/cn/teammodel/controller/frontend/AiController.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; @RestController -@RequestMapping("/ai") +@RequestMapping("public/ai") @Api(tags = "AI 能力") public class AiController { @Resource diff --git a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java index 19a7f34..e5faaff 100644 --- a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java @@ -115,8 +115,9 @@ public class ChatMessageServiceImpl implements ChatMessageService { * 会话模式 */ private SseEmitter completionBySession(ChatCompletionReqDto chatCompletionReqDto) { - User user = SecurityUtil.getLoginUser(); - String userId = user.getId(); +// User user = SecurityUtil.getLoginUser(); +// String userId = user.getId(); + String userId = "1595321354"; String userPrompt = chatCompletionReqDto.getText(); String sessionId = chatCompletionReqDto.getSessionId(); diff --git a/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java b/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java index 5fe3a36..b5bfb30 100644 --- a/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java @@ -4,12 +4,10 @@ import cn.hutool.core.lang.UUID; import cn.teammodel.common.ErrorCode; import cn.teammodel.common.PK; import cn.teammodel.config.exception.ServiceException; -import cn.teammodel.repository.ChatSessionRepository; import cn.teammodel.model.dto.ai.UpdateSessionDto; -import cn.teammodel.model.entity.User; import cn.teammodel.model.entity.ai.ChatSession; import cn.teammodel.model.entity.ai.ChatSession.Message; -import cn.teammodel.security.utils.SecurityUtil; +import cn.teammodel.repository.ChatSessionRepository; import cn.teammodel.service.ChatSessionService; import cn.teammodel.utils.RepositoryUtil; import com.azure.cosmos.models.CosmosPatchOperations; @@ -36,10 +34,11 @@ public class ChatSessionServiceImpl implements ChatSessionService { @Override public String createSession() { - User user = SecurityUtil.getLoginUser(); - String userId = user.getId(); +// todo User user = SecurityUtil.getLoginUser(); || 2. user.getName() +// String userId = user.getId(); + String userId = "1595321354"; // 初始化欢迎语 - Message message = Message.of("", "你好" + user.getName() + " ,我是你的私人 AI 助手小豆,你可以问我任何包括但不仅限于教育的问题,我会尽力为您解答!"); + Message message = Message.of("", "你好" + "罗老师" + " ,我是你的私人 AI 助手小豆,你可以问我任何包括但不仅限于教育的问题,我会尽力为您解答!"); List history = Collections.singletonList(message); ChatSession chatSession = new ChatSession(); chatSession.setId(UUID.randomUUID().toString()); @@ -54,7 +53,8 @@ public class ChatSessionServiceImpl implements ChatSessionService { @Override public List listMySession() { - String userId = SecurityUtil.getUserId(); +// String userId = SecurityUtil.getUserId(); + String userId = "1595321354"; List sessions = chatSessionRepository.findByUserId(userId); // 按更新时间排序 if (ObjectUtils.isNotEmpty(sessions)) { @@ -67,8 +67,9 @@ public class ChatSessionServiceImpl implements ChatSessionService { public ChatSession updateSession(UpdateSessionDto updateSessionDto) { String id = updateSessionDto.getId(); String title = updateSessionDto.getTitle(); - User user = SecurityUtil.getLoginUser(); - String userId = user.getId(); +// User user = SecurityUtil.getLoginUser(); +// String userId = user.getId(); + String userId = "1595321354"; ChatSession session = RepositoryUtil.findOne(chatSessionRepository.findBySessionId(id), ""); if (!session.getUserId().equals(userId)) { @@ -82,8 +83,9 @@ public class ChatSessionServiceImpl implements ChatSessionService { @Override public void deleteSession(String id) { - User user = SecurityUtil.getLoginUser(); - String userId = user.getId(); +// User user = SecurityUtil.getLoginUser(); +// String userId = user.getId(); + String userId = "1595321354"; ChatSession session = RepositoryUtil.findOne(chatSessionRepository.findBySessionId(id), "该会话不存在"); // 鉴权 if (!session.getUserId().equals(userId)) { @@ -94,8 +96,8 @@ public class ChatSessionServiceImpl implements ChatSessionService { @Override public List listMyHistory(String sessionId) { - User user = SecurityUtil.getLoginUser(); - String userId = user.getId(); +// User user = SecurityUtil.getLoginUser(); + String userId = "1595321354"; ChatSession session = chatSessionRepository.findChatSessionByIdAndCode(sessionId, PK.CHAT_SESSION); if (!userId.equals(session.getUserId())) { throw new ServiceException(ErrorCode.NO_AUTH_ERROR); diff --git a/src/main/java/cn/teammodel/utils/PdfUtil.java b/src/main/java/cn/teammodel/utils/PdfUtil.java index 4e07a00..af5bdf7 100644 --- a/src/main/java/cn/teammodel/utils/PdfUtil.java +++ b/src/main/java/cn/teammodel/utils/PdfUtil.java @@ -22,7 +22,6 @@ public class PdfUtil { Font boldFont = new Font(baseFont, 16, Font.BOLD); AcroFields fields = stamper.getAcroFields(); for (Map.Entry entry : data.entrySet()) { - fields.setFieldProperty(entry.getKey(), "textsize", boldFont.getSize(), null); fields.setFieldProperty(entry.getKey(), "textfont", baseFont, null); // 设置字体为加粗 fields.setField(entry.getKey(), entry.getValue()); @@ -41,5 +40,4 @@ public class PdfUtil { image.setAbsolutePosition(x, y); content.addImage(image); } - } \ No newline at end of file