mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-28 01:53:53 +08:00
添加了一个新的系统参数,mcp接入点参数
--Constant.java mcp接入点参数的key常量 --SysParamsServiceImpl.java 添加了mcp参数验证方法,修改是进行验证
This commit is contained in:
@@ -111,6 +111,11 @@ public interface Constant {
|
|||||||
*/
|
*/
|
||||||
String FILE_EXTENSION_SEG = ".";
|
String FILE_EXTENSION_SEG = ".";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mcp接入点路径
|
||||||
|
*/
|
||||||
|
String SERVER_MCP_ENDPOINT = "server.mcp_endpoint";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 无记忆
|
* 无记忆
|
||||||
*/
|
*/
|
||||||
|
|||||||
+14
@@ -20,6 +20,7 @@ import xiaozhi.common.exception.RenException;
|
|||||||
import xiaozhi.common.page.PageData;
|
import xiaozhi.common.page.PageData;
|
||||||
import xiaozhi.common.service.impl.BaseServiceImpl;
|
import xiaozhi.common.service.impl.BaseServiceImpl;
|
||||||
import xiaozhi.common.utils.ConvertUtils;
|
import xiaozhi.common.utils.ConvertUtils;
|
||||||
|
import xiaozhi.common.utils.HttpSendUtils;
|
||||||
import xiaozhi.common.utils.JsonUtils;
|
import xiaozhi.common.utils.JsonUtils;
|
||||||
import xiaozhi.modules.sys.dao.SysParamsDao;
|
import xiaozhi.modules.sys.dao.SysParamsDao;
|
||||||
import xiaozhi.modules.sys.dto.SysParamsDTO;
|
import xiaozhi.modules.sys.dto.SysParamsDTO;
|
||||||
@@ -34,6 +35,7 @@ import xiaozhi.modules.sys.service.SysParamsService;
|
|||||||
@Service
|
@Service
|
||||||
public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParamsEntity> implements SysParamsService {
|
public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParamsEntity> implements SysParamsService {
|
||||||
private final SysParamsRedis sysParamsRedis;
|
private final SysParamsRedis sysParamsRedis;
|
||||||
|
private final HttpSendUtils httpSendUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageData<SysParamsDTO> page(Map<String, Object> params) {
|
public PageData<SysParamsDTO> page(Map<String, Object> params) {
|
||||||
@@ -86,6 +88,7 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||||||
public void update(SysParamsDTO dto) {
|
public void update(SysParamsDTO dto) {
|
||||||
validateParamValue(dto);
|
validateParamValue(dto);
|
||||||
detectingSMSParameters(dto.getParamCode(), dto.getParamValue());
|
detectingSMSParameters(dto.getParamCode(), dto.getParamValue());
|
||||||
|
validateMcpParams(dto.getParamCode(), dto.getParamValue());
|
||||||
SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class);
|
SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class);
|
||||||
updateById(entity);
|
updateById(entity);
|
||||||
|
|
||||||
@@ -244,4 +247,15 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateMcpParams(String paramCode, String paramValue){
|
||||||
|
if(!Constant.SERVER_MCP_ENDPOINT.equals(paramCode)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String body = httpSendUtils.fetchGetBodyAsString(paramValue);
|
||||||
|
if(body.contains("success")){
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
throw new RenException(Constant.SERVER_MCP_ENDPOINT+"的value值不符合要求");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user