feat: AgentExt service(getByAgentId / saveOrUpdate)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
SerenNoble 2026-07-02 15:45:09 +08:00
parent d02c783629
commit 0859285174
2 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,12 @@
package xiaozhi.modules.agent.service;
import xiaozhi.modules.agent.entity.AgentExtEntity;
public interface AgentExtService {
/** 取一个 agent 的扩展字段;无则 null。 */
AgentExtEntity getByAgentId(String agentId);
/** 整体覆盖一个 agent 的扩展字段(JSON 字符串)。 */
void saveOrUpdate(String agentId, String extJson);
}

View file

@ -0,0 +1,35 @@
package xiaozhi.modules.agent.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import xiaozhi.modules.agent.dao.AgentExtDao;
import xiaozhi.modules.agent.entity.AgentExtEntity;
import xiaozhi.modules.agent.service.AgentExtService;
@Service
public class AgentExtServiceImpl
extends ServiceImpl<AgentExtDao, AgentExtEntity>
implements AgentExtService {
@Override
public AgentExtEntity getByAgentId(String agentId) {
if (agentId == null || agentId.isBlank()) {
return null;
}
// agentId 即主键(@TableId IdType.INPUT),直接 getById
return this.getById(agentId);
}
@Override
public void saveOrUpdate(String agentId, String extJson) {
AgentExtEntity e = getByAgentId(agentId);
if (e == null) {
e = new AgentExtEntity();
e.setAgentId(agentId);
}
e.setExtJson(extJson);
this.saveOrUpdate(e);
}
}