test: 暂时修改ai为public,下次更新回复先前版本

11111
winter 10 months ago
parent 52773b45ff
commit ea5c6fcb81

@ -20,7 +20,7 @@ import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@RestController @RestController
@RequestMapping("/ai") @RequestMapping("public/ai")
@Api(tags = "AI 能力") @Api(tags = "AI 能力")
public class AiController { public class AiController {
@Resource @Resource

@ -115,8 +115,9 @@ public class ChatMessageServiceImpl implements ChatMessageService {
* *
*/ */
private SseEmitter completionBySession(ChatCompletionReqDto chatCompletionReqDto) { private SseEmitter completionBySession(ChatCompletionReqDto chatCompletionReqDto) {
User user = SecurityUtil.getLoginUser(); // User user = SecurityUtil.getLoginUser();
String userId = user.getId(); // String userId = user.getId();
String userId = "1595321354";
String userPrompt = chatCompletionReqDto.getText(); String userPrompt = chatCompletionReqDto.getText();
String sessionId = chatCompletionReqDto.getSessionId(); String sessionId = chatCompletionReqDto.getSessionId();

@ -4,12 +4,10 @@ import cn.hutool.core.lang.UUID;
import cn.teammodel.common.ErrorCode; import cn.teammodel.common.ErrorCode;
import cn.teammodel.common.PK; import cn.teammodel.common.PK;
import cn.teammodel.config.exception.ServiceException; import cn.teammodel.config.exception.ServiceException;
import cn.teammodel.repository.ChatSessionRepository;
import cn.teammodel.model.dto.ai.UpdateSessionDto; 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;
import cn.teammodel.model.entity.ai.ChatSession.Message; 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.service.ChatSessionService;
import cn.teammodel.utils.RepositoryUtil; import cn.teammodel.utils.RepositoryUtil;
import com.azure.cosmos.models.CosmosPatchOperations; import com.azure.cosmos.models.CosmosPatchOperations;
@ -36,10 +34,11 @@ public class ChatSessionServiceImpl implements ChatSessionService {
@Override @Override
public String createSession() { public String createSession() {
User user = SecurityUtil.getLoginUser(); // todo User user = SecurityUtil.getLoginUser(); || 2. user.getName()
String userId = user.getId(); // String userId = user.getId();
String userId = "1595321354";
// 初始化欢迎语 // 初始化欢迎语
Message message = Message.of("", "你好" + user.getName() + " ,我是你的私人 AI 助手小豆,你可以问我任何包括但不仅限于教育的问题,我会尽力为您解答!"); Message message = Message.of("", "你好" + "罗老师" + " ,我是你的私人 AI 助手小豆,你可以问我任何包括但不仅限于教育的问题,我会尽力为您解答!");
List<Message> history = Collections.singletonList(message); List<Message> history = Collections.singletonList(message);
ChatSession chatSession = new ChatSession(); ChatSession chatSession = new ChatSession();
chatSession.setId(UUID.randomUUID().toString()); chatSession.setId(UUID.randomUUID().toString());
@ -54,7 +53,8 @@ public class ChatSessionServiceImpl implements ChatSessionService {
@Override @Override
public List<ChatSession> listMySession() { public List<ChatSession> listMySession() {
String userId = SecurityUtil.getUserId(); // String userId = SecurityUtil.getUserId();
String userId = "1595321354";
List<ChatSession> sessions = chatSessionRepository.findByUserId(userId); List<ChatSession> sessions = chatSessionRepository.findByUserId(userId);
// 按更新时间排序 // 按更新时间排序
if (ObjectUtils.isNotEmpty(sessions)) { if (ObjectUtils.isNotEmpty(sessions)) {
@ -67,8 +67,9 @@ public class ChatSessionServiceImpl implements ChatSessionService {
public ChatSession updateSession(UpdateSessionDto updateSessionDto) { public ChatSession updateSession(UpdateSessionDto updateSessionDto) {
String id = updateSessionDto.getId(); String id = updateSessionDto.getId();
String title = updateSessionDto.getTitle(); String title = updateSessionDto.getTitle();
User user = SecurityUtil.getLoginUser(); // User user = SecurityUtil.getLoginUser();
String userId = user.getId(); // String userId = user.getId();
String userId = "1595321354";
ChatSession session = RepositoryUtil.findOne(chatSessionRepository.findBySessionId(id), ""); ChatSession session = RepositoryUtil.findOne(chatSessionRepository.findBySessionId(id), "");
if (!session.getUserId().equals(userId)) { if (!session.getUserId().equals(userId)) {
@ -82,8 +83,9 @@ public class ChatSessionServiceImpl implements ChatSessionService {
@Override @Override
public void deleteSession(String id) { public void deleteSession(String id) {
User user = SecurityUtil.getLoginUser(); // User user = SecurityUtil.getLoginUser();
String userId = user.getId(); // String userId = user.getId();
String userId = "1595321354";
ChatSession session = RepositoryUtil.findOne(chatSessionRepository.findBySessionId(id), "该会话不存在"); ChatSession session = RepositoryUtil.findOne(chatSessionRepository.findBySessionId(id), "该会话不存在");
// 鉴权 // 鉴权
if (!session.getUserId().equals(userId)) { if (!session.getUserId().equals(userId)) {
@ -94,8 +96,8 @@ public class ChatSessionServiceImpl implements ChatSessionService {
@Override @Override
public List<Message> listMyHistory(String sessionId) { public List<Message> listMyHistory(String sessionId) {
User user = SecurityUtil.getLoginUser(); // User user = SecurityUtil.getLoginUser();
String userId = user.getId(); String userId = "1595321354";
ChatSession session = chatSessionRepository.findChatSessionByIdAndCode(sessionId, PK.CHAT_SESSION); ChatSession session = chatSessionRepository.findChatSessionByIdAndCode(sessionId, PK.CHAT_SESSION);
if (!userId.equals(session.getUserId())) { if (!userId.equals(session.getUserId())) {
throw new ServiceException(ErrorCode.NO_AUTH_ERROR); throw new ServiceException(ErrorCode.NO_AUTH_ERROR);

@ -22,7 +22,6 @@ public class PdfUtil {
Font boldFont = new Font(baseFont, 16, Font.BOLD); Font boldFont = new Font(baseFont, 16, Font.BOLD);
AcroFields fields = stamper.getAcroFields(); AcroFields fields = stamper.getAcroFields();
for (Map.Entry<String, String> entry : data.entrySet()) { for (Map.Entry<String, String> entry : data.entrySet()) {
fields.setFieldProperty(entry.getKey(), "textsize", boldFont.getSize(), null); fields.setFieldProperty(entry.getKey(), "textsize", boldFont.getSize(), null);
fields.setFieldProperty(entry.getKey(), "textfont", baseFont, null); // 设置字体为加粗 fields.setFieldProperty(entry.getKey(), "textfont", baseFont, null); // 设置字体为加粗
fields.setField(entry.getKey(), entry.getValue()); fields.setField(entry.getKey(), entry.getValue());
@ -41,5 +40,4 @@ public class PdfUtil {
image.setAbsolutePosition(x, y); image.setAbsolutePosition(x, y);
content.addImage(image); content.addImage(image);
} }
} }
Loading…
Cancel
Save