mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-23 07:33:53 +08:00
不开启通讯录功能时不显示相关工具
关闭通讯录功能清除相关状态
This commit is contained in:
@@ -146,6 +146,11 @@ public interface Constant {
|
||||
*/
|
||||
String SERVER_AUTH_ENABLED = "server.auth.enabled";
|
||||
|
||||
/**
|
||||
* 系统功能菜单配置
|
||||
*/
|
||||
String SYSTEM_WEB_MENU = "system-web.menu";
|
||||
|
||||
/**
|
||||
* 无记忆
|
||||
*/
|
||||
|
||||
+9
-2
@@ -14,7 +14,7 @@ public interface AgentPluginMappingService extends IService<AgentPluginMapping>
|
||||
|
||||
/**
|
||||
* 根据智能体id获取插件参数
|
||||
*
|
||||
*
|
||||
* @param agentId
|
||||
* @return
|
||||
*/
|
||||
@@ -22,8 +22,15 @@ public interface AgentPluginMappingService extends IService<AgentPluginMapping>
|
||||
|
||||
/**
|
||||
* 根据智能体id删除插件参数
|
||||
*
|
||||
*
|
||||
* @param agentId
|
||||
*/
|
||||
void deleteByAgentId(String agentId);
|
||||
|
||||
/**
|
||||
* 根据插件ID删除所有智能体的插件映射
|
||||
*
|
||||
* @param pluginId 插件ID
|
||||
*/
|
||||
void deleteByPluginId(String pluginId);
|
||||
}
|
||||
|
||||
+7
@@ -104,4 +104,11 @@ public class AgentPluginMappingServiceImpl extends ServiceImpl<AgentPluginMappin
|
||||
agentPluginMappingMapper.delete(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByPluginId(String pluginId) {
|
||||
UpdateWrapper<AgentPluginMapping> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("plugin_id", pluginId);
|
||||
agentPluginMappingMapper.delete(updateWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-1
@@ -114,7 +114,12 @@ public class SysParamsController {
|
||||
// 校验mqtt密钥长度
|
||||
validateMqttSecretLength(dto.getParamCode(), dto.getParamValue());
|
||||
|
||||
sysParamsService.update(dto);
|
||||
// 如果是系统功能菜单配置,使用特殊处理
|
||||
if (Constant.SYSTEM_WEB_MENU.equals(dto.getParamCode())) {
|
||||
sysParamsService.updateSystemWebMenu(dto.getParamValue());
|
||||
} else {
|
||||
sysParamsService.update(dto);
|
||||
}
|
||||
configService.getConfig(false);
|
||||
return new Result<Void>();
|
||||
}
|
||||
|
||||
@@ -53,4 +53,19 @@ public interface SysParamsService extends BaseService<SysParamsEntity> {
|
||||
* 初始化服务器密钥
|
||||
*/
|
||||
void initServerSecret();
|
||||
|
||||
/**
|
||||
* 获取系统功能菜单配置
|
||||
*
|
||||
* @param fromCache 是否从缓存获取
|
||||
* @return 系统功能菜单配置JSON字符串
|
||||
*/
|
||||
String getSystemWebMenu(boolean fromCache);
|
||||
|
||||
/**
|
||||
* 更新系统功能菜单配置(自动处理功能相关的插件清理)
|
||||
*
|
||||
* @param configJson 新的系统功能菜单配置JSON
|
||||
*/
|
||||
void updateSystemWebMenu(String configJson);
|
||||
}
|
||||
|
||||
+61
-1
@@ -22,6 +22,7 @@ import xiaozhi.common.service.impl.BaseServiceImpl;
|
||||
import xiaozhi.common.utils.ConvertUtils;
|
||||
import xiaozhi.common.utils.JsonUtils;
|
||||
import xiaozhi.common.utils.SM2Utils;
|
||||
import xiaozhi.modules.agent.service.AgentPluginMappingService;
|
||||
import xiaozhi.modules.sys.dao.SysParamsDao;
|
||||
import xiaozhi.modules.sys.dto.SysParamsDTO;
|
||||
import xiaozhi.modules.sys.entity.SysParamsEntity;
|
||||
@@ -35,6 +36,7 @@ import xiaozhi.modules.sys.service.SysParamsService;
|
||||
@Service
|
||||
public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParamsEntity> implements SysParamsService {
|
||||
private final SysParamsRedis sysParamsRedis;
|
||||
private final AgentPluginMappingService agentPluginMappingService;
|
||||
|
||||
@Override
|
||||
public PageData<SysParamsDTO> page(Map<String, Object> params) {
|
||||
@@ -270,4 +272,62 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getSystemWebMenu(boolean fromCache) {
|
||||
return getValue(Constant.SYSTEM_WEB_MENU, fromCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSystemWebMenu(String configJson) {
|
||||
// 获取当前配置
|
||||
String currentConfig = getSystemWebMenu(false);
|
||||
Map<String, Object> currentMap = null;
|
||||
Map<String, Object> newMap = null;
|
||||
|
||||
try {
|
||||
if (StringUtils.isNotBlank(currentConfig)) {
|
||||
currentMap = JsonUtils.parseObject(currentConfig, Map.class);
|
||||
}
|
||||
if (StringUtils.isNotBlank(configJson)) {
|
||||
newMap = JsonUtils.parseObject(configJson, Map.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RenException(ErrorCode.PARAM_JSON_INVALID);
|
||||
}
|
||||
|
||||
// 检查addressBook功能是否被关闭
|
||||
if (currentMap != null && newMap != null) {
|
||||
Map<String, Object> currentFeatures = (Map<String, Object>) currentMap.get("features");
|
||||
Map<String, Object> newFeatures = (Map<String, Object>) newMap.get("features");
|
||||
|
||||
if (currentFeatures != null && newFeatures != null) {
|
||||
Object currentAddressBookObj = currentFeatures.get("addressBook");
|
||||
Object newAddressBookObj = newFeatures.get("addressBook");
|
||||
|
||||
Boolean currentEnabled = false;
|
||||
Boolean newEnabled = false;
|
||||
|
||||
if (currentAddressBookObj instanceof Map) {
|
||||
Map<String, Object> currentAddressBook = (Map<String, Object>) currentAddressBookObj;
|
||||
currentEnabled = currentAddressBook.get("enabled") != null
|
||||
? (Boolean) currentAddressBook.get("enabled") : false;
|
||||
}
|
||||
|
||||
if (newAddressBookObj instanceof Map) {
|
||||
Map<String, Object> newAddressBook = (Map<String, Object>) newAddressBookObj;
|
||||
newEnabled = newAddressBook.get("enabled") != null
|
||||
? (Boolean) newAddressBook.get("enabled") : false;
|
||||
}
|
||||
|
||||
// 如果之前是启用状态,现在被禁用,删除所有call_device插件
|
||||
if (Boolean.TRUE.equals(currentEnabled) && !Boolean.TRUE.equals(newEnabled)) {
|
||||
agentPluginMappingService.deleteByPluginId("SYSTEM_PLUGIN_CALL_DEVICE");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新配置
|
||||
updateValueByCode(Constant.SYSTEM_WEB_MENU, configJson);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user