fix(rebase): reconcile manager API contracts

This commit is contained in:
lapy 2026-10-11 11:41:55 +01:00
parent 1692ca69bd
commit 67a0a512d9
9 changed files with 50 additions and 2 deletions

View file

@ -0,0 +1,24 @@
package xiaozhi.common.utils;
import java.util.Collection;
import java.util.Map;
/** Lightweight collection and value emptiness helpers retained for legacy callers. */
public final class ToolUtil {
private ToolUtil() {}
public static boolean isNotEmpty(Object value) {
return !isEmpty(value);
}
public static boolean isEmpty(Object value) {
if (value == null) return true;
if (value instanceof CharSequence) return value.toString().trim().isEmpty();
if (value instanceof Collection<?>) return ((Collection<?>) value).isEmpty();
if (value instanceof Map<?, ?>) return ((Map<?, ?>) value).isEmpty();
if (value instanceof Object[]) return ((Object[]) value).length == 0;
if (value instanceof int[]) return ((int[]) value).length == 0;
if (value instanceof long[]) return ((long[]) value).length == 0;
return false;
}
}

View file

@ -36,6 +36,8 @@ public interface AgentService extends BaseService<AgentEntity> {
*/
AgentInfoVO getAgentById(String id);
AgentInfoVO getAgentById(String id, Long userId);
/**
* Insert an agent.
*
@ -51,6 +53,8 @@ public interface AgentService extends BaseService<AgentEntity> {
*/
void deleteAgentByUserId(Long userId);
void deleteAgent(String agentId);
/**
* Get a user's agents.
*
@ -94,6 +98,14 @@ public interface AgentService extends BaseService<AgentEntity> {
*/
void updateAgentById(String agentId, AgentUpdateDTO dto);
void updateAgentById(String agentId, AgentUpdateDTO dto, Long userId);
void updateAgentById(String agentId, AgentUpdateDTO dto, boolean createSnapshot);
void updateAgentMemoryByDeviceMacAddress(String macAddress, AgentMemoryDTO dto, Long userId);
void deleteAgentById(String agentId, Long userId);
/**
* Create an agent.
*

View file

@ -21,6 +21,7 @@ import xiaozhi.common.constant.Constant;
import xiaozhi.common.page.PageData;
import xiaozhi.common.utils.ConvertUtils;
import xiaozhi.common.utils.JsonUtils;
import xiaozhi.common.utils.ToolUtil;
import xiaozhi.modules.agent.Enums.AgentChatHistoryType;
import xiaozhi.modules.agent.dao.AiAgentChatHistoryDao;
import xiaozhi.modules.agent.dto.AgentChatHistoryDTO;

View file

@ -226,7 +226,7 @@ public class AgentMcpAccessPointServiceImpl implements AgentMcpAccessPointServic
*/
private static String encryptToken(String agentId, String key) {
// Use MD5 to encrypt agent ID
String md5 = HashEncryptionUtil.Md5hexDigest(agentId);
String md5 = DigestUtil.md5Hex(agentId);
// AES needs encrypted text
String json = "{\"agentId\": \"%s\"}".formatted(md5);
// Encrypt to token value

View file

@ -287,7 +287,7 @@ public class OTAMagController {
// Return the file path.
return new Result<String>().ok(filePath.toString());
} catch (IOException | NoSuchAlgorithmException e) {
} catch (IOException e) {
return new Result<String>().error("File upload failed: " + e.getMessage());
}
}

View file

@ -32,12 +32,18 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.http.ContentType;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -52,6 +58,7 @@ import xiaozhi.common.user.UserDetail;
import xiaozhi.common.utils.ConvertUtils;
import xiaozhi.common.utils.DateUtils;
import xiaozhi.common.utils.JsonUtils;
import xiaozhi.common.utils.ToolUtil;
import xiaozhi.modules.device.dao.DeviceDao;
import xiaozhi.modules.device.dto.DeviceManualAddDTO;
import xiaozhi.modules.device.dto.DevicePageUserDTO;

View file

@ -2,6 +2,7 @@ package xiaozhi.modules.security.service.impl;
import java.io.IOException;
import java.time.Duration;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;

View file

@ -22,6 +22,7 @@ import xiaozhi.common.redis.RedisUtils;
import xiaozhi.common.service.impl.BaseServiceImpl;
import xiaozhi.common.utils.ConvertUtils;
import xiaozhi.common.utils.JsonUtils;
import xiaozhi.common.utils.ToolUtil;
import xiaozhi.modules.sys.dao.SysDictDataDao;
import xiaozhi.modules.sys.dao.SysUserDao;
import xiaozhi.modules.sys.dto.SysDictDataDTO;

View file

@ -57,6 +57,8 @@ public interface TimbreService extends BaseService<TimbreEntity> {
List<VoiceDTO> getVoiceNames(String ttsModelId, String voiceName);
String getDefaultLanguageById(String id);
/**
* Get timbre name by ID
*