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;
@RestController
@RequestMapping("/ai")
@RequestMapping("public/ai")
@Api(tags = "AI 能力")
public class AiController {
@Resource

@ -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();

@ -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<Message> 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<ChatSession> listMySession() {
String userId = SecurityUtil.getUserId();
// String userId = SecurityUtil.getUserId();
String userId = "1595321354";
List<ChatSession> 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<Message> 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);

@ -22,7 +22,6 @@ public class PdfUtil {
Font boldFont = new Font(baseFont, 16, Font.BOLD);
AcroFields fields = stamper.getAcroFields();
for (Map.Entry<String, String> 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);
}
}
Loading…
Cancel
Save