(improvement)(launchers) Demo data initialization optimization (#1015)

This commit is contained in:
LXW
2024-05-20 18:26:26 +08:00
committed by GitHub
parent eaec7b4663
commit d513b6d2cc
17 changed files with 274 additions and 604 deletions

View File

@@ -6,7 +6,7 @@ import java.util.List;
public interface ChatRepository {
boolean createChat(ChatDO chatDO);
Long createChat(ChatDO chatDO);
List<ChatDO> getAll(String creator, Integer agentId);

View File

@@ -1,14 +1,15 @@
package com.tencent.supersonic.chat.server.persistence.repository.impl;
import com.tencent.supersonic.chat.server.persistence.dataobject.QueryDO;
import com.tencent.supersonic.chat.server.persistence.dataobject.ChatDO;
import com.tencent.supersonic.chat.server.persistence.dataobject.QueryDO;
import com.tencent.supersonic.chat.server.persistence.mapper.ChatMapper;
import com.tencent.supersonic.chat.server.persistence.repository.ChatRepository;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
@Primary
@Slf4j
@@ -21,8 +22,9 @@ public class ChatRepositoryImpl implements ChatRepository {
}
@Override
public boolean createChat(ChatDO chatDO) {
return chatMapper.createChat(chatDO);
public Long createChat(ChatDO chatDO) {
chatMapper.createChat(chatDO);
return chatDO.getChatId();
}
@Override

View File

@@ -32,7 +32,8 @@ public class ChatController {
public Boolean save(@RequestParam(value = "chatName") String chatName,
@RequestParam(value = "agentId", required = false) Integer agentId,
HttpServletRequest request, HttpServletResponse response) {
return chatService.addChat(UserHolder.findUser(request, response), chatName, agentId);
chatService.addChat(UserHolder.findUser(request, response), chatName, agentId);
return true;
}
@GetMapping("/getAll")

View File

@@ -8,7 +8,7 @@ public interface AgentService {
List<Agent> getAgents();
void createAgent(Agent agent, User user);
Integer createAgent(Agent agent, User user);
void updateAgent(Agent agent, User user);

View File

@@ -17,7 +17,7 @@ import com.tencent.supersonic.headless.api.pojo.response.QueryResult;
import java.util.List;
public interface ChatManageService {
Boolean addChat(User user, String chatName, Integer agentId);
Long addChat(User user, String chatName, Integer agentId);
List<ChatDO> getAll(String userName, Integer agentId);

View File

@@ -26,9 +26,11 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO>
}
@Override
public void createAgent(Agent agent, User user) {
public Integer createAgent(Agent agent, User user) {
agent.createdBy(user.getName());
save(convert(agent));
AgentDO agentDO = convert(agent);
save(agentDO);
return agentDO.getId();
}
@Override

View File

@@ -43,7 +43,7 @@ public class ChatManageServiceImpl implements ChatManageService {
private ChatQueryRepository chatQueryRepository;
@Override
public Boolean addChat(User user, String chatName, Integer agentId) {
public Long addChat(User user, String chatName, Integer agentId) {
ChatDO chatDO = new ChatDO();
chatDO.setChatName(chatName);
chatDO.setCreator(user.getName());

View File

@@ -49,7 +49,7 @@
where chat_id = #{chatId}
</update>
<insert id="createChat" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatDO">
<insert id="createChat" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatDO" useGeneratedKeys="true" keyProperty="chatId">
insert into s2_chat
(agent_id, chat_name, create_time, last_time, creator, last_question, is_delete, is_top)
values (#{agentId}, #{chatName}, #{createTime}, #{lastTime}, #{creator}, #{lastQuestion}, #{isDelete}, #{isTop})