wangzhibo
2026-10-08 220e4fab27b7f419b3e89e2f2d28ae789aac09d7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package xiaozhi.modules.agent.service;
 
import java.util.List;
import java.util.Map;
 
import xiaozhi.common.page.PageData;
import xiaozhi.common.service.BaseService;
import xiaozhi.modules.agent.dto.AgentCreateDTO;
import xiaozhi.modules.agent.dto.AgentDTO;
import xiaozhi.modules.agent.dto.AgentMemoryDTO;
import xiaozhi.modules.agent.dto.AgentUpdateDTO;
import xiaozhi.modules.agent.entity.AgentEntity;
import xiaozhi.modules.agent.vo.AgentInfoVO;
 
/**
 * 智能体表处理service
 *
 * @author Goody
 * @version 1.0, 2025/4/30
 * @since 1.0.0
 */
public interface AgentService extends BaseService<AgentEntity> {
    /**
     * 获取管理员智能体列表
     *
     * @param params 查询参数
     * @return 分页数据
     */
    PageData<AgentEntity> adminAgentList(Map<String, Object> params);
 
    /**
     * 根据ID获取智能体
     *
     * @param id 智能体ID
     * @return 智能体实体
     */
    AgentInfoVO getAgentById(String id);
 
    /**
     * 根据ID获取当前用户有权访问的智能体
     *
     * @param id     智能体ID
     * @param userId 当前用户ID
     * @return 智能体实体
     */
    AgentInfoVO getAgentById(String id, Long userId);
 
    /**
     * 插入智能体
     *
     * @param entity 智能体实体
     * @return 是否成功
     */
    boolean insert(AgentEntity entity);
 
    /**
     * 根据用户ID删除智能体
     *
     * @param userId 用户ID
     */
    void deleteAgentByUserId(Long userId);
 
    /**
     * 删除智能体及其关联数据
     *
     * @param agentId 智能体ID
     */
    void deleteAgent(String agentId);
 
    /**
     * 获取用户智能体列表
     *
     * @param userId 用户ID
     * @param keyword 搜索关键词
     * @param searchType 搜索类型(name - 按名称搜索,mac - 按MAC地址搜索)
     * @return 智能体列表
     */
    List<AgentDTO> getUserAgents(Long userId, String keyword, String searchType);
 
    /**
     * 根据智能体ID获取设备数量
     *
     * @param agentId 智能体ID
     * @return 设备数量
     */
    Integer getDeviceCountByAgentId(String agentId);
 
    /**
     * 根据设备MAC地址查询对应设备的默认智能体信息
     *
     * @param macAddress 设备MAC地址
     * @return 默认智能体信息,不存在时返回null
     */
    AgentEntity getDefaultAgentByMacAddress(String macAddress);
 
    /**
     * 检查用户是否有权限访问智能体
     *
     * @param agentId 智能体ID
     * @param userId  用户ID
     * @return 是否有权限
     */
    boolean checkAgentPermission(String agentId, Long userId);
 
    /**
     * 更新智能体
     *
     * @param agentId 智能体ID
     * @param dto     更新智能体所需的信息
     */
    void updateAgentById(String agentId, AgentUpdateDTO dto);
 
    /**
     * 更新当前用户有权访问的智能体
     *
     * @param agentId 智能体ID
     * @param dto     更新智能体所需的信息
     * @param userId  当前用户ID
     */
    void updateAgentById(String agentId, AgentUpdateDTO dto, Long userId);
 
    /**
     * 根据设备MAC地址更新当前用户有权访问的智能体记忆
     *
     * @param macAddress 设备MAC地址
     * @param dto        智能体记忆
     * @param userId     当前用户ID
     */
    void updateAgentMemoryByDeviceMacAddress(String macAddress, AgentMemoryDTO dto, Long userId);
 
    /**
     * 删除当前用户有权访问的智能体
     *
     * @param agentId 智能体ID
     * @param userId  当前用户ID
     */
    void deleteAgentById(String agentId, Long userId);
 
    /**
     * 更新智能体
     *
     * @param agentId        智能体ID
     * @param dto            更新智能体所需的信息
     * @param createSnapshot 是否创建配置快照
     */
    void updateAgentById(String agentId, AgentUpdateDTO dto, boolean createSnapshot);
 
    /**
     * 创建智能体
     *
     * @param dto 创建智能体所需的信息
     * @return 创建的智能体ID
     */
    String createAgent(AgentCreateDTO dto);
 
 
}