Skip to content

Commit

Permalink
对话问题记录待办
Browse files Browse the repository at this point in the history
  • Loading branch information
xigua0824 committed Dec 19, 2023
1 parent 18ee3b9 commit aa2629b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.beauty.aide.common.model.entity;

import lombok.Data;

/**
* @author xiaoliu
*/
@Data
public class ChatRecordDO extends BaseDO {

private String sessionId;
private String content;
private String answer;
private Long userId;
private String status;

}
32 changes: 32 additions & 0 deletions src/main/java/com/beauty/aide/controller/ChatController.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package com.beauty.aide.controller;

import com.beauty.aide.adaptor.TongYiAdaptor;
import com.beauty.aide.common.errors.UserErrorCode;
import com.beauty.aide.common.model.vo.AccountVO;
import com.beauty.aide.common.result.ResultDO;
import com.beauty.aide.manager.AccountManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
* @author xiaoliu
*/
Expand All @@ -12,7 +21,30 @@
@Slf4j
public class ChatController {

@Resource
private HttpServletRequest request;
@Resource
private AccountManager accountManager;
@Resource
private TongYiAdaptor tongYiAdaptor;
// @Resource
// private ChatRecordDAO chatRecordDAO;

// @TODO 创建一个新会话

// @TODO 发送问题
@PostMapping("/sendMessage")
public ResultDO<String> sendMessage(String question,String uuid) {
AccountVO user = accountManager.getLoginUser(request);
if (user == null) {
return ResultDO.errorOf(UserErrorCode.USER_NOT_LOGIN);
}

String messgae = tongYiAdaptor.sendChatRequest(question, uuid);
// @TODO 存储问题数据库

return ResultDO.succOf(messgae);
}

// @TODO 查看我的问题

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/beauty/aide/utils/CommonUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.beauty.aide.utils;

import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;

/**
* @author xiaoliu
*/
public class CommonUtil {

public static String md5(String content) {
return DigestUtils.md5DigestAsHex(content.getBytes(StandardCharsets.UTF_8));
}

public static String md5(String content, String salt) {
return md5(String.format("%s%s", content, salt));
}

}

0 comments on commit aa2629b

Please sign in to comment.