mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
feat: AgentExt service(getByAgentId / saveOrUpdate)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d02c783629
commit
0859285174
2 changed files with 47 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue