, T, D> extends Bas
public void delete(Serializable[] ids) {
baseDao.deleteBatchIds(Arrays.asList(ids));
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/user/UserDetail.java b/main/manager-api/src/main/java/xiaozhi/common/user/UserDetail.java
index 0aa9210ba..17a349436 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/user/UserDetail.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/user/UserDetail.java
@@ -5,8 +5,8 @@ import java.io.Serializable;
import lombok.Data;
/**
- * 登录用户信息
- * Copyright (c) 人人开源 All rights reserved.
+ * Login user information
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
@Data
@@ -16,4 +16,4 @@ public class UserDetail implements Serializable {
private Integer superAdmin;
private String token;
private Integer status;
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/AESUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/AESUtils.java
index 660e3cba4..f4a73dda8 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/AESUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/AESUtils.java
@@ -12,15 +12,15 @@ public class AESUtils {
private static final String TRANSFORMATION = "AES/ECB/PKCS5Padding";
/**
- * AES加密
+ * AES encryption
*
- * @param key 密钥(16位、24位或32位)
- * @param plainText 待加密字符串
- * @return 加密后的Base64字符串
+ * @param key Key (16, 24 or 32 bits)
+ * @param plainText String to be encrypted
+ * @return Encrypted Base64 string
*/
public static String encrypt(String key, String plainText) {
try {
- // 确保密钥长度为16、24或32位
+ // Ensure key length is 16, 24 or 32 bits
byte[] keyBytes = padKey(key.getBytes(StandardCharsets.UTF_8));
SecretKeySpec secretKey = new SecretKeySpec(keyBytes, ALGORITHM);
@@ -30,20 +30,20 @@ public class AESUtils {
byte[] encryptedBytes = cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8));
return Base64.getEncoder().encodeToString(encryptedBytes);
} catch (Exception e) {
- throw new RuntimeException("AES加密失败", e);
+ throw new RuntimeException("AES encryption failed", e);
}
}
/**
- * AES解密
+ * AES decryption
*
- * @param key 密钥(16位、24位或32位)
- * @param encryptedText 待解密的Base64字符串
- * @return 解密后的字符串
+ * @param key Key (16, 24 or 32 bits)
+ * @param encryptedText Base64 string to be decrypted
+ * @return Decrypted string
*/
public static String decrypt(String key, String encryptedText) {
try {
- // 确保密钥长度为16、24或32位
+ // Ensure key length is 16, 24 or 32 bits
byte[] keyBytes = padKey(key.getBytes(StandardCharsets.UTF_8));
SecretKeySpec secretKey = new SecretKeySpec(keyBytes, ALGORITHM);
@@ -54,15 +54,15 @@ public class AESUtils {
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
return new String(decryptedBytes, StandardCharsets.UTF_8);
} catch (Exception e) {
- throw new RuntimeException("AES解密失败", e);
+ throw new RuntimeException("AES decryption failed", e);
}
}
/**
- * 填充密钥到指定长度(16、24或32位)
+ * Pad key to specified length (16, 24 or 32 bits)
*
- * @param keyBytes 原始密钥字节数组
- * @return 填充后的密钥字节数组
+ * @param keyBytes Original key byte array
+ * @return Padded key byte array
*/
private static byte[] padKey(byte[] keyBytes) {
int keyLength = keyBytes.length;
@@ -70,7 +70,7 @@ public class AESUtils {
return keyBytes;
}
- // 如果密钥长度不足,用0填充;如果超过,截取前32位
+ // If key length is insufficient, pad with 0; if exceeds, truncate to first 32 bits
byte[] paddedKey = new byte[32];
System.arraycopy(keyBytes, 0, paddedKey, 0, Math.min(keyLength, 32));
return paddedKey;
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/ConvertUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/ConvertUtils.java
index 07ade50f3..cee35f6be 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/ConvertUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/ConvertUtils.java
@@ -9,8 +9,8 @@ import org.springframework.beans.BeanUtils;
import lombok.extern.slf4j.Slf4j;
/**
- * 转换工具类
- * Copyright (c) 人人开源 All rights reserved.
+ * Conversion utility class
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
@Slf4j
@@ -48,4 +48,4 @@ public class ConvertUtils {
return targetList;
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/DateUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/DateUtils.java
index 800733c11..b4b4992e2 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/DateUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/DateUtils.java
@@ -8,38 +8,38 @@ import java.time.temporal.ChronoUnit;
import java.util.Date;
/**
- * 日期处理
- * Copyright (c) 人人开源 All rights reserved.
+ * Date processing
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class DateUtils {
/**
- * 时间格式(yyyy-MM-dd)
+ * Time format (yyyy-MM-dd)
*/
public final static String DATE_PATTERN = "yyyy-MM-dd";
/**
- * 时间格式(yyyy-MM-dd HH:mm:ss)
+ * Time format (yyyy-MM-dd HH:mm:ss)
*/
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
public final static String DATE_TIME_MILLIS_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS";
/**
- * 日期格式化 日期格式为:yyyy-MM-dd
+ * Date formatting with format: yyyy-MM-dd
*
- * @param date 日期
- * @return 返回yyyy-MM-dd格式日期
+ * @param date Date
+ * @return Returns date in yyyy-MM-dd format
*/
public static String format(Date date) {
return format(date, DATE_PATTERN);
}
/**
- * 日期格式化 日期格式为:yyyy-MM-dd
+ * Date formatting with format: yyyy-MM-dd
*
- * @param date 日期
- * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
- * @return 返回yyyy-MM-dd格式日期
+ * @param date Date
+ * @param pattern Format, e.g.: DateUtils.DATE_TIME_PATTERN
+ * @return Returns date in yyyy-MM-dd format
*/
public static String format(Date date, String pattern) {
if (date != null) {
@@ -50,11 +50,11 @@ public class DateUtils {
}
/**
- * 日期解析
+ * Date parsing
*
- * @param date 日期
- * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
- * @return 返回Date
+ * @param date Date
+ * @param pattern Format, e.g.: DateUtils.DATE_TIME_PATTERN
+ * @return Returns Date
*/
public static Date parse(String date, String pattern) {
try {
@@ -79,7 +79,7 @@ public class DateUtils {
}
/**
- * 获取简短的时间字符串:10秒前返回刚刚,多少秒前,几小时前,超过一周返回年月日时分秒
+ * Get short time string: returns "just now" for 10 seconds ago, "X seconds ago", "X hours ago", returns full date time for over a week
* @param date
* @return
*/
@@ -87,29 +87,29 @@ public class DateUtils {
if (date == null) {
return null;
}
- // 将 Date 转换为 Instant
+ // Convert Date to Instant
LocalDateTime localDateTime = date.toInstant()
- // 获取系统默认时区
+ // Get system default timezone
.atZone(ZoneId.systemDefault())
- // 转换为 LocalDateTime
+ // Convert to LocalDateTime
.toLocalDateTime();
- // 当前时间
+ // Current time
LocalDateTime now = LocalDateTime.now();
- // 时间差,单位为秒
+ // Time difference in seconds
long secondsBetween = ChronoUnit.SECONDS.between(localDateTime, now);
if (secondsBetween <= 10) {
- return "刚刚";
+ return "just now";
} else if (secondsBetween < 60) {
- return secondsBetween + "秒前";
+ return secondsBetween + " seconds ago";
} else if (secondsBetween < 60 * 60) {
- return secondsBetween / 60 + "分钟前";
+ return secondsBetween / 60 + " minutes ago";
} else if (secondsBetween < 86400) {
- return secondsBetween / 3600 + "小时前";
+ return secondsBetween / 3600 + " hours ago";
} else if (secondsBetween < 604800) {
- return secondsBetween / 86400 + "天前";
+ return secondsBetween / 86400 + " days ago";
} else {
- // 超过一周,显示完整日期时间
+ // Over a week, show full date time
return format(date,DATE_TIME_PATTERN);
}
}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/HashEncryptionUtil.java b/main/manager-api/src/main/java/xiaozhi/common/utils/HashEncryptionUtil.java
index 79b051927..dd0c26305 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/HashEncryptionUtil.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/HashEncryptionUtil.java
@@ -6,38 +6,38 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
- * 哈希加密算法的工具类
+ * Hash encryption algorithm utility class
* @author zjy
*/
@Slf4j
public class HashEncryptionUtil {
/**
- * 使用md5进行加密
- * @param context 被加密的内容
- * @return 哈希值
+ * Encrypt using md5
+ * @param context Content to be encrypted
+ * @return Hash value
*/
public static String Md5hexDigest(String context){
return hexDigest(context,"MD5");
}
/**
- * 指定哈希算法进行加密
- * @param context 被加密的内容
- * @param algorithm 哈希算法
- * @return 哈希值
+ * Encrypt using specified hash algorithm
+ * @param context Content to be encrypted
+ * @param algorithm Hash algorithm
+ * @return Hash value
*/
public static String hexDigest(String context,String algorithm ){
- // 获取MD5算法实例
+ // Get MD5 algorithm instance
MessageDigest md = null;
try {
md = MessageDigest.getInstance(algorithm);
} catch (NoSuchAlgorithmException e) {
- log.error("加密失败的算法:{}",algorithm);
- throw new RuntimeException("加密失败,"+ algorithm +"哈希算法系统不支持");
+ log.error("Encryption failed algorithm: {}",algorithm);
+ throw new RuntimeException("Encryption failed, system does not support "+ algorithm +" hash algorithm");
}
- // 计算智能体id的MD5值
+ // Calculate MD5 value of agent id
byte[] messageDigest = md.digest(context.getBytes());
- // 将字节数组转换为十六进制字符串
+ // Convert byte array to hexadecimal string
StringBuilder hexString = new StringBuilder();
for (byte b : messageDigest) {
String hex = Integer.toHexString(0xFF & b);
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/HttpContextUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/HttpContextUtils.java
index 0e46acf16..8152e50a8 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/HttpContextUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/HttpContextUtils.java
@@ -18,7 +18,7 @@ import xiaozhi.common.exception.RenException;
/**
* Http
- * Copyright (c) 人人开源 All rights reserved.
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class HttpContextUtils {
@@ -71,22 +71,22 @@ public class HttpContextUtils {
}
public static String getLanguage() {
- // 默认语言
- String defaultLanguage = "zh-CN";
+ // Default language
+ String defaultLanguage = "en-US";
// request
HttpServletRequest request = getHttpServletRequest();
if (request == null) {
return defaultLanguage;
}
- // 请求语言
+ // Request language
defaultLanguage = request.getHeader(HttpHeaders.ACCEPT_LANGUAGE);
return defaultLanguage;
}
/**
- * 获取客户端的唯一标识
+ * Get client unique identifier
*
* @return
*/
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/IpUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/IpUtils.java
index fef7972f2..972518662 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/IpUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/IpUtils.java
@@ -6,17 +6,17 @@ import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
/**
- * IP地址
- * Copyright (c) 人人开源 All rights reserved.
+ * IP address
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
@Slf4j
public class IpUtils {
/**
- * 获取IP地址
+ * Get IP address
*
- * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
- * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
+ * When using reverse proxy software like Nginx, cannot get IP address through request.getRemoteAddr()
+ * If multiple levels of reverse proxy are used, X-Forwarded-For will contain multiple IP addresses, and the first non-unknown valid IP string in X-Forwarded-For is the real IP address
*/
public static String getIpAddr(HttpServletRequest request) {
String unknown = "unknown";
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/JsonRpcTwo.java b/main/manager-api/src/main/java/xiaozhi/common/utils/JsonRpcTwo.java
index c522a61dc..8632a992b 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/JsonRpcTwo.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/JsonRpcTwo.java
@@ -2,7 +2,7 @@ package xiaozhi.common.utils;
import lombok.Data;
/**
- * JSON-RPC2.0 格式规范对象
+ * JSON-RPC2.0 format specification object
*/
@Data
public class JsonRpcTwo {
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/JsonUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/JsonUtils.java
index 288dae9ab..21d1bf211 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/JsonUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/JsonUtils.java
@@ -10,8 +10,8 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
/**
- * JSON 工具类
- * Copyright (c) 人人开源 All rights reserved.
+ * JSON utility class
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class JsonUtils {
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/MessageUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/MessageUtils.java
index abcc2cb3d..76b552d6d 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/MessageUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/MessageUtils.java
@@ -4,8 +4,8 @@ import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
/**
- * 国际化
- * Copyright (c) 人人开源 All rights reserved.
+ * Internationalization
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class MessageUtils {
@@ -17,7 +17,7 @@ public class MessageUtils {
public static String getMessage(int code, String... params) {
if (messageSource == null) {
- // 延迟初始化,确保Spring上下文已完全初始化
+ // Initialize lazily after the Spring context is fully ready.
messageSource = (MessageSource) SpringContextUtils.getBean("messageSource");
}
return messageSource.getMessage(code + "", params, LocaleContextHolder.getLocale());
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/PropertiesUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/PropertiesUtils.java
index 1064299be..f07560272 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/PropertiesUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/PropertiesUtils.java
@@ -3,7 +3,7 @@ package xiaozhi.common.utils;
import org.springframework.stereotype.Component;
/**
- * 获取配置文件信息
+ * Get configuration file information
* Copyright xin-nan.com
*/
@Component
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/ResourcesUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/ResourcesUtils.java
index cf2d0bcc5..b7f7fa724 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/ResourcesUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/ResourcesUtils.java
@@ -14,7 +14,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
/**
- * 资源处理工具
+ * Resource processing utility
*/
@AllArgsConstructor
@Slf4j
@@ -23,9 +23,9 @@ public class ResourcesUtils {
private ResourceLoader resourceLoader;
/**
- * 读取资源,返回字符串
- * @param fileName 资源路径:resources下开始
- * @return 字符串
+ * Read resource, return string
+ * @param fileName Resource path: starting from resources
+ * @return String
*/
public String loadString(String fileName) {
Resource resource = resourceLoader.getResource("classpath:" + fileName);
@@ -37,7 +37,7 @@ public class ResourcesUtils {
luaScriptBuilder.append(line).append("\n");
}
} catch (IOException e){
- log.error("方法:loadString()读取资源失败--{}",e.getMessage());
+ log.error("Method: loadString() failed to read resource--{}",e.getMessage());
throw new RenException(ErrorCode.RESOURCE_READ_ERROR);
}
return luaScriptBuilder.toString();
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/Result.java b/main/manager-api/src/main/java/xiaozhi/common/utils/Result.java
index 9c326af70..bffc1ddaf 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/Result.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/Result.java
@@ -7,28 +7,28 @@ import lombok.Data;
import xiaozhi.common.exception.ErrorCode;
/**
- * 响应数据
- * Copyright (c) 人人开源 All rights reserved.
+ * Response data
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
@Data
-@Schema(description = "响应")
+@Schema(description = "Response")
public class Result implements Serializable {
/**
- * 编码:0表示成功,其他值表示失败
+ * Code: 0 indicates success, other values indicate failure
*/
- @Schema(description = "编码:0表示成功,其他值表示失败")
+ @Schema(description = "Code: 0 indicates success, other values indicate failure")
private int code = 0;
/**
- * 消息内容
+ * Message content
*/
- @Schema(description = "消息内容")
+ @Schema(description = "Message content")
private String msg = "success";
/**
- * 响应数据
+ * Response data
*/
- @Schema(description = "响应数据")
+ @Schema(description = "Response data")
private T data;
public Result ok(T data) {
@@ -60,4 +60,4 @@ public class Result implements Serializable {
return this;
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/ResultUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/ResultUtils.java
index 3f9fe27dc..4927bc7dc 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/ResultUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/ResultUtils.java
@@ -1,7 +1,7 @@
package xiaozhi.common.utils;
/**
- * 返回响应体工具类
+ * Response body utility class
*/
public class ResultUtils
{
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/SM2Utils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/SM2Utils.java
index cf0ed9c5b..669dfb62e 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/SM2Utils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/SM2Utils.java
@@ -21,16 +21,16 @@ import java.util.HashMap;
import java.util.Map;
/**
- * SM2加密工具类(采用十六进制格式,与chancheng-archive-service项目保持一致)
+ * SM2 encryption utility that uses hexadecimal encoding.
*/
public class SM2Utils {
/**
- * 公钥常量
+ * Public-key map key.
*/
public static final String KEY_PUBLIC_KEY = "publicKey";
/**
- * 私钥返回值常量
+ * Private-key map key.
*/
public static final String KEY_PRIVATE_KEY = "privateKey";
@@ -39,78 +39,78 @@ public class SM2Utils {
}
/**
- * SM2加密算法
+ * Encrypt plaintext with SM2.
*
- * @param publicKey 十六进制公钥
- * @param data 明文数据
- * @return 十六进制密文
+ * @param publicKey hexadecimal public key
+ * @param data plaintext data
+ * @return hexadecimal ciphertext
*/
public static String encrypt(String publicKey, String data) {
try {
- // 获取一条SM2曲线参数
+ // Load SM2 curve parameters.
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
- // 构造ECC算法参数,曲线方程、椭圆曲线G点、大整数N
+ // Build ECC domain parameters.
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(), sm2ECParameters.getN());
- //提取公钥点
+ // Extract the public-key point.
ECPoint pukPoint = sm2ECParameters.getCurve().decodePoint(Hex.decode(publicKey));
- // 公钥前面的02或者03表示是压缩公钥,04表示未压缩公钥, 04的时候,可以去掉前面的04
+ // 02 or 03 indicates a compressed key, while 04 indicates an uncompressed key.
ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
SM2Engine sm2Engine = new SM2Engine(SM2Engine.Mode.C1C3C2);
- // 设置sm2为加密模式
+ // Initialize SM2 in encryption mode.
sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom()));
byte[] in = data.getBytes(StandardCharsets.UTF_8);
byte[] arrayOfBytes = sm2Engine.processBlock(in, 0, in.length);
return Hex.toHexString(arrayOfBytes);
} catch (Exception e) {
- throw new RuntimeException("SM2加密失败", e);
+ throw new RuntimeException("SM2 encryption failed", e);
}
}
/**
- * SM2解密算法
+ * Decrypt ciphertext with SM2.
*
- * @param privateKey 十六进制私钥
- * @param cipherData 十六进制密文数据
- * @return 明文
+ * @param privateKey hexadecimal private key
+ * @param cipherData hexadecimal ciphertext
+ * @return plaintext
*/
public static String decrypt(String privateKey, String cipherData) {
try {
- // 使用BC库加解密时密文以04开头,传入的密文前面没有04则补上
+ // Bouncy Castle expects ciphertext to start with 04, so prepend it when needed.
if (!cipherData.startsWith("04")) {
cipherData = "04" + cipherData;
}
byte[] cipherDataByte = Hex.decode(cipherData);
BigInteger privateKeyD = new BigInteger(privateKey, 16);
- //获取一条SM2曲线参数
+ // Load SM2 curve parameters.
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
- //构造domain参数
+ // Build domain parameters.
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(), sm2ECParameters.getN());
ECPrivateKeyParameters privateKeyParameters = new ECPrivateKeyParameters(privateKeyD, domainParameters);
SM2Engine sm2Engine = new SM2Engine(SM2Engine.Mode.C1C3C2);
- // 设置sm2为解密模式
+ // Initialize SM2 in decryption mode.
sm2Engine.init(false, privateKeyParameters);
byte[] arrayOfBytes = sm2Engine.processBlock(cipherDataByte, 0, cipherDataByte.length);
return new String(arrayOfBytes, StandardCharsets.UTF_8);
} catch (Exception e) {
- throw new RuntimeException("SM2解密失败", e);
+ throw new RuntimeException("SM2 decryption failed", e);
}
}
/**
- * 生成密钥对
+ * Generate a key pair.
*/
public static Map createKey() {
try {
ECGenParameterSpec sm2Spec = new ECGenParameterSpec("sm2p256v1");
- // 获取一个椭圆曲线类型的密钥对生成器
+ // Get an elliptic-curve key-pair generator.
KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", new BouncyCastleProvider());
- // 使用SM2参数初始化生成器
+ // Initialize the generator with SM2 parameters.
kpg.initialize(sm2Spec);
- // 获取密钥对
+ // Generate the key pair.
KeyPair keyPair = kpg.generateKeyPair();
PublicKey publicKey = keyPair.getPublic();
BCECPublicKey p = (BCECPublicKey) publicKey;
@@ -122,9 +122,9 @@ public class SM2Utils {
result.put(KEY_PRIVATE_KEY, Hex.toHexString(s.getD().toByteArray()));
return result;
} catch (Exception e) {
- throw new RuntimeException("生成SM2密钥对失败", e);
+ throw new RuntimeException("Failed to generate SM2 key pair", e);
}
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/SensitiveDataUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/SensitiveDataUtils.java
index 4d5715cc1..5b5f6c60e 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/SensitiveDataUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/SensitiveDataUtils.java
@@ -11,24 +11,24 @@ import org.apache.commons.lang3.StringUtils;
import cn.hutool.json.JSONObject;
/**
- * 敏感数据处理工具类
+ * Utility helpers for sensitive data handling.
*/
public class SensitiveDataUtils {
- // 敏感字段列表
+ // List of sensitive fields.
private static final Set SENSITIVE_FIELDS = new HashSet<>(Arrays.asList(
"api_key", "personal_access_token", "access_token", "token",
"secret", "access_key_secret", "secret_key"));
/**
- * 检查字段是否为敏感字段
+ * Check whether the field is sensitive.
*/
public static boolean isSensitiveField(String fieldName) {
return StringUtils.isNotBlank(fieldName) && SENSITIVE_FIELDS.contains(fieldName.toLowerCase());
}
/**
- * 隐藏字符串中间部分
+ * Mask the middle section of a string.
*/
public static String maskMiddle(String value) {
if (StringUtils.isBlank(value) || value.length() == 1) {
@@ -37,10 +37,10 @@ public class SensitiveDataUtils {
int length = value.length();
if (length <= 8) {
- // 短字符串保留前2后2
+ // Short strings keep the first two and last two characters.
return value.substring(0, 2) + "****" + value.substring(length - 2);
} else {
- // 长字符串保留前4后4
+ // Long strings keep the first four and last four characters.
int maskLength = length - 8;
StringBuilder maskBuilder = new StringBuilder();
for (int i = 0; i < maskLength; i++) {
@@ -51,18 +51,18 @@ public class SensitiveDataUtils {
}
/**
- * 判断字符串是否是被掩码处理过的值
+ * Check whether the string is already masked.
*/
public static boolean isMaskedValue(String value) {
if (StringUtils.isBlank(value)) {
return false;
}
- // 掩码值至少包含4个连续的*
+ // A masked value should include at least four consecutive asterisks.
return value.contains("****");
}
/**
- * 处理JSONObject中的敏感字段
+ * Mask sensitive fields in a JSONObject.
*/
public static JSONObject maskSensitiveFields(JSONObject jsonObject) {
if (jsonObject == null) {
@@ -87,8 +87,8 @@ public class SensitiveDataUtils {
}
/**
- * 比较两个JSONObject的敏感字段是否相同
- * 特别针对api_key等敏感字段进行单独比较
+ * Compare the sensitive fields of two JSONObjects.
+ * This is primarily used for fields such as api_key.
*/
public static boolean isSensitiveDataEqual(JSONObject original, JSONObject updated) {
if (original == null && updated == null) {
@@ -98,7 +98,7 @@ public class SensitiveDataUtils {
return false;
}
- // 提取并比较特定敏感字段
+ // Extract and compare the supported sensitive fields.
return compareSpecificSensitiveFields(original, updated, "api_key") &&
compareSpecificSensitiveFields(original, updated, "personal_access_token") &&
compareSpecificSensitiveFields(original, updated, "access_token") &&
@@ -109,24 +109,24 @@ public class SensitiveDataUtils {
}
/**
- * 比较两个JSON对象中特定敏感字段是否相同
- * 遍历整个JSON对象树,查找并比较指定敏感字段
+ * Compare a specific sensitive field across two JSON objects.
+ * Traverse the full JSON tree to find and compare the requested field.
*/
private static boolean compareSpecificSensitiveFields(JSONObject original, JSONObject updated, String fieldName) {
- // 提取原始对象中的指定敏感字段
+ // Extract the target sensitive field from the original object.
Map originalFields = new HashMap<>();
extractSpecificSensitiveField(original, originalFields, fieldName, "");
- // 提取更新对象中的指定敏感字段
+ // Extract the target sensitive field from the updated object.
Map updatedFields = new HashMap<>();
extractSpecificSensitiveField(updated, updatedFields, fieldName, "");
- // 如果字段数量不同,说明有增删
+ // Different field counts mean entries were added or removed.
if (originalFields.size() != updatedFields.size()) {
return false;
}
- // 比较每个字段的值
+ // Compare every field value.
for (Map.Entry entry : originalFields.entrySet()) {
String key = entry.getKey();
String originalValue = entry.getValue();
@@ -141,7 +141,7 @@ public class SensitiveDataUtils {
}
/**
- * 递归提取JSON对象中指定名称的敏感字段
+ * Recursively extract sensitive fields with the requested name.
*/
private static void extractSpecificSensitiveField(JSONObject jsonObject, Map fieldsMap,
String targetFieldName, String parentPath) {
@@ -154,12 +154,12 @@ public class SensitiveDataUtils {
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
- // 递归处理嵌套JSON对象
+ // Recurse into nested JSON objects.
extractSpecificSensitiveField((JSONObject) value, fieldsMap, targetFieldName, fullPath);
} else if (value instanceof String && key.equalsIgnoreCase(targetFieldName)) {
- // 找到目标敏感字段,保存其路径和值
+ // Found the target sensitive field. Save its path and value.
fieldsMap.put(fullPath, (String) value);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/Sm2DecryptUtil.java b/main/manager-api/src/main/java/xiaozhi/common/utils/Sm2DecryptUtil.java
index 332e9c808..c7fd127b7 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/Sm2DecryptUtil.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/Sm2DecryptUtil.java
@@ -8,34 +8,34 @@ import xiaozhi.modules.security.service.CaptchaService;
import xiaozhi.modules.sys.service.SysParamsService;
/**
- * SM2解密和验证码验证工具类
- * 封装了重复的SM2解密、验证码提取和验证逻辑
+ * Utility for SM2 decryption and captcha validation.
+ * Encapsulates shared logic for decrypting SM2 payloads, extracting captchas, and validating them.
*/
public class Sm2DecryptUtil {
/**
- * 验证码长度
+ * Captcha length.
*/
private static final int CAPTCHA_LENGTH = 5;
/**
- * 解密SM2加密内容,提取验证码并验证
- *
- * @param encryptedPassword SM2加密的密码字符串
- * @param captchaId 验证码ID
- * @param captchaService 验证码服务
- * @param sysParamsService 系统参数服务
- * @return 解密后的实际密码
+ * Decrypt SM2-encrypted content, extract the captcha, and validate it.
+ *
+ * @param encryptedPassword SM2-encrypted password string
+ * @param captchaId captcha ID
+ * @param captchaService captcha service
+ * @param sysParamsService system-parameter service
+ * @return decrypted actual password
*/
public static String decryptAndValidateCaptcha(String encryptedPassword, String captchaId,
CaptchaService captchaService, SysParamsService sysParamsService) {
- // 获取SM2私钥
+ // Load the SM2 private key.
String privateKeyStr = sysParamsService.getValue(Constant.SM2_PRIVATE_KEY, true);
if (StringUtils.isBlank(privateKeyStr)) {
throw new RenException(ErrorCode.SM2_KEY_NOT_CONFIGURED);
}
- // 使用SM2私钥解密密码
+ // Decrypt the password with the SM2 private key.
String decryptedContent;
try {
decryptedContent = SM2Utils.decrypt(privateKeyStr, encryptedPassword);
@@ -43,7 +43,7 @@ public class Sm2DecryptUtil {
throw new RenException(ErrorCode.SM2_DECRYPT_ERROR);
}
- // 分离验证码和密码:前5位是验证码,后面是密码
+ // Split captcha and password: the first 5 characters are the captcha and the rest is the password.
if (decryptedContent.length() > CAPTCHA_LENGTH) {
String embeddedCaptcha = decryptedContent.substring(0, CAPTCHA_LENGTH);
String actualPassword = decryptedContent.substring(CAPTCHA_LENGTH);
@@ -60,4 +60,4 @@ public class Sm2DecryptUtil {
throw new RenException(ErrorCode.SM2_DECRYPT_ERROR);
}
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/SpringContextUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/SpringContextUtils.java
index 52aec0b72..2c7d08eca 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/SpringContextUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/SpringContextUtils.java
@@ -6,7 +6,7 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
- * Spring Context 工具类
+ * Spring Context utility class
*/
@Component
public class SpringContextUtils implements ApplicationContextAware {
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/ToolUtil.java b/main/manager-api/src/main/java/xiaozhi/common/utils/ToolUtil.java
index 408889651..c0e278662 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/ToolUtil.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/ToolUtil.java
@@ -12,20 +12,20 @@ import java.util.Map;
import java.util.Set;
/**
- * 通用工具类
+ * General utility helpers.
*/
public class ToolUtil {
private static final Logger logger = LoggerFactory.getLogger(ToolUtil.class);
/**
- * 对象是否不为空(新增)
+ * Whether an object is not empty.
*/
public static boolean isNotEmpty(Object o) {
return !isEmpty(o);
}
/**
- * 对象是否为空
+ * Whether an object is empty.
*/
public static boolean isEmpty(Object o) {
if (o == null) {
@@ -64,7 +64,7 @@ public class ToolUtil {
}
/**
- * 对象组中是否存在空对象
+ * Whether any object in the group is empty.
*/
public static boolean isOneEmpty(Object... os) {
for (Object o : os) {
@@ -76,7 +76,7 @@ public class ToolUtil {
}
/**
- * 对象组中是否全是空对象
+ * Whether all objects in the group are empty.
*/
public static boolean isAllEmpty(Object... os) {
for (Object o : os) {
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/TreeNode.java b/main/manager-api/src/main/java/xiaozhi/common/utils/TreeNode.java
index 5fdb5985e..34a319a11 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/TreeNode.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/TreeNode.java
@@ -7,24 +7,24 @@ import java.util.List;
import lombok.Data;
/**
- * 树节点,所有需要实现树节点的,都需要继承该类
- * Copyright (c) 人人开源 All rights reserved.
+ * Tree node, all classes that need to implement tree nodes should inherit from this class
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
@Data
public class TreeNode implements Serializable {
/**
- * 主键
+ * Primary key
*/
private Long id;
/**
- * 上级ID
+ * Parent ID
*/
private Long pid;
/**
- * 子节点列表
+ * Child node list
*/
private List children = new ArrayList<>();
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/TreeUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/TreeUtils.java
index e76190eba..d98b4fa7a 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/utils/TreeUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/utils/TreeUtils.java
@@ -8,17 +8,17 @@ import java.util.Map;
import xiaozhi.common.validator.AssertUtils;
/**
- * 树形结构工具类,如:菜单、部门等
- * Copyright (c) 人人开源 All rights reserved.
+ * Tree structure utility class, such as: menu, department, etc.
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class TreeUtils {
/**
- * 根据pid,构建树节点
+ * Build tree nodes based on pid
*/
public static > List build(List treeNodes, Long pid) {
- // pid不能为空
+ // pid cannot be null
AssertUtils.isNull(pid, "pid");
List treeList = new ArrayList<>();
@@ -32,7 +32,7 @@ public class TreeUtils {
}
/**
- * 查找子节点
+ * Find child nodes
*/
private static > T findChildren(List treeNodes, T rootNode) {
for (T treeNode : treeNodes) {
@@ -44,12 +44,12 @@ public class TreeUtils {
}
/**
- * 构建树节点
+ * Build tree nodes
*/
public static > List build(List treeNodes) {
List result = new ArrayList<>();
- // list转map
+ // Convert list to map
Map nodeMap = new LinkedHashMap<>(treeNodes.size());
for (T treeNode : treeNodes) {
nodeMap.put(treeNode.getId(), treeNode);
@@ -68,4 +68,4 @@ public class TreeUtils {
return result;
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/AssertUtils.java b/main/manager-api/src/main/java/xiaozhi/common/validator/AssertUtils.java
index c86aa5176..3c10f5e42 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/validator/AssertUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/validator/AssertUtils.java
@@ -12,8 +12,8 @@ import xiaozhi.common.exception.ErrorCode;
import xiaozhi.common.exception.RenException;
/**
- * 校验工具类
- * Copyright (c) 人人开源 All rights reserved.
+ * Validation utility class
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class AssertUtils {
@@ -87,4 +87,4 @@ public class AssertUtils {
throw new RenException(code, params);
}
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/ValidatorUtils.java b/main/manager-api/src/main/java/xiaozhi/common/validator/ValidatorUtils.java
index 364da0d99..a805ca980 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/validator/ValidatorUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/validator/ValidatorUtils.java
@@ -15,8 +15,8 @@ import jakarta.validation.Validator;
import xiaozhi.common.exception.RenException;
/**
- * hibernate-validator校验工具类
- * 参考文档:http://docs.jboss.org/hibernate/validator/6.0/reference/en-US/html_single/
+ * hibernate-validator validation utility class
+ * Reference documentation: http://docs.jboss.org/hibernate/validator/6.0/reference/en-US/html_single/
*/
public class ValidatorUtils {
@@ -28,10 +28,10 @@ public class ValidatorUtils {
}
/**
- * 校验对象
+ * Validate object
*
- * @param object 待校验对象
- * @param groups 待校验的组
+ * @param object Object to be validated
+ * @param groups Groups to be validated
*/
public static void validateEntity(Object object, Class>... groups)
throws RenException {
@@ -48,9 +48,9 @@ public class ValidatorUtils {
}
/**
- * 国际手机号正则表达式
- * 要求必须带国际区号,格式:+[国家代码][手机号]
- * 例如:
+ * International phone number regular expression
+ * Must include international area code, format: +[country code][phone number]
+ * For example:
* - +8613800138000
* - +12345678900
* - +447123456789
@@ -58,11 +58,11 @@ public class ValidatorUtils {
private static final String INTERNATIONAL_PHONE_REGEX = "^\\+[1-9]\\d{0,3}[1-9]\\d{4,14}$";
/**
- * 校验手机号是否有效
- * 要求必须带国际区号,格式:+[国家代码][手机号]
- * 例如:+8613800138000
+ * Validate if phone number is valid
+ * Must include international area code, format: +[country code][phone number]
+ * For example: +8613800138000
*
- * @param phone 手机号
+ * @param phone Phone number
* @return boolean
*/
public static boolean isValidPhone(String phone) {
@@ -70,7 +70,7 @@ public class ValidatorUtils {
return false;
}
- // 验证必须带国际区号的手机号格式
+ // Validate phone number format with international area code
Pattern pattern = Pattern.compile(INTERNATIONAL_PHONE_REGEX);
return pattern.matcher(phone).matches();
}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/group/AddGroup.java b/main/manager-api/src/main/java/xiaozhi/common/validator/group/AddGroup.java
index fd8290fde..7ed4977e6 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/validator/group/AddGroup.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/validator/group/AddGroup.java
@@ -1,7 +1,7 @@
package xiaozhi.common.validator.group;
/**
- * 新增 Group
+ * Add Group
*/
public interface AddGroup {
diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/group/DefaultGroup.java b/main/manager-api/src/main/java/xiaozhi/common/validator/group/DefaultGroup.java
index 60ddb7305..587d7b7de 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/validator/group/DefaultGroup.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/validator/group/DefaultGroup.java
@@ -1,7 +1,7 @@
package xiaozhi.common.validator.group;
/**
- * 默认 Group
+ * Default Group
*/
public interface DefaultGroup {
diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/group/UpdateGroup.java b/main/manager-api/src/main/java/xiaozhi/common/validator/group/UpdateGroup.java
index 220fda333..454adc7ac 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/validator/group/UpdateGroup.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/validator/group/UpdateGroup.java
@@ -1,7 +1,7 @@
package xiaozhi.common.validator.group;
/**
- * 修改 Group
+ * Update Group
*/
public interface UpdateGroup {
diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/SqlFilter.java b/main/manager-api/src/main/java/xiaozhi/common/xss/SqlFilter.java
index 2bf4ab928..10032392e 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/xss/SqlFilter.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/xss/SqlFilter.java
@@ -6,35 +6,35 @@ import xiaozhi.common.exception.ErrorCode;
import xiaozhi.common.exception.RenException;
/**
- * SQL过滤
- * Copyright (c) 人人开源 All rights reserved.
+ * SQL filtering
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class SqlFilter {
/**
- * SQL注入过滤
+ * SQL injection filtering
*
- * @param str 待验证的字符串
+ * @param str String to be validated
*/
public static String sqlInject(String str) {
if (StringUtils.isBlank(str)) {
return null;
}
- // 去掉'|"|;|\字符
+ // Remove '|"|;|\ characters
str = StringUtils.replace(str, "'", "");
str = StringUtils.replace(str, "\"", "");
str = StringUtils.replace(str, ";", "");
str = StringUtils.replace(str, "\\", "");
- // 转换成小写
+ // Convert to lowercase
str = str.toLowerCase();
- // 非法字符
+ // Illegal characters
String[] keywords = { "master", "truncate", "insert", "select", "delete", "update", "declare", "alter",
"drop" };
- // 判断是否包含非法字符
+ // Check if contains illegal characters
for (String keyword : keywords) {
if (str.contains(keyword)) {
throw new RenException(ErrorCode.INVALID_SYMBOL);
diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssConfig.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssConfig.java
index e4b654659..fab433bd6 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssConfig.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/xss/XssConfig.java
@@ -10,8 +10,8 @@ import org.springframework.util.PathMatcher;
import jakarta.servlet.DispatcherType;
/**
- * XSS 配置文件
- * Copyright (c) 人人开源 All rights reserved.
+ * XSS configuration file
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
@Configuration
diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssFilter.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssFilter.java
index db7699897..3ddf27cbf 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssFilter.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/xss/XssFilter.java
@@ -14,15 +14,19 @@ import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
/**
- * XSS过滤
- * Copyright (c) 人人开源 All rights reserved.
+ * XSS filtering
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
-@AllArgsConstructor
public class XssFilter implements Filter {
private final XssProperties properties;
private final PathMatcher pathMatcher;
+ public XssFilter(XssProperties properties, PathMatcher pathMatcher) {
+ this.properties = properties;
+ this.pathMatcher = pathMatcher;
+ }
+
@Override
public void init(FilterConfig config) throws ServletException {
}
@@ -32,7 +36,7 @@ public class XssFilter implements Filter {
throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
- // 放行
+ // Allow
if (shouldNotFilter(httpServletRequest)) {
chain.doFilter(request, response);
@@ -43,7 +47,7 @@ public class XssFilter implements Filter {
}
private boolean shouldNotFilter(HttpServletRequest request) {
- // 放行不过滤的URL
+ // Allow URLs that should not be filtered
return properties.getExcludeUrls().stream()
.anyMatch(excludeUrl -> pathMatcher.match(excludeUrl, request.getServletPath()));
}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssHttpServletRequestWrapper.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssHttpServletRequestWrapper.java
index ecb364061..4ae15f44a 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssHttpServletRequestWrapper.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/xss/XssHttpServletRequestWrapper.java
@@ -17,8 +17,8 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;
/**
- * XSS过滤处理
- * Copyright (c) 人人开源 All rights reserved.
+ * XSS filtering processing
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
@@ -29,18 +29,18 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
@Override
public ServletInputStream getInputStream() throws IOException {
- // 非json类型,直接返回
+ // Non-json type, return directly
if (!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))) {
return super.getInputStream();
}
- // 为空,直接返回
+ // If empty, return directly
String json = IoUtil.readUtf8(super.getInputStream());
if (StringUtils.isBlank(json)) {
return super.getInputStream();
}
- // xss过滤
+ // XSS filtering
json = xssEncode(json);
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
return new ServletInputStream() {
@@ -115,4 +115,4 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
return XssUtils.filter(input);
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssProperties.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssProperties.java
index 5d9b8b01d..bea09b819 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssProperties.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/xss/XssProperties.java
@@ -8,19 +8,23 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data;
/**
- * XSS 配置项
- * Copyright (c) 人人开源 All rights reserved.
+ * XSS configuration items
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
@Data
@ConfigurationProperties(prefix = "renren.xss")
public class XssProperties {
/**
- * 是否开启 XSS
+ * Whether to enable XSS
*/
private boolean enabled;
/**
- * 排除的URL列表
+ * Excluded URL list
*/
private List excludeUrls = Collections.emptyList();
+
+ public List getExcludeUrls() {
+ return excludeUrls;
+ }
}
diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssUtils.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssUtils.java
index 165883924..e0bdbd2c6 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssUtils.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/xss/XssUtils.java
@@ -4,25 +4,25 @@ import org.jsoup.Jsoup;
import org.jsoup.safety.Safelist;
/**
- * XSS过滤工具类
- * Copyright (c) 人人开源 All rights reserved.
+ * XSS filtering utility class
+ * Copyright (c) Renren Open Source All rights reserved.
* Website: https://www.renren.io
*/
public class XssUtils extends Safelist {
/**
- * XSS过滤
+ * XSS filtering
*/
public static String filter(String html) {
return Jsoup.clean(html, xssWhitelist());
}
/**
- * XSS过滤白名单
+ * XSS filtering whitelist
*/
private static Safelist xssWhitelist() {
return new Safelist()
- // 支持的标签
+ // Supported tags
.addTags("a", "b", "blockquote", "br", "caption", "cite", "code", "col", "colgroup", "dd", "div", "dl",
"dt", "em", "h1", "h2", "h3", "h4", "h5", "h6", "i", "img", "li", "ol", "p", "pre", "q",
"small",
@@ -30,7 +30,7 @@ public class XssUtils extends Safelist {
"ul",
"embed", "object", "param", "span")
- // 支持的标签属性
+ // Supported tag attributes
.addAttributes("a", "href", "class", "style", "target", "rel", "nofollow")
.addAttributes("blockquote", "cite")
.addAttributes("code", "class", "style")
@@ -55,7 +55,7 @@ public class XssUtils extends Safelist {
.addAttributes("param", "name", "value")
.addAttributes("span", "class", "style")
- // 标签属性对应的协议
+ // Protocols corresponding to tag attributes
.addProtocols("a", "href", "ftp", "http", "https", "mailto")
.addProtocols("img", "src", "http", "https")
.addProtocols("blockquote", "cite", "http", "https")
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/AgentChatHistoryType.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/AgentChatHistoryType.java
index 49ed2dce7..caffb793b 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/AgentChatHistoryType.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/AgentChatHistoryType.java
@@ -4,7 +4,7 @@ package xiaozhi.modules.agent.Enums;
import lombok.Getter;
/**
- * 智能体聊天记录类型
+ * Agent chat history type
*/
@Getter
public enum AgentChatHistoryType {
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/XiaoZhiMcpJsonRpcJson.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/XiaoZhiMcpJsonRpcJson.java
index 114b1ab95..926f01c02 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/XiaoZhiMcpJsonRpcJson.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/XiaoZhiMcpJsonRpcJson.java
@@ -7,16 +7,16 @@ import java.util.Map;
/**
- * 小智MCP JSON-RPC 请求json
+ * XiaoZhi MCP JSON-RPC request json
*/
public class XiaoZhiMcpJsonRpcJson {
- //小智初始化mcp请求json
+ //XiaoZhi initialize MCP request json
private static final String INITIALIZE_JSON;
- //小智mcp初始化成功,返回通知请求json
+ //XiaoZhi MCP initialization successful, return notification request json
private static final String NOTIFICATIONS_INITIALIZED_JSON;
- //小智mcp获取mcp工具集合请求json
+ //XiaoZhi MCP get MCP tool collection request json
private static final String TOOLS_LIST_REQUEST;
- // 延迟加载
+ // Lazy loading
static {
INITIALIZE_JSON = JsonUtils.toJsonString(new JsonRpcTwo("initialize",
Map.of(
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java
index 49096d43e..7b2f31cba 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java
@@ -42,7 +42,7 @@ import xiaozhi.modules.agent.service.AgentService;
import xiaozhi.modules.agent.service.biz.AgentChatHistoryBizService;
import xiaozhi.modules.security.user.SecurityUser;
-@Tag(name = "智能体聊天历史管理")
+@Tag(name = "Agent Chat History Management")
@RequiredArgsConstructor
@RestController
@RequestMapping("/agent/chat-history")
@@ -53,13 +53,13 @@ public class AgentChatHistoryController {
private final RedisUtils redisUtils;
/**
- * 小智服务聊天上报请求
+ * XiaoZhi service chat report request
*
- * 小智服务聊天上报请求,包含Base64编码的音频数据和相关信息。
+ * XiaoZhi service chat report request, including Base64 encoded audio data and related information.
*
- * @param request 包含上传文件及相关信息的请求对象
+ * @param request Request object containing uploaded file and related information
*/
- @Operation(summary = "小智服务聊天上报请求")
+ @Operation(summary = "XiaoZhi service chat report request")
@PostMapping("/report")
public Result uploadFile(@Valid @RequestBody AgentChatHistoryReportDTO request) {
Boolean result = agentChatHistoryBizService.report(request);
@@ -67,50 +67,50 @@ public class AgentChatHistoryController {
}
/**
- * 获取聊天记录下载链接
- *
- * @param agentId 智能体ID
- * @param sessionId 会话ID
- * @return UUID作为下载标识
+ * Get a download link for chat history.
+ *
+ * @param agentId agent ID
+ * @param sessionId session ID
+ * @return UUID used as the download token
*/
- @Operation(summary = "获取聊天记录下载链接")
+ @Operation(summary = "Get chat-history download link")
@RequiresPermissions("sys:role:normal")
@PostMapping("/getDownloadUrl/{agentId}/{sessionId}")
public Result getDownloadUrl(@PathVariable("agentId") String agentId,
@PathVariable("sessionId") String sessionId) {
- // 获取当前用户
+ // Resolve the current user.
UserDetail user = SecurityUser.getUser();
- // 检查权限
+ // Validate permissions.
if (!agentService.checkAgentPermission(agentId, user.getId())) {
throw new RenException(ErrorCode.CHAT_HISTORY_NO_PERMISSION);
}
- // 生成UUID
+ // Generate a UUID.
String uuid = UUID.randomUUID().toString();
- // 存储agentId和sessionId到Redis,格式为agentId:sessionId
+ // Store agentId and sessionId in Redis as agentId:sessionId.
redisUtils.set(RedisKeys.getChatHistoryKey(uuid), agentId + ":" + sessionId);
return new Result().ok(uuid);
}
/**
- * 下载本会话聊天记录
- *
- * @param uuid 下载标识
- * @param response HTTP响应
+ * Download chat history for the current session.
+ *
+ * @param uuid download token
+ * @param response HTTP response
*/
- @Operation(summary = "下载本会话聊天记录")
+ @Operation(summary = "Download current-session chat history")
@GetMapping("/download/{uuid}/current")
public void downloadCurrentSession(@PathVariable("uuid") String uuid,
HttpServletResponse response) {
- // 从Redis获取agentId和sessionId
+ // Load agentId and sessionId from Redis.
String agentSessionInfo = (String) redisUtils.get(RedisKeys.getChatHistoryKey(uuid));
if (StringUtils.isBlank(agentSessionInfo)) {
throw new RenException(ErrorCode.DOWNLOAD_LINK_EXPIRED);
}
try {
- // 解析agentId和sessionId
+ // Parse agentId and sessionId.
String[] parts = agentSessionInfo.split(":");
if (parts.length != 2) {
throw new RenException(ErrorCode.DOWNLOAD_LINK_INVALID);
@@ -118,32 +118,32 @@ public class AgentChatHistoryController {
String agentId = parts[0];
String sessionId = parts[1];
- // 执行下载
+ // Start the download.
downloadChatHistory(agentId, List.of(sessionId), response);
} finally {
- // 下载完成后删除UUID,防止盗刷
+ // Remove the one-time token after download completes.
redisUtils.delete(RedisKeys.getChatHistoryKey(uuid));
}
}
/**
- * 下载本会话及前20条会话聊天记录
- *
- * @param uuid 下载标识
- * @param response HTTP响应
+ * Download the current session together with up to 20 earlier sessions.
+ *
+ * @param uuid download token
+ * @param response HTTP response
*/
- @Operation(summary = "下载本会话及前20条会话聊天记录")
+ @Operation(summary = "Download current session with up to 20 previous sessions")
@GetMapping("/download/{uuid}/previous")
public void downloadCurrentSessionWithPrevious(@PathVariable("uuid") String uuid,
HttpServletResponse response) {
- // 从Redis获取agentId和sessionId
+ // Load agentId and sessionId from Redis.
String agentSessionInfo = (String) redisUtils.get(RedisKeys.getChatHistoryKey(uuid));
if (StringUtils.isBlank(agentSessionInfo)) {
throw new RenException(ErrorCode.DOWNLOAD_LINK_EXPIRED);
}
try {
- // 解析agentId和sessionId
+ // Parse agentId and sessionId.
String[] parts = agentSessionInfo.split(":");
if (parts.length != 2) {
throw new RenException(ErrorCode.DOWNLOAD_LINK_INVALID);
@@ -151,16 +151,16 @@ public class AgentChatHistoryController {
String agentId = parts[0];
String sessionId = parts[1];
- // 获取所有会话列表
+ // Load the full session list.
Map params = Map.of(
"agentId", agentId,
Constant.PAGE, 1,
- Constant.LIMIT, 1000 // 获取足够多的会话
+ Constant.LIMIT, 1000 // Load enough sessions for the export window.
);
PageData sessionPage = agentChatHistoryService.getSessionListByAgentId(params);
List allSessions = sessionPage.getList();
- // 查找当前会话在列表中的位置
+ // Find the position of the current session in the list.
int currentIndex = -1;
for (int i = 0; i < allSessions.size(); i++) {
if (allSessions.get(i).getSessionId().equals(sessionId)) {
@@ -169,50 +169,50 @@ public class AgentChatHistoryController {
}
}
- // 如果找到了当前会话,收集当前会话及前20条会话ID
+ // If the current session was found, collect it and the next 20 sessions in the ordered list.
List sessionIdsToDownload = new ArrayList<>();
if (currentIndex != -1) {
- // 从当前会话开始,向后(数组后面)取最多20条会话(包括当前会话)
- int endIndex = Math.min(allSessions.size() - 1, currentIndex + 20); // 确保不越界
+ // Start from the current session and include at most 20 later entries in the array.
+ int endIndex = Math.min(allSessions.size() - 1, currentIndex + 20); // Keep index bounds safe.
for (int i = currentIndex; i <= endIndex; i++) {
sessionIdsToDownload.add(allSessions.get(i).getSessionId());
}
}
- // 如果没有找到当前会话,至少下载当前会话
+ // If the current session was not found, at least download that session.
if (sessionIdsToDownload.isEmpty()) {
sessionIdsToDownload.add(sessionId);
}
downloadChatHistory(agentId, sessionIdsToDownload, response);
} finally {
- // 下载完成后删除UUID,防止盗刷
+ // Remove the one-time token after download completes.
redisUtils.delete(RedisKeys.getChatHistoryKey(uuid));
}
}
/**
- * 下载指定会话的聊天记录
- *
- * @param agentId 智能体ID
- * @param sessionIds 会话ID列表
- * @param response HTTP响应
+ * Download chat history for the specified sessions.
+ *
+ * @param agentId agent ID
+ * @param sessionIds session ID list
+ * @param response HTTP response
*/
private void downloadChatHistory(String agentId, List sessionIds, HttpServletResponse response) {
try {
- // 设置响应头
+ // Set response headers.
response.setContentType("text/plain;charset=UTF-8");
String fileName = URLEncoder.encode("history.txt", StandardCharsets.UTF_8.toString());
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
- // 获取聊天记录并写入响应流
+ // Load chat history and stream it to the response.
try (OutputStream out = response.getOutputStream()) {
- // 为每个会话生成聊天记录
+ // Emit history for each session.
for (String sessionId : sessionIds) {
- // 获取该会话的所有聊天记录
+ // Load all chat messages for this session.
List chatHistoryList = agentChatHistoryService
.getChatHistoryBySessionId(agentId, sessionId);
- // 从聊天记录中获取第一条消息的创建时间作为会话时间
+ // Use the first message timestamp as the session timestamp.
if (!chatHistoryList.isEmpty()) {
Date firstMessageTime = chatHistoryList.get(0).getCreatedAt();
String sessionTimeStr = DateUtils.format(firstMessageTime, DateUtils.DATE_TIME_PATTERN);
@@ -231,7 +231,7 @@ public class AgentChatHistoryController {
out.write(line.getBytes(StandardCharsets.UTF_8));
}
- // 会话之间添加空行分隔
+ // Separate sessions with a blank line.
if (sessionIds.indexOf(sessionId) < sessionIds.size() - 1) {
out.write("\n".getBytes(StandardCharsets.UTF_8));
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java
index 77907cc5b..7f3e2de36 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java
@@ -58,7 +58,7 @@ import xiaozhi.modules.device.entity.DeviceEntity;
import xiaozhi.modules.device.service.DeviceService;
import xiaozhi.modules.security.user.SecurityUser;
-@Tag(name = "智能体管理")
+@Tag(name = "Agent Management")
@AllArgsConstructor
@RestController
@RequestMapping("/agent")
@@ -75,24 +75,24 @@ public class AgentController {
private final AgentTagService agentTagService;
@GetMapping("/list")
- @Operation(summary = "获取用户智能体列表")
+ @Operation(summary = "Get user agent list")
@RequiresPermissions("sys:role:normal")
public Result> getUserAgents(
@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "searchType", defaultValue = "name") String searchType) {
UserDetail user = SecurityUser.getUser();
- // 直接调用整合后的getUserAgents方法,无需再区分搜索和普通查询
+ // Call the unified getUserAgents method directly without splitting search and regular queries.
List agents = agentService.getUserAgents(user.getId(), keyword, searchType);
return new Result>().ok(agents);
}
@GetMapping("/all")
- @Operation(summary = "智能体列表(管理员)")
+ @Operation(summary = "List agents (admin)")
@RequiresPermissions("sys:role:superAdmin")
@Parameters({
- @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true),
- @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true),
+ @Parameter(name = Constant.PAGE, description = "Current page number, starting from 1", required = true),
+ @Parameter(name = Constant.LIMIT, description = "Records per page", required = true),
})
public Result> adminAgentList(
@Parameter(hidden = true) @RequestParam Map params) {
@@ -101,7 +101,7 @@ public class AgentController {
}
@GetMapping("/{id}")
- @Operation(summary = "获取智能体详情")
+ @Operation(summary = "Get agent details")
@RequiresPermissions("sys:role:normal")
public Result getAgentById(@PathVariable("id") String id) {
AgentInfoVO agent = agentService.getAgentById(id);
@@ -109,7 +109,7 @@ public class AgentController {
}
@PostMapping
- @Operation(summary = "创建智能体")
+ @Operation(summary = "Create agent")
@RequiresPermissions("sys:role:normal")
public Result save(@RequestBody @Valid AgentCreateDTO dto) {
String agentId = agentService.createAgent(dto);
@@ -117,7 +117,7 @@ public class AgentController {
}
@PutMapping("/saveMemory/{macAddress}")
- @Operation(summary = "根据设备id更新智能体")
+ @Operation(summary = "Update an agent by device ID")
public Result updateByDeviceId(@PathVariable String macAddress, @RequestBody @Valid AgentMemoryDTO dto) {
DeviceEntity device = deviceService.getDeviceByMacAddress(macAddress);
if (device == null) {
@@ -130,23 +130,25 @@ public class AgentController {
}
@PostMapping("/chat-summary/{sessionId}/save")
- @Operation(summary = "根据会话ID生成聊天记录总结并保存(异步执行)")
+ @Operation(summary = "Generate and save a chat summary by session ID asynchronously")
public Result generateAndSaveChatSummary(@PathVariable String sessionId) {
try {
- // 异步执行总结生成任务,立即返回成功响应
+ // Run the summary task asynchronously and return success immediately.
new Thread(() -> {
try {
agentChatSummaryService.generateAndSaveChatSummary(sessionId);
- System.out.println("异步执行会话 " + sessionId + " 的聊天记录总结完成");
+ System.out.println("Asynchronous chat-summary generation completed for session " + sessionId);
} catch (Exception e) {
- System.err.println("异步执行会话 " + sessionId + " 的聊天记录总结失败: " + e.getMessage());
+ System.err.println(
+ "Asynchronous chat-summary generation failed for session " + sessionId + ": "
+ + e.getMessage());
}
}).start();
- // 立即返回成功响应,不等待总结生成完成
+ // Return success immediately without waiting for summary generation to finish.
return new Result().ok(null);
} catch (Exception e) {
- return new Result().error("启动异步总结生成任务失败: " + e.getMessage());
+ return new Result().error("Failed to start asynchronous chat-summary generation: " + e.getMessage());
}
}
@@ -158,7 +160,7 @@ public class AgentController {
}
@PutMapping("/{id}")
- @Operation(summary = "更新智能体")
+ @Operation(summary = "Update agent")
@RequiresPermissions("sys:role:normal")
public Result update(@PathVariable String id, @RequestBody @Valid AgentUpdateDTO dto) {
agentService.updateAgentById(id, dto);
@@ -166,24 +168,24 @@ public class AgentController {
}
@DeleteMapping("/{id}")
- @Operation(summary = "删除智能体")
+ @Operation(summary = "Delete agent")
@RequiresPermissions("sys:role:normal")
public Result delete(@PathVariable String id) {
- // 先删除关联的设备
+ // Delete related devices first.
deviceService.deleteByAgentId(id);
- // 删除关联的聊天记录
+ // Delete related chat history.
agentChatHistoryService.deleteByAgentId(id, true, true);
- // 删除关联的插件
+ // Delete related plugins.
agentPluginMappingService.deleteByAgentId(id);
- // 删除关联的上下文源配置
+ // Delete related context-provider configuration.
agentContextProviderService.deleteByAgentId(id);
- // 再删除智能体
+ // Delete the agent last.
agentService.deleteById(id);
return new Result<>();
}
@GetMapping("/template")
- @Operation(summary = "智能体模板模板列表")
+ @Operation(summary = "List agent templates")
@RequiresPermissions("sys:role:normal")
public Result> templateList() {
List list = agentTemplateService
@@ -192,11 +194,11 @@ public class AgentController {
}
@GetMapping("/{id}/sessions")
- @Operation(summary = "获取智能体会话列表")
+ @Operation(summary = "Get agent session list")
@RequiresPermissions("sys:role:normal")
@Parameters({
- @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true),
- @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true),
+ @Parameter(name = Constant.PAGE, description = "Current page number, starting from 1", required = true),
+ @Parameter(name = Constant.LIMIT, description = "Records per page", required = true),
})
public Result> getAgentSessions(
@PathVariable("id") String id,
@@ -207,59 +209,59 @@ public class AgentController {
}
@GetMapping("/{id}/chat-history/{sessionId}")
- @Operation(summary = "获取智能体聊天记录")
+ @Operation(summary = "Get agent chat history")
@RequiresPermissions("sys:role:normal")
public Result> getAgentChatHistory(
@PathVariable("id") String id,
@PathVariable("sessionId") String sessionId) {
- // 获取当前用户
+ // Resolve the current user.
UserDetail user = SecurityUser.getUser();
- // 检查权限
+ // Validate access permissions.
if (!agentService.checkAgentPermission(id, user.getId())) {
- return new Result>().error("没有权限查看该智能体的聊天记录");
+ return new Result>().error("You do not have permission to view this agent's chat history");
}
- // 查询聊天记录
+ // Query chat history.
List result = agentChatHistoryService.getChatHistoryBySessionId(id, sessionId);
return new Result>().ok(result);
}
@GetMapping("/{id}/chat-history/user")
- @Operation(summary = "获取智能体聊天记录(用户)")
+ @Operation(summary = "Get agent chat history (user)")
@RequiresPermissions("sys:role:normal")
public Result> getRecentlyFiftyByAgentId(
@PathVariable("id") String id) {
- // 获取当前用户
+ // Resolve the current user.
UserDetail user = SecurityUser.getUser();
- // 检查权限
+ // Validate access permissions.
if (!agentService.checkAgentPermission(id, user.getId())) {
- return new Result>().error("没有权限查看该智能体的聊天记录");
+ return new Result>().error("You do not have permission to view this agent's chat history");
}
- // 查询聊天记录
+ // Query chat history.
List data = agentChatHistoryService.getRecentlyFiftyByAgentId(id);
return new Result>().ok(data);
}
@GetMapping("/{id}/chat-history/audio")
- @Operation(summary = "获取音频内容")
+ @Operation(summary = "Get audio content")
@RequiresPermissions("sys:role:normal")
public Result getContentByAudioId(
@PathVariable("id") String id) {
- // 查询聊天记录
+ // Query chat history.
String data = agentChatHistoryService.getContentByAudioId(id);
return new Result().ok(data);
}
@PostMapping("/audio/{audioId}")
- @Operation(summary = "获取音频下载ID")
+ @Operation(summary = "Get audio download ID")
@RequiresPermissions("sys:role:normal")
public Result getAudioId(@PathVariable("audioId") String audioId) {
byte[] audioData = agentChatAudioService.getAudio(audioId);
if (audioData == null) {
- return new Result().error("音频不存在");
+ return new Result().error("Audio was not found");
}
String uuid = UUID.randomUUID().toString();
redisUtils.set(RedisKeys.getAgentAudioIdKey(uuid), audioId);
@@ -267,7 +269,7 @@ public class AgentController {
}
@GetMapping("/play/{uuid}")
- @Operation(summary = "播放音频")
+ @Operation(summary = "Play audio")
public ResponseEntity playAudio(@PathVariable("uuid") String uuid) {
String audioId = (String) redisUtils.get(RedisKeys.getAgentAudioIdKey(uuid));
@@ -287,19 +289,19 @@ public class AgentController {
}
@PostMapping("/tag")
- @Operation(summary = "创建标签")
+ @Operation(summary = "Create tag")
@RequiresPermissions("sys:role:normal")
public Result createTag(@RequestBody Map params) {
String tagName = params.get("tagName");
if (StringUtils.isBlank(tagName)) {
- return new Result().error("标签名称不能为空");
+ return new Result().error("Tag name cannot be empty");
}
AgentTagEntity tag = agentTagService.saveTag(tagName);
return new Result().ok(tag);
}
@GetMapping("/tag/list")
- @Operation(summary = "获取所有标签列表")
+ @Operation(summary = "Get all tags")
@RequiresPermissions("sys:role:normal")
public Result> getAllTags() {
List tags = agentTagService.getAllTags();
@@ -307,7 +309,7 @@ public class AgentController {
}
@DeleteMapping("/tag/{id}")
- @Operation(summary = "删除标签")
+ @Operation(summary = "Delete tag")
@RequiresPermissions("sys:role:normal")
public Result deleteTag(@PathVariable String id) {
agentTagService.deleteTag(id);
@@ -315,7 +317,7 @@ public class AgentController {
}
@GetMapping("/{id}/tags")
- @Operation(summary = "获取智能体的标签")
+ @Operation(summary = "Get agent tags")
@RequiresPermissions("sys:role:normal")
public Result> getAgentTags(@PathVariable String id) {
List tags = agentTagService.getTagsByAgentId(id);
@@ -323,7 +325,7 @@ public class AgentController {
}
@PutMapping("/{id}/tags")
- @Operation(summary = "保存智能体的标签")
+ @Operation(summary = "Save agent tags")
@RequiresPermissions("sys:role:normal")
public Result saveAgentTags(@PathVariable String id, @RequestBody Map params) {
List tagIds = (List) params.get("tagIds");
@@ -332,4 +334,4 @@ public class AgentController {
return new Result().ok(null);
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentMcpAccessPointController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentMcpAccessPointController.java
index c805a4e78..96e3d1b35 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentMcpAccessPointController.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentMcpAccessPointController.java
@@ -18,7 +18,7 @@ import xiaozhi.modules.agent.service.AgentMcpAccessPointService;
import xiaozhi.modules.agent.service.AgentService;
import xiaozhi.modules.security.user.SecurityUser;
-@Tag(name = "智能体Mcp接入点管理")
+@Tag(name = "Agent MCP Access Point Management")
@RequiredArgsConstructor
@RestController
@RequestMapping("/agent/mcp")
@@ -27,19 +27,19 @@ public class AgentMcpAccessPointController {
private final AgentService agentService;
/**
- * 获取智能体的Mcp接入点地址
- *
- * @param agentId 智能体id
- * @return 返回错误提醒或者Mcp接入点地址
+ * Get the MCP access-point address for an agent.
+ *
+ * @param agentId agent ID
+ * @return error information or the MCP access-point address
*/
- @Operation(summary = "获取智能体的Mcp接入点地址")
+ @Operation(summary = "Get agent MCP access-point address")
@GetMapping("/address/{agentId}")
@RequiresPermissions("sys:role:normal")
public Result getAgentMcpAccessAddress(@PathVariable("agentId") String agentId) {
- // 获取当前用户
+ // Resolve the current user.
UserDetail user = SecurityUser.getUser();
- // 检查权限
+ // Validate permissions.
if (!agentService.checkAgentPermission(agentId, user.getId())) {
return new Result().error(ErrorCode.MCP_ACCESS_POINT_ADDRESS_NO_PERMISSION);
}
@@ -50,14 +50,14 @@ public class AgentMcpAccessPointController {
return new Result().ok(agentMcpAccessAddress);
}
- @Operation(summary = "获取智能体的Mcp工具列表")
+ @Operation(summary = "Get agent MCP tools")
@GetMapping("/tools/{agentId}")
@RequiresPermissions("sys:role:normal")
public Result> getAgentMcpToolsList(@PathVariable("agentId") String agentId) {
- // 获取当前用户
+ // Resolve the current user.
UserDetail user = SecurityUser.getUser();
- // 检查权限
+ // Validate permissions.
if (!agentService.checkAgentPermission(agentId, user.getId())) {
return new Result>().error(ErrorCode.MCP_ACCESS_POINT_TOOLS_LIST_NO_PERMISSION);
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentTemplateController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentTemplateController.java
index 9c8366ed6..52e16d9a6 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentTemplateController.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentTemplateController.java
@@ -33,7 +33,7 @@ import xiaozhi.modules.agent.entity.AgentTemplateEntity;
import xiaozhi.modules.agent.service.AgentTemplateService;
import xiaozhi.modules.agent.vo.AgentTemplateVO;
-@Tag(name = "智能体模板管理")
+@Tag(name = "Agent Template Management")
@AllArgsConstructor
@RestController
@RequestMapping("/agent/template")
@@ -42,22 +42,22 @@ public class AgentTemplateController {
private final AgentTemplateService agentTemplateService;
@GetMapping("/page")
- @Operation(summary = "获取模板分页列表")
+ @Operation(summary = "Get template paginated list")
@RequiresPermissions("sys:role:superAdmin")
@Parameters({
- @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true),
- @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true),
- @Parameter(name = "agentName", description = "模板名称,模糊查询")
+ @Parameter(name = Constant.PAGE, description = "Current page number, starting from 1", required = true),
+ @Parameter(name = Constant.LIMIT, description = "Number of records per page", required = true),
+ @Parameter(name = "agentName", description = "Template name, fuzzy search")
})
public Result> getAgentTemplatesPage(
@Parameter(hidden = true) @RequestParam Map params) {
- // 创建分页对象
+ // Create pagination object
int page = Integer.parseInt(params.getOrDefault(Constant.PAGE, "1").toString());
int limit = Integer.parseInt(params.getOrDefault(Constant.LIMIT, "10").toString());
Page pageInfo = new Page<>(page, limit);
- // 创建查询条件
+ // Create query conditions
QueryWrapper wrapper = new QueryWrapper<>();
String agentName = (String) params.get("agentName");
if (agentName != null && !agentName.isEmpty()) {
@@ -65,94 +65,94 @@ public class AgentTemplateController {
}
wrapper.orderByAsc("sort");
- // 执行分页查询
+ // Execute paginated query
IPage pageResult = agentTemplateService.page(pageInfo, wrapper);
- // 使用ConvertUtils转换为VO列表
+ // Use ConvertUtils to convert to VO list
List voList = ConvertUtils.sourceToTarget(pageResult.getRecords(), AgentTemplateVO.class);
- // 修复:使用构造函数创建PageData对象,而不是无参构造+setter
+ // Fix: Use constructor to create PageData object instead of no-arg constructor + setter
PageData pageData = new PageData<>(voList, pageResult.getTotal());
return new Result>().ok(pageData);
}
@GetMapping("/{id}")
- @Operation(summary = "获取模板详情")
+ @Operation(summary = "Get template details")
@RequiresPermissions("sys:role:superAdmin")
public Result getAgentTemplateById(@PathVariable("id") String id) {
AgentTemplateEntity template = agentTemplateService.getById(id);
if (template == null) {
- return ResultUtils.error("模板不存在");
+ return ResultUtils.error("Template does not exist");
}
- // 使用ConvertUtils转换为VO
+ // Use ConvertUtils to convert to VO
AgentTemplateVO vo = ConvertUtils.sourceToTarget(template, AgentTemplateVO.class);
return ResultUtils.success(vo);
}
@PostMapping
- @Operation(summary = "创建模板")
+ @Operation(summary = "Create template")
@RequiresPermissions("sys:role:superAdmin")
public Result createAgentTemplate(@Valid @RequestBody AgentTemplateEntity template) {
- // 设置排序值为下一个可用的序号
+ // Set sort value to next available sequence number
template.setSort(agentTemplateService.getNextAvailableSort());
boolean saved = agentTemplateService.save(template);
if (saved) {
return ResultUtils.success(template);
} else {
- return ResultUtils.error("创建模板失败");
+ return ResultUtils.error("Failed to create template");
}
}
@PutMapping
- @Operation(summary = "更新模板")
+ @Operation(summary = "Update template")
@RequiresPermissions("sys:role:superAdmin")
public Result updateAgentTemplate(@Valid @RequestBody AgentTemplateEntity template) {
boolean updated = agentTemplateService.updateById(template);
if (updated) {
return ResultUtils.success(template);
} else {
- return ResultUtils.error("更新模板失败");
+ return ResultUtils.error("Failed to update template");
}
}
@DeleteMapping("/{id}")
- @Operation(summary = "删除模板")
+ @Operation(summary = "Delete template")
@RequiresPermissions("sys:role:superAdmin")
public Result deleteAgentTemplate(@PathVariable("id") String id) {
- // 先查询要删除的模板信息,获取其排序值
+ // First query the template to be deleted to get its sort value
AgentTemplateEntity template = agentTemplateService.getById(id);
if (template == null) {
- return ResultUtils.error("模板不存在");
+ return ResultUtils.error("Template does not exist");
}
Integer deletedSort = template.getSort();
- // 执行删除操作
+ // Execute delete operation
boolean deleted = agentTemplateService.removeById(id);
if (deleted) {
- // 删除成功后,重新排序剩余模板
+ // After successful deletion, reorder remaining templates
agentTemplateService.reorderTemplatesAfterDelete(deletedSort);
- return ResultUtils.success("删除模板成功");
+ return ResultUtils.success("Template deleted successfully");
} else {
- return ResultUtils.error("删除模板失败");
+ return ResultUtils.error("Failed to delete template");
}
}
- // 添加新的批量删除方法,使用不同的URL
+ // Add new batch delete method using different URL
@PostMapping("/batch-remove")
- @Operation(summary = "批量删除模板")
+ @Operation(summary = "Batch delete templates")
@RequiresPermissions("sys:role:superAdmin")
public Result batchRemoveAgentTemplates(@RequestBody List ids) {
boolean deleted = agentTemplateService.removeByIds(ids);
if (deleted) {
- return ResultUtils.success("批量删除成功");
+ return ResultUtils.success("Batch delete successful");
} else {
- return ResultUtils.error("批量删除模板失败");
+ return ResultUtils.error("Failed to batch delete templates");
}
}
}
\ No newline at end of file
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentVoicePrintController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentVoicePrintController.java
index 9b7555eb4..d94242d9e 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentVoicePrintController.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentVoicePrintController.java
@@ -27,7 +27,7 @@ import xiaozhi.modules.agent.vo.AgentVoicePrintVO;
import xiaozhi.modules.security.user.SecurityUser;
import xiaozhi.modules.sys.service.SysParamsService;
-@Tag(name = "智能体声纹管理")
+@Tag(name = "Agent Voiceprint Management")
@AllArgsConstructor
@RestController
@RequestMapping("/agent/voice-print")
@@ -36,7 +36,7 @@ public class AgentVoicePrintController {
private final SysParamsService sysParamsService;
@PostMapping
- @Operation(summary = "创建智能体的声纹")
+ @Operation(summary = "Create agent voiceprint")
@RequiresPermissions("sys:role:normal")
public Result save(@RequestBody @Valid AgentVoicePrintSaveDTO dto) {
boolean b = agentVoicePrintService.insert(dto);
@@ -47,7 +47,7 @@ public class AgentVoicePrintController {
}
@PutMapping
- @Operation(summary = "更新智能体的对应声纹")
+ @Operation(summary = "Update agent corresponding voiceprint")
@RequiresPermissions("sys:role:normal")
public Result update(@RequestBody @Valid AgentVoicePrintUpdateDTO dto) {
Long userId = SecurityUser.getUserId();
@@ -59,11 +59,11 @@ public class AgentVoicePrintController {
}
@DeleteMapping("/{id}")
- @Operation(summary = "删除智能体对应声纹")
+ @Operation(summary = "Delete agent corresponding voiceprint")
@RequiresPermissions("sys:role:normal")
public Result delete(@PathVariable String id) {
Long userId = SecurityUser.getUserId();
- // 先删除关联的设备
+ // First delete associated devices
boolean delete = agentVoicePrintService.delete(userId, id);
if (delete) {
return new Result<>();
@@ -72,7 +72,7 @@ public class AgentVoicePrintController {
}
@GetMapping("/list/{id}")
- @Operation(summary = "获取用户指定智能体声纹列表")
+ @Operation(summary = "Get user specified agent voiceprint list")
@RequiresPermissions("sys:role:normal")
public Result> list(@PathVariable String id) {
String voiceprintUrl = sysParamsService.getValue("server.voice_print", true);
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentDao.java
index 03e569cdc..98a80b761 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentDao.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentDao.java
@@ -11,18 +11,18 @@ import xiaozhi.modules.agent.vo.AgentInfoVO;
@Mapper
public interface AgentDao extends BaseDao {
/**
- * 获取智能体的设备数量
+ * Get device count for agent
*
- * @param agentId 智能体ID
- * @return 设备数量
+ * @param agentId Agent ID
+ * @return Device count
*/
Integer getDeviceCountByAgentId(@Param("agentId") String agentId);
/**
- * 根据设备MAC地址查询对应设备的默认智能体信息
+ * Query default agent information for device by device MAC address
*
- * @param macAddress 设备MAC地址
- * @return 默认智能体信息
+ * @param macAddress Device MAC address
+ * @return Default agent information
*/
@Select(" SELECT a.* FROM ai_device d " +
" LEFT JOIN ai_agent a ON d.agent_id = a.id " +
@@ -31,9 +31,9 @@ public interface AgentDao extends BaseDao {
AgentEntity getDefaultAgentByMacAddress(@Param("macAddress") String macAddress);
/**
- * 根据id查询agent信息,包括插件信息
+ * Query agent information by ID, including plugin information
*
- * @param agentId 智能体ID
+ * @param agentId Agent ID
*/
AgentInfoVO selectAgentInfoById(@Param("agentId") String agentId);
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentPluginMappingMapper.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentPluginMappingMapper.java
index 2fe817533..4bba45590 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentPluginMappingMapper.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentPluginMappingMapper.java
@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
-* @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Mapper
+* @description Database operation Mapper for table [ai_agent_plugin_mapping(unique mapping table between Agent and plugins)]
* @createDate 2025-05-25 22:33:17
* @Entity xiaozhi.modules.agent.entity.AgentPluginMapping
*/
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentTemplateDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentTemplateDao.java
index 48d95bef0..ab5ceea2b 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentTemplateDao.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentTemplateDao.java
@@ -8,7 +8,7 @@ import xiaozhi.modules.agent.entity.AgentTemplateEntity;
/**
* @author chenerlei
- * @description 针对表【ai_agent_template(智能体配置模板表)】的数据库操作Mapper
+ * @description Database operation Mapper for table [ai_agent_template(agent configuration template table)]
* @createDate 2025-03-22 11:48:18
*/
@Mapper
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentVoicePrintDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentVoicePrintDao.java
index 1a5ee3649..7abd198df 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentVoicePrintDao.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentVoicePrintDao.java
@@ -8,7 +8,7 @@ import xiaozhi.modules.agent.entity.AgentChatHistoryEntity;
import xiaozhi.modules.agent.entity.AgentVoicePrintEntity;
/**
- * {@link AgentChatHistoryEntity} 智能体聊天历史记录Dao对象
+ * {@link AgentChatHistoryEntity} Agent chat history record Dao object
*
* @author Goody
* @version 1.0, 2025/4/30
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatAudioDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatAudioDao.java
index 355b25acf..a12935c84 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatAudioDao.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatAudioDao.java
@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import xiaozhi.modules.agent.entity.AgentChatAudioEntity;
/**
- * {@link AgentChatAudioEntity} 智能体聊天音频数据Dao对象
+ * {@link AgentChatAudioEntity} Agent chat audio data Dao object
*
* @author Goody
* @version 1.0, 2025/5/8
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatHistoryDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatHistoryDao.java
index 7c9bf1eb4..2ea59741d 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatHistoryDao.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatHistoryDao.java
@@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import xiaozhi.modules.agent.entity.AgentChatHistoryEntity;
/**
- * {@link AgentChatHistoryEntity} 智能体聊天历史记录Dao对象
+ * DAO for {@link AgentChatHistoryEntity}.
*
* @author Goody
* @version 1.0, 2025/4/30
@@ -20,31 +20,31 @@ import xiaozhi.modules.agent.entity.AgentChatHistoryEntity;
public interface AiAgentChatHistoryDao extends BaseMapper {
/**
- * 根据智能体ID删除聊天历史记录
+ * Delete chat history by agent ID.
*
- * @param agentId 智能体ID
+ * @param agentId agent ID
*/
void deleteHistoryByAgentId(String agentId);
/**
- * 根据智能体ID删除音频ID
+ * Delete audio IDs by agent ID.
*
- * @param agentId 智能体ID
+ * @param agentId agent ID
*/
void deleteAudioIdByAgentId(String agentId);
/**
- * 根据智能体ID获取所有音频ID列表
+ * Get all audio IDs by agent ID.
*
- * @param agentId 智能体ID
- * @return 音频ID列表
+ * @param agentId agent ID
+ * @return audio ID list
*/
List getAudioIdsByAgentId(String agentId);
/**
- * 批量删除音频
+ * Delete audio records in batch.
*
- * @param audioIds 音频ID列表
+ * @param audioIds audio ID list
*/
void deleteAudioByIds(@Param("audioIds") List audioIds);
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryDTO.java
index fd49e52b4..0499c090d 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryDTO.java
@@ -6,23 +6,23 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
- * 智能体聊天记录DTO
+ * Agent chat history DTO
*/
@Data
-@Schema(description = "智能体聊天记录")
+@Schema(description = "Agent chat history")
public class AgentChatHistoryDTO {
- @Schema(description = "创建时间")
+ @Schema(description = "Creation time")
private Date createdAt;
- @Schema(description = "消息类型: 1-用户, 2-智能体")
+ @Schema(description = "Message type: 1-user, 2-agent")
private Byte chatType;
- @Schema(description = "聊天内容")
+ @Schema(description = "Chat content")
private String content;
- @Schema(description = "音频ID")
+ @Schema(description = "Audio ID")
private String audioId;
- @Schema(description = "MAC地址")
+ @Schema(description = "MAC address")
private String macAddress;
}
\ No newline at end of file
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryReportDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryReportDTO.java
index ae58783f3..601c01b6f 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryReportDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryReportDTO.java
@@ -6,28 +6,28 @@ import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
- * 小智设备聊天上报请求
+ * XiaoZhi device chat report request
*
* @author Haotian
* @version 1.0, 2025/5/8
*/
@Data
-@Schema(description = "小智设备聊天上报请求")
+@Schema(description = "XiaoZhi device chat report request")
public class AgentChatHistoryReportDTO {
- @Schema(description = "MAC地址", example = "00:11:22:33:44:55")
+ @Schema(description = "MAC address", example = "00:11:22:33:44:55")
@NotBlank
private String macAddress;
- @Schema(description = "会话ID", example = "79578c31-f1fb-426a-900e-1e934215f05a")
+ @Schema(description = "Session ID", example = "79578c31-f1fb-426a-900e-1e934215f05a")
@NotBlank
private String sessionId;
- @Schema(description = "消息类型: 1-用户, 2-智能体", example = "1")
+ @Schema(description = "Message type: 1-User, 2-Agent", example = "1")
@NotNull
private Byte chatType;
- @Schema(description = "聊天内容", example = "你好呀")
+ @Schema(description = "Chat content", example = "Hello")
@NotBlank
private String content;
- @Schema(description = "base64编码的opus音频数据", example = "")
+ @Schema(description = "Base64 encoded opus audio data", example = "")
private String audioBase64;
- @Schema(description = "上报时间,十位时间戳,空时默认使用当前时间", example = "1745657732")
+ @Schema(description = "Report time, 10-digit timestamp, defaults to current time if empty", example = "1745657732")
private Long reportTime;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSessionDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSessionDTO.java
index 841b69768..41bc97783 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSessionDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSessionDTO.java
@@ -5,22 +5,22 @@ import java.time.LocalDateTime;
import lombok.Data;
/**
- * 智能体会话列表DTO
+ * Agent session list DTO
*/
@Data
public class AgentChatSessionDTO {
/**
- * 会话ID
+ * Session ID
*/
private String sessionId;
/**
- * 会话时间
+ * Session time
*/
private LocalDateTime createdAt;
/**
- * 聊天条数
+ * Chat count
*/
private Integer chatCount;
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSummaryDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSummaryDTO.java
index f6fbe6605..34eb29681 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSummaryDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSummaryDTO.java
@@ -4,25 +4,25 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
- * 智能体聊天记录总结DTO
+ * Agent chat-summary DTO.
*/
@Data
-@Schema(description = "智能体聊天记录总结对象")
+@Schema(description = "Agent chat-summary object")
public class AgentChatSummaryDTO {
- @Schema(description = "会话ID")
+ @Schema(description = "Session ID")
private String sessionId;
- @Schema(description = "智能体ID")
+ @Schema(description = "Agent ID")
private String agentId;
- @Schema(description = "总结内容")
+ @Schema(description = "Summary content")
private String summary;
- @Schema(description = "总结状态")
+ @Schema(description = "Summary status")
private boolean success;
- @Schema(description = "错误信息")
+ @Schema(description = "Error message")
private String errorMessage;
public AgentChatSummaryDTO() {
@@ -42,4 +42,4 @@ public class AgentChatSummaryDTO {
this.success = false;
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentCreateDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentCreateDTO.java
index 59e770075..2fca17b20 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentCreateDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentCreateDTO.java
@@ -7,15 +7,15 @@ import jakarta.validation.constraints.NotBlank;
import lombok.Data;
/**
- * 智能体创建DTO
- * 专用于新增智能体,不包含id、agentCode和sort字段,这些字段由系统自动生成/设置默认值
+ * Agent creation DTO
+ * Specifically for creating new agents, does not include id, agentCode and sort fields, these fields are automatically generated/set to default values by the system
*/
@Data
-@Schema(description = "智能体创建对象")
+@Schema(description = "Agent creation object")
public class AgentCreateDTO implements Serializable {
private static final long serialVersionUID = 1L;
- @Schema(description = "智能体名称", example = "客服助手")
- @NotBlank(message = "智能体名称不能为空")
+ @Schema(description = "Agent name", example = "Customer Service Assistant")
+ @NotBlank(message = "Agent name cannot be empty")
private String agentName;
}
\ No newline at end of file
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentDTO.java
index 77028f2a1..5e360d6d6 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentDTO.java
@@ -8,46 +8,46 @@ import lombok.Data;
import xiaozhi.modules.agent.dto.AgentTagDTO;
/**
- * 智能体数据传输对象
- * 用于在服务层和控制器层之间传递智能体相关的数据
+ * Agent data transfer object
+ * Used to pass agent-related data between service layer and controller layer
*/
@Data
-@Schema(description = "智能体对象")
+@Schema(description = "Agent object")
public class AgentDTO {
- @Schema(description = "智能体编码", example = "AGT_1234567890")
+ @Schema(description = "Agent code", example = "AGT_1234567890")
private String id;
- @Schema(description = "智能体名称", example = "客服助手")
+ @Schema(description = "Agent name", example = "Customer Service Assistant")
private String agentName;
- @Schema(description = "语音合成模型名称", example = "tts_model_01")
+ @Schema(description = "TTS model name", example = "tts_model_01")
private String ttsModelName;
- @Schema(description = "音色名称", example = "voice_01")
+ @Schema(description = "Voice name", example = "voice_01")
private String ttsVoiceName;
- @Schema(description = "大语言模型名称", example = "llm_model_01")
+ @Schema(description = "LLM model name", example = "llm_model_01")
private String llmModelName;
- @Schema(description = "视觉模型名称", example = "vllm_model_01")
+ @Schema(description = "Vision model name", example = "vllm_model_01")
private String vllmModelName;
- @Schema(description = "记忆模型ID", example = "mem_model_01")
+ @Schema(description = "Memory model ID", example = "mem_model_01")
private String memModelId;
- @Schema(description = "角色设定参数", example = "你是一个专业的客服助手,负责回答用户问题并提供帮助")
+ @Schema(description = "Role setting parameters", example = "You are a professional customer service assistant, responsible for answering user questions and providing help")
private String systemPrompt;
- @Schema(description = "总结记忆", example = "构建可生长的动态记忆网络,在有限空间内保留关键信息的同时,智能维护信息演变轨迹\n" +
- "根据对话记录,总结user的重要信息,以便在未来的对话中提供更个性化的服务", required = false)
+ @Schema(description = "Summary memory", example = "Build a growing dynamic memory network that retains key information in limited space while intelligently maintaining information evolution trajectories\n" +
+ "Based on conversation records, summarize important user information to provide more personalized service in future conversations", required = false)
private String summaryMemory;
- @Schema(description = "最后连接时间", example = "2024-03-20 10:00:00")
+ @Schema(description = "Last connection time", example = "2024-03-20 10:00:00")
private Date lastConnectedAt;
- @Schema(description = "设备数量", example = "10")
+ @Schema(description = "Device count", example = "10")
private Integer deviceCount;
- @Schema(description = "标签列表")
+ @Schema(description = "Tag list")
private List tags;
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentMemoryDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentMemoryDTO.java
index ed210c60a..556b4437e 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentMemoryDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentMemoryDTO.java
@@ -6,14 +6,14 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
- * 智能体记忆更新DTO
+ * Agent memory update DTO
*/
@Data
-@Schema(description = "智能体记忆更新对象")
+@Schema(description = "Agent memory update object")
public class AgentMemoryDTO implements Serializable {
private static final long serialVersionUID = 1L;
- @Schema(description = "总结记忆", example = "构建可生长的动态记忆网络,在有限空间内保留关键信息的同时,智能维护信息演变轨迹\n" +
- "根据对话记录,总结user的重要信息,以便在未来的对话中提供更个性化的服务", required = false)
+ @Schema(description = "Summary memory", example = "Build a growing dynamic memory network that retains key information in limited space while intelligently maintaining information evolution trajectory\n" +
+ "Summarize important user information based on conversation records to provide more personalized service in future conversations", required = false)
private String summaryMemory;
}
\ No newline at end of file
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentTagDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentTagDTO.java
index 5dfc5f520..6cfb3ae33 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentTagDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentTagDTO.java
@@ -7,14 +7,14 @@ import java.io.Serializable;
import java.util.List;
@Data
-@Schema(description = "智能体标签DTO")
+@Schema(description = "Agent tag DTO")
public class AgentTagDTO implements Serializable {
private static final long serialVersionUID = 1L;
- @Schema(description = "标签ID")
+ @Schema(description = "Tag ID")
private String id;
- @Schema(description = "标签名称")
+ @Schema(description = "Tag name")
private String tagName;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentUpdateDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentUpdateDTO.java
index 13d95ddc5..462f3aab6 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentUpdateDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentUpdateDTO.java
@@ -9,28 +9,28 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
- * 智能体更新DTO
- * 专用于更新智能体,id字段是必需的,用于标识要更新的智能体
- * 其他字段均为非必填,只更新提供的字段
+ * Agent update DTO.
+ * Used specifically for agent updates. All fields are optional and only
+ * provided values will be updated.
*/
@Data
-@Schema(description = "智能体更新对象")
+@Schema(description = "Agent update object")
public class AgentUpdateDTO implements Serializable {
private static final long serialVersionUID = 1L;
- @Schema(description = "智能体编码", example = "AGT_1234567890", nullable = true)
+ @Schema(description = "Agent code", example = "AGT_1234567890", nullable = true)
private String agentCode;
- @Schema(description = "智能体名称", example = "客服助手", nullable = true)
+ @Schema(description = "Agent name", example = "Support Assistant", nullable = true)
private String agentName;
- @Schema(description = "语音识别模型标识", example = "asr_model_02", nullable = true)
+ @Schema(description = "ASR model ID", example = "asr_model_02", nullable = true)
private String asrModelId;
- @Schema(description = "语音活动检测标识", example = "vad_model_02", nullable = true)
+ @Schema(description = "VAD model ID", example = "vad_model_02", nullable = true)
private String vadModelId;
- @Schema(description = "大语言模型标识", example = "llm_model_02", nullable = true)
+ @Schema(description = "LLM model ID", example = "llm_model_02", nullable = true)
private String llmModelId;
@Schema(description = "小模型标识", example = "slm_model_02", nullable = true)
@@ -39,64 +39,64 @@ public class AgentUpdateDTO implements Serializable {
@Schema(description = "VLLM模型标识", example = "vllm_model_02", required = false)
private String vllmModelId;
- @Schema(description = "语音合成模型标识", example = "tts_model_02", required = false)
+ @Schema(description = "TTS model ID", example = "tts_model_02", required = false)
private String ttsModelId;
- @Schema(description = "音色标识", example = "voice_02", nullable = true)
+ @Schema(description = "Voice ID", example = "voice_02", nullable = true)
private String ttsVoiceId;
- @Schema(description = "音色语言", example = "普通话", nullable = true)
+ @Schema(description = "Voice language", example = "English", nullable = true)
private String ttsLanguage;
- @Schema(description = "TTS音量", example = "50", nullable = true)
+ @Schema(description = "TTS volume", example = "50", nullable = true)
private Integer ttsVolume;
- @Schema(description = "TTS语速", example = "50", nullable = true)
+ @Schema(description = "TTS speed", example = "50", nullable = true)
private Integer ttsRate;
- @Schema(description = "TTS音调", example = "50", nullable = true)
+ @Schema(description = "TTS pitch", example = "50", nullable = true)
private Integer ttsPitch;
- @Schema(description = "记忆模型标识", example = "mem_model_02", nullable = true)
+ @Schema(description = "Memory model ID", example = "mem_model_02", nullable = true)
private String memModelId;
- @Schema(description = "意图模型标识", example = "intent_model_02", nullable = true)
+ @Schema(description = "Intent model ID", example = "intent_model_02", nullable = true)
private String intentModelId;
- @Schema(description = "插件函数信息", nullable = true)
+ @Schema(description = "Plugin function information", nullable = true)
private List functions;
- @Schema(description = "角色设定参数", example = "你是一个专业的客服助手,负责回答用户问题并提供帮助", nullable = true)
+ @Schema(description = "System prompt", example = "You are a professional support assistant who helps answer user questions.", nullable = true)
private String systemPrompt;
- @Schema(description = "总结记忆", example = "构建可生长的动态记忆网络,在有限空间内保留关键信息的同时,智能维护信息演变轨迹\n"
- + "根据对话记录,总结user的重要信息,以便在未来的对话中提供更个性化的服务", nullable = true)
+ @Schema(description = "Summary memory", example = "Build a growing memory graph that preserves key information while tracking how it evolves over time.\n"
+ + "Summarize the user's important details from the conversation so future interactions can be more personalized.", nullable = true)
private String summaryMemory;
- @Schema(description = "聊天记录配置(0不记录 1仅记录文本 2记录文本和语音)", example = "3", nullable = true)
+ @Schema(description = "Chat-history mode (0 disabled, 1 text only, 2 text and audio)", example = "2", nullable = true)
private Integer chatHistoryConf;
- @Schema(description = "语言编码", example = "zh_CN", nullable = true)
+ @Schema(description = "Language code", example = "en_US", nullable = true)
private String langCode;
- @Schema(description = "交互语种", example = "中文", nullable = true)
+ @Schema(description = "Interaction language", example = "English", nullable = true)
private String language;
- @Schema(description = "排序", example = "1", nullable = true)
+ @Schema(description = "Sort order", example = "1", nullable = true)
private Integer sort;
- @Schema(description = "上下文源配置", nullable = true)
+ @Schema(description = "Context-provider configuration", nullable = true)
private List contextProviders;
@Data
- @Schema(description = "插件函数信息")
+ @Schema(description = "Plugin function information")
public static class FunctionInfo implements Serializable {
- @Schema(description = "插件ID", example = "plugin_01")
+ @Schema(description = "Plugin ID", example = "plugin_01")
private String pluginId;
- @Schema(description = "函数参数信息", nullable = true)
+ @Schema(description = "Function parameter information", nullable = true)
private HashMap paramInfo;
private static final long serialVersionUID = 1L;
}
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintSaveDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintSaveDTO.java
index 0ff3b0cad..61192e188 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintSaveDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintSaveDTO.java
@@ -3,26 +3,26 @@ package xiaozhi.modules.agent.dto;
import lombok.Data;
/**
- * 保存智能体声纹的dto
+ * DTO for saving agent voiceprint
*
* @author zjy
*/
@Data
public class AgentVoicePrintSaveDTO {
/**
- * 关联的智能体id
+ * Associated agent id
*/
private String agentId;
/**
- * 音频文件id
+ * Audio file id
*/
private String audioId;
/**
- * 声纹来源的人姓名
+ * Name of the person whose voiceprint this is from
*/
private String sourceName;
/**
- * 描述声纹来源的人
+ * Description of the person whose voiceprint this is from
*/
private String introduce;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintUpdateDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintUpdateDTO.java
index 60643e294..c79c52c73 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintUpdateDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintUpdateDTO.java
@@ -3,26 +3,26 @@ package xiaozhi.modules.agent.dto;
import lombok.Data;
/**
- * 修改智能体声纹的dto
+ * DTO for updating agent voiceprint
*
* @author zjy
*/
@Data
public class AgentVoicePrintUpdateDTO {
/**
- * 智能体声纹id
+ * Agent voiceprint id
*/
private String id;
/**
- * 音频文件id
+ * Audio file id
*/
private String audioId;
/**
- * 声纹来源的人姓名
+ * Name of the person whose voiceprint this is from
*/
private String sourceName;
/**
- * 描述声纹来源的人
+ * Description of the person whose voiceprint this is from
*/
private String introduce;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/ContextProviderDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/ContextProviderDTO.java
index 0b8edfd8d..33706f2d1 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/ContextProviderDTO.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/ContextProviderDTO.java
@@ -7,13 +7,13 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
-@Schema(description = "上下文源配置DTO")
+@Schema(description = "Context-provider DTO")
public class ContextProviderDTO implements Serializable {
private static final long serialVersionUID = 1L;
- @Schema(description = "URL地址")
+ @Schema(description = "URL")
private String url;
- @Schema(description = "请求头")
+ @Schema(description = "Request headers")
private Map headers;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/IdentifyVoicePrintResponse.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/IdentifyVoicePrintResponse.java
index 14ce57c2b..e7eeb3d29 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/IdentifyVoicePrintResponse.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/IdentifyVoicePrintResponse.java
@@ -5,17 +5,17 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
- * 声纹识别接口返回的对象
+ * Object returned by voiceprint recognition interface
*/
@Data
public class IdentifyVoicePrintResponse {
/**
- * 最匹配的声纹id
+ * Most matching voiceprint id
*/
@JsonProperty("speaker_id")
private String speakerId;
/**
- * 声纹的分数
+ * Voiceprint score
*/
private Double score;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/McpJsonRpcResponse.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/McpJsonRpcResponse.java
index 1bd667e6d..e1bfc6416 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/McpJsonRpcResponse.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/McpJsonRpcResponse.java
@@ -3,7 +3,7 @@ package xiaozhi.modules.agent.dto;
import lombok.Data;
/**
- * MCP JSON-RPC 响应 DTO
+ * MCP JSON-RPC response DTO
*/
@Data
public class McpJsonRpcResponse {
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatAudioEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatAudioEntity.java
index ac30d9d49..1dc255881 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatAudioEntity.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatAudioEntity.java
@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
- * 智能体聊天音频数据表
+ * Agent chat audio data table
*
* @author Goody
* @version 1.0, 2025/5/8
@@ -17,13 +17,13 @@ import lombok.Data;
@TableName("ai_agent_chat_audio")
public class AgentChatAudioEntity {
/**
- * 主键ID
+ * Primary key ID
*/
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
- * 音频opus数据
+ * Audio opus data
*/
private byte[] audio;
}
\ No newline at end of file
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatHistoryEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatHistoryEntity.java
index 679c814ab..90ed90aab 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatHistoryEntity.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatHistoryEntity.java
@@ -13,7 +13,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
- * 智能体聊天记录表
+ * Agent chat history table
*
* @author Goody
* @version 1.0, 2025/4/30
@@ -26,55 +26,55 @@ import lombok.NoArgsConstructor;
@TableName(value = "ai_agent_chat_history")
public class AgentChatHistoryEntity {
/**
- * 主键ID
+ * Primary key ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
- * MAC地址
+ * MAC address
*/
@TableField(value = "mac_address")
private String macAddress;
/**
- * 智能体id
+ * Agent ID
*/
@TableField(value = "agent_id")
private String agentId;
/**
- * 会话ID
+ * Session ID
*/
@TableField(value = "session_id")
private String sessionId;
/**
- * 消息类型: 1-用户, 2-智能体
+ * Message type: 1-user, 2-agent
*/
@TableField(value = "chat_type")
private Byte chatType;
/**
- * 聊天内容
+ * Chat content
*/
@TableField(value = "content")
private String content;
/**
- * 音频base64数据
+ * Audio base64 data
*/
@TableField(value = "audio_id")
private String audioId;
/**
- * 创建时间
+ * Creation time
*/
@TableField(value = "created_at")
private Date createdAt;
/**
- * 更新时间
+ * Update time
*/
@TableField(value = "updated_at")
private Date updatedAt;
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentContextProviderEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentContextProviderEntity.java
index 937556efc..d01fb7881 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentContextProviderEntity.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentContextProviderEntity.java
@@ -15,29 +15,29 @@ import xiaozhi.modules.agent.dto.ContextProviderDTO;
@Data
@TableName(value = "ai_agent_context_provider", autoResultMap = true)
-@Schema(description = "智能体上下文源配置")
+@Schema(description = "Agent context-provider configuration")
public class AgentContextProviderEntity {
@TableId(type = IdType.ASSIGN_UUID)
- @Schema(description = "主键")
+ @Schema(description = "Primary key")
private String id;
- @Schema(description = "智能体ID")
+ @Schema(description = "Agent ID")
private String agentId;
- @Schema(description = "上下文源配置")
+ @Schema(description = "Context-provider configuration")
@TableField(typeHandler = JacksonTypeHandler.class)
private List contextProviders;
- @Schema(description = "创建者")
+ @Schema(description = "Created by")
private Long creator;
- @Schema(description = "创建时间")
+ @Schema(description = "Created at")
private Date createdAt;
- @Schema(description = "更新者")
+ @Schema(description = "Updated by")
private Long updater;
- @Schema(description = "更新时间")
+ @Schema(description = "Updated at")
private Date updatedAt;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentEntity.java
index ce752b01e..40f69d381 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentEntity.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentEntity.java
@@ -12,29 +12,29 @@ import lombok.Data;
@Data
@TableName("ai_agent")
-@Schema(description = "智能体信息")
+@Schema(description = "Agent information")
public class AgentEntity {
@TableId(type = IdType.ASSIGN_UUID)
- @Schema(description = "智能体唯一标识")
+ @Schema(description = "Unique agent ID")
private String id;
- @Schema(description = "所属用户ID")
+ @Schema(description = "Owner user ID")
private Long userId;
- @Schema(description = "智能体编码")
+ @Schema(description = "Agent code")
private String agentCode;
- @Schema(description = "智能体名称")
+ @Schema(description = "Agent name")
private String agentName;
- @Schema(description = "语音识别模型标识")
+ @Schema(description = "ASR model ID")
private String asrModelId;
- @Schema(description = "语音活动检测标识")
+ @Schema(description = "VAD model ID")
private String vadModelId;
- @Schema(description = "大语言模型标识")
+ @Schema(description = "LLM model ID")
private String llmModelId;
@Schema(description = "小模型标识")
@@ -43,58 +43,58 @@ public class AgentEntity {
@Schema(description = "VLLM模型标识")
private String vllmModelId;
- @Schema(description = "语音合成模型标识")
+ @Schema(description = "TTS model ID")
private String ttsModelId;
- @Schema(description = "音色标识")
+ @Schema(description = "Voice ID")
private String ttsVoiceId;
- @Schema(description = "音色语言")
+ @Schema(description = "Voice language")
private String ttsLanguage;
- @Schema(description = "TTS音量")
+ @Schema(description = "TTS volume")
private Integer ttsVolume;
- @Schema(description = "TTS语速")
+ @Schema(description = "TTS speed")
private Integer ttsRate;
- @Schema(description = "TTS音调")
+ @Schema(description = "TTS pitch")
private Integer ttsPitch;
- @Schema(description = "记忆模型标识")
+ @Schema(description = "Memory model ID")
private String memModelId;
- @Schema(description = "意图模型标识")
+ @Schema(description = "Intent model ID")
private String intentModelId;
- @Schema(description = "聊天记录配置(0不记录 1仅记录文本 2记录文本和语音)")
+ @Schema(description = "Chat-history mode (0 disabled, 1 text only, 2 text and audio)")
private Integer chatHistoryConf;
- @Schema(description = "角色设定参数")
+ @Schema(description = "System prompt")
private String systemPrompt;
- @Schema(description = "总结记忆", example = "构建可生长的动态记忆网络,在有限空间内保留关键信息的同时,智能维护信息演变轨迹\n" +
- "根据对话记录,总结user的重要信息,以便在未来的对话中提供更个性化的服务", required = false)
+ @Schema(description = "Summary memory", example = "Build a growing memory graph that preserves key information while tracking how it evolves over time.\n" +
+ "Summarize the user's important details from the conversation so future interactions can be more personalized.", required = false)
private String summaryMemory;
- @Schema(description = "语言编码")
+ @Schema(description = "Language code")
private String langCode;
- @Schema(description = "交互语种")
+ @Schema(description = "Interaction language")
private String language;
- @Schema(description = "排序")
+ @Schema(description = "Sort order")
private Integer sort;
- @Schema(description = "创建者")
+ @Schema(description = "Created by")
private Long creator;
- @Schema(description = "创建时间")
+ @Schema(description = "Created at")
private Date createdAt;
- @Schema(description = "更新者")
+ @Schema(description = "Updated by")
private Long updater;
- @Schema(description = "更新时间")
+ @Schema(description = "Updated at")
private Date updatedAt;
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentPluginMapping.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentPluginMapping.java
index ae99b0ebf..9514699f6 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentPluginMapping.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentPluginMapping.java
@@ -11,42 +11,42 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
- * Agent与插件的唯一映射表
+ * Unique mapping table between Agent and plugins
*
* @TableName ai_agent_plugin_mapping
*/
@Data
@TableName(value = "ai_agent_plugin_mapping")
-@Schema(description = "Agent与插件的唯一映射表")
+@Schema(description = "Unique mapping table between Agent and plugins")
public class AgentPluginMapping implements Serializable {
/**
- * 主键
+ * Primary key
*/
@TableId(type = IdType.ASSIGN_ID)
- @Schema(description = "映射信息主键ID")
+ @Schema(description = "Mapping information primary key ID")
private Long id;
/**
- * 智能体ID
+ * Agent ID
*/
- @Schema(description = "智能体ID")
+ @Schema(description = "Agent ID")
private String agentId;
/**
- * 插件ID
+ * Plugin ID
*/
- @Schema(description = "插件ID")
+ @Schema(description = "Plugin ID")
private String pluginId;
/**
- * 插件参数(Json)格式
+ * Plugin parameters (JSON format)
*/
- @Schema(description = "插件参数(Json)格式")
+ @Schema(description = "Plugin parameters (JSON format)")
private String paramInfo;
- // 冗余字段,用于方便在根据id查询插件时,对照查出插件的Provider_code,详见dao层xml文件
+ // Redundant field for convenience when querying plugins by id, to find the plugin's Provider_code, see dao layer xml file
@TableField(exist = false)
- @Schema(description = "插件provider_code, 对应表ai_model_provider")
+ @Schema(description = "Plugin provider_code, corresponds to table ai_model_provider")
private String providerCode;
@TableField(exist = false)
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTagEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTagEntity.java
index 82555c3eb..68c1b48ba 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTagEntity.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTagEntity.java
@@ -11,31 +11,31 @@ import lombok.Data;
@Data
@TableName("ai_agent_tag")
-@Schema(description = "智能体标签")
+@Schema(description = "Agent tag")
public class AgentTagEntity {
@TableId(type = IdType.ASSIGN_UUID)
- @Schema(description = "主键")
+ @Schema(description = "Primary key")
private String id;
- @Schema(description = "标签名称")
+ @Schema(description = "Tag name")
private String tagName;
- @Schema(description = "排序")
+ @Schema(description = "Sort order")
private Integer sort;
- @Schema(description = "创建者")
+ @Schema(description = "Created by")
private Long creator;
- @Schema(description = "创建时间")
+ @Schema(description = "Created at")
private Date createdAt;
- @Schema(description = "更新者")
+ @Schema(description = "Updated by")
private Long updater;
- @Schema(description = "更新时间")
+ @Schema(description = "Updated at")
private Date updatedAt;
- @Schema(description = "删除标记")
+ @Schema(description = "Deleted flag")
private Integer deleted;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTagRelationEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTagRelationEntity.java
index cc345d71e..4fe05e3b7 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTagRelationEntity.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTagRelationEntity.java
@@ -11,31 +11,31 @@ import lombok.Data;
@Data
@TableName("ai_agent_tag_relation")
-@Schema(description = "智能体标签关联")
+@Schema(description = "Agent tag relation")
public class AgentTagRelationEntity {
@TableId(type = IdType.ASSIGN_UUID)
- @Schema(description = "主键")
+ @Schema(description = "Primary key")
private String id;
- @Schema(description = "智能体ID")
+ @Schema(description = "Agent ID")
private String agentId;
- @Schema(description = "标签ID")
+ @Schema(description = "Tag ID")
private String tagId;
- @Schema(description = "排序")
+ @Schema(description = "Sort order")
private Integer sort;
- @Schema(description = "创建者")
+ @Schema(description = "Created by")
private Long creator;
- @Schema(description = "创建时间")
+ @Schema(description = "Created at")
private Date createdAt;
- @Schema(description = "更新者")
+ @Schema(description = "Updated by")
private Long updater;
- @Schema(description = "更新时间")
+ @Schema(description = "Updated at")
private Date updatedAt;
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTemplateEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTemplateEntity.java
index b06cda917..045ded778 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTemplateEntity.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTemplateEntity.java
@@ -12,138 +12,138 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
- * 智能体配置模板表
- *
+ * Agent configuration template table.
+ *
* @TableName ai_agent_template
*/
@TableName(value = "ai_agent_template")
@Data
public class AgentTemplateEntity implements Serializable {
/**
- * 智能体唯一标识
+ * Unique agent ID.
*/
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
- * 智能体编码
+ * Agent code.
*/
private String agentCode;
/**
- * 智能体名称
+ * Agent name.
*/
private String agentName;
/**
- * 语音识别模型标识
+ * ASR model ID.
*/
private String asrModelId;
/**
- * 语音活动检测标识
+ * VAD model ID.
*/
private String vadModelId;
/**
- * 大语言模型标识
+ * LLM model ID.
*/
private String llmModelId;
/**
- * VLLM模型标识
+ * VLLM model ID.
*/
private String vllmModelId;
/**
- * 语音合成模型标识
+ * TTS model ID.
*/
private String ttsModelId;
/**
- * 音色标识
+ * Voice ID.
*/
private String ttsVoiceId;
/**
- * 音色语言
+ * Voice language.
*/
private String ttsLanguage;
/**
- * TTS音量
+ * TTS volume.
*/
private Integer ttsVolume;
/**
- * TTS语速
+ * TTS speed.
*/
private Integer ttsRate;
/**
- * TTS音调
+ * TTS pitch.
*/
private Integer ttsPitch;
/**
- * 记忆模型标识
+ * Memory model ID.
*/
private String memModelId;
/**
- * 意图模型标识
+ * Intent model ID.
*/
private String intentModelId;
/**
- * 聊天记录配置(0不记录 1仅记录文本 2记录文本和语音)
+ * Chat-history mode (0 disabled, 1 text only, 2 text and audio).
*/
private Integer chatHistoryConf;
/**
- * 角色设定参数
+ * System prompt.
*/
private String systemPrompt;
/**
- * 总结记忆
+ * Summary memory.
*/
private String summaryMemory;
/**
- * 语言编码
+ * Language code.
*/
private String langCode;
/**
- * 交互语种
+ * Interaction language.
*/
private String language;
/**
- * 排序权重
+ * Sort weight.
*/
private Integer sort;
/**
- * 创建者 ID
+ * Creator ID.
*/
private Long creator;
/**
- * 创建时间
+ * Created at.
*/
private Date createdAt;
/**
- * 更新者 ID
+ * Updated by.
*/
private Long updater;
/**
- * 更新时间
+ * Updated at.
*/
private Date updatedAt;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentVoicePrintEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentVoicePrintEntity.java
index 4998b2888..bc917df37 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentVoicePrintEntity.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentVoicePrintEntity.java
@@ -11,7 +11,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
- * 智能体声纹表
+ * Agent voiceprint table
*
* @author zjy
*/
@@ -19,45 +19,45 @@ import lombok.Data;
@Data
public class AgentVoicePrintEntity {
/**
- * 主键id
+ * Primary key id
*/
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
- * 关联的智能体id
+ * Associated agent id
*/
private String agentId;
/**
- * 关联的音频id
+ * Associated audio id
*/
private String audioId;
/**
- * 声纹来源的人姓名
+ * Name of the person whose voiceprint this is from
*/
private String sourceName;
/**
- * 描述声纹来源的人
+ * Description of the person whose voiceprint this is from
*/
private String introduce;
/**
- * 创建者
+ * Creator
*/
@TableField(fill = FieldFill.INSERT)
private Long creator;
/**
- * 创建时间
+ * Creation time
*/
@TableField(fill = FieldFill.INSERT)
private Date createDate;
/**
- * 更新者
+ * Updater
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
/**
- * 更新时间
+ * Update time
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatAudioService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatAudioService.java
index 04be9f360..805c13ba1 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatAudioService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatAudioService.java
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import xiaozhi.modules.agent.entity.AgentChatAudioEntity;
/**
- * 智能体聊天音频数据表处理service
+ * Agent chat audio data table processing service
*
* @author Goody
* @version 1.0, 2025/5/8
@@ -13,18 +13,18 @@ import xiaozhi.modules.agent.entity.AgentChatAudioEntity;
*/
public interface AgentChatAudioService extends IService {
/**
- * 保存音频数据
+ * Save audio data
*
- * @param audioData 音频数据
- * @return 音频ID
+ * @param audioData Audio data
+ * @return Audio ID
*/
String saveAudio(byte[] audioData);
/**
- * 获取音频数据
+ * Get audio data
*
- * @param audioId 音频ID
- * @return 音频数据
+ * @param audioId Audio ID
+ * @return Audio data
*/
byte[] getAudio(String audioId);
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatHistoryService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatHistoryService.java
index 459b5a5a1..9b1d01924 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatHistoryService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatHistoryService.java
@@ -12,7 +12,7 @@ import xiaozhi.modules.agent.entity.AgentChatHistoryEntity;
import xiaozhi.modules.agent.vo.AgentChatHistoryUserVO;
/**
- * 智能体聊天记录表处理service
+ * Agent chat history table processing service
*
* @author Goody
* @version 1.0, 2025/4/30
@@ -21,54 +21,62 @@ import xiaozhi.modules.agent.vo.AgentChatHistoryUserVO;
public interface AgentChatHistoryService extends IService {
/**
- * 根据智能体ID获取会话列表
+ * Get session list by agent ID
*
- * @param params 查询参数,包含agentId、page、limit
- * @return 分页的会话列表
+ * @param params Query parameters, including agentId, page, limit
+ * @return Paginated session list
*/
PageData getSessionListByAgentId(Map params);
/**
- * 根据会话ID获取聊天记录列表
+ * Get chat record list by session ID
*
- * @param agentId 智能体ID
- * @param sessionId 会话ID
- * @return 聊天记录列表
+ * @param agentId Agent ID
+ * @param sessionId Session ID
+ * @return Chat record list
*/
List getChatHistoryBySessionId(String agentId, String sessionId);
/**
- * 根据智能体ID删除聊天记录
+ * Delete chat records by agent ID
*
- * @param agentId 智能体ID
- * @param deleteAudio 是否删除音频
- * @param deleteText 是否删除文本
+ * @param agentId Agent ID
+ * @param deleteAudio Whether to delete audio
+ * @param deleteText Whether to delete text
*/
void deleteByAgentId(String agentId, Boolean deleteAudio, Boolean deleteText);
/**
- * 根据智能体ID获取最近50条用户的聊天记录数据(带音频数据)
+ * Delete chat session by agent ID and session ID
*
- * @param agentId 智能体id
- * @return 聊天记录列表(只有用户)
+ * @param agentId Agent ID
+ * @param sessionId Session ID
+ */
+ void deleteBySessionId(String agentId, String sessionId);
+
+ /**
+ * Get recent 50 user chat records by agent ID (with audio data)
+ *
+ * @param agentId Agent ID
+ * @return Chat record list (user only)
*/
List getRecentlyFiftyByAgentId(String agentId);
/**
- * 根据音频数据ID获取聊天内容
+ * Get chat content by audio data ID
*
- * @param audioId 音频id
- * @return 聊天内容
+ * @param audioId Audio ID
+ * @return Chat content
*/
String getContentByAudioId(String audioId);
/**
- * 查询此音频id是否属于此智能体
+ * Check if this audio ID belongs to this agent
*
- * @param audioId 音频id
- * @param agentId 音频id
- * @return T:属于 F:不属于
+ * @param audioId Audio ID
+ * @param agentId Agent ID
+ * @return T: belongs F: does not belong
*/
boolean isAudioOwnedByAgent(String audioId,String agentId);
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatSummaryService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatSummaryService.java
index 336058490..82f45e18d 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatSummaryService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatSummaryService.java
@@ -1,15 +1,15 @@
package xiaozhi.modules.agent.service;
/**
- * 智能体聊天记录总结服务接口
+ * Agent chat-summary service interface.
*/
public interface AgentChatSummaryService {
/**
- * 根据会话ID生成聊天记录总结并保存到智能体记忆
- *
- * @param sessionId 会话ID
- * @return 保存结果
+ * Generate a chat summary by session ID and save it to agent memory.
+ *
+ * @param sessionId session ID
+ * @return save result
*/
boolean generateAndSaveChatSummary(String sessionId);
@@ -20,4 +20,4 @@ public interface AgentChatSummaryService {
* @return 是否成功
*/
boolean generateAndSaveChatTitle(String sessionId);
-}
\ No newline at end of file
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentContextProviderService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentContextProviderService.java
index da759971c..ff4b5cf8b 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentContextProviderService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentContextProviderService.java
@@ -5,21 +5,24 @@ import xiaozhi.modules.agent.entity.AgentContextProviderEntity;
public interface AgentContextProviderService extends BaseService {
/**
- * 根据智能体ID获取上下文源配置
- * @param agentId 智能体ID
- * @return 上下文源配置实体
+ * Get context-provider configuration by agent ID.
+ *
+ * @param agentId agent ID
+ * @return context-provider configuration entity
*/
AgentContextProviderEntity getByAgentId(String agentId);
/**
- * 保存或更新上下文源配置
- * @param entity 实体
+ * Save or update context-provider configuration.
+ *
+ * @param entity entity to persist
*/
void saveOrUpdateByAgentId(AgentContextProviderEntity entity);
/**
- * 根据智能体ID删除上下文源配置
- * @param agentId 智能体ID
+ * Delete context-provider configuration by agent ID.
+ *
+ * @param agentId agent ID
*/
void deleteByAgentId(String agentId);
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentMcpAccessPointService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentMcpAccessPointService.java
index 336ade653..0c232873b 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentMcpAccessPointService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentMcpAccessPointService.java
@@ -4,22 +4,22 @@ package xiaozhi.modules.agent.service;
import java.util.List;
/**
- * 智能体Mcp接入点处理service
+ * Agent MCP access point processing service
*
* @author zjy
*/
public interface AgentMcpAccessPointService {
/**
- * 获取智能体的mcp接入点地址
- * @param id 智能体id
- * @return mcp接入点地址
+ * Get agent MCP access point address
+ * @param id Agent id
+ * @return MCP access point address
*/
String getAgentMcpAccessAddress(String id);
/**
- * 获取智能体的mcp接入点已有的工具列表
- * @param id 智能体id
- * @return 工具列表
+ * Get the existing tool list for the agent's MCP access point
+ * @param id Agent id
+ * @return Tool list
*/
List getAgentMcpToolsList(String id);
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentPluginMappingService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentPluginMappingService.java
index 79d97d2ed..c0e993463 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentPluginMappingService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentPluginMappingService.java
@@ -7,13 +7,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
import xiaozhi.modules.agent.entity.AgentPluginMapping;
/**
- * @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Service
+ * @description Database operation Service for table [ai_agent_plugin_mapping(unique mapping table between Agent and plugins)]
* @createDate 2025-05-25 22:33:17
*/
public interface AgentPluginMappingService extends IService {
/**
- * 根据智能体id获取插件参数
+ * Get plugin parameters by agent id
*
* @param agentId
* @return
@@ -21,7 +21,7 @@ public interface AgentPluginMappingService extends IService
List agentPluginParamsByAgentId(String agentId);
/**
- * 根据智能体id删除插件参数
+ * Delete plugin parameters by agent id
*
* @param agentId
*/
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentService.java
index 22e8a2e07..c235c23a2 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentService.java
@@ -12,7 +12,7 @@ import xiaozhi.modules.agent.entity.AgentEntity;
import xiaozhi.modules.agent.vo.AgentInfoVO;
/**
- * 智能体表处理service
+ * Agent service interface.
*
* @author Goody
* @version 1.0, 2025/4/30
@@ -20,84 +20,84 @@ import xiaozhi.modules.agent.vo.AgentInfoVO;
*/
public interface AgentService extends BaseService {
/**
- * 获取管理员智能体列表
+ * Get the admin-facing agent list.
*
- * @param params 查询参数
- * @return 分页数据
+ * @param params query parameters
+ * @return paginated data
*/
PageData adminAgentList(Map params);
/**
- * 根据ID获取智能体
+ * Get an agent by ID.
*
- * @param id 智能体ID
- * @return 智能体实体
+ * @param id agent ID
+ * @return agent details
*/
AgentInfoVO getAgentById(String id);
/**
- * 插入智能体
+ * Insert an agent.
*
- * @param entity 智能体实体
- * @return 是否成功
+ * @param entity agent entity
+ * @return whether the operation succeeded
*/
boolean insert(AgentEntity entity);
/**
- * 根据用户ID删除智能体
+ * Delete agents by user ID.
*
- * @param userId 用户ID
+ * @param userId user ID
*/
void deleteAgentByUserId(Long userId);
/**
- * 获取用户智能体列表
+ * Get a user's agents.
*
- * @param userId 用户ID
- * @param keyword 搜索关键词
- * @param searchType 搜索类型(name - 按名称搜索,mac - 按MAC地址搜索)
- * @return 智能体列表
+ * @param userId user ID
+ * @param keyword search keyword
+ * @param searchType search type: `name` for agent name, `mac` for MAC address
+ * @return agent list
*/
List getUserAgents(Long userId, String keyword, String searchType);
/**
- * 根据智能体ID获取设备数量
+ * Get the number of devices linked to an agent.
*
- * @param agentId 智能体ID
- * @return 设备数量
+ * @param agentId agent ID
+ * @return device count
*/
Integer getDeviceCountByAgentId(String agentId);
/**
- * 根据设备MAC地址查询对应设备的默认智能体信息
+ * Get the default agent linked to a device MAC address.
*
- * @param macAddress 设备MAC地址
- * @return 默认智能体信息,不存在时返回null
+ * @param macAddress device MAC address
+ * @return default agent info, or {@code null} if none exists
*/
AgentEntity getDefaultAgentByMacAddress(String macAddress);
/**
- * 检查用户是否有权限访问智能体
+ * Check whether a user can access an agent.
*
- * @param agentId 智能体ID
- * @param userId 用户ID
- * @return 是否有权限
+ * @param agentId agent ID
+ * @param userId user ID
+ * @return whether access is allowed
*/
boolean checkAgentPermission(String agentId, Long userId);
/**
- * 更新智能体
+ * Update an agent.
*
- * @param agentId 智能体ID
- * @param dto 更新智能体所需的信息
+ * @param agentId agent ID
+ * @param dto updated agent data
*/
void updateAgentById(String agentId, AgentUpdateDTO dto);
/**
- * 创建智能体
+ * Create an agent.
*
- * @param dto 创建智能体所需的信息
- * @return 创建的智能体ID
+ * @param dto agent data needed for creation
+ * @return created agent ID
*/
String createAgent(AgentCreateDTO dto);
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentTemplateService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentTemplateService.java
index b10a67f99..092f02b89 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentTemplateService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentTemplateService.java
@@ -6,37 +6,37 @@ import xiaozhi.modules.agent.entity.AgentTemplateEntity;
/**
* @author chenerlei
- * @description 针对表【ai_agent_template(智能体配置模板表)】的数据库操作Service
+ * @description Database operation Service for table [ai_agent_template(agent configuration template table)]
* @createDate 2025-03-22 11:48:18
*/
public interface AgentTemplateService extends IService {
/**
- * 获取默认模板
+ * Get default template
*
- * @return 默认模板实体
+ * @return Default template entity
*/
AgentTemplateEntity getDefaultTemplate();
/**
- * 更新默认模板中的模型ID
+ * Update model ID in default template
*
- * @param modelType 模型类型
- * @param modelId 模型ID
+ * @param modelType Model type
+ * @param modelId Model ID
*/
void updateDefaultTemplateModelId(String modelType, String modelId);
/**
- * 删除模板后重新排序剩余模板
+ * Reorder remaining templates after deleting a template
*
- * @param deletedSort 被删除模板的排序值
+ * @param deletedSort Sort value of the deleted template
*/
void reorderTemplatesAfterDelete(Integer deletedSort);
/**
- * 获取下一个可用的排序序号(寻找最小的未使用序号)
+ * Get next available sort number (find smallest unused number)
*
- * @return 下一个可用的排序序号
+ * @return Next available sort number
*/
Integer getNextAvailableSort();
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentVoicePrintService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentVoicePrintService.java
index c9d38abd4..4f5328075 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentVoicePrintService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentVoicePrintService.java
@@ -7,43 +7,43 @@ import xiaozhi.modules.agent.dto.AgentVoicePrintUpdateDTO;
import xiaozhi.modules.agent.vo.AgentVoicePrintVO;
/**
- * 智能体声纹处理service
+ * Agent voiceprint processing service
*
* @author zjy
*/
public interface AgentVoicePrintService {
/**
- * 添加智能体新的声纹
+ * Add new voiceprint for agent
*
- * @param dto 保存智能体声纹的数据
- * @return T:成功 F:失败
+ * @param dto Data for saving agent voiceprint
+ * @return T: success F: failure
*/
boolean insert(AgentVoicePrintSaveDTO dto);
/**
- * 删除智能体的指的声纹
+ * Delete specified voiceprint of agent
*
- * @param userId 当前登录的用户id
- * @param voicePrintId 声纹id
- * @return 是否成功 T:成功 F:失败
+ * @param userId Current logged in user id
+ * @param voicePrintId Voiceprint id
+ * @return Whether successful T: success F: failure
*/
boolean delete(Long userId, String voicePrintId);
/**
- * 获取指定智能体的所有声纹数据
+ * Get all voiceprint data for specified agent
*
- * @param userId 当前登录的用户id
- * @param agentId 智能体id
- * @return 声纹数据集合
+ * @param userId Current logged in user ID
+ * @param agentId Agent ID
+ * @return Voiceprint data collection
*/
List list(Long userId, String agentId);
/**
- * 更新智能体的指的声纹数据
+ * Update specified voiceprint data for agent
*
- * @param userId 当前登录的用户id
- * @param dto 修改的声纹的数据
- * @return 是否成功 T:成功 F:失败
+ * @param userId Current logged in user ID
+ * @param dto Modified voiceprint data
+ * @return Whether successful T: success F: failure
*/
boolean update(Long userId, AgentVoicePrintUpdateDTO dto);
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/AgentChatHistoryBizService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/AgentChatHistoryBizService.java
index 191b231b4..d176602bc 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/AgentChatHistoryBizService.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/AgentChatHistoryBizService.java
@@ -3,7 +3,7 @@ package xiaozhi.modules.agent.service.biz;
import xiaozhi.modules.agent.dto.AgentChatHistoryReportDTO;
/**
- * 智能体聊天历史业务逻辑层
+ * Agent chat history business logic layer
*
* @author Goody
* @version 1.0, 2025/4/30
@@ -12,11 +12,11 @@ import xiaozhi.modules.agent.dto.AgentChatHistoryReportDTO;
public interface AgentChatHistoryBizService {
/**
- * 聊天上报方法
+ * Chat report method
*
- * @param agentChatHistoryReportDTO 包含聊天上报所需信息的输入对象
- * 例如:设备MAC地址、文件类型、内容等
- * @return 上传结果,true表示成功,false表示失败
+ * @param agentChatHistoryReportDTO Input object containing information required for chat report
+ * For example: device MAC address, file type, content, etc.
+ * @return Upload result, true means success, false means failure
*/
Boolean report(AgentChatHistoryReportDTO agentChatHistoryReportDTO);
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/impl/AgentChatHistoryBizServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/impl/AgentChatHistoryBizServiceImpl.java
index ac1b5d065..23cd9534e 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/impl/AgentChatHistoryBizServiceImpl.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/impl/AgentChatHistoryBizServiceImpl.java
@@ -42,10 +42,10 @@ public class AgentChatHistoryBizServiceImpl implements AgentChatHistoryBizServic
private final DeviceService deviceService;
/**
- * 处理聊天记录上报,包括文件上传和相关信息记录
+ * Process a chat-history report, including audio upload and related metadata persistence.
*
- * @param report 包含聊天上报所需信息的输入对象
- * @return 上传结果,true表示成功,false表示失败
+ * @param report chat-history report payload
+ * @return upload result, true for success and false for failure
*/
@Override
@Transactional(rollbackFor = Exception.class)
@@ -54,9 +54,10 @@ public class AgentChatHistoryBizServiceImpl implements AgentChatHistoryBizServic
Byte chatType = report.getChatType();
Long reportTimeMillis = null != report.getReportTime() ? report.getReportTime()
: System.currentTimeMillis();
- log.info("小智设备聊天上报请求: macAddress={}, type={} reportTime={}", macAddress, chatType, reportTimeMillis);
+ log.info("Device chat-history report received: macAddress={}, type={} reportTime={}", macAddress, chatType,
+ reportTimeMillis);
- // 根据设备MAC地址查询对应的默认智能体,判断是否需要上报
+ // Resolve the default agent linked to the device MAC address.
AgentEntity agentEntity = agentService.getDefaultAgentByMacAddress(macAddress);
if (agentEntity == null) {
return Boolean.FALSE;
@@ -72,22 +73,22 @@ public class AgentChatHistoryBizServiceImpl implements AgentChatHistoryBizServic
saveChatText(report, agentId, macAddress, audioId, reportTimeMillis);
}
- // 更新设备最后对话时间
+ // Update the last conversation timestamp for the agent/device pair.
redisUtils.set(RedisKeys.getAgentDeviceLastConnectedAtById(agentId), new Date());
- // 更新设备最后连接时间
+ // Update the device last-connection time.
DeviceEntity device = deviceService.getDeviceByMacAddress(macAddress);
if (device != null) {
deviceService.updateDeviceConnectionInfo(agentId, device.getId(), null);
} else {
- log.warn("聊天记录上报时,未找到mac地址为 {} 的设备", macAddress);
+ log.warn("No device was found for macAddress {} while processing chat-history reporting", macAddress);
}
return Boolean.TRUE;
}
/**
- * base64解码report.getOpusDataBase64(),存入ai_agent_chat_audio表
+ * Decode Base64 audio data and persist it in ai_agent_chat_audio.
*/
private String saveChatAudio(AgentChatHistoryReportDTO report) {
String audioId = null;
@@ -96,9 +97,9 @@ public class AgentChatHistoryBizServiceImpl implements AgentChatHistoryBizServic
try {
byte[] audioData = Base64.getDecoder().decode(report.getAudioBase64());
audioId = agentChatAudioService.saveAudio(audioData);
- log.info("音频数据保存成功,audioId={}", audioId);
+ log.info("Audio data saved successfully, audioId={}", audioId);
} catch (Exception e) {
- log.error("音频数据保存失败", e);
+ log.error("Failed to save audio data", e);
return null;
}
}
@@ -106,11 +107,11 @@ public class AgentChatHistoryBizServiceImpl implements AgentChatHistoryBizServic
}
/**
- * 组装上报数据
+ * Build and persist the reported chat record.
*/
private void saveChatText(AgentChatHistoryReportDTO report, String agentId, String macAddress, String audioId,
Long reportTime) {
- // 构建聊天记录实体
+ // Build the chat-history entity.
AgentChatHistoryEntity entity = AgentChatHistoryEntity.builder()
.macAddress(macAddress)
.agentId(agentId)
@@ -119,12 +120,12 @@ public class AgentChatHistoryBizServiceImpl implements AgentChatHistoryBizServic
.content(report.getContent())
.audioId(audioId)
.createdAt(new Date(reportTime))
- // NOTE(haotian): 2025/5/26 updateAt可以不设置,重点是createAt,而且这样可以看到上报延迟
+ // NOTE(haotian): createAt matters most here, and leaving updateAt unset makes reporting delay easier to see.
.build();
- // 保存数据
+ // Persist the chat-history record.
agentChatHistoryService.save(entity);
- log.info("设备 {} 对应智能体 {} 上报成功", macAddress, agentId);
+ log.info("Chat-history reporting succeeded for device {} and agent {}", macAddress, agentId);
}
}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatAudioServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatAudioServiceImpl.java
index efcae485b..457faab85 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatAudioServiceImpl.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatAudioServiceImpl.java
@@ -9,7 +9,7 @@ import xiaozhi.modules.agent.entity.AgentChatAudioEntity;
import xiaozhi.modules.agent.service.AgentChatAudioService;
/**
- * 智能体聊天音频数据表处理service {@link AgentChatAudioService} impl
+ * Agent chat audio data table processing service {@link AgentChatAudioService} impl
*
* @author Goody
* @version 1.0, 2025/5/8
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatHistoryServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatHistoryServiceImpl.java
index 9cfece89b..e839f4a99 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatHistoryServiceImpl.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatHistoryServiceImpl.java
@@ -31,7 +31,7 @@ import xiaozhi.modules.agent.service.AgentChatTitleService;
import xiaozhi.modules.agent.vo.AgentChatHistoryUserVO;
/**
- * 智能体聊天记录表处理service {@link AgentChatHistoryService} impl
+ * Chat-history service implementation for agents.
*
* @author Goody
* @version 1.0, 2025/4/30
@@ -50,14 +50,14 @@ public class AgentChatHistoryServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>();
wrapper.select("session_id", "MAX(created_at) as created_at", "COUNT(*) as chat_count")
.eq("agent_id", agentId)
.groupBy("session_id")
.orderByDesc("created_at");
- // 执行分页查询
+ // Run the paginated query.
Page