mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
同步上游
This commit is contained in:
parent
d190122f1b
commit
c24adb77f1
67 changed files with 1709 additions and 2143 deletions
|
|
@ -127,29 +127,14 @@ docker run -it --name xiaozhi-env --restart always --security-opt seccomp:unconf
|
|||
在刚刚的打开的终端运行
|
||||
|
||||
```sh
|
||||
poetry install --no-root
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
```sh
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends libopus0 ffmpeg
|
||||
```
|
||||
|
||||
速度慢可以尝试使用清华镜像
|
||||
|
||||
```sh
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends libopus0 ffmpeg
|
||||
```
|
||||
|
||||
## 6.运行项目
|
||||
|
||||
```sh
|
||||
poetry run python app.py
|
||||
python app.py
|
||||
```
|
||||
|
||||
# 方式三:本地源码运行
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# 项目目录介绍
|
||||
当你看到这份文件的时候,这个这个项目还没完善好。我们还有很多东西要做。
|
||||
|
||||
如果你会开发,我们非常欢迎您的加入。
|
||||
如果你是一名软件开发者,这里有一份[《致开发者的公开信》](../docs/contributor_open_letter.md),欢迎归队!
|
||||
|
||||
```
|
||||
xiaozhi-esp32-server
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ public class AdminApplication {
|
|||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
System.out.println("http://localhost:8002/xiaozhi-esp32-api/doc.html");
|
||||
System.out.println("http://localhost:8002/xiaozhi-esp32-api/api/v1/doc.html");
|
||||
}
|
||||
}
|
||||
|
|
@ -22,24 +22,25 @@ public interface ErrorCode {
|
|||
int CAPTCHA_ERROR = 10007;
|
||||
int SUB_MENU_EXIST = 10008;
|
||||
int PASSWORD_ERROR = 10009;
|
||||
|
||||
int SUPERIOR_DEPT_ERROR = 10011;
|
||||
int SUPERIOR_MENU_ERROR = 10012;
|
||||
int DATA_SCOPE_PARAMS_ERROR = 10013;
|
||||
int DEPT_SUB_DELETE_ERROR = 10014;
|
||||
int DEPT_USER_DELETE_ERROR = 10015;
|
||||
|
||||
int UPLOAD_FILE_EMPTY = 10019;
|
||||
int TOKEN_NOT_EMPTY = 10020;
|
||||
int TOKEN_INVALID = 10021;
|
||||
int ACCOUNT_LOCK = 10022;
|
||||
|
||||
int OSS_UPLOAD_FILE_ERROR = 10024;
|
||||
|
||||
int REDIS_ERROR = 10027;
|
||||
int JOB_ERROR = 10028;
|
||||
int INVALID_SYMBOL = 10029;
|
||||
|
||||
|
||||
int PASSWORD_LENGTH_ERROR = 10030;
|
||||
int PASSWORD_WEAK_ERROR = 10031;
|
||||
int DEL_MYSELF_ERROR = 10032;
|
||||
// 验证码错误
|
||||
int VERIFICATION_CODE = 10033;
|
||||
int DEVICE_CAPTCHA_ERROR = 10033;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,60 +21,9 @@ public class RedisKeys {
|
|||
}
|
||||
|
||||
/**
|
||||
* 登录用户Key
|
||||
* 未注册设备验证码Key
|
||||
*/
|
||||
public static String getSecurityUserKey(Long id) {
|
||||
return "sys:security:user:" + id;
|
||||
public static String getDeviceCaptchaKey(String captcha) {
|
||||
return "sys:device:captcha:" + captcha;
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统日志Key
|
||||
*/
|
||||
public static String getSysLogKey() {
|
||||
return "sys:log";
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统资源Key
|
||||
*/
|
||||
public static String getSysResourceKey() {
|
||||
return "sys:resource";
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户菜单导航Key
|
||||
*/
|
||||
public static String getUserMenuNavKey(Long userId) {
|
||||
return "sys:user:nav:" + userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户权限标识Key
|
||||
*/
|
||||
public static String getUserPermissionsKey(Long userId) {
|
||||
return "sys:user:permissions:" + userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登陆错误次数
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public static String getUserLoginErrorCountKey(String username) {
|
||||
return "sys:user:login:error:" + username;
|
||||
}
|
||||
|
||||
public static String getUserInfoKey(Long userId) {
|
||||
return "sys:user:" + userId;
|
||||
}
|
||||
|
||||
public static String getDataScopeListKey(Long userId) {
|
||||
return "sys:user:data:scope:" + userId;
|
||||
}
|
||||
|
||||
public static String getSysUserName(Long id) {
|
||||
return "sys:user:name" + id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
package xiaozhi.modules.device.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xiaozhi.common.constant.Constant;
|
||||
import xiaozhi.common.exception.ErrorCode;
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.redis.RedisKeys;
|
||||
import xiaozhi.common.redis.RedisUtils;
|
||||
import xiaozhi.common.user.UserDetail;
|
||||
import xiaozhi.common.utils.JsonUtils;
|
||||
import xiaozhi.common.utils.Result;
|
||||
import xiaozhi.modules.device.dto.DeviceHeaderDTO;
|
||||
import xiaozhi.modules.device.dto.DeviceUnBindDTO;
|
||||
import xiaozhi.modules.device.entity.DeviceEntity;
|
||||
import xiaozhi.modules.device.service.DeviceService;
|
||||
import xiaozhi.modules.security.user.SecurityUser;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/device")
|
||||
@Tag(name = "设备管理")
|
||||
|
||||
public class DeviceController {
|
||||
private final DeviceService deviceService;
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
|
||||
@PostMapping("/bind/{deviceCode}")
|
||||
@Operation(summary = "绑定设备")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<DeviceEntity> bindDevice(@PathVariable String deviceCode) {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
|
||||
String deviceHeaders = (String) redisUtils.get(RedisKeys.getDeviceCaptchaKey(deviceCode));
|
||||
if (StringUtils.isBlank(deviceHeaders)) {
|
||||
return new Result<DeviceEntity>().error(ErrorCode.DEVICE_CAPTCHA_ERROR);
|
||||
}
|
||||
DeviceHeaderDTO deviceHeader = JsonUtils.parseObject(deviceHeaders.getBytes(), DeviceHeaderDTO.class);
|
||||
DeviceEntity device = deviceService.bindDevice(user.getId(), deviceHeader);
|
||||
return new Result<DeviceEntity>().ok(device);
|
||||
}
|
||||
|
||||
@GetMapping("/bind")
|
||||
@Operation(summary = "获取已绑定设备")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<List<DeviceEntity>> getUserDevices() {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<DeviceEntity> devices = deviceService.getUserDevices(user.getId());
|
||||
return new Result<List<DeviceEntity>>().ok(devices);
|
||||
}
|
||||
|
||||
@PostMapping("/unbind")
|
||||
@Operation(summary = "解绑设备")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result unbindDevice(@RequestBody DeviceUnBindDTO unDeviveBind) {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
deviceService.unbindDevice(user.getId(), unDeviveBind.getDeviceId());
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@GetMapping("/all")
|
||||
@Operation(summary = "设备列表(管理员)")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true),
|
||||
})
|
||||
public Result<PageData<DeviceEntity>> adminDeviceList(
|
||||
@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<DeviceEntity> page = deviceService.adminDeviceList(params);
|
||||
return new Result<PageData<DeviceEntity>>().ok(page);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package xiaozhi.modules.device.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import xiaozhi.modules.device.entity.DeviceEntity;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceDao extends BaseMapper<DeviceEntity> {
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package xiaozhi.modules.device.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(description = "设备连接头信息")
|
||||
public class DeviceHeaderDTO {
|
||||
|
||||
@Schema(description = "设备ID")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "协议版本号")
|
||||
private Long protocolVersion;
|
||||
|
||||
@Schema(description = "认证信息")
|
||||
private String authorization;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package xiaozhi.modules.device.dto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 设备解绑表单
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "设备解绑表单")
|
||||
public class DeviceUnBindDTO implements Serializable {
|
||||
|
||||
@Schema(description = "设备ID")
|
||||
@NotBlank(message = "设备ID不能为空")
|
||||
private Long deviceId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package xiaozhi.modules.device.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("ai_device")
|
||||
@Schema(description = "设备信息")
|
||||
public class DeviceEntity {
|
||||
@Schema(description = "设备ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "MAC地址")
|
||||
private String macAddress;
|
||||
|
||||
@Schema(description = "最后连接时间")
|
||||
private Date lastConnectedAt;
|
||||
|
||||
@Schema(description = "自动更新开关(0关闭/1开启)")
|
||||
private Integer autoUpdate;
|
||||
|
||||
@Schema(description = "设备硬件型号")
|
||||
private String board;
|
||||
|
||||
@Schema(description = "设备别名")
|
||||
private String alias;
|
||||
|
||||
@Schema(description = "智能体ID")
|
||||
private String agentId;
|
||||
|
||||
@Schema(description = "固件版本号")
|
||||
private String appVersion;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
private Long creator;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createDate;
|
||||
|
||||
@Schema(description = "更新者")
|
||||
private Long updater;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private Date updateDate;
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package xiaozhi.modules.device.service;
|
||||
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.modules.device.dto.DeviceHeaderDTO;
|
||||
import xiaozhi.modules.device.entity.DeviceEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DeviceService {
|
||||
DeviceEntity bindDevice(Long userId, DeviceHeaderDTO deviceHeader);
|
||||
|
||||
List<DeviceEntity> getUserDevices(Long userId);
|
||||
|
||||
void unbindDevice(Long userId, Long deviceId);
|
||||
|
||||
PageData<DeviceEntity> adminDeviceList(Map<String, Object> params);
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package xiaozhi.modules.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.stereotype.Service;
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.service.impl.BaseServiceImpl;
|
||||
import xiaozhi.modules.device.dao.DeviceDao;
|
||||
import xiaozhi.modules.device.dto.DeviceHeaderDTO;
|
||||
import xiaozhi.modules.device.entity.DeviceEntity;
|
||||
import xiaozhi.modules.device.service.DeviceService;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity> implements DeviceService {
|
||||
private final DeviceDao deviceDao;
|
||||
|
||||
// 添加构造函数来初始化 deviceMapper
|
||||
public DeviceServiceImpl(DeviceDao deviceDao) {
|
||||
this.deviceDao = deviceDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceEntity bindDevice(Long userId, DeviceHeaderDTO deviceHeader) {
|
||||
DeviceEntity device = new DeviceEntity();
|
||||
device.setUserId(userId);
|
||||
device.setMacAddress(deviceHeader.getDeviceId());
|
||||
device.setCreateDate(new Date());
|
||||
deviceDao.insert(device);
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceEntity> getUserDevices(Long userId) {
|
||||
QueryWrapper<DeviceEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("user_id", userId);
|
||||
return deviceDao.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unbindDevice(Long userId, Long deviceId) {
|
||||
deviceDao.deleteById(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageData<DeviceEntity> adminDeviceList(Map<String, Object> params) {
|
||||
IPage<DeviceEntity> page = deviceDao.selectPage(
|
||||
getPage(params, "sort", true),
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
return new PageData<>(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -61,14 +61,10 @@ public class ShiroConfig {
|
|||
Map<String, String> filterMap = new LinkedHashMap<>();
|
||||
filterMap.put("/webjars/**", "anon");
|
||||
filterMap.put("/druid/**", "anon");
|
||||
filterMap.put("/login", "anon");
|
||||
filterMap.put("/publicKey", "anon");
|
||||
filterMap.put("/v3/api-docs/**", "anon");
|
||||
filterMap.put("/doc.html", "anon");
|
||||
filterMap.put("/sys/oss/download/**", "anon");
|
||||
filterMap.put("/captcha", "anon");
|
||||
filterMap.put("/favicon.ico", "anon");
|
||||
filterMap.put("/mobile/**", "anon");
|
||||
filterMap.put("/user/**", "anon");
|
||||
filterMap.put("/**", "oauth2");
|
||||
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,41 +2,37 @@ package xiaozhi.modules.security.controller;
|
|||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xiaozhi.common.exception.ErrorCode;
|
||||
import xiaozhi.common.redis.RedisUtils;
|
||||
import xiaozhi.common.utils.PropertiesUtils;
|
||||
import xiaozhi.common.exception.RenException;
|
||||
import xiaozhi.common.utils.Result;
|
||||
import xiaozhi.common.validator.AssertUtils;
|
||||
import xiaozhi.modules.security.dto.LoginDTO;
|
||||
import xiaozhi.modules.security.password.PasswordUtils;
|
||||
import xiaozhi.modules.security.service.CaptchaService;
|
||||
import xiaozhi.modules.security.service.SysUserTokenService;
|
||||
import xiaozhi.modules.sys.service.SysParamsService;
|
||||
import xiaozhi.modules.sys.dto.SysUserDTO;
|
||||
import xiaozhi.modules.sys.service.SysUserService;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* 登录控制层
|
||||
*/
|
||||
@Tag(name = "登录管理")
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@Tag(name = "登录管理")
|
||||
public class LoginController {
|
||||
private final SysUserService sysUserService;
|
||||
private final SysUserTokenService sysUserTokenService;
|
||||
private final CaptchaService captchaService;
|
||||
private final RedisUtils redisUtils;
|
||||
private final SysParamsService sysParamsService;
|
||||
private final PropertiesUtils propertiesUtils;
|
||||
|
||||
@GetMapping("captcha")
|
||||
|
||||
@GetMapping("/captcha")
|
||||
@Operation(summary = "验证码")
|
||||
public void captcha(HttpServletResponse response, String uuid) throws IOException {
|
||||
//uuid不能为空
|
||||
|
|
@ -46,10 +42,46 @@ public class LoginController {
|
|||
captchaService.create(response, uuid);
|
||||
}
|
||||
|
||||
@PostMapping("login")
|
||||
@PostMapping("/login")
|
||||
@Operation(summary = "登录")
|
||||
public Result login(HttpServletRequest request, @RequestBody LoginDTO login) {
|
||||
return sysUserTokenService.createToken(1L);
|
||||
public Result login( @RequestBody LoginDTO login) {
|
||||
// 验证是否正确输入验证码
|
||||
boolean validate = captchaService.validate(login.getCaptchaId(), login.getCaptcha());
|
||||
if (!validate) {
|
||||
throw new RenException("验证码错误,请重新获取");
|
||||
}
|
||||
// 按照用户名获取用户
|
||||
SysUserDTO userDTO = sysUserService.getByUsername(login.getUsername());
|
||||
// 判断用户是否存在
|
||||
if (userDTO == null) {
|
||||
throw new RenException("请检测用户和密码是否输入错误");
|
||||
}
|
||||
// 判断密码是否正确,不一样则进入if
|
||||
if (!PasswordUtils.matches(login.getPassword(), userDTO.getPassword())) {
|
||||
throw new RenException("请检测用户和密码是否输入错误");
|
||||
}
|
||||
return sysUserTokenService.createToken(userDTO.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
@Operation(summary = "注册")
|
||||
public Result<Void> register(@RequestBody LoginDTO login) {
|
||||
// 验证是否正确输入验证码
|
||||
boolean validate = captchaService.validate(login.getCaptchaId(), login.getCaptcha());
|
||||
if (!validate) {
|
||||
throw new RenException("验证码错误,请重新获取");
|
||||
}
|
||||
// 按照用户名获取用户
|
||||
SysUserDTO userDTO = sysUserService.getByUsername(login.getUsername());
|
||||
if (userDTO != null){
|
||||
throw new RenException("此手机号码已经注册过");
|
||||
}
|
||||
userDTO = new SysUserDTO();
|
||||
userDTO.setUsername(login.getUsername());
|
||||
userDTO.setPassword(login.getPassword());
|
||||
sysUserService.save(userDTO);
|
||||
return new Result<Void>();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import java.io.Serializable;
|
|||
@Schema(description = "登录表单")
|
||||
public class LoginDTO implements Serializable {
|
||||
|
||||
@Schema(description = "用户名", required = true)
|
||||
@Schema(description = "手机号码")
|
||||
@NotBlank(message = "{sysuser.username.require}")
|
||||
private String username;
|
||||
|
||||
|
|
@ -27,6 +27,6 @@ public class LoginDTO implements Serializable {
|
|||
|
||||
@Schema(description = "唯一标识")
|
||||
@NotBlank(message = "{sysuser.uuid.require}")
|
||||
private String uuid;
|
||||
private String captchaId;
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,5 @@
|
|||
package xiaozhi.modules.security.oauth2;
|
||||
|
||||
import xiaozhi.common.exception.ErrorCode;
|
||||
import xiaozhi.common.user.UserDetail;
|
||||
import xiaozhi.common.utils.ConvertUtils;
|
||||
import xiaozhi.common.utils.MessageUtils;
|
||||
import xiaozhi.modules.security.entity.SysUserTokenEntity;
|
||||
import xiaozhi.modules.security.service.ShiroService;
|
||||
import xiaozhi.modules.sys.entity.SysUserEntity;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.shiro.authc.*;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
|
|
@ -15,8 +8,15 @@ import org.apache.shiro.realm.AuthorizingRealm;
|
|||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import xiaozhi.common.exception.ErrorCode;
|
||||
import xiaozhi.common.user.UserDetail;
|
||||
import xiaozhi.common.utils.ConvertUtils;
|
||||
import xiaozhi.common.utils.MessageUtils;
|
||||
import xiaozhi.modules.security.entity.SysUserTokenEntity;
|
||||
import xiaozhi.modules.security.service.ShiroService;
|
||||
import xiaozhi.modules.sys.entity.SysUserEntity;
|
||||
import xiaozhi.modules.sys.enums.SuperAdminEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
|
@ -45,6 +45,13 @@ public class Oauth2Realm extends AuthorizingRealm {
|
|||
//用户权限列表
|
||||
Set<String> permsSet = shiroService.getUserPermissions(user);
|
||||
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) {
|
||||
permsSet.add("sys:role:superAdmin");
|
||||
permsSet.add("sys:role:normal");
|
||||
} else {
|
||||
permsSet.add("sys:role:normal");
|
||||
}
|
||||
|
||||
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
|
||||
info.setStringPermissions(permsSet);
|
||||
return info;
|
||||
|
|
|
|||
|
|
@ -1,34 +1,9 @@
|
|||
package xiaozhi.modules.sys.controller;
|
||||
|
||||
import xiaozhi.common.annotation.LogOperation;
|
||||
import xiaozhi.common.constant.Constant;
|
||||
import xiaozhi.common.exception.ErrorCode;
|
||||
import xiaozhi.common.exception.RenException;
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.user.UserDetail;
|
||||
import xiaozhi.common.utils.ConvertUtils;
|
||||
import xiaozhi.common.utils.Result;
|
||||
import xiaozhi.common.validator.AssertUtils;
|
||||
import xiaozhi.common.validator.ValidatorUtils;
|
||||
import xiaozhi.common.validator.group.AddGroup;
|
||||
import xiaozhi.common.validator.group.DefaultGroup;
|
||||
import xiaozhi.common.validator.group.UpdateGroup;
|
||||
import xiaozhi.modules.security.password.PasswordUtils;
|
||||
import xiaozhi.modules.security.user.SecurityUser;
|
||||
import xiaozhi.modules.sys.dto.PasswordDTO;
|
||||
import xiaozhi.modules.sys.dto.SysUserDTO;
|
||||
import xiaozhi.modules.sys.service.SysUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 用户管理
|
||||
|
|
@ -38,119 +13,5 @@ import java.util.Map;
|
|||
@RequestMapping("/sys/user")
|
||||
@Tag(name = "用户管理")
|
||||
public class SysUserController {
|
||||
private final SysUserService sysUserService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"),
|
||||
@Parameter(name = "username", description = "用户名"),
|
||||
@Parameter(name = "gender", description = "性别"),
|
||||
@Parameter(name = "deptId", description = "部门ID")
|
||||
})
|
||||
@RequiresPermissions("sys:user:page")
|
||||
public Result<PageData<SysUserDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<SysUserDTO> page = sysUserService.page(params);
|
||||
|
||||
return new Result<PageData<SysUserDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("sys:user:info")
|
||||
public Result<SysUserDTO> get(@PathVariable("id") Long id) {
|
||||
SysUserDTO data = sysUserService.get(id);
|
||||
return new Result<SysUserDTO>().ok(data);
|
||||
}
|
||||
|
||||
@GetMapping("info")
|
||||
@Operation(summary = "登录用户信息")
|
||||
public Result<SysUserDTO> info() {
|
||||
SysUserDTO data = ConvertUtils.sourceToTarget(SecurityUser.getUser(), SysUserDTO.class);
|
||||
return new Result<SysUserDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PutMapping("password")
|
||||
@Operation(summary = "修改密码")
|
||||
@LogOperation("修改密码")
|
||||
public Result password(@RequestBody PasswordDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto);
|
||||
String newPassword = dto.getNewPassword();
|
||||
String password = dto.getPassword();
|
||||
|
||||
//密码的强度
|
||||
if (newPassword == null || newPassword.length() < 8) {
|
||||
return new Result().error(ErrorCode.PASSWORD_LENGTH_ERROR);
|
||||
}
|
||||
if (!sysUserService.isStrongPassword(newPassword)) {
|
||||
return new Result().error(ErrorCode.PASSWORD_WEAK_ERROR);
|
||||
}
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
//原密码不正确
|
||||
if (!PasswordUtils.matches(dto.getPassword(), user.getPassword())) {
|
||||
return new Result().error(ErrorCode.PASSWORD_ERROR);
|
||||
}
|
||||
|
||||
sysUserService.updatePassword(user.getId(), dto.getNewPassword());
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("sys:user:save")
|
||||
public Result save(@RequestBody SysUserDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
|
||||
sysUserService.save(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:user:update")
|
||||
public Result update(@RequestBody SysUserDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
sysUserService.update(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping("app")
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:user:update")
|
||||
public Result updateUserInfo(@RequestBody SysUserDTO dto) {
|
||||
sysUserService.updateUserInfo(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:user:delete")
|
||||
public Result delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
||||
List<Long> idList = Arrays.asList(ids);
|
||||
if (idList.contains(SecurityUser.getUserId())) {
|
||||
throw new RenException(ErrorCode.DEL_MYSELF_ERROR);
|
||||
}
|
||||
|
||||
sysUserService.deleteBatchIds(idList);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,8 @@
|
|||
package xiaozhi.modules.sys.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import xiaozhi.common.dao.BaseDao;
|
||||
import xiaozhi.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
|
|
@ -14,21 +10,4 @@ import java.util.Map;
|
|||
@Mapper
|
||||
public interface SysUserDao extends BaseDao<SysUserEntity> {
|
||||
|
||||
List<SysUserEntity> getList(Map<String, Object> params);
|
||||
|
||||
SysUserEntity getById(Long id);
|
||||
|
||||
SysUserEntity getByUsername(String username);
|
||||
|
||||
int updatePassword(@Param("id") Long id, @Param("newPassword") String newPassword);
|
||||
|
||||
/**
|
||||
* 根据部门ID,查询用户数
|
||||
*/
|
||||
int getCountByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据部门ID,查询用户ID列表
|
||||
*/
|
||||
List<Long> getUserIdListByDeptId(List<Long> deptIdList);
|
||||
}
|
||||
|
|
@ -24,30 +24,6 @@ public class SysUserEntity extends BaseEntity {
|
|||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String realName;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String headUrl;
|
||||
/**
|
||||
* 性别 0:男 1:女 2:保密
|
||||
*/
|
||||
private Integer gender;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 超级管理员 0:否 1:是
|
||||
*/
|
||||
|
|
@ -56,6 +32,11 @@ public class SysUserEntity extends BaseEntity {
|
|||
* 状态 0:停用 1:正常
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createDate;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,67 +1,19 @@
|
|||
package xiaozhi.modules.sys.service;
|
||||
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.service.BaseService;
|
||||
import xiaozhi.modules.sys.dto.SysUserDTO;
|
||||
import xiaozhi.modules.sys.entity.SysUserEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*/
|
||||
public interface SysUserService extends BaseService<SysUserEntity> {
|
||||
|
||||
PageData<SysUserDTO> page(Map<String, Object> params);
|
||||
|
||||
List<SysUserDTO> list(Map<String, Object> params);
|
||||
|
||||
SysUserDTO get(Long id);
|
||||
|
||||
SysUserDTO getByUsername(String username);
|
||||
|
||||
void save(SysUserDTO dto);
|
||||
|
||||
void update(SysUserDTO dto);
|
||||
|
||||
void updateUserInfo(SysUserDTO dto);
|
||||
|
||||
void delete(Long[] ids);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param id 用户ID
|
||||
* @param newPassword 新密码
|
||||
*/
|
||||
void updatePassword(Long id, String newPassword);
|
||||
|
||||
/**
|
||||
* 根据部门ID,查询用户数
|
||||
*/
|
||||
int getCountByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据部门ID,查询用户Id列表
|
||||
*/
|
||||
List<Long> getUserIdListByDeptId(List<Long> deptIdList);
|
||||
|
||||
/**
|
||||
* 删除用户缓存
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void deleteUserCache(Long userId);
|
||||
|
||||
/**
|
||||
* 验证密码强度
|
||||
*
|
||||
* @param newPassword
|
||||
* @return
|
||||
*/
|
||||
boolean isStrongPassword(String newPassword);
|
||||
|
||||
String getName(Long creator);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,22 @@
|
|||
package xiaozhi.modules.sys.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import xiaozhi.common.exception.ErrorCode;
|
||||
import xiaozhi.common.exception.RenException;
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.redis.RedisKeys;
|
||||
import xiaozhi.common.redis.RedisUtils;
|
||||
import xiaozhi.common.service.impl.BaseServiceImpl;
|
||||
import xiaozhi.common.user.UserDetail;
|
||||
import xiaozhi.common.utils.ConvertUtils;
|
||||
import xiaozhi.modules.security.password.PasswordUtils;
|
||||
import xiaozhi.modules.security.user.SecurityUser;
|
||||
import xiaozhi.modules.sys.dao.SysUserDao;
|
||||
import xiaozhi.modules.sys.dto.SysUserDTO;
|
||||
import xiaozhi.modules.sys.entity.SysUserEntity;
|
||||
import xiaozhi.modules.sys.enums.SuperAdminEnum;
|
||||
import xiaozhi.modules.sys.service.SysUserService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
|
@ -34,40 +27,17 @@ import java.util.regex.Pattern;
|
|||
@AllArgsConstructor
|
||||
@Service
|
||||
public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntity> implements SysUserService {
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
public PageData<SysUserDTO> page(Map<String, Object> params) {
|
||||
//转换成like
|
||||
paramsToLike(params, "username");
|
||||
|
||||
//分页
|
||||
IPage<SysUserEntity> page = getPage(params, "t1.create_date", false);
|
||||
|
||||
//查询
|
||||
List<SysUserEntity> list = baseDao.getList(params);
|
||||
|
||||
return getPageData(list, page.getTotal(), SysUserDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserDTO> list(Map<String, Object> params) {
|
||||
|
||||
List<SysUserEntity> entityList = baseDao.getList(params);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysUserDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserDTO get(Long id) {
|
||||
SysUserEntity entity = baseDao.getById(id);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entity, SysUserDTO.class);
|
||||
}
|
||||
private final SysUserDao sysUserDao;
|
||||
|
||||
@Override
|
||||
public SysUserDTO getByUsername(String username) {
|
||||
SysUserEntity entity = baseDao.getByUsername(username);
|
||||
QueryWrapper<SysUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("username", username);
|
||||
List<SysUserEntity> users = sysUserDao.selectList(queryWrapper);
|
||||
if (users == null || users.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
SysUserEntity entity = users.getFirst();
|
||||
return ConvertUtils.sourceToTarget(entity, SysUserDTO.class);
|
||||
}
|
||||
|
||||
|
|
@ -86,42 +56,15 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
entity.setPassword(password);
|
||||
|
||||
//保存用户
|
||||
entity.setSuperAdmin(SuperAdminEnum.NO.value());
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysUserDTO dto) {
|
||||
SysUserEntity entity = ConvertUtils.sourceToTarget(dto, SysUserEntity.class);
|
||||
|
||||
//密码加密
|
||||
if (StringUtils.isBlank(dto.getPassword())) {
|
||||
entity.setPassword(null);
|
||||
Long userCount = getUserCount();
|
||||
if (userCount == 0) {
|
||||
entity.setSuperAdmin(SuperAdminEnum.YES.value());
|
||||
} else {
|
||||
//密码强度
|
||||
if (!isStrongPassword(entity.getPassword())) {
|
||||
throw new RenException(ErrorCode.PASSWORD_WEAK_ERROR);
|
||||
}
|
||||
String password = PasswordUtils.encode(entity.getPassword());
|
||||
entity.setPassword(password);
|
||||
entity.setSuperAdmin(SuperAdminEnum.NO.value());
|
||||
}
|
||||
entity.setStatus(1);
|
||||
|
||||
//更新用户
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateUserInfo(SysUserDTO dto) {
|
||||
SysUserEntity entity = selectById(dto.getId());
|
||||
entity.setHeadUrl(dto.getHeadUrl());
|
||||
entity.setRealName(dto.getRealName());
|
||||
entity.setGender(dto.getGender());
|
||||
entity.setMobile(dto.getMobile());
|
||||
entity.setEmail(dto.getEmail());
|
||||
|
||||
updateById(entity);
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -131,51 +74,17 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePassword(Long id, String newPassword) {
|
||||
newPassword = PasswordUtils.encode(newPassword);
|
||||
|
||||
baseDao.updatePassword(id, newPassword);
|
||||
private Long getUserCount() {
|
||||
QueryWrapper<SysUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
return baseDao.selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCountByDeptId(Long deptId) {
|
||||
return baseDao.getCountByDeptId(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getUserIdListByDeptId(List<Long> deptIdList) {
|
||||
return baseDao.getUserIdListByDeptId(deptIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserCache(Long userId) {
|
||||
// 删除缓存
|
||||
redisUtils.delete(RedisKeys.getUserInfoKey(userId));
|
||||
redisUtils.delete(RedisKeys.getDataScopeListKey(userId));
|
||||
redisUtils.delete(RedisKeys.getSysUserName(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStrongPassword(String password) {
|
||||
private boolean isStrongPassword(String password) {
|
||||
// 弱密码的正则表达式
|
||||
String weakPasswordRegex = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).+$";
|
||||
Pattern pattern = Pattern.compile(weakPasswordRegex);
|
||||
Matcher matcher = pattern.matcher(password);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(Long id) {
|
||||
String name = (String) redisUtils.get(RedisKeys.getSysUserName(id));
|
||||
if (StringUtils.isBlank(name)) {
|
||||
SysUserEntity sysUserEntity = selectById(id);
|
||||
if (sysUserEntity != null) {
|
||||
redisUtils.set(RedisKeys.getSysUserName(id), sysUserEntity.getUsername());
|
||||
return sysUserEntity.getUsername();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ server:
|
|||
min-spare: 30
|
||||
port: 8002
|
||||
servlet:
|
||||
context-path: /xiaozhi-esp32-api
|
||||
context-path: /xiaozhi-esp32-api/api/v1
|
||||
session:
|
||||
cookie:
|
||||
http-only: true
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
DROP TABLE IF EXISTS sys_user;
|
||||
DROP TABLE IF EXISTS sys_params;
|
||||
DROP TABLE IF EXISTS sys_user_token;
|
||||
DROP TABLE IF EXISTS sys_dict_type;
|
||||
DROP TABLE IF EXISTS sys_dict_data;
|
||||
|
||||
-- 系统用户
|
||||
CREATE TABLE sys_user (
|
||||
id bigint NOT NULL COMMENT 'id',
|
||||
username varchar(50) NOT NULL COMMENT '用户名',
|
||||
password varchar(100) COMMENT '密码',
|
||||
super_admin tinyint unsigned COMMENT '超级管理员 0:否 1:是',
|
||||
status tinyint COMMENT '状态 0:停用 1:正常',
|
||||
create_date datetime COMMENT '创建时间',
|
||||
updater bigint COMMENT '更新者',
|
||||
creator bigint COMMENT '创建者',
|
||||
update_date datetime COMMENT '更新时间',
|
||||
primary key (id),
|
||||
unique key uk_username (username)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统用户';
|
||||
|
||||
-- 系统用户Token
|
||||
CREATE TABLE sys_user_token (
|
||||
id bigint NOT NULL COMMENT 'id',
|
||||
user_id bigint NOT NULL COMMENT '用户id',
|
||||
token varchar(100) NOT NULL COMMENT '用户token',
|
||||
expire_date datetime COMMENT '过期时间',
|
||||
update_date datetime COMMENT '更新时间',
|
||||
create_date datetime COMMENT '创建时间',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY user_id (user_id),
|
||||
UNIQUE KEY token (token)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统用户Token';
|
||||
|
||||
-- 参数管理
|
||||
create table sys_params
|
||||
(
|
||||
id bigint NOT NULL COMMENT 'id',
|
||||
param_code varchar(32) COMMENT '参数编码',
|
||||
param_value varchar(2000) COMMENT '参数值',
|
||||
param_type tinyint unsigned default 1 COMMENT '类型 0:系统参数 1:非系统参数',
|
||||
remark varchar(200) COMMENT '备注',
|
||||
creator bigint COMMENT '创建者',
|
||||
create_date datetime COMMENT '创建时间',
|
||||
updater bigint COMMENT '更新者',
|
||||
update_date datetime COMMENT '更新时间',
|
||||
primary key (id),
|
||||
unique key uk_param_code (param_code)
|
||||
)ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT='参数管理';
|
||||
|
||||
-- 字典类型
|
||||
create table sys_dict_type
|
||||
(
|
||||
id bigint NOT NULL COMMENT 'id',
|
||||
dict_type varchar(100) NOT NULL COMMENT '字典类型',
|
||||
dict_name varchar(255) NOT NULL COMMENT '字典名称',
|
||||
remark varchar(255) COMMENT '备注',
|
||||
sort int unsigned COMMENT '排序',
|
||||
creator bigint COMMENT '创建者',
|
||||
create_date datetime COMMENT '创建时间',
|
||||
updater bigint COMMENT '更新者',
|
||||
update_date datetime COMMENT '更新时间',
|
||||
primary key (id),
|
||||
UNIQUE KEY(dict_type)
|
||||
)ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT='字典类型';
|
||||
|
||||
-- 字典数据
|
||||
create table sys_dict_data
|
||||
(
|
||||
id bigint NOT NULL COMMENT 'id',
|
||||
dict_type_id bigint NOT NULL COMMENT '字典类型ID',
|
||||
dict_label varchar(255) NOT NULL COMMENT '字典标签',
|
||||
dict_value varchar(255) COMMENT '字典值',
|
||||
remark varchar(255) COMMENT '备注',
|
||||
sort int unsigned COMMENT '排序',
|
||||
creator bigint COMMENT '创建者',
|
||||
create_date datetime COMMENT '创建时间',
|
||||
updater bigint COMMENT '更新者',
|
||||
update_date datetime COMMENT '更新时间',
|
||||
primary key (id),
|
||||
unique key uk_dict_type_value (dict_type_id, dict_value),
|
||||
key idx_sort (sort)
|
||||
)ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT='字典数据';
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
-- 模型供应器表
|
||||
DROP TABLE IF EXISTS `ai_model_provider`;
|
||||
CREATE TABLE `ai_model_provider` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '主键',
|
||||
`model_type` VARCHAR(20) COMMENT '模型类型(Memory/ASR/VAD/LLM/TTS)',
|
||||
`provider_code` VARCHAR(50) COMMENT '供应器类型',
|
||||
`name` VARCHAR(50) COMMENT '供应器名称',
|
||||
`fields` JSON COMMENT '供应器字段列表(JSON格式)',
|
||||
`sort` INT UNSIGNED DEFAULT 0 COMMENT '排序',
|
||||
`creator` BIGINT COMMENT '创建者',
|
||||
`create_date` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者',
|
||||
`update_date` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_ai_model_provider_model_type` (`model_type`) COMMENT '创建模型类型的索引,用于快速查找特定类型下的所有供应器信息'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='模型配置表';
|
||||
|
||||
-- 模型配置表
|
||||
DROP TABLE IF EXISTS `ai_model_config`;
|
||||
CREATE TABLE `ai_model_config` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '主键',
|
||||
`model_type` VARCHAR(20) COMMENT '模型类型(Memory/ASR/VAD/LLM/TTS)',
|
||||
`model_code` VARCHAR(50) COMMENT '模型编码(如AliLLM、DoubaoTTS)',
|
||||
`model_name` VARCHAR(50) COMMENT '模型名称',
|
||||
`is_default` TINYINT(1) DEFAULT 0 COMMENT '是否默认配置(0否 1是)',
|
||||
`is_enabled` TINYINT(1) DEFAULT 0 COMMENT '是否启用',
|
||||
`config_json` JSON COMMENT '模型配置(JSON格式)',
|
||||
`doc_link` VARCHAR(200) COMMENT '官方文档链接',
|
||||
`remark` VARCHAR(255) COMMENT '备注',
|
||||
`sort` INT UNSIGNED DEFAULT 0 COMMENT '排序',
|
||||
`creator` BIGINT COMMENT '创建者',
|
||||
`create_date` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者',
|
||||
`update_date` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_ai_model_config_model_type` (`model_type`) COMMENT '创建模型类型的索引,用于快速查找特定类型下的所有配置信息'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='模型配置表';
|
||||
|
||||
-- TTS 音色表
|
||||
DROP TABLE IF EXISTS `ai_tts_voice`;
|
||||
CREATE TABLE `ai_tts_voice` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '主键',
|
||||
`tts_model_id` VARCHAR(32) COMMENT '对应 TTS 模型主键',
|
||||
`name` VARCHAR(20) COMMENT '音色名称',
|
||||
`tts_voice` VARCHAR(50) COMMENT '音色编码',
|
||||
`languages` VARCHAR(50) COMMENT '语言',
|
||||
`voice_demo` VARCHAR(500) DEFAULT NULL COMMENT '音色 Demo',
|
||||
`remark` VARCHAR(255) COMMENT '备注',
|
||||
`sort` INT UNSIGNED DEFAULT 0 COMMENT '排序',
|
||||
`creator` BIGINT COMMENT '创建者',
|
||||
`create_date` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者',
|
||||
`update_date` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_ai_tts_voice_tts_model_id` (`tts_model_id`) COMMENT '创建 TTS 模型主键的索引,用于快速查找对应模型的音色信息'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='TTS 音色表';
|
||||
|
||||
-- 智能体配置模板表
|
||||
DROP TABLE IF EXISTS `ai_agent_template`;
|
||||
CREATE TABLE `ai_agent_template` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '智能体唯一标识',
|
||||
`agent_code` VARCHAR(36) COMMENT '智能体编码',
|
||||
`agent_name` VARCHAR(64) COMMENT '智能体名称',
|
||||
`asr_model_id` VARCHAR(32) COMMENT '语音识别模型标识',
|
||||
`vad_model_id` VARCHAR(64) COMMENT '语音活动检测标识',
|
||||
`llm_model_id` VARCHAR(32) COMMENT '大语言模型标识',
|
||||
`tts_model_id` VARCHAR(32) COMMENT '语音合成模型标识',
|
||||
`tts_voice_id` VARCHAR(32) COMMENT '音色标识',
|
||||
`mem_model_id` VARCHAR(32) COMMENT '记忆模型标识',
|
||||
`intent_model_id` VARCHAR(32) COMMENT '意图模型标识',
|
||||
`system_prompt` TEXT COMMENT '角色设定参数',
|
||||
`lang_code` VARCHAR(10) COMMENT '语言编码',
|
||||
`language` VARCHAR(10) COMMENT '交互语种',
|
||||
`sort` INT UNSIGNED DEFAULT 0 COMMENT '排序权重',
|
||||
`creator` BIGINT COMMENT '创建者 ID',
|
||||
`created_at` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者 ID',
|
||||
`updated_at` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='智能体配置模板表';
|
||||
|
||||
-- 智能体配置表
|
||||
DROP TABLE IF EXISTS `ai_agent`;
|
||||
CREATE TABLE `ai_agent` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '智能体唯一标识',
|
||||
`user_id` BIGINT COMMENT '所属用户 ID',
|
||||
`agent_code` VARCHAR(36) COMMENT '智能体编码',
|
||||
`agent_name` VARCHAR(64) COMMENT '智能体名称',
|
||||
`asr_model_id` VARCHAR(32) COMMENT '语音识别模型标识',
|
||||
`vad_model_id` VARCHAR(64) COMMENT '语音活动检测标识',
|
||||
`llm_model_id` VARCHAR(32) COMMENT '大语言模型标识',
|
||||
`tts_model_id` VARCHAR(32) COMMENT '语音合成模型标识',
|
||||
`tts_voice_id` VARCHAR(32) COMMENT '音色标识',
|
||||
`mem_model_id` VARCHAR(32) COMMENT '记忆模型标识',
|
||||
`intent_model_id` VARCHAR(32) COMMENT '意图模型标识',
|
||||
`system_prompt` TEXT COMMENT '角色设定参数',
|
||||
`lang_code` VARCHAR(10) COMMENT '语言编码',
|
||||
`language` VARCHAR(10) COMMENT '交互语种',
|
||||
`sort` INT UNSIGNED DEFAULT 0 COMMENT '排序权重',
|
||||
`creator` BIGINT COMMENT '创建者 ID',
|
||||
`created_at` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者 ID',
|
||||
`updated_at` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_ai_agent_user_id` (`user_id`) COMMENT '创建用户的索引,用于快速查找用户下的智能体信息'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='智能体配置表';
|
||||
|
||||
-- 设备信息表
|
||||
DROP TABLE IF EXISTS `ai_device`;
|
||||
CREATE TABLE `ai_device` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '设备唯一标识',
|
||||
`user_id` BIGINT COMMENT '关联用户 ID',
|
||||
`mac_address` VARCHAR(50) COMMENT 'MAC 地址',
|
||||
`last_connected_at` DATETIME COMMENT '最后连接时间',
|
||||
`auto_update` TINYINT UNSIGNED DEFAULT 0 COMMENT '自动更新开关(0 关闭/1 开启)',
|
||||
`board` VARCHAR(50) COMMENT '设备硬件型号',
|
||||
`alias` VARCHAR(64) DEFAULT NULL COMMENT '设备别名',
|
||||
`agent_id` VARCHAR(32) COMMENT '智能体 ID',
|
||||
`app_version` VARCHAR(20) COMMENT '固件版本号',
|
||||
`sort` INT UNSIGNED DEFAULT 0 COMMENT '排序',
|
||||
`creator` BIGINT COMMENT '创建者',
|
||||
`create_date` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者',
|
||||
`update_date` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_ai_device_created_at` (`mac_address`) COMMENT '创建mac的索引,用于快速查找设备信息'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备信息表';
|
||||
|
||||
-- 声纹识别表
|
||||
DROP TABLE IF EXISTS `ai_voiceprint`;
|
||||
CREATE TABLE `ai_voiceprint` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '声纹唯一标识',
|
||||
`name` VARCHAR(64) COMMENT '声纹名称',
|
||||
`user_id` BIGINT COMMENT '用户 ID(关联用户表)',
|
||||
`agent_id` VARCHAR(32) COMMENT '关联智能体 ID',
|
||||
`agent_code` VARCHAR(36) COMMENT '关联智能体编码',
|
||||
`agent_name` VARCHAR(36) COMMENT '关联智能体名称',
|
||||
`description` VARCHAR(255) COMMENT '声纹描述',
|
||||
`embedding` LONGTEXT COMMENT '声纹特征向量(JSON 数组格式)',
|
||||
`memory` TEXT COMMENT '关联记忆数据',
|
||||
`sort` INT UNSIGNED DEFAULT 0 COMMENT '排序权重',
|
||||
`creator` BIGINT COMMENT '创建者 ID',
|
||||
`created_at` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者 ID',
|
||||
`updated_at` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='声纹识别表';
|
||||
|
||||
-- 对话历史表
|
||||
DROP TABLE IF EXISTS `ai_chat_history`;
|
||||
CREATE TABLE `ai_chat_history` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '对话编号',
|
||||
`user_id` BIGINT COMMENT '用户编号',
|
||||
`agent_id` VARCHAR(32) DEFAULT NULL COMMENT '聊天角色',
|
||||
`device_id` VARCHAR(32) DEFAULT NULL COMMENT '设备编号',
|
||||
`message_count` INT COMMENT '信息汇总',
|
||||
`creator` BIGINT COMMENT '创建者',
|
||||
`create_date` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者',
|
||||
`update_date` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='对话历史表';
|
||||
|
||||
-- 对话信息表
|
||||
DROP TABLE IF EXISTS `ai_chat_message`;
|
||||
CREATE TABLE `ai_chat_message` (
|
||||
`id` VARCHAR(32) NOT NULL COMMENT '对话记录唯一标识',
|
||||
`user_id` BIGINT COMMENT '用户唯一标识',
|
||||
`chat_id` VARCHAR(64) COMMENT '对话历史 ID',
|
||||
`role` ENUM('user', 'assistant') COMMENT '角色(用户或助理)',
|
||||
`content` TEXT COMMENT '对话内容',
|
||||
`prompt_tokens` INT UNSIGNED DEFAULT 0 COMMENT '提示令牌数',
|
||||
`total_tokens` INT UNSIGNED DEFAULT 0 COMMENT '总令牌数',
|
||||
`completion_tokens` INT UNSIGNED DEFAULT 0 COMMENT '完成令牌数',
|
||||
`prompt_ms` INT UNSIGNED DEFAULT 0 COMMENT '提示耗时(毫秒)',
|
||||
`total_ms` INT UNSIGNED DEFAULT 0 COMMENT '总耗时(毫秒)',
|
||||
`completion_ms` INT UNSIGNED DEFAULT 0 COMMENT '完成耗时(毫秒)',
|
||||
`creator` BIGINT COMMENT '创建者',
|
||||
`create_date` DATETIME COMMENT '创建时间',
|
||||
`updater` BIGINT COMMENT '更新者',
|
||||
`update_date` DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_ai_chat_message_user_id_chat_id_role` (`user_id`, `chat_id`) COMMENT '用户 ID、聊天会话 ID 和角色的联合索引,用于快速检索对话记录',
|
||||
INDEX `idx_ai_chat_message_created_at` (`create_date`) COMMENT '创建时间的索引,用于按时间排序或检索对话记录'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='对话信息表';
|
||||
|
|
@ -3,9 +3,16 @@
|
|||
# 每次对数据表进行改动时,只允许新建新对changeSet,不允许对上一个changeSet配置及文件进行修改
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 001create_sys
|
||||
id: 202503141335
|
||||
author: John
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/001create_sys.sql
|
||||
path: classpath:db/changelog/202503141335.sql
|
||||
- changeSet:
|
||||
id: 202503141346
|
||||
author: czc
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202503141346.sql
|
||||
|
|
@ -9,7 +9,6 @@
|
|||
10005=\u8D26\u53F7\u5DF2\u88AB\u505C\u7528
|
||||
10006=\u552F\u4E00\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10007=\u9A8C\u8BC1\u7801\u4E0D\u6B63\u786E
|
||||
10008=\u5148\u5220\u9664\u5B50\u83DC\u5355\u6216\u6309\u94AE
|
||||
10009=\u539F\u5BC6\u7801\u4E0D\u6B63\u786E
|
||||
10010=\u8D26\u53F7\u6216\u5BC6\u7801\u4E0D\u6B63\u786E,\u60A8\u8FD8\u6709\u53EF\u4EE5\u5C1D\u8BD5{0}\u6B21
|
||||
10011=\u4E0A\u7EA7\u90E8\u95E8\u9009\u62E9\u9519\u8BEF
|
||||
|
|
@ -31,24 +30,7 @@
|
|||
10027=Redis\u670D\u52A1\u5F02\u5E38
|
||||
10028=\u5B9A\u65F6\u4EFB\u52A1\u5931\u8D25
|
||||
10029=\u4E0D\u80FD\u5305\u542B\u975E\u6CD5\u5B57\u7B26
|
||||
10030=\u53C2\u6570\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u8BF7\u4F7F\u7528JSON\u683C\u5F0F
|
||||
10031=\u8BF7\u5148\u5B8C\u6210\u77ED\u4FE1\u914D\u7F6E
|
||||
10032=\u4EFB\u52A1\u5DF2\u88AB\u7B7E\u6536\uFF0C\u64CD\u4F5C\u5931\u8D25
|
||||
10033=\u4E0D\u5B58\u5728\u7684\u6D41\u7A0B\u5B9A\u4E49
|
||||
10034=\u4E0A\u7EA7\u8282\u70B9\u4E0D\u5B58\u5728
|
||||
10035=\u9A73\u56DE
|
||||
10036=\u56DE\u9000
|
||||
10037=\u4EFB\u52A1\u6CA1\u6709\u5206\u7EC4\uFF0C\u65E0\u6CD5\u53D6\u6D88\u8BA4\u9886
|
||||
10038=\u4E0A\u7EA7\u533A\u57DF\u9009\u62E9\u9519\u8BEF
|
||||
10039=\u8BF7\u5148\u5220\u9664\u4E0B\u7EA7\u533A\u57DF
|
||||
10040=\u6D41\u7A0B\u5DF2\u6302\u8D77\uFF0C\u4E0D\u80FD\u542F\u52A8\u5B9E\u4F8B
|
||||
10041=\u591A\u5B9E\u4F8B\u4EFB\u52A1\u4E0D\u80FD\u9A73\u56DE
|
||||
10042=\u5B58\u5728\u591A\u4E2A\u5904\u7406\u4E2D\u7684\u4EFB\u52A1\uFF0C\u4E0D\u80FD\u9A73\u56DE
|
||||
10043=\u591A\u5B9E\u4F8B\u4EFB\u52A1\u4E0D\u80FD\u7EC8\u6B62
|
||||
10044=\u5B58\u5728\u591A\u4E2A\u5904\u7406\u4E2D\u7684\u4EFB\u52A1\uFF0C\u4E0D\u80FD\u7EC8\u6B62\u6D41\u7A0B
|
||||
10045=\u7EC8\u6B62
|
||||
10046=\u591A\u5B9E\u4F8B\u4EFB\u52A1\u4E0D\u80FD\u56DE\u9000
|
||||
10047=\u5B58\u5728\u591A\u4E2A\u5E76\u884C\u6267\u884C\u7684\u4EFB\u52A1\uFF0C\u4E0D\u80FD\u56DE\u9000
|
||||
10048=\u767B\u5F55\u8D26\u53F7\uFF0C\u65E0\u6743\u5220\u9664
|
||||
10055=\u60A8\u7684\u5BC6\u7801\u957F\u5EA6\u4E0D\u591F8\u4F4D
|
||||
10056=\u60A8\u7684\u5BC6\u7801\u590D\u6742\u5EA6\u4E0D\u591F\uFF0C\u9700\u8981\u540C\u65F6\u5305\u542B\u6570\u5B57,\u5C0F\u5199\u82F1\u6587,\u5927\u5199\u82F1\u6587
|
||||
10030=\u5BC6\u7801\u957F\u5EA6\u4E0D\u8DB3{0}\u4F4D
|
||||
10031=\u5F31\u5BC6\u7801
|
||||
10032=\u5220\u9664\u672C\u6570\u636E\u5F02\u5E38
|
||||
10033=\u8BBE\u5907\u9A8C\u8BC1\u7801\u9519\u8BEF
|
||||
|
|
|
|||
|
|
@ -11,44 +11,25 @@
|
|||
10007=The verification code is incorrect
|
||||
10008=First delete submenu or button
|
||||
10009=The original password is incorrect
|
||||
10010=password error,you can try {0} times
|
||||
|
||||
10011=The superior department made a wrong choice
|
||||
10012=Upper menu cannot be for itself
|
||||
10013=Data permission interface, which can only be a Map type parameter.
|
||||
10014=Please delete the subordinate department first
|
||||
10015=Please delete the user under the department first
|
||||
10016=Deployment failed, no process
|
||||
10017=Model diagram is incorrect, please check
|
||||
10018=The export failed with the model ID {0}
|
||||
|
||||
10019=Please upload a file
|
||||
10020=token cannot be empty
|
||||
10021=token is invalid, please log in again
|
||||
10022=The account has been locked
|
||||
10023=Please upload zip, bar, bpmn, bpmn20.xml format file
|
||||
|
||||
10024=Failed to upload file {0}
|
||||
10025=Failed to send SMS {0}
|
||||
10026=Mail template does not exist
|
||||
|
||||
10027=Redis service exception
|
||||
10028=Timed task failed
|
||||
10029=Cannot contain illegal characters
|
||||
10030=The parameter format is incorrect. Please use JSON format.
|
||||
10031=Please complete the SMS configuration first.
|
||||
10032=Task has been signed and operation failed
|
||||
10033=Non-existent process definition
|
||||
10034=Superior node does not exist
|
||||
10035=Reject
|
||||
10036=Rollback
|
||||
10037=Tasks are not grouped and cannot be cancelled
|
||||
10038=Upper area selection error
|
||||
10039=Please delete the subordinate area first
|
||||
10040=The process has been suspended and the instance cannot be started
|
||||
10041=Multi-instance tasks cannot be rejected
|
||||
10042=Tasks in multiple processes cannot be rejected
|
||||
10043=Multi-instance tasks cannot be terminated
|
||||
10044=There are tasks in multiple processes that cannot terminate the process
|
||||
10045=END
|
||||
10046=Multi-instance tasks cannot be rolled back
|
||||
10047=There are multiple parallel tasks that cannot be rolled back
|
||||
10048 = Login account, no right to delete
|
||||
10055=Your password length is less than 8 digits
|
||||
10056=Your password is not complex enough and needs to include both numbers, lowercase English, and uppercase English
|
||||
|
||||
10030=The password is less than {0} digits.
|
||||
10031=The password must consist of numbers, uppercase and lowercase letters, and special characters at the same time
|
||||
10032=Exception in deleting this data
|
||||
10033=Device verification code error
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
500=\u670D\u52A1\u5668\u5185\u90E8\u5F02\u5E38
|
||||
401=\u672A\u6388\u6743
|
||||
403=\u62D2\u7EDD\u8BBF\u95EE\uFF0C\u6CA1\u6709\u6743\u9650
|
||||
|
||||
10001={0}\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10002=\u6570\u636E\u5E93\u4E2D\u5DF2\u5B58\u5728\u8BE5\u8BB0\u5F55
|
||||
10003=\u83B7\u53D6\u53C2\u6570\u5931\u8D25
|
||||
|
|
@ -11,44 +12,24 @@
|
|||
10007=\u9A8C\u8BC1\u7801\u4E0D\u6B63\u786E
|
||||
10008=\u5148\u5220\u9664\u5B50\u83DC\u5355\u6216\u6309\u94AE
|
||||
10009=\u539F\u5BC6\u7801\u4E0D\u6B63\u786E
|
||||
10010=\u8D26\u53F7\u6216\u5BC6\u7801\u4E0D\u6B63\u786E,\u60A8\u8FD8\u6709\u53EF\u4EE5\u5C1D\u8BD5{0}\u6B21
|
||||
|
||||
10011=\u4E0A\u7EA7\u90E8\u95E8\u9009\u62E9\u9519\u8BEF
|
||||
10012=\u4E0A\u7EA7\u83DC\u5355\u4E0D\u80FD\u4E3A\u81EA\u8EAB
|
||||
10013=\u6570\u636E\u6743\u9650\u63A5\u53E3\uFF0C\u53EA\u80FD\u662FMap\u7C7B\u578B\u53C2\u6570
|
||||
10014=\u8BF7\u5148\u5220\u9664\u4E0B\u7EA7\u90E8\u95E8
|
||||
10015=\u8BF7\u5148\u5220\u9664\u90E8\u95E8\u4E0B\u7684\u7528\u6237
|
||||
10016=\u90E8\u7F72\u5931\u8D25\uFF0C\u6CA1\u6709\u6D41\u7A0B
|
||||
10017=\u6A21\u578B\u56FE\u4E0D\u6B63\u786E\uFF0C\u8BF7\u68C0\u67E5
|
||||
10018=\u5BFC\u51FA\u5931\u8D25\uFF0C\u6A21\u578BID\u4E3A{0}
|
||||
|
||||
10019=\u8BF7\u4E0A\u4F20\u6587\u4EF6
|
||||
10020=token\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10021=token\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55
|
||||
10022=\u8D26\u53F7\u5DF2\u88AB\u9501\u5B9A
|
||||
10023=\u8BF7\u4E0A\u4F20zip\u3001bar\u3001bpmn\u3001bpmn20.xml\u683C\u5F0F\u6587\u4EF6
|
||||
|
||||
10024=\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25{0}
|
||||
10025=\u53D1\u9001\u77ED\u4FE1\u5931\u8D25{0}
|
||||
10026=\u90AE\u4EF6\u6A21\u677F\u4E0D\u5B58\u5728
|
||||
|
||||
10027=Redis\u670D\u52A1\u5F02\u5E38
|
||||
10028=\u5B9A\u65F6\u4EFB\u52A1\u5931\u8D25
|
||||
10029=\u4E0D\u80FD\u5305\u542B\u975E\u6CD5\u5B57\u7B26
|
||||
10030=\u53C2\u6570\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u8BF7\u4F7F\u7528JSON\u683C\u5F0F
|
||||
10031=\u8BF7\u5148\u5B8C\u6210\u77ED\u4FE1\u914D\u7F6E
|
||||
10032=\u4EFB\u52A1\u5DF2\u88AB\u7B7E\u6536\uFF0C\u64CD\u4F5C\u5931\u8D25
|
||||
10033=\u4E0D\u5B58\u5728\u7684\u6D41\u7A0B\u5B9A\u4E49
|
||||
10034=\u4E0A\u7EA7\u8282\u70B9\u4E0D\u5B58\u5728
|
||||
10035=\u9A73\u56DE
|
||||
10036=\u56DE\u9000
|
||||
10037=\u4EFB\u52A1\u6CA1\u6709\u5206\u7EC4\uFF0C\u65E0\u6CD5\u53D6\u6D88\u8BA4\u9886
|
||||
10038=\u4E0A\u7EA7\u533A\u57DF\u9009\u62E9\u9519\u8BEF
|
||||
10039=\u8BF7\u5148\u5220\u9664\u4E0B\u7EA7\u533A\u57DF
|
||||
10040=\u6D41\u7A0B\u5DF2\u6302\u8D77\uFF0C\u4E0D\u80FD\u542F\u52A8\u5B9E\u4F8B
|
||||
10041=\u591A\u5B9E\u4F8B\u4EFB\u52A1\u4E0D\u80FD\u9A73\u56DE
|
||||
10042=\u5B58\u5728\u591A\u4E2A\u5904\u7406\u4E2D\u7684\u4EFB\u52A1\uFF0C\u4E0D\u80FD\u9A73\u56DE
|
||||
10043=\u591A\u5B9E\u4F8B\u4EFB\u52A1\u4E0D\u80FD\u7EC8\u6B62
|
||||
10044=\u5B58\u5728\u591A\u4E2A\u5904\u7406\u4E2D\u7684\u4EFB\u52A1\uFF0C\u4E0D\u80FD\u7EC8\u6B62\u6D41\u7A0B
|
||||
10045=\u7EC8\u6B62
|
||||
10046=\u591A\u5B9E\u4F8B\u4EFB\u52A1\u4E0D\u80FD\u56DE\u9000
|
||||
10047=\u5B58\u5728\u591A\u4E2A\u5E76\u884C\u6267\u884C\u7684\u4EFB\u52A1\uFF0C\u4E0D\u80FD\u56DE\u9000
|
||||
10048=\u767B\u5F55\u8D26\u53F7\uFF0C\u65E0\u6743\u5220\u9664
|
||||
10055=\u60A8\u7684\u5BC6\u7801\u957F\u5EA6\u4E0D\u591F8\u4F4D
|
||||
10056=\u60A8\u7684\u5BC6\u7801\u590D\u6742\u5EA6\u4E0D\u591F\uFF0C\u9700\u8981\u540C\u65F6\u5305\u542B\u6570\u5B57,\u5C0F\u5199\u82F1\u6587,\u5927\u5199\u82F1\u6587
|
||||
10030=\u5BC6\u7801\u957F\u5EA6\u4E0D\u8DB3{0}\u4F4D
|
||||
10031=\u5BC6\u7801\u5FC5\u987B\u540C\u65F6\u5305\u542B\u6570\u5B57\u3001\u5927\u5C0F\u5B57\u6BCD\u548C\u7279\u6B8A\u5B57\u7B26\u7EC4\u6210
|
||||
10032=\u5220\u9664\u672C\u6570\u636E\u5F02\u5E38
|
||||
10033=\u8BBE\u5907\u9A8C\u8BC1\u7801\u9519\u8BEF
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
500=\u670D\u52D9\u5668\u5167\u90E8\u7570\u5E38
|
||||
401=\u672A\u6388\u6B0A
|
||||
403=\u62D2\u7D55\u8A2A\u554F\uFF0C\u6C92\u6709\u6B0A\u9650
|
||||
|
||||
10001={0}\u4E0D\u80FD\u70BA\u7A7A
|
||||
10002=\u6578\u64DA\u5EAB\u4E2D\u5DF2\u5B58\u5728\u8A72\u8A18\u9304
|
||||
10003=\u7372\u53D6\u53C3\u6578\u5931\u6557
|
||||
|
|
@ -11,44 +12,24 @@
|
|||
10007=\u9A57\u8B49\u78BC\u4E0D\u6B63\u78BA
|
||||
10008=\u5148\u522A\u9664\u5B50\u83DC\u55AE\u6216\u6309\u9215
|
||||
10009=\u539F\u5BC6\u78BC\u4E0D\u6B63\u78BA
|
||||
10010=\u8CEC\u865F\u6216\u5BC6\u78BC\u4E0D\u6B63\u78BA,\u60A8\u9084\u6709\u53EF\u4EE5\u5617\u8A66{0}\u6B21
|
||||
|
||||
10011=\u4E0A\u7D1A\u90E8\u9580\u9078\u64C7\u932F\u8AA4
|
||||
10012=\u4E0A\u7D1A\u83DC\u55AE\u4E0D\u80FD\u70BA\u81EA\u8EAB
|
||||
10013=\u6578\u64DA\u6B0A\u9650\u63A5\u53E3\uFF0C\u53EA\u80FD\u662FMap\u985E\u578B\u53C3\u6578
|
||||
10014=\u8ACB\u5148\u522A\u9664\u4E0B\u7D1A\u90E8\u9580
|
||||
10015=\u8ACB\u5148\u522A\u9664\u90E8\u9580\u4E0B\u7684\u7528\u6236
|
||||
10016=\u90E8\u7F72\u5931\u6557\uFF0C\u6C92\u6709\u6D41\u7A0B
|
||||
10017=\u6A21\u578B\u5716\u4E0D\u6B63\u78BA\uFF0C\u8ACB\u6AA2\u67E5
|
||||
10018=\u5C0E\u51FA\u5931\u6557\uFF0C\u6A21\u578BID\u70BA{0}
|
||||
|
||||
10019=\u8ACB\u4E0A\u50B3\u6587\u4EF6
|
||||
10020=token\u4E0D\u80FD\u70BA\u7A7A
|
||||
10021=token\u5931\u6548\uFF0C\u8ACB\u91CD\u65B0\u767B\u9304
|
||||
10022=\u8CEC\u865F\u5DF2\u88AB\u9396\u5B9A
|
||||
10023=\u8ACB\u4E0A\u50B3zip\u3001bar\u3001bpmn\u3001bpmn20.xml\u683C\u5F0F\u6587\u4EF6
|
||||
|
||||
10024=\u4E0A\u50B3\u6587\u4EF6\u5931\u6557{0}
|
||||
10025=\u767C\u9001\u77ED\u4FE1\u5931\u6557{0}
|
||||
10026=\u90F5\u4EF6\u6A21\u677F\u4E0D\u5B58\u5728
|
||||
|
||||
10027=Redis\u670D\u52D9\u7570\u5E38
|
||||
10028=\u5B9A\u6642\u4EFB\u52D9\u5931\u6557
|
||||
10029=\u4E0D\u80FD\u5305\u542B\u975E\u6CD5\u5B57\u7B26
|
||||
10030=\u53C3\u6578\u683C\u5F0F\u4E0D\u6B63\u78BA\uFF0C\u8ACB\u4F7F\u7528JSON\u683C\u5F0F
|
||||
10031=\u8ACB\u5148\u5B8C\u6210\u77ED\u4FE1\u914D\u7F6E
|
||||
10032=\u4EFB\u52D9\u5DF2\u88AB\u7C3D\u6536\uFF0C\u64CD\u4F5C\u5931\u6557
|
||||
10033=\u4E0D\u5B58\u5728\u7684\u6D41\u7A0B\u5B9A\u7FA9
|
||||
10034=\u4E0A\u7D1A\u7BC0\u9EDE\u4E0D\u5B58\u5728
|
||||
10035=\u99C1\u56DE
|
||||
10036=\u56DE\u9000
|
||||
10037=\u4EFB\u52D9\u6C92\u6709\u5206\u7D44\uFF0C\u7121\u6CD5\u53D6\u6D88\u8A8D\u9818
|
||||
10038=\u4E0A\u7D1A\u5340\u57DF\u9078\u64C7\u932F\u8AA4
|
||||
10039=\u8ACB\u5148\u522A\u9664\u4E0B\u7D1A\u5340\u57DF
|
||||
10040=\u6D41\u7A0B\u5DF2\u639B\u8D77\uFF0C\u4E0D\u80FD\u555F\u52D5\u5BE6\u4F8B
|
||||
10041=\u591A\u5BE6\u4F8B\u4EFB\u52D9\u4E0D\u80FD\u99C1\u56DE
|
||||
10042=\u5B58\u5728\u591A\u500B\u8655\u7406\u4E2D\u7684\u4EFB\u52D9\uFF0C\u4E0D\u80FD\u99C1\u56DE
|
||||
10043=\u591A\u5BE6\u4F8B\u4EFB\u52D9\u4E0D\u80FD\u7D42\u6B62
|
||||
10044=\u5B58\u5728\u591A\u500B\u8655\u7406\u4E2D\u7684\u4EFB\u52D9\uFF0C\u4E0D\u80FD\u7D42\u6B62\u6D41\u7A0B
|
||||
10045=\u7D42\u6B62
|
||||
10046=\u591A\u5BE6\u4F8B\u4EFB\u52D9\u4E0D\u80FD\u56DE\u9000
|
||||
10047=\u5B58\u5728\u591A\u500B\u4E26\u884C\u57F7\u884C\u7684\u4EFB\u52D9\uFF0C\u4E0D\u80FD\u56DE\u9000
|
||||
10048=\u767B\u5165\u5E33\u865F\uFF0C\u7121\u6B0A\u5220\u9664
|
||||
10055=\u60A8\u7684\u5BC6\u78BC\u9577\u5EA6\u4E0D\u59208\u4F4D
|
||||
10056=\u60A8\u7684\u5BC6\u78BC\u5FA9\u96DC\u5EA6\u4E0D\u5920\uFF0C\u9700\u8981\u540C\u6642\u5305\u542B\u6578\u5B57,\u5C0F\u5BEB\u82F1\u6587,\u5927\u5BEB\u82F1\u6587
|
||||
10030=\u5BC6\u78BC\u9577\u5EA6\u4E0D\u8DB3{0}\u4F4D
|
||||
10031=\u5BC6\u78BC\u5FC5\u9808\u540C\u6642\u5305\u542B\u6578\u5B57\u3001\u5927\u5C0F\u5B57\u6BCD\u548C\u7279\u6B8A\u5B57\u7B26\u7D44\u6210
|
||||
10032=\u522A\u9664\u6B64\u6578\u64DA\u7570\u5E38
|
||||
10033=\u8A2D\u5099\u9A57\u8B49\u78BC\u932F\u8AA4
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
#\u7B80\u4F53\u4E2D\u6587
|
||||
id.require=ID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
id.null=ID\u5FC5\u987B\u4E3A\u7A7A
|
||||
pid.require=\u4E0A\u7EA7ID\uFF0C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sort.number=\u6392\u5E8F\u503C\u4E0D\u80FD\u5C0F\u4E8E0
|
||||
|
||||
sysdict.type.require=\u5B57\u5178\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.name.require=\u5B57\u5178\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.label.require=\u5B57\u5178\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysparams.paramcode.require=\u53C2\u6570\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.paramvalue.require=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
|
|
@ -11,99 +15,8 @@ sysuser.username.require=\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
|||
sysuser.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.realname.require=\u59D3\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.gender.range=\u6027\u522B\u53D6\u503C\u8303\u56F40~2
|
||||
sysuser.email.require=\u90AE\u7BB1\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.email.error=\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
sysuser.mobile.require=\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.deptId.require=\u90E8\u95E8\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.superadmin.range=\u8D85\u7EA7\u7BA1\u7406\u5458\u53D6\u503C\u8303\u56F40~1
|
||||
sysuser.status.range=\u72B6\u6001\u53D6\u503C\u8303\u56F40~1
|
||||
sysuser.captcha.require=\u9A8C\u8BC1\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.uuid.require=\u552F\u4E00\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysmenu.pid.require=\u8BF7\u9009\u62E9\u4E0A\u7EA7\u83DC\u5355
|
||||
sysmenu.name.require=\u83DC\u5355\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysmenu.type.range=\u83DC\u5355\u7C7B\u578B\u53D6\u503C\u8303\u56F40~1
|
||||
sysmenu.openstyle.range=\u83DC\u5355\u6253\u5F00\u65B9\u5F0F\u53D6\u503C\u8303\u56F40~1
|
||||
|
||||
sysdept.pid.require=\u8BF7\u9009\u62E9\u4E0A\u7EA7\u90E8\u95E8
|
||||
sysdept.name.require=\u90E8\u95E8\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysrole.name.require=\u89D2\u8272\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysdict.type.require=\u5B57\u5178\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.name.require=\u5B57\u5178\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.label.require=\u5B57\u5178\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
schedule.status.range=\u72B6\u6001\u53D6\u503C\u8303\u56F40~1
|
||||
schedule.cron.require=cron\u8868\u8FBE\u5F0F\u4E0D\u80FD\u4E3A\u7A7A
|
||||
schedule.bean.require=bean\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
oss.type.range=\u7C7B\u578B\u53D6\u503C\u8303\u56F41~5
|
||||
|
||||
aliyun.accesskeyid.require=\u963F\u91CC\u4E91AccessKeyId\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.accesskeysecret.require=\u963F\u91CC\u4E91AccessKeySecret\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.signname.require=\u963F\u91CC\u4E91\u77ED\u4FE1\u7B7E\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.templatecode.require=\u963F\u91CC\u4E91\u77ED\u4FE1\u6A21\u677F\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.domain.require=\u963F\u91CC\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.domain.url=\u963F\u91CC\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
aliyun.endPoint.require=\u963F\u91CC\u4E91EndPoint\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.bucketname.require=\u963F\u91CC\u4E91BucketName\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
qcloud.appid.require=\u817E\u8BAF\u4E91AppId\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.appkey.require=\u817E\u8BAF\u4E91AppKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.secretId.require=\u817E\u8BAF\u4E91SecretId\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.secretkey.require=\u817E\u8BAF\u4E91SecretKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.signname.require=\u817E\u8BAF\u4E91\u77ED\u4FE1\u7B7E\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.templateid.require=\u817E\u8BAF\u4E91\u77ED\u4FE1\u6A21\u677FID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.domain.require=\u817E\u8BAF\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.domain.url=\u817E\u8BAF\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
qcloud.bucketname.require=\u817E\u8BAF\u4E91BucketName\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.region.require=\u6240\u5C5E\u5730\u533A\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
qiniu.domain.require=\u4E03\u725B\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qiniu.domain.url=\u4E03\u725B\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
qiniu.accesskey.require=\u4E03\u725BAccessKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qiniu.secretkey.require=\u4E03\u725BSecretKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qiniu.bucketname.require=\u4E03\u725B\u7A7A\u95F4\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qiniu.templateId.require=\u4E03\u725B\u6A21\u677FID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
fastdfs.domain.require=FastDFS\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
fastdfs.domain.url=FastDFS\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
|
||||
local.domain.require=\u672C\u5730\u4E0A\u4F20\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
local.domain.url=\u672C\u5730\u4E0A\u4F20\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
local.path.url=\u5B58\u50A8\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
minio.endPoint.require=Minio EndPoint\u4E0D\u80FD\u4E3A\u7A7A
|
||||
minio.accesskey.require=Minio AccessKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
minio.secretkey.require=Minio SecretKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
minio.bucketname.require=Minio BucketName\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sms.platform.range=\u5E73\u53F0\u7C7B\u578B\u53D6\u503C\u8303\u56F41~2
|
||||
email.smtp.require=SMTP\u4E0D\u80FD\u4E3A\u7A7A
|
||||
email.port.require=\u7AEF\u53E3\u53F7\u4E0D\u80FD\u4E3A\u7A7A
|
||||
email.username.require=\u90AE\u7BB1\u8D26\u53F7\u4E0D\u80FD\u4E3A\u7A7A
|
||||
email.password.require=\u90AE\u7BB1\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
mail.name.require=\u6A21\u677F\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
mail.subject.require=\u90AE\u4EF6\u4E3B\u9898\u4E0D\u80FD\u4E3A\u7A7A
|
||||
mail.content.require=\u90AE\u4EF6\u6B63\u6587\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
model.name.require=\u6A21\u578B\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
model.key.require=\u6A21\u578B\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
news.title.require=\u6807\u9898\u4E0D\u80FD\u4E3A\u7A7A
|
||||
news.content.require=\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A
|
||||
news.pubdate.require=\u53D1\u5E03\u65F6\u95F4\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
region.id.require=\u533A\u57DF\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A
|
||||
region.pid.require=\u4E0A\u7EA7\u533A\u57DF\u4E0D\u80FD\u4E3A\u7A7A
|
||||
region.name.require=\u533A\u57DF\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
processBizRoute.procDefId.require=\u6D41\u7A0B\u5B9A\u4E49ID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
processBizRoute.bizRoute.require=\u4E1A\u52A1\u8DEF\u7531\u4E0D\u80FD\u4E3A\u7A7A
|
||||
processBizRoute.procDefKey.require=\u6D41\u7A0B\u5B9A\u4E49KEY\u4E0D\u80FD\u4E3A\u7A7A
|
||||
processBizRoute.version.require=\u6D41\u7A0B\u5B9A\u4E49\u7248\u672C\u53F7\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
ProcessStart.processDefinitionKey.require=\u6D41\u7A0B\u5B9A\u4E49KEY\u4E0D\u80FD\u4E3A\u7A7A
|
||||
ProcessStart.businessKey.require=\u4E1A\u52A1KEY\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
#English
|
||||
id.require=ID can not be empty
|
||||
id.null=ID has to be empty
|
||||
pid.require=Parent ID, cannot be empty
|
||||
|
||||
sort.number=The sort value cannot be less than 0
|
||||
|
||||
sysdict.type.require=The dictionary type cannot be empty
|
||||
sysdict.name.require=The dictionary name cannot be empty
|
||||
sysdict.label.require=Dictionary tag cannot be empty
|
||||
|
||||
sysparams.paramcode.require=Parameter encoding cannot be empty
|
||||
sysparams.paramvalue.require=Parameter values cannot be empty
|
||||
|
||||
|
|
@ -11,100 +15,8 @@ sysuser.username.require=The username cannot be empty
|
|||
sysuser.password.require=The password cannot be empty
|
||||
sysuser.realname.require=The realname cannot be empty
|
||||
sysuser.gender.range=Gender ranges from 0 to 2
|
||||
sysuser.email.require=Mailbox cannot be empty
|
||||
sysuser.email.error=Incorrect email format
|
||||
sysuser.mobile.require=The phone number cannot be empty
|
||||
sysuser.deptId.require=Departments cannot be empty
|
||||
sysuser.superadmin.range=Super administrator values range from 0 to 1
|
||||
sysuser.status.range=State ranges from 0 to 1
|
||||
sysuser.captcha.require=The captcha cannot be empty
|
||||
sysuser.uuid.require=The unique identifier cannot be empty
|
||||
|
||||
sysmenu.pid.require=Please select superior menu
|
||||
sysmenu.name.require=Menu name cannot be empty
|
||||
sysmenu.type.range=Menu type ranges from 0 to 1
|
||||
sysmenu.openstyle.range=Menu open style ranges from 0 to 1
|
||||
|
||||
sysdept.pid.require=Please select superior department
|
||||
sysdept.name.require=The department name cannot be empty
|
||||
|
||||
sysrole.name.require=The role name cannot be empty
|
||||
|
||||
sysdict.type.require=The dictionary type cannot be empty
|
||||
sysdict.name.require=The dictionary name cannot be empty
|
||||
sysdict.label.require=Dictionary tag cannot be empty
|
||||
|
||||
schedule.status.range=Status ranges from 0 to 1
|
||||
schedule.cron.require=Cron expression cannot be empty
|
||||
schedule.bean.require=Bean name cannot be empty
|
||||
|
||||
oss.type.range=Type ranges from 1 to 5
|
||||
|
||||
aliyun.accesskeyid.require=Aliyun AccessKeyId cannot be empty
|
||||
aliyun.accesskeysecret.require=Aliyun AccessKeySecret cannot be empty
|
||||
aliyun.signname.require=Aliyun message signature cannot be empty
|
||||
aliyun.templatecode.require=Aliyun message template cannot be empty
|
||||
aliyun.domain.require=Aliyun bound domain name cannot be empty
|
||||
aliyun.domain.url=Aliyun binding domain name format is incorrect
|
||||
aliyun.endPoint.require=The aliyun EndPoint cannot be empty
|
||||
aliyun.bucketname.require=Aliyun BucketName cannot be empty
|
||||
|
||||
qcloud.appid.require=Tencent cloud AppId cannot be empty
|
||||
qcloud.appkey.require=Tencent cloud AppKey cannot be empty
|
||||
qcloud.secretId.require=Tencent cloud SecretId cannot be empty
|
||||
qcloud.secretkey.require=Tencent cloud SecretKey cannot be empty
|
||||
qcloud.signname.require=Tencent cloud SMS signature cannot be empty
|
||||
qcloud.templateid.require=Tencent cloud SMS template ID cannot be empty
|
||||
qcloud.domain.require=Tencent cloud bound domain name cannot be empty
|
||||
qcloud.domain.url=Tencent cloud binding domain name format is incorrect
|
||||
qcloud.bucketname.require=Tencent cloud BucketName cannot be empty
|
||||
qcloud.region.require=The region cannot be empty
|
||||
|
||||
qiniu.domain.require=Bound domain name cannot be empty
|
||||
qiniu.domain.url=Binding domain name format is incorrect
|
||||
qiniu.accesskey.require=The AccessKey cannot be empty
|
||||
qiniu.secretkey.require=The SecretKey of seven cows cannot be empty
|
||||
qiniu.bucketname.require=Space names cannot be empty
|
||||
qiniu.templateId.require=Template ID cannot be empty
|
||||
|
||||
fastdfs.domain.require=FastDFS bound domain name cannot be empty
|
||||
fastdfs.domain.url=FastDFS bound domain name format is incorrect
|
||||
|
||||
local.domain.require=Local upload bound domain name cannot be empty
|
||||
local.domain.url=The domain name bound for local upload is not formatted correctly
|
||||
local.path.url=The storage directory cannot be empty
|
||||
|
||||
minio.endPoint.require=Minio EndPoint cannot be empty
|
||||
minio.accesskey.require=Minio AccessKey cannot be empty
|
||||
minio.secretkey.require=Minio SecretKey cannot be empty
|
||||
minio.bucketname.require=Minio BucketName cannot be empty
|
||||
|
||||
sms.platform.range=Platform type ranges from 1 to 2
|
||||
|
||||
email.smtp.require=SMTP cannot be empty
|
||||
email.port.require=Port number cannot be empty
|
||||
email.username.require=The email account cannot be empty
|
||||
email.password.require=The password cannot be empty
|
||||
|
||||
mail.name.require=The template name cannot be empty
|
||||
mail.subject.require=Mail subject cannot be empty
|
||||
mail.content.require=Message text cannot be empty
|
||||
|
||||
model.name.require=The model name cannot be empty
|
||||
model.key.require=The model key cannot be empty
|
||||
|
||||
news.title.require=The title cannot be empty
|
||||
news.content.require=Content cannot be empty
|
||||
news.pubdate.require=The release time cannot be empty
|
||||
|
||||
region.id.require=Region ID cannot be empty
|
||||
region.pid.require=Upper area cannot be empty
|
||||
region.name.require=Region name cannot be empty
|
||||
|
||||
processBizRoute.procDefId.require=Process Definition ID cannot be empty
|
||||
processBizRoute.bizRoute.require=Service routing cannot be empty
|
||||
processBizRoute.procDefKey.require=Process Definition KEY cannot be empty
|
||||
processBizRoute.version.require=Process Definition Version number cannot be empty
|
||||
|
||||
ProcessStart.processDefinitionKey.require=Process Definition KEY cannot be empty
|
||||
ProcessStart.businessKey.require=Business KEY cannot be empty
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
#\u7B80\u4F53\u4E2D\u6587
|
||||
id.require=ID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
id.null=ID\u5FC5\u987B\u4E3A\u7A7A
|
||||
pid.require=\u4E0A\u7EA7ID\uFF0C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sort.number=\u6392\u5E8F\u503C\u4E0D\u80FD\u5C0F\u4E8E0
|
||||
|
||||
sysdict.type.require=\u5B57\u5178\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.name.require=\u5B57\u5178\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.label.require=\u5B57\u5178\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysparams.paramcode.require=\u53C2\u6570\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.paramvalue.require=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
|
|
@ -11,99 +15,9 @@ sysuser.username.require=\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
|||
sysuser.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.realname.require=\u59D3\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.gender.range=\u6027\u522B\u53D6\u503C\u8303\u56F40~2
|
||||
sysuser.email.require=\u90AE\u7BB1\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.email.error=\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
sysuser.mobile.require=\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.deptId.require=\u90E8\u95E8\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.superadmin.range=\u8D85\u7EA7\u7BA1\u7406\u5458\u53D6\u503C\u8303\u56F40~1
|
||||
sysuser.status.range=\u72B6\u6001\u53D6\u503C\u8303\u56F40~1
|
||||
sysuser.captcha.require=\u9A8C\u8BC1\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.uuid.require=\u552F\u4E00\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysmenu.pid.require=\u8BF7\u9009\u62E9\u4E0A\u7EA7\u83DC\u5355
|
||||
sysmenu.name.require=\u83DC\u5355\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysmenu.type.range=\u83DC\u5355\u7C7B\u578B\u53D6\u503C\u8303\u56F40~1
|
||||
sysmenu.openstyle.range=\u83DC\u5355\u6253\u5F00\u65B9\u5F0F\u53D6\u503C\u8303\u56F40~1
|
||||
|
||||
sysdept.pid.require=\u8BF7\u9009\u62E9\u4E0A\u7EA7\u90E8\u95E8
|
||||
sysdept.name.require=\u90E8\u95E8\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysrole.name.require=\u89D2\u8272\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysdict.type.require=\u5B57\u5178\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.name.require=\u5B57\u5178\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.label.require=\u5B57\u5178\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
schedule.status.range=\u72B6\u6001\u53D6\u503C\u8303\u56F40~1
|
||||
schedule.cron.require=cron\u8868\u8FBE\u5F0F\u4E0D\u80FD\u4E3A\u7A7A
|
||||
schedule.bean.require=bean\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
oss.type.range=\u7C7B\u578B\u53D6\u503C\u8303\u56F41~5
|
||||
|
||||
aliyun.accesskeyid.require=\u963F\u91CC\u4E91AccessKeyId\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.accesskeysecret.require=\u963F\u91CC\u4E91AccessKeySecret\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.signname.require=\u963F\u91CC\u4E91\u77ED\u4FE1\u7B7E\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.templatecode.require=\u963F\u91CC\u4E91\u77ED\u4FE1\u6A21\u677F\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.domain.require=\u963F\u91CC\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.domain.url=\u963F\u91CC\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
aliyun.endPoint.require=\u963F\u91CC\u4E91EndPoint\u4E0D\u80FD\u4E3A\u7A7A
|
||||
aliyun.bucketname.require=\u963F\u91CC\u4E91BucketName\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
qcloud.appid.require=\u817E\u8BAF\u4E91AppId\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.appkey.require=\u817E\u8BAF\u4E91AppKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.secretId.require=\u817E\u8BAF\u4E91SecretId\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.secretkey.require=\u817E\u8BAF\u4E91SecretKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.signname.require=\u817E\u8BAF\u4E91\u77ED\u4FE1\u7B7E\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.templateid.require=\u817E\u8BAF\u4E91\u77ED\u4FE1\u6A21\u677FID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.domain.require=\u817E\u8BAF\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.domain.url=\u817E\u8BAF\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
qcloud.bucketname.require=\u817E\u8BAF\u4E91BucketName\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qcloud.region.require=\u6240\u5C5E\u5730\u533A\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
qiniu.domain.require=\u4E03\u725B\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qiniu.domain.url=\u4E03\u725B\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
qiniu.accesskey.require=\u4E03\u725BAccessKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qiniu.secretkey.require=\u4E03\u725BSecretKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qiniu.bucketname.require=\u4E03\u725B\u7A7A\u95F4\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
qiniu.templateId.require=\u4E03\u725B\u6A21\u677FID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
fastdfs.domain.require=FastDFS\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
fastdfs.domain.url=FastDFS\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
|
||||
local.domain.require=\u672C\u5730\u4E0A\u4F20\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
local.domain.url=\u672C\u5730\u4E0A\u4F20\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
local.path.url=\u5B58\u50A8\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
minio.endPoint.require=Minio EndPoint\u4E0D\u80FD\u4E3A\u7A7A
|
||||
minio.accesskey.require=Minio AccessKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
minio.secretkey.require=Minio SecretKey\u4E0D\u80FD\u4E3A\u7A7A
|
||||
minio.bucketname.require=Minio BucketName\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sms.platform.range=\u5E73\u53F0\u7C7B\u578B\u53D6\u503C\u8303\u56F41~2
|
||||
email.smtp.require=SMTP\u4E0D\u80FD\u4E3A\u7A7A
|
||||
email.port.require=\u7AEF\u53E3\u53F7\u4E0D\u80FD\u4E3A\u7A7A
|
||||
email.username.require=\u90AE\u7BB1\u8D26\u53F7\u4E0D\u80FD\u4E3A\u7A7A
|
||||
email.password.require=\u90AE\u7BB1\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
mail.name.require=\u6A21\u677F\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
mail.subject.require=\u90AE\u4EF6\u4E3B\u9898\u4E0D\u80FD\u4E3A\u7A7A
|
||||
mail.content.require=\u90AE\u4EF6\u6B63\u6587\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
model.name.require=\u6A21\u578B\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
model.key.require=\u6A21\u578B\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
news.title.require=\u6807\u9898\u4E0D\u80FD\u4E3A\u7A7A
|
||||
news.content.require=\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A
|
||||
news.pubdate.require=\u53D1\u5E03\u65F6\u95F4\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
region.id.require=\u533A\u57DF\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A
|
||||
region.pid.require=\u4E0A\u7EA7\u533A\u57DF\u4E0D\u80FD\u4E3A\u7A7A
|
||||
region.name.require=\u533A\u57DF\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
processBizRoute.procDefId.require=\u6D41\u7A0B\u5B9A\u4E49ID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
processBizRoute.bizRoute.require=\u4E1A\u52A1\u8DEF\u7531\u4E0D\u80FD\u4E3A\u7A7A
|
||||
processBizRoute.procDefKey.require=\u6D41\u7A0B\u5B9A\u4E49KEY\u4E0D\u80FD\u4E3A\u7A7A
|
||||
processBizRoute.version.require=\u6D41\u7A0B\u5B9A\u4E49\u7248\u672C\u53F7\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
ProcessStart.processDefinitionKey.require=\u6D41\u7A0B\u5B9A\u4E49KEY\u4E0D\u80FD\u4E3A\u7A7A
|
||||
ProcessStart.businessKey.require=\u4E1A\u52A1KEY\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
|
@ -1,110 +1,22 @@
|
|||
#\u7E41\u4F53\u4E2D\u6587
|
||||
id.require=ID\u4E0D\u80FD\u70BA\u7A7A
|
||||
id.null=ID\u5FC5\u9808\u70BA\u7A7A
|
||||
pid.require=\u4E0A\u7D1AID\uFF0C\u4E0D\u80FD\u70BA\u7A7A
|
||||
sort.number=\u6392\u5E8F\u503C\u4E0D\u80FD\u5C0F\u65BC0
|
||||
#\u7B80\u4F53\u4E2D\u6587
|
||||
id.require=ID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
id.null=ID\u5FC5\u987B\u4E3A\u7A7A
|
||||
|
||||
sysparams.paramcode.require=\u53C3\u6578\u7DE8\u78BC\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysparams.paramvalue.require=\u53C3\u6578\u503C\u4E0D\u80FD\u70BA\u7A7A
|
||||
sort.number=\u6392\u5E8F\u503C\u4E0D\u80FD\u5C0F\u4E8E0
|
||||
|
||||
sysuser.username.require=\u7528\u6236\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysuser.password.require=\u5BC6\u78BC\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysuser.realname.require=\u59D3\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysuser.gender.range=\u6027\u5225\u53D6\u503C\u7BC4\u570D0~2
|
||||
sysuser.email.require=\u90F5\u7BB1\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysuser.email.error=\u90F5\u7BB1\u683C\u5F0F\u4E0D\u6B63\u78BA
|
||||
sysuser.mobile.require=\u624B\u6A5F\u865F\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysuser.deptId.require=\u90E8\u9580\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysuser.superadmin.range=\u8D85\u7D1A\u7BA1\u7406\u54E1\u53D6\u503C\u7BC4\u570D0~1
|
||||
sysuser.status.range=\u72C0\u614B\u53D6\u503C\u7BC4\u570D0~1
|
||||
sysuser.captcha.require=\u9A57\u8B49\u78BC\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysuser.uuid.require=\u552F\u4E00\u6A19\u8B58\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysdict.type.require=\u5B57\u5178\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.name.require=\u5B57\u5178\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.label.require=\u5B57\u5178\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysmenu.pid.require=\u8ACB\u9078\u64C7\u4E0A\u7D1A\u83DC\u55AE
|
||||
sysmenu.name.require=\u83DC\u55AE\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysmenu.type.range=\u83DC\u55AE\u985E\u578B\u53D6\u503C\u7BC4\u570D0~1
|
||||
sysmenu.openstyle.range=\u83DC\u55AE\u6253\u958B\u65B9\u5F0F\u53D6\u503C\u7BC4\u570D0~1
|
||||
sysparams.paramcode.require=\u53C2\u6570\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.paramvalue.require=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysdept.pid.require=\u8ACB\u9078\u64C7\u4E0A\u7D1A\u90E8\u9580
|
||||
sysdept.name.require=\u90E8\u9580\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
sysrole.name.require=\u89D2\u8272\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
sysdict.type.require=\u5B57\u5178\u985E\u578B\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysdict.name.require=\u5B57\u5178\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysdict.label.require=\u5B57\u5178\u6A19\u7C64\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
schedule.status.range=\u72C0\u614B\u53D6\u503C\u7BC4\u570D0~1
|
||||
schedule.cron.require=cron\u8868\u9054\u5F0F\u4E0D\u80FD\u70BA\u7A7A
|
||||
schedule.bean.require=bean\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
oss.type.range=\u985E\u578B\u53D6\u503C\u7BC4\u570D1~5
|
||||
|
||||
aliyun.accesskeyid.require=\u963F\u91CC\u96F2AccessKeyId\u4E0D\u80FD\u70BA\u7A7A
|
||||
aliyun.accesskeysecret.require=\u963F\u91CC\u96F2AccessKeySecret\u4E0D\u80FD\u70BA\u7A7A
|
||||
aliyun.signname.require=\u963F\u91CC\u96F2\u77ED\u4FE1\u7C3D\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
aliyun.templatecode.require=\u963F\u91CC\u96F2\u77ED\u4FE1\u6A21\u677F\u4E0D\u80FD\u70BA\u7A7A
|
||||
aliyun.domain.require=\u963F\u91CC\u96F2\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
aliyun.domain.url=\u963F\u91CC\u96F2\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA
|
||||
aliyun.endPoint.require=\u963F\u91CC\u96F2EndPoint\u4E0D\u80FD\u70BA\u7A7A
|
||||
aliyun.bucketname.require=\u963F\u91CC\u96F2BucketName\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
qcloud.appid.require=\u9A30\u8A0A\u96F2AppId\u4E0D\u80FD\u70BA\u7A7A
|
||||
qcloud.appkey.require=\u9A30\u8A0A\u96F2AppKey\u4E0D\u80FD\u70BA\u7A7A
|
||||
qcloud.secretId.require=\u9A30\u8A0A\u96F2SecretId\u4E0D\u80FD\u70BA\u7A7A
|
||||
qcloud.secretkey.require=\u9A30\u8A0A\u96F2SecretKey\u4E0D\u80FD\u70BA\u7A7A
|
||||
qcloud.signname.require=\u9A30\u8A0A\u96F2\u77ED\u4FE1\u7C3D\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
qcloud.templateid.require=\u9A30\u8A0A\u96F2\u77ED\u4FE1\u6A21\u677FID\u4E0D\u80FD\u70BA\u7A7A
|
||||
qcloud.domain.require=\u9A30\u8A0A\u96F2\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
qcloud.domain.url=\u9A30\u8A0A\u96F2\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA
|
||||
qcloud.bucketname.require=\u9A30\u8A0A\u96F2BucketName\u4E0D\u80FD\u70BA\u7A7A
|
||||
qcloud.region.require=\u6240\u5C6C\u5730\u5340\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
qiniu.domain.require=\u4E03\u725B\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
qiniu.domain.url=\u4E03\u725B\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA
|
||||
qiniu.accesskey.require=\u4E03\u725BAccessKey\u4E0D\u80FD\u70BA\u7A7A
|
||||
qiniu.secretkey.require=\u4E03\u725BSecretKey\u4E0D\u80FD\u70BA\u7A7A
|
||||
qiniu.bucketname.require=\u4E03\u725B\u7A7A\u9593\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
qiniu.templateId.require=\u4E03\u725B\u6A21\u677FID\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
fastdfs.domain.require=FastDFS\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
fastdfs.domain.url=FastDFS\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA
|
||||
|
||||
local.domain.require=\u672C\u5730\u4E0A\u50B3\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A
|
||||
local.domain.url=\u672C\u5730\u4E0A\u50B3\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA
|
||||
local.path.url=\u5B58\u5132\u76EE\u9304\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
minio.endPoint.require=Minio EndPoint\u4E0D\u80FD\u70BA\u7A7A
|
||||
minio.accesskey.require=Minio AccessKey\u4E0D\u80FD\u70BA\u7A7A
|
||||
minio.secretkey.require=Minio SecretKey\u4E0D\u80FD\u70BA\u7A7A
|
||||
minio.bucketname.require=Minio BucketName\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
sms.platform.range=\u5E73\u53F0\u985E\u578B\u53D6\u503C\u7BC4\u570D1~2
|
||||
|
||||
email.smtp.require=SMTP\u4E0D\u80FD\u70BA\u7A7A
|
||||
email.port.require=\u7AEF\u53E3\u865F\u4E0D\u80FD\u70BA\u7A7A
|
||||
email.username.require=\u90F5\u7BB1\u8CEC\u865F\u4E0D\u80FD\u70BA\u7A7A
|
||||
email.password.require=\u90F5\u7BB1\u5BC6\u78BC\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
mail.name.require=\u6A21\u677F\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
|
||||
mail.subject.require=\u90F5\u4EF6\u4E3B\u984C\u4E0D\u80FD\u70BA\u7A7A
|
||||
mail.content.require=\u90F5\u4EF6\u6B63\u6587\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
model.name.require=\u6A21\u578B\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
|
||||
model.key.require=\u6A21\u578B\u6A19\u8B58\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
news.title.require=\u6A19\u984C\u4E0D\u80FD\u70BA\u7A7A
|
||||
news.content.require=\u5167\u5BB9\u4E0D\u80FD\u70BA\u7A7A
|
||||
news.pubdate.require=\u767C\u4F48\u6642\u9593\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
region.id.require=\u5340\u57DF\u6A19\u8B58\u4E0D\u80FD\u70BA\u7A7A
|
||||
region.pid.require=\u4E0A\u7D1A\u5340\u57DF\u4E0D\u80FD\u70BA\u7A7A
|
||||
region.name.require=\u5340\u57DF\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
processBizRoute.procDefId.require=\u6D41\u7A0B\u5B9A\u7FA9ID\u4E0D\u80FD\u70BA\u7A7A
|
||||
processBizRoute.bizRoute.require=\u696D\u52D9\u8DEF\u7531\u4E0D\u80FD\u70BA\u7A7A
|
||||
processBizRoute.procDefKey.require=\u6D41\u7A0B\u5B9A\u7FA9KEY\u4E0D\u80FD\u70BA\u7A7A
|
||||
processBizRoute.version.require=\u6D41\u7A0B\u5B9A\u7FA9\u7248\u672C\u865F\u4E0D\u80FD\u70BA\u7A7A
|
||||
|
||||
ProcessStart.processDefinitionKey.require=\u6D41\u7A0B\u5B9A\u7FA9KEY\u4E0D\u80FD\u70BA\u7A7A
|
||||
ProcessStart.businessKey.require=\u696D\u52D9KEY\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysuser.username.require=\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.realname.require=\u59D3\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.gender.range=\u6027\u522B\u53D6\u503C\u8303\u56F40~2
|
||||
sysuser.email.error=\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E
|
||||
sysuser.deptId.require=\u90E8\u95E8\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.status.range=\u72B6\u6001\u53D6\u503C\u8303\u56F40~1
|
||||
sysuser.captcha.require=\u9A8C\u8BC1\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.uuid.require=\u552F\u4E00\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
|
|
|||
|
|
@ -3,48 +3,4 @@
|
|||
|
||||
<mapper namespace="xiaozhi.modules.sys.dao.SysUserDao">
|
||||
|
||||
<select id="getList" resultType="xiaozhi.modules.sys.entity.SysUserEntity">
|
||||
select t1.*, (select t2.name from sys_dept t2 where t2.id=t1.dept_id) deptName
|
||||
from sys_user t1 where t1.super_admin = 0
|
||||
<if test="username != null and username.trim() != ''">
|
||||
and t1.username like #{username}
|
||||
</if>
|
||||
<if test="deptId != null and deptId.trim() != ''">
|
||||
and t1.dept_id = #{deptId}
|
||||
</if>
|
||||
<if test="gender != null and gender.trim() != ''">
|
||||
and t1.gender = #{gender}
|
||||
</if>
|
||||
<if test="deptIdList != null">
|
||||
and t1.dept_id in
|
||||
<foreach item="id" collection="deptIdList" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="xiaozhi.modules.sys.entity.SysUserEntity">
|
||||
select t1.*, (select t2.name from sys_dept t2 where t2.id=t1.dept_id) deptName from sys_user t1
|
||||
where t1.id = #{value}
|
||||
</select>
|
||||
|
||||
<select id="getByUsername" resultType="xiaozhi.modules.sys.entity.SysUserEntity">
|
||||
select * from sys_user where username = #{value}
|
||||
</select>
|
||||
|
||||
<update id="updatePassword">
|
||||
update sys_user set password = #{newPassword} where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getCountByDeptId" resultType="int">
|
||||
select count(*) from sys_user where dept_id = #{value}
|
||||
</select>
|
||||
|
||||
<select id="getUserIdListByDeptId" resultType="Long">
|
||||
select id from sys_user where dept_id in
|
||||
<foreach item="deptId" collection="list" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
267
main/manager-web/package-lock.json
generated
267
main/manager-web/package-lock.json
generated
|
|
@ -8,14 +8,14 @@
|
|||
"name": "xiaozhi",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"axios": "^1.8.1",
|
||||
"element-ui": "^2.15.14",
|
||||
"flyio": "^0.6.14",
|
||||
"normalize.css": "^8.0.1",
|
||||
"vue": "^2.6.14",
|
||||
"vue-axios": "^3.5.2",
|
||||
"vue-router": "^3.6.5",
|
||||
"vuex": "^3.6.2"
|
||||
"vuex": "^3.6.2",
|
||||
"xiaozhi": "file:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-router": "~5.0.0",
|
||||
|
|
@ -325,48 +325,6 @@
|
|||
"@parcel/watcher-win32-x64": "2.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-android-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-darwin-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-darwin-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz",
|
||||
|
|
@ -388,216 +346,6 @@
|
|||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-freebsd-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz",
|
||||
"integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz",
|
||||
"integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm64-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz",
|
||||
"integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm64-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-x64-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz",
|
||||
"integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-x64-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-ia32": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz",
|
||||
"integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz",
|
||||
"integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@polka/url": {
|
||||
"version": "1.0.0-next.28",
|
||||
"resolved": "https://registry.npmmirror.com/@polka/url/-/url-1.0.0-next.28.tgz",
|
||||
|
|
@ -1777,6 +1525,7 @@
|
|||
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.8.2.tgz",
|
||||
"integrity": "sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.0",
|
||||
|
|
@ -3488,6 +3237,7 @@
|
|||
"resolved": "https://registry.npmmirror.com/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
||||
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.6",
|
||||
|
|
@ -3934,6 +3684,7 @@
|
|||
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.2.tgz",
|
||||
"integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
|
|
@ -4256,6 +4007,7 @@
|
|||
"resolved": "https://registry.npmmirror.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.3"
|
||||
},
|
||||
|
|
@ -7031,7 +6783,8 @@
|
|||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/pseudomap": {
|
||||
"version": "1.0.2",
|
||||
|
|
@ -9405,6 +9158,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xiaozhi": {
|
||||
"resolved": "",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/y18n": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/y18n/-/y18n-5.0.8.tgz",
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@
|
|||
"build": "vue-cli-service build"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.8.1",
|
||||
"element-ui": "^2.15.14",
|
||||
"flyio": "^0.6.14",
|
||||
"normalize.css": "^8.0.1",
|
||||
"vue": "^2.6.14",
|
||||
"vue-axios": "^3.5.2",
|
||||
"vue-router": "^3.6.5",
|
||||
"vuex": "^3.6.2"
|
||||
"vuex": "^3.6.2",
|
||||
"xiaozhi": "file:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-router": "~5.0.0",
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<title>小智-智控台</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,13 @@ import user from './module/user.js'
|
|||
|
||||
/**
|
||||
* 接口地址
|
||||
* 在开发阶段,如果地址写的是相对路径,请与vue.config.js的devServer配置相结合,方便跨域请求
|
||||
* 当前8002端口接口还没开发完成,暂时用 apifoxmock 接口代替
|
||||
* 如果你想调用8002端口,就用'/xiaozhi-esp32-api/api/v1',请与vue.config.js的devServer配置相结合,方便跨域请求
|
||||
*
|
||||
*/
|
||||
const DEV_API_SERVICE = 'https://apifoxmock.com/m1/5931378-5618560-default'
|
||||
// 8002开发完成完成后使用这个
|
||||
// const DEV_API_SERVICE = '/xiaozhi-esp32-api'
|
||||
|
||||
/**
|
||||
* 根据开发环境返回接口url
|
||||
|
|
|
|||
|
|
@ -23,21 +23,27 @@ function sendRequest() {
|
|||
_data: {},
|
||||
_header: {'content-type': 'application/json; charset=utf-8'},
|
||||
_url: '',
|
||||
_responseType: undefined, // 新增响应类型字段
|
||||
'send'() {
|
||||
this._header.token = localStorage.getItem(Constant.STORAGE_KEY.TOKEN)
|
||||
|
||||
// 打印请求信息
|
||||
fly.request(this._url, this._data, {
|
||||
method: this._method,
|
||||
headers: this._header
|
||||
headers: this._header,
|
||||
responseType: this._responseType
|
||||
}).then((res) => {
|
||||
const error = httpHandlerError(res, this._failCallback)
|
||||
const error = httpHandlerError(res, this._failCallback);
|
||||
if (error) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this._sucCallback) {
|
||||
this._sucCallback(res)
|
||||
}
|
||||
}).catch((res) => {
|
||||
console.log(1111, res)
|
||||
// 打印失败响应
|
||||
console.log(res)
|
||||
httpHandlerError(res, this._failCallback)
|
||||
})
|
||||
return this
|
||||
|
|
@ -75,6 +81,11 @@ function sendRequest() {
|
|||
},
|
||||
'async'(flag) {
|
||||
this.async = flag
|
||||
},
|
||||
// 新增类型设置方法
|
||||
'type'(responseType) {
|
||||
this._responseType = responseType;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -84,11 +95,14 @@ function sendRequest() {
|
|||
* callBack 回调函数
|
||||
* errTip 自定义错误信息
|
||||
*/
|
||||
// 在错误处理函数中添加日志
|
||||
function httpHandlerError(info, callBack) {
|
||||
|
||||
/** 请求成功,退出该函数 可以根据项目需求来判断是否请求成功。这里判断的是status为200的时候是成功 */
|
||||
let networkError = false
|
||||
if (info.status === 200) {
|
||||
if (info.data.code === 'success' || info.data.code === 0) {
|
||||
|
||||
if (info.data.code === 'success' || info.data.code === 0 || info.data.code === undefined) {
|
||||
return networkError
|
||||
}else if (info.data.code === 401) {
|
||||
goToPage(Constant.PAGE.LOGIN, true)
|
||||
|
|
|
|||
|
|
@ -43,4 +43,66 @@ export default {
|
|||
})
|
||||
}).send()
|
||||
},
|
||||
// 解绑设备
|
||||
unbindDevice(device_id, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/device/unbind/${device_id}`)
|
||||
.method('PUT')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail(() => {
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.unbindDevice(device_id, callback);
|
||||
});
|
||||
}).send()
|
||||
},
|
||||
// 绑定设备
|
||||
bindDevice(deviceCode, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/device/bind/${deviceCode}`)
|
||||
.method('POST')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('绑定设备失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.bindDevice(deviceCode, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
// 获取验证码
|
||||
getCaptcha(uuid, callback) {
|
||||
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/captcha?uuid=${uuid}`)
|
||||
.method('GET')
|
||||
.type('blob')
|
||||
.header({
|
||||
'Content-Type': 'image/gif',
|
||||
'Pragma': 'No-cache',
|
||||
'Cache-Control': 'no-cache'
|
||||
})
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => { // 添加错误参数
|
||||
|
||||
}).send()
|
||||
},
|
||||
// 注册账号
|
||||
register(registerForm, callback) {
|
||||
RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/register`).method('POST')
|
||||
.data(registerForm)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail(() => {
|
||||
}).send()
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import Vue from 'vue'
|
|||
import VueRouter from 'vue-router'
|
||||
import Welcome from '../views/welcome.vue'
|
||||
import Login from '../views/login.vue'
|
||||
import Register from '@/views/register.vue'
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
|
|
@ -9,7 +10,7 @@ const routes = [
|
|||
{
|
||||
path: '/',
|
||||
name: 'welcome',
|
||||
component: Welcome
|
||||
component: Login
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
|
|
@ -27,7 +28,17 @@ const routes = [
|
|||
component: function () {
|
||||
return import(/* webpackChunkName: "about" */ '../views/home.vue')
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
name: 'Register',
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: function () {
|
||||
return import(/* webpackChunkName: "about" */ '../views/register.vue')
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
const HAVE_NO_RESULT = '暂无'
|
||||
export default {
|
||||
HAVE_NO_RESULT, // 项目的配置信息
|
||||
PAGE: {
|
||||
LOGIN: '/login',
|
||||
},
|
||||
STORAGE_KEY: {
|
||||
TOKEN: 'TOKEN',
|
||||
PUBLIC_KEY: 'PUBLIC_KEY',
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@
|
|||
</div>
|
||||
<div style="display: flex;align-items: center;gap: 8px;margin-top: 10px">
|
||||
<div class="serach-box">
|
||||
<el-input placeholder="输入名称搜索.." v-model="serach" style="border: none; background: transparent;" />
|
||||
<el-input placeholder="输入名称搜索.." v-model="serach" style="border: none; background: transparent;" @keyup.enter.native="handleSearch" />
|
||||
<img src="@/assets/home/search.png" alt=""
|
||||
style="width: 12px;height: 12px;margin-right: 11px;cursor: pointer;" />
|
||||
style="width: 12px;height: 12px;margin-right: 11px;cursor: pointer;" @click="handleSearch" />
|
||||
</div>
|
||||
<img src="@/assets/home/avatar.png" alt="" style="width: 21px;height: 21px;" />
|
||||
<div class="user-info">
|
||||
|
|
@ -56,16 +56,16 @@
|
|||
</div>
|
||||
</div>
|
||||
<div
|
||||
style="display: flex;flex-wrap: wrap;margin-top: 15px;gap: 15px;justify-content: space-between;box-sizing: border-box;">
|
||||
<div class="device-item" v-for="(item,index) in deviceList" :key="index">
|
||||
<div style="display: flex;justify-content: space-between;">
|
||||
style="display: flex;flex-wrap: wrap;margin-top: 15px;gap: 15px;justify-content: flex-start;box-sizing: border-box;">
|
||||
<div class="device-item" v-for="(item,index) in filteredDeviceList" :key="index">
|
||||
<div style="display: flex;justify-content: space-between; align-items: center; ">
|
||||
<div style="font-weight: 700;font-size: 18px;text-align: left;color: #3d4566;">
|
||||
<!-- CC:ba:97:11:a6:ac-->
|
||||
{{item.list[0]?.mac_address}}
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: flex;align-items: center;">
|
||||
<img src="@/assets/home/delete.png" alt=""
|
||||
style="width: 18px;height: 18px;margin-right: 8px;" />
|
||||
style="width: 18px;height: 18px;margin-right: 8px;" @click="unbindDevice(item.list[0]?.id)" />
|
||||
<img src="@/assets/home/info.png" alt="" style="width: 18px;height: 18px;" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -210,7 +210,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div style="display: flex;margin: 0 20px;gap: 10px;">
|
||||
<div class="dialog-btn" @click="addDeviceDialogVisible=false">确定</div>
|
||||
<div class="dialog-btn" @click="addDevice">确定</div>
|
||||
<div class="dialog-btn"
|
||||
style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;"
|
||||
@click="addDeviceDialogVisible=false">
|
||||
|
|
@ -229,10 +229,12 @@ export default {
|
|||
name: 'home',
|
||||
data() {
|
||||
return {
|
||||
serach: '',
|
||||
serach: '', // 搜索框输入内容
|
||||
deviceList: [], // 原始设备列表
|
||||
filteredDeviceList: [], // 过滤后的设备列表
|
||||
switchValue: false,
|
||||
addDeviceDialogVisible: false,
|
||||
deviceCode: "",
|
||||
deviceCode: "", // 设备验证码
|
||||
settingDevice: false,
|
||||
form: {
|
||||
name: "",
|
||||
|
|
@ -250,8 +252,7 @@ export default {
|
|||
}],
|
||||
userInfo: {
|
||||
mobile: '' // 初始化用户信息
|
||||
},
|
||||
deviceList:[]
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -270,14 +271,68 @@ export default {
|
|||
// 获取已绑设备
|
||||
getList(){
|
||||
Api.user.getHomeList(({data})=>{
|
||||
console.log(data.data)
|
||||
this.deviceList = data.data
|
||||
this.deviceList = data.data; // 保存原始设备列表
|
||||
this.filteredDeviceList = data.data; // 初始化过滤后的设备列表
|
||||
})
|
||||
},
|
||||
// 处理搜索
|
||||
handleSearch() {
|
||||
if (this.serach.trim() === '') {
|
||||
// 如果搜索框为空,显示全部设备
|
||||
this.filteredDeviceList = this.deviceList;
|
||||
} else {
|
||||
// 过滤设备列表
|
||||
this.filteredDeviceList = this.deviceList.filter(device => {
|
||||
return (
|
||||
device.list[0]?.mac_address?.includes(this.serach) || // 匹配MAC地址
|
||||
device.list[0]?.device_type?.includes(this.serach) || // 匹配设备型号
|
||||
device.list[0]?.app_version?.includes(this.serach) // 匹配APP版本
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
// 解绑设备
|
||||
unbindDevice(device_id) {
|
||||
this.$confirm('确定要解绑该设备吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 调用解绑设备的接口
|
||||
Api.user.unbindDevice(device_id, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('解绑成功');
|
||||
this.getList();
|
||||
} else {
|
||||
this.$message.error(data.msg || '解绑失败');
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
this.$message.info('已取消解绑');
|
||||
});
|
||||
},
|
||||
// 添加设备
|
||||
addDevice() {
|
||||
if (!this.deviceCode) {
|
||||
this.$message.warning('请输入设备验证码');
|
||||
return;
|
||||
}
|
||||
|
||||
Api.user.bindDevice(this.deviceCode, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('设备绑定成功');
|
||||
this.addDeviceDialogVisible = false;
|
||||
this.getList(); // 刷新设备列表
|
||||
} else {
|
||||
this.$message.error(data.msg || '设备绑定失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchUserInfo(); // 组件加载时获取用户信息
|
||||
this.getList()
|
||||
this.getList(); // 初始化设备列表
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -25,15 +25,23 @@
|
|||
</div>
|
||||
<div class="input-box">
|
||||
<img src="@/assets/login/password.png" alt="" class="input-icon"/>
|
||||
<el-input v-model="form.password" placeholder="请输入密码"/>
|
||||
<el-input v-model="form.password" type="password" placeholder="请输入密码"/>
|
||||
</div>
|
||||
<div class="input-box">
|
||||
<div style="display: flex; align-items: center; margin-top: 20px; width: 100%; gap: 10px;">
|
||||
<div class="input-box" style="width: calc(100% - 130px); margin-top: 0;">
|
||||
<img src="@/assets/login/shield.png" alt="" class="input-icon"/>
|
||||
<el-input v-model="form.captcha" placeholder="请输入验证码"/>
|
||||
<el-input v-model="form.captcha" placeholder="请输入验证码" style="flex: 1;"/>
|
||||
</div>
|
||||
<img v-if="captchaUrl"
|
||||
:src="captchaUrl"
|
||||
alt="验证码"
|
||||
style="width: 150px; height: 40px; cursor: pointer;"
|
||||
@click="fetchCaptcha"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
style="font-weight: 400;font-size: 14px;text-align: left;color: #5778ff;display: flex;justify-content: space-between;margin-top: 20px;">
|
||||
<div style="cursor: pointer;">新用户注册</div>
|
||||
<div style="cursor: pointer;" @click="goToRegister">新用户注册</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-btn" @click="login">登陆</div>
|
||||
|
|
@ -55,8 +63,9 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import Api from '@/apis/api'
|
||||
import {isNull, showDanger, showSuccess, goToPage} from '@/utils'
|
||||
import {getUUID, goToPage, showDanger, showSuccess} from '@/utils'
|
||||
import Api from '@/apis/api';
|
||||
|
||||
|
||||
export default {
|
||||
name: 'login',
|
||||
|
|
@ -66,162 +75,63 @@ export default {
|
|||
form: {
|
||||
username: '',
|
||||
password: '',
|
||||
captcha: ''
|
||||
}
|
||||
captcha: '',
|
||||
captchaId: ''
|
||||
},
|
||||
captchaUuid: '',
|
||||
captchaUrl: ''
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchCaptcha();
|
||||
},
|
||||
methods: {
|
||||
login() {
|
||||
if (isNull(this.form.username)) {
|
||||
fetchCaptcha() {
|
||||
this.captchaUuid = getUUID();
|
||||
|
||||
Api.user.getCaptcha(this.captchaUuid, (res) => {
|
||||
if (res.status === 200) {
|
||||
const blob = new Blob([res.data], {type: res.data.type});
|
||||
this.captchaUrl = URL.createObjectURL(blob);
|
||||
|
||||
} else {
|
||||
console.error('验证码加载异常:', error);
|
||||
showDanger('验证码加载失败,点击刷新')
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
async login() {
|
||||
if (!this.form.username.trim()) { // 替换isNull校验
|
||||
showDanger('用户名不能为空')
|
||||
return
|
||||
}
|
||||
if (isNull(this.form.password)) {
|
||||
if (!this.form.password.trim()) { // 替换isNull校验
|
||||
showDanger('密码不能为空')
|
||||
return
|
||||
}
|
||||
if (isNull(this.form.captcha)) {
|
||||
if (!this.form.captcha.trim()) { // 替换isNull校验
|
||||
showDanger('验证码不能为空')
|
||||
return
|
||||
}
|
||||
|
||||
this.form.captchaId = this.captchaUuid
|
||||
Api.user.login(this.form, ({data}) => {
|
||||
console.log(data)
|
||||
showSuccess('登陆成功!')
|
||||
goToPage('/home')
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.fetchCaptcha()
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
goToRegister() {
|
||||
goToPage('/register')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.welcome {
|
||||
min-width: 1200px;
|
||||
min-height: 675px;
|
||||
height: 100vh;
|
||||
background-image: url("@/assets/login/background.png");
|
||||
background-size: cover;
|
||||
/* 确保背景图像覆盖整个元素 */
|
||||
background-position: center;
|
||||
/* 从顶部中心对齐 */
|
||||
-webkit-background-size: cover;
|
||||
/* 兼容老版本WebKit浏览器 */
|
||||
-o-background-size: cover;
|
||||
/* 兼容老版本Opera浏览器 */
|
||||
}
|
||||
|
||||
.login-text {
|
||||
font-weight: 700;
|
||||
font-size: 32px;
|
||||
text-align: left;
|
||||
color: #3d4566;
|
||||
}
|
||||
|
||||
.login-welcome {
|
||||
font-weight: 400;
|
||||
font-size: 9px;
|
||||
text-align: left;
|
||||
color: #818cae;
|
||||
align-self: flex-end;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
.login-box {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
right: 18%;
|
||||
background-color: #fff;
|
||||
border-radius: 20px;
|
||||
padding: 35px 0;
|
||||
width: 450px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.el-dropdown-link {
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
text-align: left;
|
||||
color: #979db1;
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
width: 19px;
|
||||
height: 22px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
height: 35px;
|
||||
background: #5778ff;
|
||||
border-radius: 10px;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
line-height: 35px;
|
||||
margin: 35px 15px 15px;
|
||||
}
|
||||
|
||||
.code-send {
|
||||
width: 70px;
|
||||
height: 32px;
|
||||
border-radius: 10px;
|
||||
background: #e6ebff;
|
||||
line-height: 32px;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #5778ff;
|
||||
flex-shrink: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
align-items: center;
|
||||
border-radius: 10px;
|
||||
background: #f6f8fb;
|
||||
border: 1px solid #e4e6ef;
|
||||
height: 40px;
|
||||
padding: 0 15px;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
::v-deep {
|
||||
.el-tabs__nav-wrap::after {
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.el-tabs__nav-wrap::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background-color: #e4e7ed;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.el-tabs__item {
|
||||
height: 65px;
|
||||
line-height: 65px;
|
||||
font-weight: 700;
|
||||
color: #3d4566;
|
||||
}
|
||||
|
||||
.el-tabs__item.is-active {
|
||||
color: #5778ff;
|
||||
}
|
||||
|
||||
.el-tabs__nav-scroll {
|
||||
padding: 0 30px;
|
||||
}
|
||||
|
||||
.el-input__inner {
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
height: 56px;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
@import './auth.scss'; // 添加这行引用
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,27 @@
|
|||
import asyncio
|
||||
import sys
|
||||
import signal
|
||||
from config.settings import load_config, check_config_file
|
||||
from core.websocket_server import WebSocketServer
|
||||
from core.utils.util import check_ffmpeg_installed
|
||||
|
||||
TAG = __name__
|
||||
|
||||
async def wait_for_exit():
|
||||
"""Windows 和 Linux 兼容的退出监听"""
|
||||
loop = asyncio.get_running_loop()
|
||||
stop_event = asyncio.Event()
|
||||
|
||||
if sys.platform == "win32":
|
||||
# Windows: 用 sys.stdin.read() 监听 Ctrl + C
|
||||
await loop.run_in_executor(None, sys.stdin.read)
|
||||
else:
|
||||
# Linux/macOS: 用 signal 监听 Ctrl + C
|
||||
def stop():
|
||||
stop_event.set()
|
||||
loop.add_signal_handler(signal.SIGINT, stop)
|
||||
loop.add_signal_handler(signal.SIGTERM, stop) # 支持 kill 进程
|
||||
await stop_event.wait()
|
||||
|
||||
async def main():
|
||||
check_config_file()
|
||||
|
|
@ -16,11 +33,19 @@ async def main():
|
|||
ws_task = asyncio.create_task(ws_server.start())
|
||||
|
||||
try:
|
||||
# 等待 WebSocket 服务器运行
|
||||
await ws_task
|
||||
await wait_for_exit() # 监听退出信号
|
||||
except asyncio.CancelledError:
|
||||
print("任务被取消,清理资源中...")
|
||||
finally:
|
||||
ws_task.cancel()
|
||||
|
||||
try:
|
||||
await ws_task
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
print("服务器已关闭,程序退出。")
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
asyncio.run(main())
|
||||
except KeyboardInterrupt:
|
||||
print("手动中断,程序终止。")
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ log:
|
|||
data_dir: data
|
||||
iot:
|
||||
Speaker:
|
||||
volume: 100
|
||||
# 设置esp32的音量,范围0-100
|
||||
volume: 80
|
||||
xiaozhi:
|
||||
type: hello
|
||||
version: 1
|
||||
|
|
@ -64,20 +65,47 @@ CMD_exit:
|
|||
|
||||
# 具体处理时选择的模块(The module selected for specific processing)
|
||||
selected_module:
|
||||
ASR: FunASR
|
||||
# 语音活动检测模块,默认使用SileroVAD模型
|
||||
VAD: SileroVAD
|
||||
# 语音识别模块,默认使用FunASR本地模型
|
||||
ASR: FunASR
|
||||
# 将根据配置名称对应的type调用实际的LLM适配器
|
||||
LLM: ChatGLMLLM
|
||||
# TTS将根据配置名称对应的type调用实际的TTS适配器
|
||||
TTS: EdgeTTS
|
||||
Memory: mem0ai
|
||||
# 记忆模块,默认不开启记忆;如果想使用超长记忆,推荐使用mem0ai;如果注重隐私,请使用本地的mem_local_short
|
||||
Memory: nomem
|
||||
# 意图识别模块,默认不开启。开启后,可以播放音乐、控制音量、识别退出指令
|
||||
# 意图识别使用intent_llm,优点:通用性强,缺点:增加串行前置意图识别模块,会增加处理时间
|
||||
# 意图识别使用function_call,缺点:需要所选择的LLM支持function_call,优点:按需调用工具、速度快
|
||||
# 如果意图识别设置成 function_call,建议把LLM设置成:DoubaoLLM,使用的具体model_name是:doubao-pro-32k-functioncall-241028
|
||||
Intent: nointent
|
||||
|
||||
# 意图识别,是用于理解用户意图的模块,例如:播放音乐
|
||||
Intent:
|
||||
# 不使用意图识别
|
||||
nointent:
|
||||
# 不需要动
|
||||
type: nointent
|
||||
intent_llm:
|
||||
# 不需要动
|
||||
type: intent_llm
|
||||
function_call:
|
||||
# 不需要动
|
||||
type: nointent
|
||||
|
||||
Memory:
|
||||
mem0ai:
|
||||
type: mem0ai
|
||||
# https://app.mem0.ai/dashboard/api-keys
|
||||
# 每月有1000次免费调用
|
||||
api_key: 填写你申请的key
|
||||
api_key: m0-sLgoEcHDl35WQttEMpFSr3F1FA75nvozKEhb7eh5
|
||||
nomem:
|
||||
# 不想使用记忆功能,可以使用nomem
|
||||
type: nomem
|
||||
mem_local_short:
|
||||
# 本地记忆功能,通过selected_module的llm总结,数据保存在本地,不会上传到服务器
|
||||
type: mem_local_short
|
||||
|
||||
ASR:
|
||||
FunASR:
|
||||
|
|
@ -105,6 +133,16 @@ LLM:
|
|||
base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
|
||||
model_name: qwen-turbo
|
||||
api_key: 你的deepseek web key
|
||||
DoubaoLLM:
|
||||
# 定义LLM API类型
|
||||
type: openai
|
||||
# 先开通服务,打开以下网址,开通的服务搜索Doubao-pro-32k,开通它
|
||||
# 开通改地址:https://console.volcengine.com/ark/region:ark+cn-beijing/openManagement?LLM=%7B%7D&OpenTokenDrawer=false
|
||||
# 免费额度500000token
|
||||
# 开通后,进入这里获取密钥:https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey?apikey=%7B%7D
|
||||
base_url: https://ark.cn-beijing.volces.com/api/v3
|
||||
model_name: doubao-pro-32k-functioncall-241028
|
||||
api_key: 你的doubao web key
|
||||
DeepSeekLLM:
|
||||
# 定义LLM API类型
|
||||
type: openai
|
||||
|
|
@ -119,7 +157,7 @@ LLM:
|
|||
# 可在这里找到你的api key https://bigmodel.cn/usercenter/proj-mgmt/apikeys
|
||||
model_name: glm-4-flash
|
||||
url: https://open.bigmodel.cn/api/paas/v4/
|
||||
api_key: 你自己的key
|
||||
api_key: d796742def124203a77940bc2cca3273.kVHYy17ZWTUQWfst
|
||||
OllamaLLM:
|
||||
# 定义LLM API类型
|
||||
type: ollama
|
||||
|
|
@ -143,8 +181,9 @@ LLM:
|
|||
CozeLLM:
|
||||
# 定义LLM API类型
|
||||
type: coze
|
||||
bot_id: 你的bot_id
|
||||
user_id: 你的user_id
|
||||
# bot_id和user_id的内容写在引号之内
|
||||
bot_id: "你的bot_id"
|
||||
user_id: "你的user_id"
|
||||
personal_access_token: 你的coze个人令牌
|
||||
LMStudioLLM:
|
||||
# 定义LLM API类型
|
||||
|
|
@ -258,6 +297,21 @@ TTS:
|
|||
parallel_infer: true
|
||||
repetition_penalty: 1.35
|
||||
aux_ref_audio_paths: []
|
||||
GPT_SOVITS_V3:
|
||||
type: gpt_sovits_v3
|
||||
url: "http://127.0.0.1:9880/tts"
|
||||
output_file: tmp/
|
||||
text_lang: "auto"
|
||||
ref_audio_path: "caixukun.wav"
|
||||
prompt_lang: "zh"
|
||||
prompt_text: ""
|
||||
top_k: 5
|
||||
top_p: 1
|
||||
temperature: 1
|
||||
sample_steps: 16
|
||||
media_type: "wav"
|
||||
streaming_mode: false
|
||||
threshold: 30
|
||||
MinimaxTTS:
|
||||
# Minimax语音合成服务,需要先在minimax平台创建账户充值,并获取登录信息
|
||||
# 平台地址:https://platform.minimaxi.com/
|
||||
|
|
@ -321,7 +375,7 @@ TTS:
|
|||
TTS302AI:
|
||||
# 302AI语音合成服务,需要先在302平台创建账户充值,并获取密钥信息
|
||||
# 获取api_keyn路径:https://dash.302.ai/apis/list
|
||||
# 价格,$35/百万字符。火山原版¥450元/万字符
|
||||
# 价格,$35/百万字符。火山原版¥450元/百万字符
|
||||
type: doubao
|
||||
api_url: https://api.302ai.cn/doubao/tts_hd
|
||||
authorization: "Bearer "
|
||||
|
|
@ -367,18 +421,6 @@ module_test:
|
|||
|
||||
# 本地音乐播放配置
|
||||
music:
|
||||
music_commands:
|
||||
- "来一首歌"
|
||||
- "唱一首歌"
|
||||
- "播放音乐"
|
||||
- "来点音乐"
|
||||
- "背景音乐"
|
||||
- "放首歌"
|
||||
- "播放歌曲"
|
||||
- "来点背景音乐"
|
||||
- "我想听歌"
|
||||
- "我要听歌"
|
||||
- "放点音乐"
|
||||
music_dir: "./music" # 音乐文件存放路径,将从该目录及子目录下搜索音乐文件
|
||||
music_ext: # 音乐文件类型,p3格式效率最高
|
||||
- ".mp3"
|
||||
|
|
|
|||
|
|
@ -4,55 +4,26 @@ from loguru import logger
|
|||
from config.settings import load_config
|
||||
|
||||
def setup_logging():
|
||||
"""
|
||||
从配置文件中读取日志配置,并设置日志输出格式和级别。
|
||||
|
||||
该函数的主要用途是初始化日志系统,配置日志的输出格式、级别以及存储位置。
|
||||
日志可以同时输出到控制台和文件中,方便调试和问题排查。
|
||||
|
||||
返回:
|
||||
logger: 配置好的日志记录器对象。
|
||||
"""
|
||||
# 从配置文件中加载配置
|
||||
"""从配置文件中读取日志配置,并设置日志输出格式和级别"""
|
||||
config = load_config()
|
||||
|
||||
# 获取日志相关的配置项
|
||||
log_config = config["log"]
|
||||
|
||||
# 获取日志格式配置,如果未配置则使用默认格式
|
||||
log_format = log_config.get("log_format", "<green>{time:YY-MM-DD HH:mm:ss}</green>[<light-blue>{extra[tag]}</light-blue>] - <level>{level}</level> - <light-green>{message}</light-green>")
|
||||
|
||||
# 获取文件日志格式配置,如果未配置则使用默认格式
|
||||
log_format_simple = log_config.get("log_format_file", "{time:YYYY-MM-DD HH:mm:ss} - {name} - {level} - {extra[tag]} - {message}")
|
||||
|
||||
# 获取日志级别配置,如果未配置则默认使用 INFO 级别
|
||||
log_level = log_config.get("log_level", "INFO")
|
||||
|
||||
# 获取日志存储目录配置,如果未配置则默认使用 "tmp" 目录
|
||||
log_dir = log_config.get("log_dir", "tmp")
|
||||
|
||||
# 获取日志文件名配置,如果未配置则默认使用 "server.log"
|
||||
log_file = log_config.get("log_file", "server.log")
|
||||
|
||||
# 获取数据存储目录配置,如果未配置则默认使用 "data" 目录
|
||||
data_dir = log_config.get("data_dir", "data")
|
||||
|
||||
# 创建日志目录(如果不存在)
|
||||
os.makedirs(log_dir, exist_ok=True)
|
||||
|
||||
# 创建数据目录(如果不存在)
|
||||
os.makedirs(data_dir, exist_ok=True)
|
||||
|
||||
# 移除默认的日志处理器
|
||||
# 配置日志输出
|
||||
logger.remove()
|
||||
|
||||
# 添加控制台日志处理器
|
||||
# 使用配置的日志格式和级别,将日志输出到控制台
|
||||
# 输出到控制台
|
||||
logger.add(sys.stdout, format=log_format, level=log_level)
|
||||
|
||||
# 添加文件日志处理器
|
||||
# 使用配置的日志格式和级别,将日志输出到指定文件
|
||||
# 输出到文件
|
||||
logger.add(os.path.join(log_dir, log_file), format=log_format_simple, level=log_level)
|
||||
|
||||
# 返回配置好的日志记录器对象
|
||||
return logger
|
||||
|
|
@ -8,71 +8,45 @@ from core.utils.util import get_project_dir
|
|||
from core.utils import llm, tts
|
||||
from core.utils.lock_manager import FileLockManager
|
||||
|
||||
# 定义当前模块的标签,用于日志记录
|
||||
TAG = __name__
|
||||
|
||||
class PrivateConfig:
|
||||
"""
|
||||
设备私有配置管理类。
|
||||
|
||||
该类用于管理设备的私有配置,包括加载、更新、删除配置,以及创建私有模块实例。
|
||||
配置存储在 YAML 文件中,支持多设备配置管理。
|
||||
"""
|
||||
|
||||
def __init__(self, device_id: str, default_config: Dict[str, Any], auth_code_gen=None):
|
||||
"""
|
||||
初始化私有配置管理类。
|
||||
|
||||
Args:
|
||||
device_id (str): 设备唯一标识。
|
||||
default_config (Dict[str, Any]): 默认配置字典。
|
||||
auth_code_gen: 认证码生成器(可选)。
|
||||
"""
|
||||
self.device_id = device_id # 设备唯一标识
|
||||
self.default_config = default_config # 默认配置
|
||||
self.config_path = get_project_dir() + 'data/.private_config.yaml' # 配置文件路径
|
||||
self.logger = setup_logging() # 日志记录器
|
||||
self.private_config = {} # 当前设备的私有配置
|
||||
self.auth_code_gen = auth_code_gen # 认证码生成器
|
||||
self.lock_manager = FileLockManager() # 文件锁管理器,用于并发控制
|
||||
self.device_id = device_id
|
||||
self.default_config = default_config
|
||||
self.config_path = get_project_dir() + 'data/.private_config.yaml'
|
||||
self.logger = setup_logging()
|
||||
self.private_config = {}
|
||||
self.auth_code_gen = auth_code_gen
|
||||
self.lock_manager = FileLockManager()
|
||||
|
||||
async def load_or_create(self):
|
||||
"""
|
||||
加载或创建设备的私有配置。
|
||||
|
||||
如果配置文件不存在或设备配置不存在,则根据默认配置创建新的设备配置。
|
||||
"""
|
||||
try:
|
||||
# 获取文件锁,确保并发安全
|
||||
await self.lock_manager.acquire_lock(self.config_path)
|
||||
try:
|
||||
# 检查配置文件是否存在
|
||||
if os.path.exists(self.config_path):
|
||||
# 读取配置文件
|
||||
with open(self.config_path, 'r', encoding='utf-8') as f:
|
||||
all_configs = yaml.safe_load(f) or {}
|
||||
else:
|
||||
# 如果文件不存在,初始化空配置
|
||||
all_configs = {}
|
||||
|
||||
# 检查当前设备的配置是否存在
|
||||
if self.device_id not in all_configs:
|
||||
# 获取默认配置中的模块选择
|
||||
# Get selected module names
|
||||
selected_modules = self.default_config['selected_module']
|
||||
selected_tts = selected_modules['TTS']
|
||||
selected_llm = selected_modules['LLM']
|
||||
selected_asr = selected_modules['ASR']
|
||||
selected_vad = selected_modules['VAD']
|
||||
|
||||
# 生成认证码(如果提供了认证码生成器)
|
||||
# 生成认证码
|
||||
auth_code = None
|
||||
if self.auth_code_gen:
|
||||
auth_code = self.auth_code_gen.generate_code()
|
||||
|
||||
# 初始化设备配置
|
||||
# Initialize device config with only necessary configurations
|
||||
device_config = {
|
||||
'selected_module': deepcopy(selected_modules), # 选择的模块
|
||||
'prompt': self.default_config['prompt'], # 提示词配置
|
||||
'selected_module': deepcopy(selected_modules),
|
||||
'prompt': self.default_config['prompt'],
|
||||
'LLM': {
|
||||
selected_llm: deepcopy(self.default_config['LLM'][selected_llm])
|
||||
},
|
||||
|
|
@ -85,101 +59,85 @@ class PrivateConfig:
|
|||
'VAD': {
|
||||
selected_vad: deepcopy(self.default_config['VAD'][selected_vad])
|
||||
},
|
||||
'auth_code': auth_code # 认证码
|
||||
'auth_code': auth_code # 添加认证码字段
|
||||
}
|
||||
|
||||
# 将新配置添加到所有配置中
|
||||
all_configs[self.device_id] = device_config
|
||||
|
||||
# 保存更新后的配置到文件
|
||||
# Save updated configs
|
||||
with open(self.config_path, 'w', encoding='utf-8') as f:
|
||||
yaml.dump(all_configs, f, allow_unicode=True)
|
||||
|
||||
# 设置当前设备的私有配置
|
||||
self.private_config = all_configs[self.device_id]
|
||||
|
||||
finally:
|
||||
# 释放文件锁
|
||||
self.lock_manager.release_lock(self.config_path)
|
||||
|
||||
except Exception as e:
|
||||
# 记录错误日志
|
||||
self.logger.bind(tag=TAG).error(f"Error handling private config: {e}")
|
||||
self.private_config = {}
|
||||
|
||||
async def update_config(self, selected_modules: Dict[str, str], prompt: str, nickname: str) -> bool:
|
||||
"""
|
||||
更新设备配置。
|
||||
|
||||
"""更新设备配置
|
||||
Args:
|
||||
selected_modules (Dict[str, str]): 选择的模块配置,格式如 {'LLM': 'AliLLM', 'TTS': 'EdgeTTS',...}
|
||||
prompt (str): 提示词配置
|
||||
nickname (str): 设备昵称
|
||||
|
||||
selected_modules: 选择的模块配置,格式如 {'LLM': 'AliLLM', 'TTS': 'EdgeTTS',...}
|
||||
prompt: 提示词配置
|
||||
Returns:
|
||||
bool: 更新是否成功
|
||||
"""
|
||||
try:
|
||||
# 获取文件锁,确保并发安全
|
||||
await self.lock_manager.acquire_lock(self.config_path)
|
||||
try:
|
||||
# 读取默认配置
|
||||
# Read main config to get full module configurations
|
||||
main_config = self.default_config
|
||||
|
||||
# 创建新的设备配置
|
||||
# Create new device config
|
||||
device_config = {
|
||||
'selected_module': selected_modules,
|
||||
'prompt': prompt,
|
||||
'nickname': nickname,
|
||||
}
|
||||
# 保留上次聊天时间(如果存在)
|
||||
if self.private_config.get('last_chat_time'):
|
||||
device_config['last_chat_time'] = self.private_config['last_chat_time']
|
||||
# 保留所有者信息(如果存在)
|
||||
if self.private_config.get('owner'):
|
||||
device_config['owner'] = self.private_config['owner']
|
||||
|
||||
# 从默认配置中复制完整的模块配置
|
||||
# Copy full module configurations from main config
|
||||
for module_type, selected_name in selected_modules.items():
|
||||
if selected_name and selected_name in main_config.get(module_type, {}):
|
||||
device_config[module_type] = {
|
||||
selected_name: main_config[module_type][selected_name]
|
||||
}
|
||||
|
||||
# 读取所有配置
|
||||
# Read all configs
|
||||
if os.path.exists(self.config_path):
|
||||
with open(self.config_path, 'r', encoding='utf-8') as f:
|
||||
all_configs = yaml.safe_load(f) or {}
|
||||
else:
|
||||
all_configs = {}
|
||||
|
||||
# 更新当前设备的配置
|
||||
# Update device config
|
||||
all_configs[self.device_id] = device_config
|
||||
self.private_config = device_config
|
||||
|
||||
# 保存更新后的配置到文件
|
||||
# Save back to file
|
||||
with open(self.config_path, 'w', encoding='utf-8') as f:
|
||||
yaml.dump(all_configs, f, allow_unicode=True)
|
||||
|
||||
return True
|
||||
finally:
|
||||
# 释放文件锁
|
||||
self.lock_manager.release_lock(self.config_path)
|
||||
|
||||
except Exception as e:
|
||||
# 记录错误日志
|
||||
self.logger.bind(tag=TAG).error(f"Error updating config: {e}")
|
||||
return False
|
||||
|
||||
async def delete_config(self) -> bool:
|
||||
"""
|
||||
删除设备配置。
|
||||
|
||||
"""删除设备配置
|
||||
Returns:
|
||||
bool: 删除是否成功
|
||||
"""
|
||||
try:
|
||||
# 获取文件锁,确保并发安全
|
||||
await self.lock_manager.acquire_lock(self.config_path)
|
||||
try:
|
||||
# 读取所有配置
|
||||
|
|
@ -189,43 +147,32 @@ class PrivateConfig:
|
|||
else:
|
||||
return False
|
||||
|
||||
# 删除当前设备的配置
|
||||
# 删除设备配置
|
||||
if self.device_id in all_configs:
|
||||
del all_configs[self.device_id]
|
||||
|
||||
# 保存更新后的配置到文件
|
||||
# 保存更新后的配置
|
||||
with open(self.config_path, 'w', encoding='utf-8') as f:
|
||||
yaml.dump(all_configs, f, allow_unicode=True)
|
||||
|
||||
# 清空当前设备的私有配置
|
||||
self.private_config = {}
|
||||
return True
|
||||
|
||||
return False
|
||||
finally:
|
||||
# 释放文件锁
|
||||
self.lock_manager.release_lock(self.config_path)
|
||||
|
||||
except Exception as e:
|
||||
# 记录错误日志
|
||||
self.logger.bind(tag=TAG).error(f"Error deleting config: {e}")
|
||||
return False
|
||||
|
||||
def create_private_instances(self):
|
||||
"""
|
||||
创建私有模块实例。
|
||||
|
||||
根据私有配置创建 LLM 和 TTS 模块的实例。
|
||||
|
||||
Returns:
|
||||
Tuple: 返回 LLM 和 TTS 模块的实例,如果配置不存在则返回 (None, None)。
|
||||
"""
|
||||
# 检查私有配置是否存在
|
||||
# 判断存在私有配置,并且self.device_id在私有配置中
|
||||
if not self.private_config:
|
||||
self.logger.bind(tag=TAG).error("Private config not found for device_id: {}", self.device_id)
|
||||
return None, None
|
||||
|
||||
# 获取配置中的模块选择
|
||||
"""创建私有处理模块实例"""
|
||||
config = self.private_config
|
||||
selected_modules = config['selected_module']
|
||||
return (
|
||||
|
|
@ -242,70 +189,53 @@ class PrivateConfig:
|
|||
else
|
||||
config["TTS"][selected_modules["TTS"]]["type"],
|
||||
config["TTS"][selected_modules["TTS"]],
|
||||
self.default_config.get("delete_audio", True) # 使用默认配置中的全局设置
|
||||
self.default_config.get("delete_audio", True) # Using default_config for global settings
|
||||
)
|
||||
)
|
||||
|
||||
async def update_last_chat_time(self, timestamp=None):
|
||||
"""
|
||||
更新设备最近一次的聊天时间。
|
||||
|
||||
"""更新设备最近一次的聊天时间
|
||||
Args:
|
||||
timestamp: 指定的时间戳,如果不传则使用当前时间。
|
||||
|
||||
Returns:
|
||||
bool: 更新是否成功
|
||||
timestamp: 指定的时间戳,不传则使用当前时间
|
||||
"""
|
||||
if not self.private_config:
|
||||
self.logger.bind(tag=TAG).error("Private config not found")
|
||||
return False
|
||||
|
||||
try:
|
||||
# 获取文件锁,确保并发安全
|
||||
await self.lock_manager.acquire_lock(self.config_path)
|
||||
try:
|
||||
# 如果未提供时间戳,则使用当前时间
|
||||
if timestamp is None:
|
||||
timestamp = int(time.time())
|
||||
|
||||
# 更新最近聊天时间
|
||||
self.private_config['last_chat_time'] = timestamp
|
||||
|
||||
# 读取所有配置
|
||||
with open(self.config_path, 'r', encoding='utf-8') as f:
|
||||
all_configs = yaml.safe_load(f) or {}
|
||||
|
||||
# 更新当前设备的配置
|
||||
# 更新当前设备配置
|
||||
all_configs[self.device_id] = self.private_config
|
||||
|
||||
# 保存更新后的配置到文件
|
||||
# 保存回文件
|
||||
with open(self.config_path, 'w', encoding='utf-8') as f:
|
||||
yaml.dump(all_configs, f, allow_unicode=True)
|
||||
|
||||
return True
|
||||
finally:
|
||||
# 释放文件锁
|
||||
self.lock_manager.release_lock(self.config_path)
|
||||
|
||||
except Exception as e:
|
||||
# 记录错误日志
|
||||
self.logger.bind(tag=TAG).error(f"Error updating last chat time: {e}")
|
||||
return False
|
||||
|
||||
def get_auth_code(self) -> str:
|
||||
"""
|
||||
获取设备的认证码。
|
||||
|
||||
"""获取设备的认证码
|
||||
Returns:
|
||||
str: 认证码,如果没有则返回空字符串。
|
||||
str: 认证码,如果没有返回空字符串
|
||||
"""
|
||||
return self.private_config.get('auth_code', '')
|
||||
|
||||
def get_owner(self) -> Optional[str]:
|
||||
"""
|
||||
获取设备当前所有者。
|
||||
|
||||
Returns:
|
||||
Optional[str]: 所有者信息,如果没有则返回 None。
|
||||
"""
|
||||
"""获取设备当前所有者"""
|
||||
return self.private_config.get('owner')
|
||||
|
|
@ -11,10 +11,11 @@ import websockets
|
|||
from typing import Dict, Any
|
||||
from core.utils.dialogue import Message, Dialogue
|
||||
from core.handle.textHandle import handleTextMessage
|
||||
from core.utils.util import get_string_no_punctuation_or_emoji
|
||||
from core.utils.util import get_string_no_punctuation_or_emoji, extract_json_from_string
|
||||
from concurrent.futures import ThreadPoolExecutor, TimeoutError
|
||||
from core.handle.sendAudioHandle import sendAudioMessage
|
||||
from core.handle.receiveAudioHandle import handleAudioMessage
|
||||
from core.handle.intentHandler import Action, get_functions, handle_llm_function_call
|
||||
from config.private_config import PrivateConfig
|
||||
from core.auth import AuthMiddleware, AuthenticationError
|
||||
from core.utils.auth_code_gen import AuthCodeGenerator
|
||||
|
|
@ -27,7 +28,7 @@ class TTSException(RuntimeError):
|
|||
|
||||
|
||||
class ConnectionHandler:
|
||||
def __init__(self, config: Dict[str, Any], _vad, _asr, _llm, _tts, _music, _memory):
|
||||
def __init__(self, config: Dict[str, Any], _vad, _asr, _llm, _tts, _music, _memory, _intent):
|
||||
self.config = config
|
||||
self.logger = setup_logging()
|
||||
self.auth = AuthMiddleware(config)
|
||||
|
|
@ -55,6 +56,7 @@ class ConnectionHandler:
|
|||
self.llm = _llm
|
||||
self.tts = _tts
|
||||
self.memory = _memory
|
||||
self.intent = _intent
|
||||
|
||||
# vad相关变量
|
||||
self.client_audio_buffer = bytes()
|
||||
|
|
@ -88,6 +90,10 @@ class ConnectionHandler:
|
|||
self.auth_code_gen = AuthCodeGenerator.get_instance()
|
||||
self.is_device_verified = False # 添加设备验证状态标志
|
||||
self.music_handler = _music
|
||||
self.close_after_chat = False # 是否在聊天结束后关闭连接
|
||||
self.use_function_call_mode = False
|
||||
if self.config["selected_module"]["Intent"] == 'function_call':
|
||||
self.use_function_call_mode = True
|
||||
|
||||
async def handle_connection(self, ws):
|
||||
try:
|
||||
|
|
@ -101,7 +107,8 @@ class ConnectionHandler:
|
|||
await self.auth.authenticate(self.headers)
|
||||
|
||||
device_id = self.headers.get("device-id", None)
|
||||
self.memory.set_role_id(device_id)
|
||||
self.memory.init_memory(device_id, self.llm)
|
||||
self.intent.set_llm(self.llm)
|
||||
|
||||
# Load private configuration if device_id is provided
|
||||
bUsePrivateConfig = self.config.get("use_private_config", False)
|
||||
|
|
@ -204,7 +211,6 @@ class ConnectionHandler:
|
|||
return False
|
||||
return not self.is_device_verified
|
||||
|
||||
|
||||
def chat(self, query):
|
||||
if self.isNeedAuth():
|
||||
self.llm_finish_task = True
|
||||
|
|
@ -213,6 +219,7 @@ class ConnectionHandler:
|
|||
return True
|
||||
|
||||
self.dialogue.put(Message(role="user", content=query))
|
||||
|
||||
response_message = []
|
||||
processed_chars = 0 # 跟踪已处理的字符位置
|
||||
try:
|
||||
|
|
@ -221,7 +228,7 @@ class ConnectionHandler:
|
|||
future = asyncio.run_coroutine_threadsafe(self.memory.query_memory(query), self.loop)
|
||||
memory_str = future.result()
|
||||
|
||||
self.logger.bind(tag=TAG).info(f"记忆内容: {memory_str}")
|
||||
self.logger.bind(tag=TAG).debug(f"记忆内容: {memory_str}")
|
||||
llm_responses = self.llm.response(
|
||||
self.session_id,
|
||||
self.dialogue.get_llm_dialogue_with_memory(memory_str)
|
||||
|
|
@ -245,7 +252,7 @@ class ConnectionHandler:
|
|||
current_text = full_text[processed_chars:] # 从未处理的位置开始
|
||||
|
||||
# 查找最后一个有效标点
|
||||
punctuations = ("。", "?", "!", "?", "!", ";", ";", ":", ":")
|
||||
punctuations = ("。", "?", "!", ";", ":")
|
||||
last_punct_pos = -1
|
||||
for punct in punctuations:
|
||||
pos = current_text.rfind(punct)
|
||||
|
|
@ -282,6 +289,157 @@ class ConnectionHandler:
|
|||
self.logger.bind(tag=TAG).debug(json.dumps(self.dialogue.get_llm_dialogue(), indent=4, ensure_ascii=False))
|
||||
return True
|
||||
|
||||
def chat_with_function_calling(self, query):
|
||||
self.logger.bind(tag=TAG).debug(f"Chat with function calling start: {query}")
|
||||
"""Chat with function calling for intent detection using streaming"""
|
||||
if self.isNeedAuth():
|
||||
self.llm_finish_task = True
|
||||
future = asyncio.run_coroutine_threadsafe(self._check_and_broadcast_auth_code(), self.loop)
|
||||
future.result()
|
||||
return True
|
||||
|
||||
self.dialogue.put(Message(role="user", content=query))
|
||||
|
||||
# Define intent functions
|
||||
functions = get_functions()
|
||||
|
||||
response_message = []
|
||||
processed_chars = 0 # 跟踪已处理的字符位置
|
||||
|
||||
try:
|
||||
start_time = time.time()
|
||||
|
||||
# 使用带记忆的对话
|
||||
future = asyncio.run_coroutine_threadsafe(self.memory.query_memory(query), self.loop)
|
||||
memory_str = future.result()
|
||||
|
||||
#self.logger.bind(tag=TAG).info(f"对话记录: {self.dialogue.get_llm_dialogue_with_memory(memory_str)}")
|
||||
|
||||
# 使用支持functions的streaming接口
|
||||
llm_responses = self.llm.response_with_functions(
|
||||
self.session_id,
|
||||
self.dialogue.get_llm_dialogue_with_memory(memory_str),
|
||||
functions=functions
|
||||
)
|
||||
except Exception as e:
|
||||
self.logger.bind(tag=TAG).error(f"LLM 处理出错 {query}: {e}")
|
||||
return None
|
||||
|
||||
self.llm_finish_task = False
|
||||
text_index = 0
|
||||
|
||||
# 处理流式响应
|
||||
tool_call_flag = False
|
||||
function_name = None
|
||||
function_id = None
|
||||
function_arguments = ""
|
||||
content_arguments = ""
|
||||
for response in llm_responses:
|
||||
content, tools_call = response
|
||||
if content is not None and len(content)>0:
|
||||
if len(response_message)<=0 and content=="```":
|
||||
tool_call_flag = True
|
||||
|
||||
if tools_call is not None:
|
||||
tool_call_flag = True
|
||||
if tools_call[0].id is not None:
|
||||
function_id = tools_call[0].id
|
||||
if tools_call[0].function.name is not None:
|
||||
function_name = tools_call[0].function.name
|
||||
if tools_call[0].function.arguments is not None:
|
||||
function_arguments += tools_call[0].function.arguments
|
||||
|
||||
if content is not None and len(content) > 0:
|
||||
if tool_call_flag:
|
||||
content_arguments+=content
|
||||
else:
|
||||
response_message.append(content)
|
||||
|
||||
if self.client_abort:
|
||||
break
|
||||
|
||||
end_time = time.time()
|
||||
self.logger.bind(tag=TAG).debug(f"大模型返回时间: {end_time - start_time} 秒, 生成token={content}")
|
||||
|
||||
# 处理文本分段和TTS逻辑
|
||||
# 合并当前全部文本并处理未分割部分
|
||||
full_text = "".join(response_message)
|
||||
current_text = full_text[processed_chars:] # 从未处理的位置开始
|
||||
|
||||
# 查找最后一个有效标点
|
||||
punctuations = ("。", "?", "!", ";", ":")
|
||||
last_punct_pos = -1
|
||||
for punct in punctuations:
|
||||
pos = current_text.rfind(punct)
|
||||
if pos > last_punct_pos:
|
||||
last_punct_pos = pos
|
||||
|
||||
# 找到分割点则处理
|
||||
if last_punct_pos != -1:
|
||||
segment_text_raw = current_text[:last_punct_pos + 1]
|
||||
segment_text = get_string_no_punctuation_or_emoji(segment_text_raw)
|
||||
if segment_text:
|
||||
text_index += 1
|
||||
self.recode_first_last_text(segment_text, text_index)
|
||||
future = self.executor.submit(self.speak_and_play, segment_text, text_index)
|
||||
self.tts_queue.put(future)
|
||||
processed_chars += len(segment_text_raw) # 更新已处理字符位置
|
||||
|
||||
# 处理最后剩余的文本
|
||||
full_text = "".join(response_message)
|
||||
remaining_text = full_text[processed_chars:]
|
||||
if remaining_text:
|
||||
segment_text = get_string_no_punctuation_or_emoji(remaining_text)
|
||||
if segment_text:
|
||||
text_index += 1
|
||||
self.recode_first_last_text(segment_text, text_index)
|
||||
future = self.executor.submit(self.speak_and_play, segment_text, text_index)
|
||||
self.tts_queue.put(future)
|
||||
|
||||
# 存储对话内容
|
||||
if len(response_message)>0:
|
||||
self.dialogue.put(Message(role="assistant", content="".join(response_message)))
|
||||
|
||||
# 处理function call
|
||||
if tool_call_flag:
|
||||
if function_id is None:
|
||||
a = extract_json_from_string(content_arguments)
|
||||
if a is not None:
|
||||
content_arguments_json = json.loads(a)
|
||||
function_name = content_arguments_json["function_name"]
|
||||
function_arguments = json.dumps(content_arguments_json["args"], ensure_ascii=False)
|
||||
function_id = str(uuid.uuid4().hex)
|
||||
else:
|
||||
return []
|
||||
function_arguments = json.loads(function_arguments)
|
||||
self.logger.bind(tag=TAG).info(f"function_name={function_name}, function_id={function_id}, function_arguments={function_arguments}")
|
||||
function_call_data = {
|
||||
"name": function_name,
|
||||
"id": function_id,
|
||||
"arguments": function_arguments
|
||||
}
|
||||
result = handle_llm_function_call(self, function_call_data)
|
||||
self._handle_function_result(result, function_call_data, text_index+1)
|
||||
|
||||
self.llm_finish_task = True
|
||||
self.logger.bind(tag=TAG).debug(json.dumps(self.dialogue.get_llm_dialogue(), indent=4, ensure_ascii=False))
|
||||
|
||||
return True
|
||||
|
||||
def _handle_function_result(self, result, function_call_data, text_index):
|
||||
if result.action == Action.RESPONSE: # 直接回复前端
|
||||
text = result.response
|
||||
self.recode_first_last_text(text, text_index)
|
||||
future = self.executor.submit(self.speak_and_play, text, text_index)
|
||||
self.tts_queue.put(future)
|
||||
self.dialogue.put(Message(role="assistant", content=text))
|
||||
if result.action == Action.REQLLM: # 调用函数后再请求llm生成回复
|
||||
text = result.response
|
||||
if result.action == Action.NOTFOUND:
|
||||
text = result.response
|
||||
|
||||
|
||||
|
||||
def _tts_priority_thread(self):
|
||||
while not self.stop_event.is_set():
|
||||
text = None
|
||||
|
|
@ -372,3 +530,14 @@ class ConnectionHandler:
|
|||
self.client_have_voice_last_time = 0
|
||||
self.client_voice_stop = False
|
||||
self.logger.bind(tag=TAG).debug("VAD states reset.")
|
||||
|
||||
def chat_and_close(self, text):
|
||||
"""Chat with the user and then close the connection"""
|
||||
try:
|
||||
# Use the existing chat method
|
||||
self.chat(text)
|
||||
|
||||
# After chat is complete, close the connection
|
||||
self.close_after_chat = True
|
||||
except Exception as e:
|
||||
self.logger.bind(tag=TAG).error(f"Chat and close error: {str(e)}")
|
||||
|
|
|
|||
|
|
@ -109,7 +109,48 @@ async def handleIotDescriptors(conn, descriptors):
|
|||
default_iot_volume = conn.config["iot"]["Speaker"]["volume"]
|
||||
logger.bind(tag=TAG).info(f"服务端设置音量为{default_iot_volume}")
|
||||
await send_iot_conn(conn, "Speaker", "SetVolume", {"volume": default_iot_volume})
|
||||
async def handleIotStatus(conn, states):
|
||||
"""
|
||||
处理物联网状态
|
||||
示例: [{
|
||||
"name":"Speaker",
|
||||
"state":{
|
||||
"volume":100
|
||||
}
|
||||
}]
|
||||
states: 状态列表
|
||||
"""
|
||||
for state in states:
|
||||
for key, value in conn.iot_descriptors.items():
|
||||
if key == state["name"]:
|
||||
for property_item in value.properties:
|
||||
# properties为字典列表, 记录各种属性
|
||||
for k, v in state["state"].items():
|
||||
# state为字典, 记录各种属性的值, 是需要记录的信息
|
||||
if property_item["name"] == k:
|
||||
# 检查一下属性是不是相同的
|
||||
if type(v) != type(property_item["value"]):
|
||||
logger.bind(tag=TAG).error(f"属性{property_item['name']}的值类型不匹配")
|
||||
break
|
||||
else:
|
||||
property_item["value"] = v
|
||||
logger.bind(tag=TAG).info(f"物联网状态更新: {key} , {property_item['name']} = {v}")
|
||||
break
|
||||
break
|
||||
|
||||
async def get_iot_status(conn, name, property_name):
|
||||
"""
|
||||
获取物联网状态
|
||||
name: 设备名称 "Speaker"
|
||||
property_name: 属性名称 "volume"
|
||||
返回值: 属性值, 实际的属性有int, bool和str三种类型
|
||||
"""
|
||||
for key, value in conn.iot_descriptors.items():
|
||||
if key == name:
|
||||
for property_item in value.properties:
|
||||
if property_item["name"] == property_name:
|
||||
return property_item["value"]
|
||||
return None
|
||||
|
||||
async def send_iot_conn(conn, name, method_name, parameters):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,158 +1,139 @@
|
|||
# 导入所需的模块
|
||||
from config.logger import setup_logging # 导入日志设置模块
|
||||
import os # 导入操作系统模块,用于处理文件和目录路径
|
||||
import random # 导入随机模块,用于随机选择音乐文件
|
||||
import difflib # 导入差异比较模块,用于字符串匹配
|
||||
import re # 导入正则表达式模块,用于文本处理
|
||||
import traceback # 导入异常处理模块,用于捕获和记录异常信息
|
||||
from pathlib import Path # 导入路径处理模块,用于处理文件路径
|
||||
import time # 导入时间模块,用于处理时间相关的操作
|
||||
from core.handle.sendAudioHandle import send_stt_message # 导入发送音频消息的模块
|
||||
from core.utils import p3 # 导入自定义的p3模块,用于处理.p3格式的音频文件
|
||||
from config.logger import setup_logging
|
||||
import os
|
||||
import random
|
||||
import difflib
|
||||
import re
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
import time
|
||||
from core.handle.sendAudioHandle import send_stt_message
|
||||
from core.utils import p3
|
||||
|
||||
# 定义当前模块的标签,通常用于日志记录
|
||||
TAG = __name__
|
||||
|
||||
# 设置日志记录器
|
||||
logger = setup_logging()
|
||||
|
||||
|
||||
def _extract_song_name(text):
|
||||
"""从用户输入中提取歌名"""
|
||||
# 遍历关键词列表,尝试从用户输入中提取歌名
|
||||
for keyword in ["听", "播放", "放", "唱"]:
|
||||
for keyword in ["播放音乐"]:
|
||||
if keyword in text:
|
||||
# 如果找到关键词,将文本分割并提取歌名部分
|
||||
parts = text.split(keyword)
|
||||
if len(parts) > 1:
|
||||
return parts[1].strip() # 返回提取的歌名并去除前后空格
|
||||
return None # 如果没有找到关键词,返回None
|
||||
return parts[1].strip()
|
||||
return None
|
||||
|
||||
|
||||
def _find_best_match(potential_song, music_files):
|
||||
"""查找最匹配的歌曲"""
|
||||
best_match = None # 初始化最佳匹配的歌曲文件
|
||||
highest_ratio = 0 # 初始化最高匹配度
|
||||
best_match = None
|
||||
highest_ratio = 0
|
||||
|
||||
# 遍历音乐文件列表,查找与潜在歌名最匹配的文件
|
||||
for music_file in music_files:
|
||||
song_name = os.path.splitext(music_file)[0] # 去除文件扩展名,获取歌曲名
|
||||
ratio = difflib.SequenceMatcher(None, potential_song, song_name).ratio() # 计算匹配度
|
||||
if ratio > highest_ratio and ratio > 0.4: # 如果匹配度高于当前最高值且大于0.4
|
||||
highest_ratio = ratio # 更新最高匹配度
|
||||
best_match = music_file # 更新最佳匹配的歌曲文件
|
||||
return best_match # 返回最佳匹配的歌曲文件
|
||||
song_name = os.path.splitext(music_file)[0]
|
||||
ratio = difflib.SequenceMatcher(None, potential_song, song_name).ratio()
|
||||
if ratio > highest_ratio and ratio > 0.4:
|
||||
highest_ratio = ratio
|
||||
best_match = music_file
|
||||
return best_match
|
||||
|
||||
|
||||
class MusicManager:
|
||||
"""音乐文件管理类,用于管理音乐文件的获取和扫描"""
|
||||
def __init__(self, music_dir, music_ext):
|
||||
"""初始化音乐管理器"""
|
||||
self.music_dir = Path(music_dir) # 设置音乐目录路径
|
||||
self.music_ext = music_ext # 设置音乐文件的扩展名列表
|
||||
self.music_dir = Path(music_dir)
|
||||
self.music_ext = music_ext
|
||||
|
||||
def get_music_files(self):
|
||||
"""获取音乐文件列表"""
|
||||
music_files = [] # 初始化音乐文件列表
|
||||
for file in self.music_dir.rglob("*"): # 遍历音乐目录及其子目录中的所有文件
|
||||
if file.is_file(): # 判断是否是文件
|
||||
ext = file.suffix.lower() # 获取文件扩展名并转换为小写
|
||||
if ext in self.music_ext: # 如果扩展名在允许的扩展名列表中
|
||||
music_files.append(str(file.relative_to(self.music_dir))) # 添加相对路径到音乐文件列表
|
||||
return music_files # 返回音乐文件列表
|
||||
music_files = []
|
||||
for file in self.music_dir.rglob("*"):
|
||||
# 判断是否是文件
|
||||
if file.is_file():
|
||||
# 获取文件扩展名
|
||||
ext = file.suffix.lower()
|
||||
# 判断扩展名是否在列表中
|
||||
if ext in self.music_ext:
|
||||
# music_files.append(str(file.resolve())) # 添加绝对路径
|
||||
# 添加相对路径
|
||||
music_files.append(str(file.relative_to(self.music_dir)))
|
||||
return music_files
|
||||
|
||||
|
||||
class MusicHandler:
|
||||
"""音乐处理类,用于处理音乐播放相关的指令"""
|
||||
def __init__(self, config):
|
||||
"""初始化音乐处理器"""
|
||||
self.config = config # 设置配置信息
|
||||
self.music_related_keywords = [] # 初始化音乐相关关键词列表
|
||||
self.config = config
|
||||
|
||||
# 从配置中获取音乐相关的设置
|
||||
if "music" in self.config:
|
||||
self.music_config = self.config["music"]
|
||||
self.music_dir = os.path.abspath(
|
||||
self.music_config.get("music_dir", "./music") # 获取音乐目录路径,默认为"./music"
|
||||
self.music_config.get("music_dir", "./music") # 默认路径修改
|
||||
)
|
||||
self.music_related_keywords = self.music_config.get("music_commands", []) # 获取音乐相关关键词
|
||||
self.music_ext = self.music_config.get("music_ext", (".mp3", ".wav", ".p3")) # 获取音乐文件扩展名
|
||||
self.refresh_time = self.music_config.get("refresh_time", 60) # 获取音乐文件列表刷新时间,默认为60秒
|
||||
self.music_ext = self.music_config.get("music_ext", (".mp3", ".wav", ".p3"))
|
||||
self.refresh_time = self.music_config.get("refresh_time", 60)
|
||||
else:
|
||||
# 如果配置中没有音乐相关设置,使用默认值
|
||||
self.music_dir = os.path.abspath("./music")
|
||||
self.music_related_keywords = ["来一首歌", "唱一首歌", "播放音乐", "来点音乐", "背景音乐", "放首歌",
|
||||
"播放歌曲", "来点背景音乐", "我想听歌", "我要听歌", "放点音乐"]
|
||||
self.music_ext = (".mp3", ".wav", ".p3")
|
||||
self.refresh_time = 60
|
||||
|
||||
# 获取音乐文件列表
|
||||
self.music_files = MusicManager(self.music_dir, self.music_ext).get_music_files()
|
||||
self.scan_time = time.time() # 记录当前时间,用于后续刷新音乐文件列表
|
||||
logger.bind(tag=TAG).debug(f"找到的音乐文件: {self.music_files}") # 记录找到的音乐文件
|
||||
self.scan_time = time.time()
|
||||
logger.bind(tag=TAG).debug(f"找到的音乐文件: {self.music_files}")
|
||||
|
||||
async def handle_music_command(self, conn, text):
|
||||
"""处理音乐播放指令"""
|
||||
clean_text = re.sub(r'[^\w\s]', '', text).strip() # 清理文本,去除标点符号
|
||||
logger.bind(tag=TAG).debug(f"检查是否是音乐命令: {clean_text}") # 记录检查的音乐命令
|
||||
clean_text = re.sub(r'[^\w\s]', '', text).strip()
|
||||
logger.bind(tag=TAG).debug(f"检查是否是音乐命令: {clean_text}")
|
||||
|
||||
# 尝试匹配具体歌名
|
||||
if os.path.exists(self.music_dir): # 检查音乐目录是否存在
|
||||
if time.time() - self.scan_time > self.refresh_time: # 如果超过刷新时间,刷新音乐文件列表
|
||||
if os.path.exists(self.music_dir):
|
||||
if time.time() - self.scan_time > self.refresh_time:
|
||||
# 刷新音乐文件列表
|
||||
self.music_files = MusicManager(self.music_dir, self.music_ext).get_music_files()
|
||||
self.scan_time = time.time() # 更新扫描时间
|
||||
logger.bind(tag=TAG).debug(f"刷新的音乐文件: {self.music_files}") # 记录刷新的音乐文件
|
||||
|
||||
potential_song = _extract_song_name(clean_text) # 从用户输入中提取歌名
|
||||
if potential_song: # 如果提取到歌名
|
||||
best_match = _find_best_match(potential_song, self.music_files) # 查找最匹配的歌曲
|
||||
if best_match: # 如果找到匹配的歌曲
|
||||
logger.bind(tag=TAG).info(f"找到最匹配的歌曲: {best_match}") # 记录找到的歌曲
|
||||
await self.play_local_music(conn, specific_file=best_match) # 播放匹配的歌曲
|
||||
return True # 返回True表示成功处理音乐命令
|
||||
self.scan_time = time.time()
|
||||
logger.bind(tag=TAG).debug(f"刷新的音乐文件: {self.music_files}")
|
||||
|
||||
potential_song = _extract_song_name(clean_text)
|
||||
if potential_song:
|
||||
best_match = _find_best_match(potential_song, self.music_files)
|
||||
if best_match:
|
||||
logger.bind(tag=TAG).info(f"找到最匹配的歌曲: {best_match}")
|
||||
await self.play_local_music(conn, specific_file=best_match)
|
||||
return True
|
||||
# 检查是否是通用播放音乐命令
|
||||
if any(cmd in clean_text for cmd in self.music_related_keywords): # 如果用户输入包含音乐相关关键词
|
||||
await self.play_local_music(conn) # 播放随机音乐
|
||||
return True # 返回True表示成功处理音乐命令
|
||||
|
||||
return False # 如果没有处理音乐命令,返回False
|
||||
await self.play_local_music(conn)
|
||||
return True
|
||||
|
||||
async def play_local_music(self, conn, specific_file=None):
|
||||
"""播放本地音乐文件"""
|
||||
try:
|
||||
if not os.path.exists(self.music_dir): # 检查音乐目录是否存在
|
||||
logger.bind(tag=TAG).error(f"音乐目录不存在: {self.music_dir}") # 记录错误信息
|
||||
if not os.path.exists(self.music_dir):
|
||||
logger.bind(tag=TAG).error(f"音乐目录不存在: {self.music_dir}")
|
||||
return
|
||||
|
||||
# 确保路径正确性
|
||||
if specific_file: # 如果指定了具体的音乐文件
|
||||
music_path = os.path.join(self.music_dir, specific_file) # 拼接音乐文件路径
|
||||
if not os.path.exists(music_path): # 检查音乐文件是否存在
|
||||
logger.bind(tag=TAG).error(f"指定的音乐文件不存在: {music_path}") # 记录错误信息
|
||||
return
|
||||
selected_music = specific_file # 设置选定的音乐文件
|
||||
if specific_file:
|
||||
selected_music = specific_file
|
||||
music_path = os.path.join(self.music_dir, specific_file)
|
||||
else:
|
||||
if time.time() - self.scan_time > self.refresh_time: # 如果超过刷新时间,刷新音乐文件列表
|
||||
self.music_files = MusicManager(self.music_dir, self.music_ext).get_music_files()
|
||||
self.scan_time = time.time() # 更新扫描时间
|
||||
logger.bind(tag=TAG).debug(f"刷新的音乐文件列表: {self.music_files}") # 记录刷新的音乐文件列表
|
||||
if not self.music_files:
|
||||
logger.bind(tag=TAG).error("未找到MP3音乐文件")
|
||||
return
|
||||
selected_music = random.choice(self.music_files)
|
||||
music_path = os.path.join(self.music_dir, selected_music)
|
||||
|
||||
if not self.music_files: # 如果没有找到音乐文件
|
||||
logger.bind(tag=TAG).error("未找到MP3音乐文件") # 记录错误信息
|
||||
if not os.path.exists(music_path):
|
||||
logger.bind(tag=TAG).error(f"选定的音乐文件不存在: {music_path}")
|
||||
return
|
||||
selected_music = random.choice(self.music_files) # 随机选择一个音乐文件
|
||||
music_path = os.path.join(self.music_dir, selected_music) # 拼接音乐文件路径
|
||||
if not os.path.exists(music_path): # 检查音乐文件是否存在
|
||||
logger.bind(tag=TAG).error(f"选定的音乐文件不存在: {music_path}") # 记录错误信息
|
||||
return
|
||||
text = f"正在播放{selected_music}" # 设置播放提示信息
|
||||
await send_stt_message(conn, text) # 发送播放提示信息
|
||||
conn.tts_first_text_index = 0 # 重置TTS文本索引
|
||||
conn.tts_last_text_index = 0 # 重置TTS文本索引
|
||||
conn.llm_finish_task = True # 标记任务完成
|
||||
if music_path.endswith(".p3"): # 如果音乐文件是.p3格式
|
||||
opus_packets, duration = p3.decode_opus_from_file(music_path) # 解码.p3文件
|
||||
text = f"正在播放{selected_music}"
|
||||
await send_stt_message(conn, text)
|
||||
conn.tts_first_text_index = 0
|
||||
conn.tts_last_text_index = 0
|
||||
conn.llm_finish_task = True
|
||||
if music_path.endswith(".p3"):
|
||||
opus_packets, duration = p3.decode_opus_from_file(music_path)
|
||||
else:
|
||||
opus_packets, duration = conn.tts.wav_to_opus_data(music_path) # 将.wav文件转换为opus数据
|
||||
conn.audio_play_queue.put((opus_packets, selected_music, 0)) # 将音频数据放入播放队列
|
||||
opus_packets, duration = conn.tts.wav_to_opus_data(music_path)
|
||||
conn.audio_play_queue.put((opus_packets, selected_music, 0))
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"播放音乐失败: {str(e)}") # 记录播放失败的错误信息
|
||||
logger.bind(tag=TAG).error(f"详细错误: {traceback.format_exc()}") # 记录详细的错误信息
|
||||
logger.bind(tag=TAG).error(f"播放音乐失败: {str(e)}")
|
||||
logger.bind(tag=TAG).error(f"详细错误: {traceback.format_exc()}")
|
||||
|
|
@ -1,102 +1,75 @@
|
|||
# 导入所需的模块
|
||||
from config.logger import setup_logging # 导入日志设置模块
|
||||
import time # 导入时间模块,用于处理时间相关的操作
|
||||
from core.utils.util import remove_punctuation_and_length # 导入工具函数,用于去除标点符号并计算文本长度
|
||||
from core.handle.sendAudioHandle import send_stt_message # 导入发送音频消息的模块
|
||||
from config.logger import setup_logging
|
||||
import time
|
||||
from core.utils.util import remove_punctuation_and_length
|
||||
from core.handle.sendAudioHandle import send_stt_message
|
||||
from core.handle.intentHandler import handle_user_intent
|
||||
|
||||
# 定义当前模块的标签,通常用于日志记录
|
||||
TAG = __name__
|
||||
|
||||
# 设置日志记录器
|
||||
logger = setup_logging()
|
||||
|
||||
|
||||
async def handleAudioMessage(conn, audio):
|
||||
"""处理音频消息"""
|
||||
if not conn.asr_server_receive: # 如果ASR服务器未准备好接收数据
|
||||
logger.bind(tag=TAG).debug(f"前期数据处理中,暂停接收") # 记录调试信息
|
||||
if not conn.asr_server_receive:
|
||||
logger.bind(tag=TAG).debug(f"前期数据处理中,暂停接收")
|
||||
return
|
||||
|
||||
# 根据客户端的监听模式判断是否有声音
|
||||
if conn.client_listen_mode == "auto": # 如果监听模式为自动
|
||||
have_voice = conn.vad.is_vad(conn, audio) # 使用VAD(语音活动检测)判断是否有声音
|
||||
if conn.client_listen_mode == "auto":
|
||||
have_voice = conn.vad.is_vad(conn, audio)
|
||||
else:
|
||||
have_voice = conn.client_have_voice # 否则使用客户端的声音状态
|
||||
have_voice = conn.client_have_voice
|
||||
|
||||
# 如果本次没有声音且本段也没有声音,丢弃音频数据并关闭连接
|
||||
# 如果本次没有声音,本段也没声音,就把声音丢弃了
|
||||
if have_voice == False and conn.client_have_voice == False:
|
||||
await no_voice_close_connect(conn) # 调用无声音关闭连接函数
|
||||
conn.asr_audio.clear() # 清空ASR音频缓存
|
||||
await no_voice_close_connect(conn)
|
||||
conn.asr_audio.clear()
|
||||
return
|
||||
|
||||
conn.client_no_voice_last_time = 0.0 # 重置无声音计时器
|
||||
conn.asr_audio.append(audio) # 将当前音频数据添加到ASR音频缓存中
|
||||
|
||||
# 如果本段有声音且已经停止
|
||||
conn.client_no_voice_last_time = 0.0
|
||||
conn.asr_audio.append(audio)
|
||||
# 如果本段有声音,且已经停止了
|
||||
if conn.client_voice_stop:
|
||||
conn.client_abort = False # 重置客户端中止标志
|
||||
conn.asr_server_receive = False # 设置ASR服务器接收状态为False
|
||||
|
||||
# 如果音频数据太短,无法识别
|
||||
conn.client_abort = False
|
||||
conn.asr_server_receive = False
|
||||
# 音频太短了,无法识别
|
||||
if len(conn.asr_audio) < 3:
|
||||
conn.asr_server_receive = True # 设置ASR服务器接收状态为True
|
||||
conn.asr_server_receive = True
|
||||
else:
|
||||
# 调用ASR服务将音频转换为文本
|
||||
text, file_path = await conn.asr.speech_to_text(conn.asr_audio, conn.session_id)
|
||||
logger.bind(tag=TAG).info(f"识别文本: {text}") # 记录识别到的文本
|
||||
|
||||
# 去除标点符号并计算文本长度
|
||||
text_len, text_without_punctuation = remove_punctuation_and_length(text)
|
||||
|
||||
# 处理音乐命令
|
||||
if await conn.music_handler.handle_music_command(conn, text_without_punctuation):
|
||||
conn.asr_server_receive = True # 设置ASR服务器接收状态为True
|
||||
conn.asr_audio.clear() # 清空ASR音频缓存
|
||||
return
|
||||
|
||||
# 处理命令消息
|
||||
if text_len <= conn.max_cmd_length and await handleCMDMessage(conn, text_without_punctuation):
|
||||
return
|
||||
|
||||
# 如果文本长度大于0,启动聊天
|
||||
logger.bind(tag=TAG).info(f"识别文本: {text}")
|
||||
text_len, _ = remove_punctuation_and_length(text)
|
||||
if text_len > 0:
|
||||
await startToChat(conn, text)
|
||||
else:
|
||||
conn.asr_server_receive = True # 设置ASR服务器接收状态为True
|
||||
conn.asr_server_receive = True
|
||||
conn.asr_audio.clear()
|
||||
conn.reset_vad_states()
|
||||
|
||||
conn.asr_audio.clear() # 清空ASR音频缓存
|
||||
conn.reset_vad_states() # 重置VAD状态
|
||||
|
||||
async def handleCMDMessage(conn, text):
|
||||
"""处理命令消息"""
|
||||
cmd_exit = conn.cmd_exit # 获取退出命令列表
|
||||
for cmd in cmd_exit: # 遍历退出命令列表
|
||||
if text == cmd: # 如果识别到的文本与退出命令匹配
|
||||
logger.bind(tag=TAG).info("识别到明确的退出命令".format(text)) # 记录识别到的退出命令
|
||||
await conn.close() # 关闭连接
|
||||
return True
|
||||
return False # 如果没有匹配的退出命令,返回False
|
||||
|
||||
async def startToChat(conn, text):
|
||||
"""启动聊天"""
|
||||
# 异步发送STT信息
|
||||
# 首先进行意图分析
|
||||
intent_handled = await handle_user_intent(conn, text)
|
||||
|
||||
if intent_handled:
|
||||
# 如果意图已被处理,不再进行聊天
|
||||
conn.asr_server_receive = True
|
||||
return
|
||||
|
||||
# 意图未被处理,继续常规聊天流程
|
||||
await send_stt_message(conn, text)
|
||||
# 提交聊天任务到线程池
|
||||
if conn.use_function_call_mode:
|
||||
# 使用支持function calling的聊天方法
|
||||
conn.executor.submit(conn.chat_with_function_calling, text)
|
||||
else:
|
||||
conn.executor.submit(conn.chat, text)
|
||||
|
||||
|
||||
async def no_voice_close_connect(conn):
|
||||
"""无声音时关闭连接"""
|
||||
if conn.client_no_voice_last_time == 0.0: # 如果无声音计时器未启动
|
||||
conn.client_no_voice_last_time = time.time() * 1000 # 启动无声音计时器
|
||||
if conn.client_no_voice_last_time == 0.0:
|
||||
conn.client_no_voice_last_time = time.time() * 1000
|
||||
else:
|
||||
# 计算无声音时间
|
||||
no_voice_time = time.time() * 1000 - conn.client_no_voice_last_time
|
||||
# 获取配置中的无声音关闭连接时间,默认为120秒
|
||||
close_connection_no_voice_time = conn.config.get("close_connection_no_voice_time", 120)
|
||||
# 如果无声音时间超过配置的时间
|
||||
if no_voice_time > 1000 * close_connection_no_voice_time:
|
||||
conn.client_abort = False # 重置客户端中止标志
|
||||
conn.asr_server_receive = False # 设置ASR服务器接收状态为False
|
||||
# 设置提示信息
|
||||
prompt = "时间过得真快,我都好久没说话了。请你用十个字左右话跟我告别,以“再见”或“拜拜”为结尾"
|
||||
# 启动聊天
|
||||
if not conn.close_after_chat and no_voice_time > 1000 * close_connection_no_voice_time:
|
||||
conn.close_after_chat = True
|
||||
conn.client_abort = False
|
||||
conn.asr_server_receive = False
|
||||
prompt = "请你以“时间过得真快”未来头,用富有感情、依依不舍的话来结束这场对话吧。"
|
||||
await startToChat(conn, prompt)
|
||||
|
|
@ -1,95 +1,83 @@
|
|||
# 导入所需的模块
|
||||
from config.logger import setup_logging # 导入日志设置模块
|
||||
import json # 导入JSON模块,用于处理JSON数据
|
||||
import asyncio # 导入异步IO模块,用于处理异步任务
|
||||
import time # 导入时间模块,用于处理时间相关的操作
|
||||
from core.utils.util import remove_punctuation_and_length, get_string_no_punctuation_or_emoji # 导入工具函数,用于处理文本
|
||||
from config.logger import setup_logging
|
||||
import json
|
||||
import asyncio
|
||||
import time
|
||||
from core.utils.util import remove_punctuation_and_length, get_string_no_punctuation_or_emoji
|
||||
|
||||
# 定义当前模块的标签,通常用于日志记录
|
||||
TAG = __name__
|
||||
|
||||
# 设置日志记录器
|
||||
logger = setup_logging()
|
||||
|
||||
async def isLLMWantToFinish(last_text):
|
||||
"""判断LLM是否想要结束对话"""
|
||||
_, last_text_without_punctuation = remove_punctuation_and_length(last_text) # 去除标点符号并获取文本
|
||||
if "再见" in last_text_without_punctuation or "拜拜" in last_text_without_punctuation: # 如果文本中包含“再见”或“拜拜”
|
||||
return True # 返回True,表示LLM想要结束对话
|
||||
return False # 否则返回False
|
||||
|
||||
async def sendAudioMessage(conn, audios, text, text_index=0):
|
||||
"""发送音频消息"""
|
||||
# 如果是第一段语音,记录日志
|
||||
# 发送句子开始消息
|
||||
if text_index == conn.tts_first_text_index:
|
||||
logger.bind(tag=TAG).info(f"发送第一段语音: {text}")
|
||||
|
||||
# 发送句子开始消息
|
||||
await send_tts_message(conn, "sentence_start", text)
|
||||
|
||||
# 初始化流控参数
|
||||
frame_duration = 60 # 每帧音频的时长(毫秒)
|
||||
start_time = time.perf_counter() # 使用高精度计时器记录开始时间
|
||||
play_position = 0 # 已播放的时长(毫秒)
|
||||
# 流控参数优化
|
||||
original_frame_duration = 60 # 原始帧时长(毫秒)
|
||||
adjusted_frame_duration = int(original_frame_duration * 0.8) # 缩短20%
|
||||
total_frames = len(audios) # 获取总帧数
|
||||
compensation = total_frames * (original_frame_duration - adjusted_frame_duration) / 1000 # 补偿时间(秒)
|
||||
|
||||
start_time = time.perf_counter()
|
||||
play_position = 0 # 已播放时长(毫秒)
|
||||
|
||||
# 遍历音频包并发送
|
||||
for opus_packet in audios:
|
||||
if conn.client_abort: # 如果客户端中止,直接返回
|
||||
if conn.client_abort:
|
||||
return
|
||||
|
||||
# 计算当前包的预期发送时间
|
||||
# 计算带加速因子的预期时间
|
||||
expected_time = start_time + (play_position / 1000)
|
||||
current_time = time.perf_counter()
|
||||
|
||||
# 等待直到预期时间
|
||||
# 流控等待(使用加速后的帧时长)
|
||||
delay = expected_time - current_time
|
||||
if delay > 0:
|
||||
await asyncio.sleep(delay)
|
||||
|
||||
# 发送音频包
|
||||
await conn.websocket.send(opus_packet)
|
||||
play_position += frame_duration # 更新播放位置
|
||||
play_position += adjusted_frame_duration # 使用调整后的帧时长
|
||||
|
||||
# 补偿因加速损失的时长
|
||||
if compensation > 0:
|
||||
await asyncio.sleep(compensation)
|
||||
|
||||
# 发送句子结束消息
|
||||
await send_tts_message(conn, "sentence_end", text)
|
||||
|
||||
# 如果是最后一个文本且任务完成,发送停止消息
|
||||
# 发送结束消息(如果是最后一个文本)
|
||||
if conn.llm_finish_task and text_index == conn.tts_last_text_index:
|
||||
await send_tts_message(conn, 'stop', None)
|
||||
if await isLLMWantToFinish(text): # 如果LLM想要结束对话
|
||||
await conn.close() # 关闭连接
|
||||
if conn.close_after_chat:
|
||||
await conn.close()
|
||||
|
||||
async def send_tts_message(conn, state, text=None):
|
||||
"""发送 TTS 状态消息"""
|
||||
message = {
|
||||
"type": "tts", # 消息类型为TTS
|
||||
"state": state, # TTS状态
|
||||
"session_id": conn.session_id # 会话ID
|
||||
"type": "tts",
|
||||
"state": state,
|
||||
"session_id": conn.session_id
|
||||
}
|
||||
if text is not None: # 如果文本不为空,添加到消息中
|
||||
if text is not None:
|
||||
message["text"] = text
|
||||
|
||||
# 发送JSON格式的消息
|
||||
await conn.websocket.send(json.dumps(message))
|
||||
if state == "stop": # 如果状态为停止,清除说话状态
|
||||
if state == "stop":
|
||||
conn.clearSpeakStatus()
|
||||
|
||||
|
||||
async def send_stt_message(conn, text):
|
||||
"""发送 STT 状态消息"""
|
||||
stt_text = get_string_no_punctuation_or_emoji(text) # 去除标点符号和表情符号
|
||||
# 发送STT消息
|
||||
stt_text = get_string_no_punctuation_or_emoji(text)
|
||||
await conn.websocket.send(json.dumps({
|
||||
"type": "stt", # 消息类型为STT
|
||||
"text": stt_text, # 识别到的文本
|
||||
"session_id": conn.session_id # 会话ID
|
||||
}))
|
||||
# 发送LLM消息(表情)
|
||||
"type": "stt",
|
||||
"text": stt_text,
|
||||
"session_id": conn.session_id}
|
||||
))
|
||||
await conn.websocket.send(
|
||||
json.dumps({
|
||||
"type": "llm", # 消息类型为LLM
|
||||
"text": "😊", # 表情符号
|
||||
"emotion": "happy", # 情绪状态
|
||||
"session_id": conn.session_id # 会话ID
|
||||
}))
|
||||
# 发送TTS开始消息
|
||||
"type": "llm",
|
||||
"text": "😊",
|
||||
"emotion": "happy",
|
||||
"session_id": conn.session_id}
|
||||
))
|
||||
await send_tts_message(conn, "start")
|
||||
|
|
@ -1,52 +1,46 @@
|
|||
# 导入所需的模块
|
||||
from config.logger import setup_logging # 导入日志设置模块
|
||||
import json # 导入JSON模块,用于处理JSON数据
|
||||
from core.handle.abortHandle import handleAbortMessage # 导入处理中止消息的模块
|
||||
from core.handle.helloHandle import handleHelloMessage # 导入处理问候消息的模块
|
||||
from core.handle.receiveAudioHandle import startToChat # 导入处理音频消息的模块
|
||||
from core.handle.iotHandle import handleIotDescriptors # 导入处理IoT描述符的模块
|
||||
from config.logger import setup_logging
|
||||
import json
|
||||
from core.handle.abortHandle import handleAbortMessage
|
||||
from core.handle.helloHandle import handleHelloMessage
|
||||
from core.handle.receiveAudioHandle import startToChat
|
||||
from core.handle.iotHandle import handleIotDescriptors, handleIotStatus
|
||||
|
||||
# 定义当前模块的标签,通常用于日志记录
|
||||
TAG = __name__
|
||||
|
||||
# 设置日志记录器
|
||||
logger = setup_logging()
|
||||
|
||||
|
||||
async def handleTextMessage(conn, message):
|
||||
"""处理文本消息"""
|
||||
logger.bind(tag=TAG).info(f"收到文本消息:{message}") # 记录收到的文本消息
|
||||
|
||||
logger.bind(tag=TAG).info(f"收到文本消息:{message}")
|
||||
try:
|
||||
msg_json = json.loads(message) # 将消息解析为JSON格式
|
||||
if isinstance(msg_json, int): # 如果消息是整数类型(异常情况)
|
||||
await conn.websocket.send(message) # 直接返回消息
|
||||
msg_json = json.loads(message)
|
||||
if isinstance(msg_json, int):
|
||||
await conn.websocket.send(message)
|
||||
return
|
||||
|
||||
# 根据消息类型处理不同的逻辑
|
||||
if msg_json["type"] == "hello": # 如果消息类型是问候
|
||||
await handleHelloMessage(conn) # 调用处理问候消息的函数
|
||||
elif msg_json["type"] == "abort": # 如果消息类型是中止
|
||||
await handleAbortMessage(conn) # 调用处理中止消息的函数
|
||||
elif msg_json["type"] == "listen": # 如果消息类型是监听
|
||||
if "mode" in msg_json: # 如果消息中包含监听模式
|
||||
conn.client_listen_mode = msg_json["mode"] # 更新客户端的监听模式
|
||||
logger.bind(tag=TAG).debug(f"客户端拾音模式:{conn.client_listen_mode}") # 记录监听模式
|
||||
|
||||
# 根据监听状态更新客户端状态
|
||||
if msg_json["state"] == "start": # 如果监听状态为开始
|
||||
conn.client_have_voice = True # 设置客户端有声音
|
||||
conn.client_voice_stop = False # 设置客户端声音未停止
|
||||
elif msg_json["state"] == "stop": # 如果监听状态为停止
|
||||
conn.client_have_voice = True # 设置客户端有声音
|
||||
conn.client_voice_stop = True # 设置客户端声音已停止
|
||||
elif msg_json["state"] == "detect": # 如果监听状态为检测
|
||||
conn.asr_server_receive = False # 设置ASR服务器不接收数据
|
||||
conn.client_have_voice = False # 设置客户端无声音
|
||||
conn.asr_audio.clear() # 清空ASR音频缓存
|
||||
if "text" in msg_json: # 如果消息中包含文本
|
||||
await startToChat(conn, msg_json["text"]) # 启动聊天
|
||||
elif msg_json["type"] == "iot": # 如果消息类型是IoT
|
||||
if "descriptors" in msg_json: # 如果消息中包含描述符
|
||||
await handleIotDescriptors(conn, msg_json["descriptors"]) # 调用处理IoT描述符的函数
|
||||
except json.JSONDecodeError: # 如果JSON解析失败
|
||||
await conn.websocket.send(message) # 直接返回原始消息
|
||||
if msg_json["type"] == "hello":
|
||||
await handleHelloMessage(conn)
|
||||
elif msg_json["type"] == "abort":
|
||||
await handleAbortMessage(conn)
|
||||
elif msg_json["type"] == "listen":
|
||||
if "mode" in msg_json:
|
||||
conn.client_listen_mode = msg_json["mode"]
|
||||
logger.bind(tag=TAG).debug(f"客户端拾音模式:{conn.client_listen_mode}")
|
||||
if msg_json["state"] == "start":
|
||||
conn.client_have_voice = True
|
||||
conn.client_voice_stop = False
|
||||
elif msg_json["state"] == "stop":
|
||||
conn.client_have_voice = True
|
||||
conn.client_voice_stop = True
|
||||
elif msg_json["state"] == "detect":
|
||||
conn.asr_server_receive = False
|
||||
conn.client_have_voice = False
|
||||
conn.asr_audio.clear()
|
||||
if "text" in msg_json:
|
||||
await startToChat(conn, msg_json["text"])
|
||||
elif msg_json["type"] == "iot":
|
||||
if "descriptors" in msg_json:
|
||||
await handleIotDescriptors(conn, msg_json["descriptors"])
|
||||
if "states" in msg_json:
|
||||
await handleIotStatus(conn, msg_json["states"])
|
||||
except json.JSONDecodeError:
|
||||
await conn.websocket.send(message)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,38 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from config.logger import setup_logging
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
class LLMProviderBase(ABC):
|
||||
@abstractmethod
|
||||
def response(self, session_id, dialogue):
|
||||
"""LLM response generator"""
|
||||
pass
|
||||
|
||||
def response_no_stream(self, system_prompt, user_prompt):
|
||||
try:
|
||||
# 构造对话格式
|
||||
dialogue = [
|
||||
{"role": "system", "content": system_prompt},
|
||||
{"role": "user", "content": user_prompt}
|
||||
]
|
||||
result = ""
|
||||
for part in self.response("", dialogue):
|
||||
result += part
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error in Ollama response generation: {e}")
|
||||
return "【LLM服务响应异常】"
|
||||
|
||||
def response_with_functions(self, session_id, dialogue, functions=None):
|
||||
"""
|
||||
Default implementation for function calling (streaming)
|
||||
This should be overridden by providers that support function calls
|
||||
|
||||
Returns: generator that yields either text tokens or a special function call token
|
||||
"""
|
||||
# For providers that don't support functions, just return regular response
|
||||
for token in self.response(session_id, dialogue):
|
||||
yield {"type": "content", "content": token}
|
||||
|
|
@ -11,11 +11,13 @@ from cozepy import Coze, TokenAuth, Message, ChatStatus, MessageContentType, Cha
|
|||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
|
||||
class LLMProvider(LLMProviderBase):
|
||||
def __init__(self, config):
|
||||
self.personal_access_token = config.get("personal_access_token")
|
||||
self.bot_id = config.get("bot_id")
|
||||
self.user_id = config.get("user_id")
|
||||
self.session_conversation_map = {} # 存储session_id和conversation_id的映射
|
||||
|
||||
def response(self, session_id, dialogue):
|
||||
coze_api_token = self.personal_access_token
|
||||
|
|
@ -24,6 +26,16 @@ class LLMProvider(LLMProviderBase):
|
|||
last_msg = next(m for m in reversed(dialogue) if m["role"] == "user")
|
||||
|
||||
coze = Coze(auth=TokenAuth(token=coze_api_token), base_url=coze_api_base)
|
||||
conversation_id = self.session_conversation_map.get(session_id)
|
||||
|
||||
# 如果没有找到conversation_id,则创建新的对话
|
||||
if not conversation_id:
|
||||
conversation = coze.conversations.create(
|
||||
messages=[
|
||||
]
|
||||
)
|
||||
conversation_id = conversation.id
|
||||
self.session_conversation_map[session_id] = conversation_id # 更新映射
|
||||
|
||||
for event in coze.chat.stream(
|
||||
bot_id=self.bot_id,
|
||||
|
|
@ -31,6 +43,7 @@ class LLMProvider(LLMProviderBase):
|
|||
additional_messages=[
|
||||
Message.build_user_question_text(last_msg["content"]),
|
||||
],
|
||||
conversation_id=conversation_id,
|
||||
):
|
||||
if event.event == ChatEventType.CONVERSATION_MESSAGE_DELTA:
|
||||
print(event.message.content, end="", flush=True)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from config.logger import setup_logging
|
||||
import requests, json
|
||||
from openai import OpenAI
|
||||
import json
|
||||
from core.providers.llm.base import LLMProviderBase
|
||||
|
||||
TAG = __name__
|
||||
|
|
@ -8,39 +9,51 @@ logger = setup_logging()
|
|||
|
||||
class LLMProvider(LLMProviderBase):
|
||||
def __init__(self, config):
|
||||
|
||||
self.model_name = config.get("model_name")
|
||||
self.base_url = config.get("base_url", "http://localhost:11434")
|
||||
# Initialize OpenAI client with Ollama base URL
|
||||
#如果没有v1,增加v1
|
||||
if not self.base_url.endswith("/v1"):
|
||||
self.base_url = f"{self.base_url}/v1"
|
||||
|
||||
self.client = OpenAI(
|
||||
base_url=self.base_url,
|
||||
api_key="ollama" # Ollama doesn't need an API key but OpenAI client requires one
|
||||
)
|
||||
|
||||
def response(self, session_id, dialogue):
|
||||
try:
|
||||
# Convert dialogue format to Ollama format
|
||||
prompt = ""
|
||||
for msg in dialogue:
|
||||
if msg["role"] == "system":
|
||||
prompt += f"System: {msg['content']}\n"
|
||||
elif msg["role"] == "user":
|
||||
prompt += f"User: {msg['content']}\n"
|
||||
elif msg["role"] == "assistant":
|
||||
prompt += f"Assistant: {msg['content']}\n"
|
||||
|
||||
# Make request to Ollama API
|
||||
response = requests.post(
|
||||
f"{self.base_url}/api/generate",
|
||||
json={
|
||||
"model": self.model_name,
|
||||
"prompt": prompt,
|
||||
"stream": True
|
||||
},
|
||||
responses = self.client.chat.completions.create(
|
||||
model=self.model_name,
|
||||
messages=dialogue,
|
||||
stream=True
|
||||
)
|
||||
|
||||
for line in response.iter_lines():
|
||||
if line:
|
||||
json_response = json.loads(line)
|
||||
if "response" in json_response:
|
||||
yield json_response["response"]
|
||||
for chunk in responses:
|
||||
try:
|
||||
delta = chunk.choices[0].delta if getattr(chunk, 'choices', None) else None
|
||||
content = delta.content if hasattr(delta, 'content') else ''
|
||||
if content:
|
||||
yield content
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error processing chunk: {e}")
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error in Ollama response generation: {e}")
|
||||
yield "【Ollama服务响应异常】"
|
||||
|
||||
def response_with_functions(self, session_id, dialogue, functions=None):
|
||||
try:
|
||||
stream = self.client.chat.completions.create(
|
||||
model=self.model_name,
|
||||
messages=dialogue,
|
||||
stream=True,
|
||||
tools=functions,
|
||||
)
|
||||
|
||||
for chunk in stream:
|
||||
yield chunk.choices[0].delta.content, chunk.choices[0].delta.tool_calls
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error in Ollama function call: {e}")
|
||||
yield {"type": "content", "content": f"【Ollama服务响应异常: {str(e)}】"}
|
||||
|
|
@ -43,3 +43,19 @@ class LLMProvider(LLMProviderBase):
|
|||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error in response generation: {e}")
|
||||
|
||||
def response_with_functions(self, session_id, dialogue, functions=None):
|
||||
try:
|
||||
stream = self.client.chat.completions.create(
|
||||
model=self.model_name,
|
||||
messages=dialogue,
|
||||
stream=True,
|
||||
tools=functions,
|
||||
)
|
||||
|
||||
for chunk in stream:
|
||||
yield chunk.choices[0].delta.content, chunk.choices[0].delta.tool_calls
|
||||
|
||||
except Exception as e:
|
||||
self.logger.bind(tag=TAG).error(f"Error in function call streaming: {e}")
|
||||
yield {"type": "content", "content": f"【OpenAI服务响应异常: {e}】"}
|
||||
|
|
@ -8,6 +8,7 @@ class MemoryProviderBase(ABC):
|
|||
def __init__(self, config):
|
||||
self.config = config
|
||||
self.role_id = None
|
||||
self.llm = None
|
||||
|
||||
@abstractmethod
|
||||
async def save_memory(self, msgs):
|
||||
|
|
@ -19,5 +20,6 @@ class MemoryProviderBase(ABC):
|
|||
"""Query memories for specific role based on similarity"""
|
||||
return "please implement query method"
|
||||
|
||||
def set_role_id(self, role_id: str):
|
||||
def init_memory(self, role_id, llm):
|
||||
self.role_id = role_id
|
||||
self.llm = llm
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ class Dialogue:
|
|||
return dialogue
|
||||
|
||||
def get_llm_dialogue_with_memory(self, memory_str: str = None) -> List[Dict[str, str]]:
|
||||
if memory_str is None or len(memory_str) == 0:
|
||||
return self.get_llm_dialogue()
|
||||
|
||||
# 构建带记忆的对话
|
||||
dialogue = []
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import yaml
|
|||
import socket
|
||||
import subprocess
|
||||
import logging
|
||||
import re
|
||||
|
||||
|
||||
def get_project_dir():
|
||||
|
|
@ -75,7 +76,7 @@ def get_string_no_punctuation_or_emoji(s):
|
|||
def remove_punctuation_and_length(text):
|
||||
# 全角符号和半角符号的Unicode范围
|
||||
full_width_punctuations = '!"#$%&'()*+,-。/:;<=>?@[\]^_`{|}~'
|
||||
half_width_punctuations = '!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~'
|
||||
half_width_punctuations = r'!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~'
|
||||
space = ' ' # 半角空格
|
||||
full_width_space = ' ' # 全角空格
|
||||
|
||||
|
|
@ -119,3 +120,11 @@ def check_ffmpeg_installed():
|
|||
error_msg += "1、按照项目的安装文档,正确进入conda环境\n"
|
||||
error_msg += "2、查阅安装文档,如何在conda环境中安装ffmpeg\n"
|
||||
raise ValueError(error_msg)
|
||||
|
||||
def extract_json_from_string(input_string):
|
||||
"""提取字符串中的 JSON 部分"""
|
||||
pattern = r'(\{.*\})'
|
||||
match = re.search(pattern, input_string)
|
||||
if match:
|
||||
return match.group(1) # 返回提取的 JSON 字符串
|
||||
return None
|
||||
|
|
@ -4,39 +4,24 @@ from config.logger import setup_logging
|
|||
from core.connection import ConnectionHandler
|
||||
from core.handle.musicHandler import MusicHandler
|
||||
from core.utils.util import get_local_ip
|
||||
from core.utils import asr, vad, llm, tts, memory
|
||||
from core.utils import asr, vad, llm, tts, memory, intent
|
||||
|
||||
# 获取当前模块的名称作为日志标签
|
||||
TAG = __name__
|
||||
|
||||
|
||||
class WebSocketServer:
|
||||
def __init__(self, config: dict):
|
||||
"""
|
||||
初始化WebSocket服务器。
|
||||
|
||||
:param config: 包含服务器配置和模块选择的字典。
|
||||
"""
|
||||
self.config = config
|
||||
self.logger = setup_logging() # 初始化日志记录器
|
||||
# 创建处理模块的实例
|
||||
self._vad, self._asr, self._llm, self._tts, self._music, self._memory = self._create_processing_instances()
|
||||
self.active_connections = set() # 用于记录当前活动的连接
|
||||
self.logger = setup_logging()
|
||||
self._vad, self._asr, self._llm, self._tts, self._music, self._memory, self.intent = self._create_processing_instances()
|
||||
self.active_connections = set() # 添加全局连接记录
|
||||
|
||||
def _create_processing_instances(self):
|
||||
"""
|
||||
根据配置创建各个处理模块的实例。
|
||||
|
||||
:return: 返回一个包含各个模块实例的元组。
|
||||
"""
|
||||
# 获取配置中选择的Memory模块名称,默认为'mem0ai'
|
||||
memory_cls_name = self.config["selected_module"].get("Memory", "mem0ai")
|
||||
# 检查配置中是否存在Memory模块的配置
|
||||
memory_cls_name = self.config["selected_module"].get("Memory", "nomem") # 默认使用nomem
|
||||
has_memory_cfg = self.config.get("Memory") and memory_cls_name in self.config["Memory"]
|
||||
# 获取Memory模块的配置,如果不存在则使用空字典
|
||||
memory_cfg = self.config["Memory"][memory_cls_name] if has_memory_cfg else {}
|
||||
|
||||
# 创建各个处理模块的实例
|
||||
"""创建处理模块实例"""
|
||||
return (
|
||||
vad.create_instance(
|
||||
self.config["selected_module"]["VAD"],
|
||||
|
|
@ -65,40 +50,39 @@ class WebSocketServer:
|
|||
self.config["TTS"][self.config["selected_module"]["TTS"]],
|
||||
self.config["delete_audio"]
|
||||
),
|
||||
MusicHandler(self.config), # 创建音乐处理模块的实例
|
||||
memory.create_instance(memory_cls_name, memory_cfg), # 创建记忆模块的实例
|
||||
MusicHandler(self.config),
|
||||
memory.create_instance(memory_cls_name, memory_cfg),
|
||||
intent.create_instance(
|
||||
self.config["selected_module"]["Intent"]
|
||||
if not 'type' in self.config["Intent"][self.config["selected_module"]["Intent"]]
|
||||
else
|
||||
self.config["Intent"][self.config["selected_module"]["Intent"]]["type"],
|
||||
self.config["Intent"][self.config["selected_module"]["Intent"]]
|
||||
),
|
||||
)
|
||||
|
||||
async def start(self):
|
||||
"""
|
||||
启动WebSocket服务器。
|
||||
"""
|
||||
server_config = self.config["server"]
|
||||
host = server_config["ip"] # 获取服务器IP地址
|
||||
port = server_config["port"] # 获取服务器端口号
|
||||
host = server_config["ip"]
|
||||
port = server_config["port"]
|
||||
selected_module = self.config.get("selected_module")
|
||||
self.logger.bind(tag=TAG).info(f"selected_module: {selected_module}")
|
||||
|
||||
# 记录服务器启动信息
|
||||
self.logger.bind(tag=TAG).info("Server is running at ws://{}:{}", get_local_ip(), port)
|
||||
self.logger.bind(tag=TAG).info("=======上面的地址是websocket协议地址,请勿用浏览器访问=======")
|
||||
|
||||
# 启动WebSocket服务器
|
||||
async with websockets.serve(
|
||||
self._handle_connection,
|
||||
host,
|
||||
port
|
||||
):
|
||||
await asyncio.Future() # 保持服务器运行
|
||||
await asyncio.Future()
|
||||
|
||||
async def _handle_connection(self, websocket):
|
||||
"""
|
||||
处理新的WebSocket连接。
|
||||
|
||||
:param websocket: 新的WebSocket连接对象。
|
||||
"""
|
||||
# 创建ConnectionHandler实例,传入当前server实例和各个处理模块
|
||||
handler = ConnectionHandler(self.config, self._vad, self._asr, self._llm, self._tts, self._music, self._memory)
|
||||
self.active_connections.add(handler) # 将新连接添加到活动连接集合中
|
||||
"""处理新连接,每次创建独立的ConnectionHandler"""
|
||||
# 创建ConnectionHandler时传入当前server实例
|
||||
handler = ConnectionHandler(self.config, self._vad, self._asr, self._llm, self._tts, self._music, self._memory, self.intent)
|
||||
self.active_connections.add(handler)
|
||||
try:
|
||||
await handler.handle_connection(websocket) # 处理连接
|
||||
await handler.handle_connection(websocket)
|
||||
finally:
|
||||
self.active_connections.discard(handler) # 连接结束后从活动连接集合中移除
|
||||
self.active_connections.discard(handler)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,9 @@
|
|||
# 导入AutoModel类和rich_transcription_postprocess函数
|
||||
# AutoModel是FunASR库中的一个类,用于加载和运行语音识别模型
|
||||
# rich_transcription_postprocess用于对识别结果进行后处理,使其更加丰富和易读
|
||||
from funasr import AutoModel
|
||||
from funasr.utils.postprocess_utils import rich_transcription_postprocess
|
||||
|
||||
# 定义模型目录路径,这里假设模型文件存储在当前目录下
|
||||
model_dir = "./"
|
||||
|
||||
# 使用AutoModel加载模型
|
||||
# model_dir: 模型文件所在的目录路径
|
||||
# vad_model: 指定使用的语音活动检测(VAD)模型,这里使用的是"fsmn-vad"
|
||||
# vad_kwargs: VAD模型的参数配置,这里设置最大单段语音时长为30000毫秒(即30秒)
|
||||
# device: 指定运行模型的设备,例如"cuda:0"表示使用GPU,这里被注释掉了,默认使用CPU
|
||||
# hub: 指定模型来源,这里使用"hf"表示从Hugging Face Hub加载模型
|
||||
|
||||
model = AutoModel(
|
||||
model=model_dir,
|
||||
vad_model="fsmn-vad",
|
||||
|
|
@ -21,28 +12,16 @@ model = AutoModel(
|
|||
hub="hf",
|
||||
)
|
||||
|
||||
# 使用模型进行语音识别
|
||||
# input: 指定输入的音频文件路径,这里使用的是模型目录下的example/en.mp3文件
|
||||
# cache: 用于缓存中间结果,这里初始化为空字典
|
||||
# language: 指定语音识别的语言,这里设置为"auto"表示自动检测语言
|
||||
# use_itn: 是否使用逆文本归一化(Inverse Text Normalization),这里设置为True
|
||||
# batch_size_s: 指定批处理的大小,单位为秒,这里设置为60秒
|
||||
# merge_vad: 是否合并VAD检测到的语音段,这里设置为True
|
||||
# merge_length_s: 合并语音段的最大长度,单位为秒,这里设置为15秒
|
||||
# en
|
||||
res = model.generate(
|
||||
input=f"{model.model_path}/example/en.mp3",
|
||||
cache={},
|
||||
language="auto", # 可选值:"zn"(中文),"en"(英文),"yue"(粤语),"ja"(日语),"ko"(韩语),"nospeech"(无语音)
|
||||
language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech"
|
||||
use_itn=True,
|
||||
batch_size_s=60,
|
||||
merge_vad=True, #
|
||||
merge_length_s=15,
|
||||
)
|
||||
|
||||
# 对识别结果进行后处理
|
||||
# res[0]["text"]: 获取识别结果中的文本部分
|
||||
# rich_transcription_postprocess: 对文本进行后处理,使其更加丰富和易读
|
||||
text = rich_transcription_postprocess(res[0]["text"])
|
||||
|
||||
# 打印处理后的文本
|
||||
print(text)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,99 +1,56 @@
|
|||
# 定义依赖库
|
||||
dependencies = ['torch', 'torchaudio'] # 依赖的库包括 PyTorch 和 torchaudio
|
||||
|
||||
# 导入必要的库
|
||||
import torch # PyTorch 深度学习框架
|
||||
import os # 用于处理文件路径和目录
|
||||
import sys # 用于系统相关的操作,如修改 Python 路径
|
||||
|
||||
# 将当前脚本所在目录的 'src' 文件夹添加到 Python 路径中
|
||||
# 这样可以直接从 'src' 目录中导入模块
|
||||
dependencies = ['torch', 'torchaudio']
|
||||
import torch
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
||||
|
||||
# 从 silero_vad 工具库中导入必要的函数和类
|
||||
from silero_vad.utils_vad import (
|
||||
init_jit_model, # 初始化 JIT 模型
|
||||
get_speech_timestamps, # 获取语音时间戳
|
||||
save_audio, # 保存音频文件
|
||||
read_audio, # 读取音频文件
|
||||
VADIterator, # 语音活动检测迭代器
|
||||
collect_chunks, # 收集语音片段
|
||||
OnnxWrapper # ONNX 模型封装器
|
||||
)
|
||||
from silero_vad.utils_vad import (init_jit_model,
|
||||
get_speech_timestamps,
|
||||
save_audio,
|
||||
read_audio,
|
||||
VADIterator,
|
||||
collect_chunks,
|
||||
OnnxWrapper)
|
||||
|
||||
|
||||
def versiontuple(v):
|
||||
"""将版本号字符串转换为元组形式,便于比较版本号。
|
||||
|
||||
参数:
|
||||
v (str): 版本号字符串,例如 '1.12.0' 或 '2.0.0+cu102'
|
||||
|
||||
返回:
|
||||
tuple: 版本号的元组形式,例如 (1, 12, 0)
|
||||
"""
|
||||
splitted = v.split('+')[0].split(".") # 去掉版本号中的附加信息(如 '+cu102'),并按 '.' 分割
|
||||
splitted = v.split('+')[0].split(".")
|
||||
version_list = []
|
||||
for i in splitted:
|
||||
try:
|
||||
version_list.append(int(i)) # 将每个部分转换为整数
|
||||
version_list.append(int(i))
|
||||
except:
|
||||
version_list.append(0) # 如果转换失败,则默认为 0
|
||||
return tuple(version_list) # 返回元组形式的版本号
|
||||
version_list.append(0)
|
||||
return tuple(version_list)
|
||||
|
||||
|
||||
def silero_vad(onnx=False, force_onnx_cpu=False, opset_version=16):
|
||||
"""Silero 语音活动检测器 (VAD)
|
||||
|
||||
返回一个模型及其工具函数。
|
||||
更多使用示例请参考:https://github.com/snakers4/silero-vad
|
||||
|
||||
参数:
|
||||
onnx (bool): 是否使用 ONNX 格式的模型,默认为 False
|
||||
force_onnx_cpu (bool): 是否强制 ONNX 模型在 CPU 上运行,默认为 False
|
||||
opset_version (int): ONNX 模型的 opset 版本,默认为 16
|
||||
|
||||
返回:
|
||||
model: 加载的 VAD 模型
|
||||
utils: 包含工具函数的元组,包括:
|
||||
- get_speech_timestamps: 获取语音时间戳
|
||||
- save_audio: 保存音频文件
|
||||
- read_audio: 读取音频文件
|
||||
- VADIterator: 语音活动检测迭代器
|
||||
- collect_chunks: 收集语音片段
|
||||
"""Silero Voice Activity Detector
|
||||
Returns a model with a set of utils
|
||||
Please see https://github.com/snakers4/silero-vad for usage examples
|
||||
"""
|
||||
available_ops = [15, 16] # 支持的 ONNX opset 版本
|
||||
available_ops = [15, 16]
|
||||
if onnx and opset_version not in available_ops:
|
||||
raise Exception(f'Available ONNX opset_version: {available_ops}') # 如果 opset 版本不支持,抛出异常
|
||||
raise Exception(f'Available ONNX opset_version: {available_ops}')
|
||||
|
||||
if not onnx:
|
||||
# 如果不是 ONNX 模式,检查 PyTorch 版本是否满足要求
|
||||
installed_version = torch.__version__ # 获取当前安装的 PyTorch 版本
|
||||
supported_version = '1.12.0' # 支持的最低 PyTorch 版本
|
||||
installed_version = torch.__version__
|
||||
supported_version = '1.12.0'
|
||||
if versiontuple(installed_version) < versiontuple(supported_version):
|
||||
raise Exception(f'Please install torch {supported_version} or greater ({installed_version} installed)')
|
||||
|
||||
# 定义模型文件所在的目录
|
||||
model_dir = os.path.join(os.path.dirname(__file__), 'src', 'silero_vad', 'data')
|
||||
|
||||
if onnx:
|
||||
# 如果是 ONNX 模式,加载 ONNX 模型
|
||||
if opset_version == 16:
|
||||
model_name = 'silero_vad.onnx' # 默认 ONNX 模型文件名
|
||||
model_name = 'silero_vad.onnx'
|
||||
else:
|
||||
model_name = f'silero_vad_16k_op{opset_version}.onnx' # 其他 opset 版本的模型文件名
|
||||
model = OnnxWrapper(os.path.join(model_dir, model_name), force_onnx_cpu) # 加载 ONNX 模型
|
||||
model_name = f'silero_vad_16k_op{opset_version}.onnx'
|
||||
model = OnnxWrapper(os.path.join(model_dir, model_name), force_onnx_cpu)
|
||||
else:
|
||||
# 如果不是 ONNX 模式,加载 JIT 模型
|
||||
model = init_jit_model(os.path.join(model_dir, 'silero_vad.jit'))
|
||||
utils = (get_speech_timestamps,
|
||||
save_audio,
|
||||
read_audio,
|
||||
VADIterator,
|
||||
collect_chunks)
|
||||
|
||||
# 定义工具函数元组
|
||||
utils = (
|
||||
get_speech_timestamps, # 获取语音时间戳
|
||||
save_audio, # 保存音频文件
|
||||
read_audio, # 读取音频文件
|
||||
VADIterator, # 语音活动检测迭代器
|
||||
collect_chunks # 收集语音片段
|
||||
)
|
||||
|
||||
# 返回模型和工具函数
|
||||
return model, utils
|
||||
|
|
@ -18,19 +18,16 @@ logging.basicConfig(level=logging.WARNING)
|
|||
|
||||
class AsyncPerformanceTester:
|
||||
def __init__(self):
|
||||
# 读取配置文件
|
||||
self.config = read_config(get_config_file())
|
||||
# 获取测试句子,如果没有配置则使用默认的测试句子
|
||||
self.test_sentences = self.config.get("module_test", {}).get(
|
||||
"test_sentences",
|
||||
["你好,请介绍一下你自己", "What's the weather like today?",
|
||||
"请用100字概括量子计算的基本原理和应用前景"]
|
||||
)
|
||||
# 初始化结果存储字典
|
||||
self.results = {
|
||||
"llm": {}, # 存储LLM(大语言模型)的测试结果
|
||||
"tts": {}, # 存储TTS(文本转语音)的测试结果
|
||||
"combinations": [] # 存储LLM和TTS的组合测试结果
|
||||
"llm": {},
|
||||
"tts": {},
|
||||
"combinations": []
|
||||
}
|
||||
|
||||
async def _check_ollama_service(self, base_url: str, model_name: str) -> bool:
|
||||
|
|
@ -62,19 +59,15 @@ class AsyncPerformanceTester:
|
|||
async def _test_tts(self, tts_name: str, config: Dict) -> Dict:
|
||||
"""异步测试单个TTS性能"""
|
||||
try:
|
||||
# 设置TTS模块的日志级别为WARNING,避免过多的日志输出
|
||||
logging.getLogger("core.providers.tts.base").setLevel(logging.WARNING)
|
||||
|
||||
# 检查TTS配置中的关键字段是否已正确配置
|
||||
token_fields = ["access_token", "api_key", "token"]
|
||||
if any(field in config and any(x in config[field] for x in ["你的", "placeholder"]) for field in
|
||||
token_fields):
|
||||
print(f"⏭️ TTS {tts_name} 未配置access_token/api_key,已跳过")
|
||||
return {"name": tts_name, "type": "tts", "errors": 1}
|
||||
|
||||
# 获取TTS模块类型,如果没有配置则使用tts_name
|
||||
module_type = config.get('type', tts_name)
|
||||
# 创建TTS实例
|
||||
tts = create_tts_instance(
|
||||
module_type,
|
||||
config,
|
||||
|
|
@ -83,17 +76,13 @@ class AsyncPerformanceTester:
|
|||
|
||||
print(f"🎵 测试 TTS: {tts_name}")
|
||||
|
||||
# 生成临时文件名
|
||||
tmp_file = tts.generate_filename()
|
||||
# 测试TTS连接
|
||||
await tts.text_to_speak("连接测试", tmp_file)
|
||||
|
||||
# 检查生成的音频文件是否存在
|
||||
if not tmp_file or not os.path.exists(tmp_file):
|
||||
print(f"❌ {tts_name} 连接失败")
|
||||
return {"name": tts_name, "type": "tts", "errors": 1}
|
||||
|
||||
# 计算TTS合成时间
|
||||
total_time = 0
|
||||
test_count = len(self.test_sentences[:2])
|
||||
|
||||
|
|
@ -104,14 +93,12 @@ class AsyncPerformanceTester:
|
|||
duration = time.time() - start
|
||||
total_time += duration
|
||||
|
||||
# 检查生成的音频文件是否存在
|
||||
if tmp_file and os.path.exists(tmp_file):
|
||||
print(f"✓ {tts_name} [{i}/{test_count}]")
|
||||
else:
|
||||
print(f"✗ {tts_name} [{i}/{test_count}]")
|
||||
return {"name": tts_name, "type": "tts", "errors": 1}
|
||||
|
||||
# 返回测试结果
|
||||
return {
|
||||
"name": tts_name,
|
||||
"type": "tts",
|
||||
|
|
@ -137,14 +124,12 @@ class AsyncPerformanceTester:
|
|||
if not await self._check_ollama_service(base_url, model_name):
|
||||
return {"name": llm_name, "type": "llm", "errors": 1}
|
||||
else:
|
||||
# 检查LLM配置中的api_key是否已正确配置
|
||||
if "api_key" in config and any(x in config["api_key"] for x in ["你的", "placeholder", "sk-xxx"]):
|
||||
print(f"🚫 跳过未配置的LLM: {llm_name}")
|
||||
return {"name": llm_name, "type": "llm", "errors": 1}
|
||||
|
||||
# 获取LLM模块类型,如果没有配置则使用llm_name
|
||||
# 获取实际类型(兼容旧配置)
|
||||
module_type = config.get('type', llm_name)
|
||||
# 创建LLM实例
|
||||
llm = create_llm_instance(module_type, config)
|
||||
|
||||
# 统一使用UTF-8编码
|
||||
|
|
@ -164,7 +149,6 @@ class AsyncPerformanceTester:
|
|||
print(f"⚠️ {llm_name} 无有效数据,可能配置错误")
|
||||
return {"name": llm_name, "type": "llm", "errors": 1}
|
||||
|
||||
# 计算首字时间和响应时间
|
||||
first_token_times = [r["first_token_time"] for r in valid_results]
|
||||
response_times = [r["response_time"] for r in valid_results]
|
||||
|
||||
|
|
@ -177,7 +161,6 @@ class AsyncPerformanceTester:
|
|||
print(f"⚠️ {llm_name} 有效数据不足,可能网络不稳定")
|
||||
return {"name": llm_name, "type": "llm", "errors": 1}
|
||||
|
||||
# 返回测试结果
|
||||
return {
|
||||
"name": llm_name,
|
||||
"type": "llm",
|
||||
|
|
@ -230,7 +213,6 @@ class AsyncPerformanceTester:
|
|||
|
||||
def _generate_combinations(self):
|
||||
"""生成最佳组合建议"""
|
||||
# 获取有效的LLM和TTS模块
|
||||
valid_llms = [
|
||||
k for k, v in self.results["llm"].items()
|
||||
if v["errors"] == 0 and v["avg_first_token"] >= 0.05
|
||||
|
|
@ -241,7 +223,6 @@ class AsyncPerformanceTester:
|
|||
min_first_token = min([self.results["llm"][llm]["avg_first_token"] for llm in valid_llms]) if valid_llms else 1
|
||||
min_tts_time = min([self.results["tts"][tts]["avg_time"] for tts in valid_tts]) if valid_tts else 1
|
||||
|
||||
# 计算每个组合的得分
|
||||
for llm in valid_llms:
|
||||
for tts in valid_tts:
|
||||
# 计算相对性能分数(越小越好)
|
||||
|
|
@ -270,21 +251,20 @@ class AsyncPerformanceTester:
|
|||
}
|
||||
})
|
||||
|
||||
# 按分数排序,分数越小越好
|
||||
# 分数越小越好
|
||||
self.results["combinations"].sort(key=lambda x: x["score"])
|
||||
|
||||
def _print_results(self):
|
||||
"""打印测试结果"""
|
||||
# 打印LLM性能排行
|
||||
llm_table = []
|
||||
for name, data in self.results["llm"].items():
|
||||
if data["errors"] == 0:
|
||||
stability = data["std_first_token"] / data["avg_first_token"]
|
||||
llm_table.append([
|
||||
name, # 模型名称
|
||||
f"{data['avg_first_token']:.3f}秒", # 首字耗时
|
||||
f"{data['avg_response']:.3f}秒", # 总耗时
|
||||
f"{stability:.3f}" # 稳定性
|
||||
name, # 不需要固定宽度,让tabulate自己处理对齐
|
||||
f"{data['avg_first_token']:.3f}秒",
|
||||
f"{data['avg_response']:.3f}秒",
|
||||
f"{stability:.3f}"
|
||||
])
|
||||
|
||||
if llm_table:
|
||||
|
|
@ -299,13 +279,12 @@ class AsyncPerformanceTester:
|
|||
else:
|
||||
print("\n⚠️ 没有可用的LLM模块进行测试。")
|
||||
|
||||
# 打印TTS性能排行
|
||||
tts_table = []
|
||||
for name, data in self.results["tts"].items():
|
||||
if data["errors"] == 0:
|
||||
tts_table.append([
|
||||
name, # 模型名称
|
||||
f"{data['avg_time']:.3f}秒" # 合成耗时
|
||||
name, # 不需要固定宽度
|
||||
f"{data['avg_time']:.3f}秒"
|
||||
])
|
||||
|
||||
if tts_table:
|
||||
|
|
@ -320,17 +299,16 @@ class AsyncPerformanceTester:
|
|||
else:
|
||||
print("\n⚠️ 没有可用的TTS模块进行测试。")
|
||||
|
||||
# 打印推荐配置组合
|
||||
if self.results["combinations"]:
|
||||
print("\n推荐配置组合 (得分越小越好):")
|
||||
combo_table = []
|
||||
for combo in self.results["combinations"][:5]:
|
||||
combo_table.append([
|
||||
f"{combo['llm']} + {combo['tts']}", # 组合方案
|
||||
f"{combo['score']:.3f}", # 综合得分
|
||||
f"{combo['details']['llm_first_token']:.3f}秒", # LLM首字耗时
|
||||
f"{combo['details']['llm_stability']:.3f}", # 稳定性
|
||||
f"{combo['details']['tts_time']:.3f}秒" # TTS合成耗时
|
||||
f"{combo['llm']} + {combo['tts']}", # 不需要固定宽度
|
||||
f"{combo['score']:.3f}",
|
||||
f"{combo['details']['llm_first_token']:.3f}秒",
|
||||
f"{combo['details']['llm_stability']:.3f}",
|
||||
f"{combo['details']['tts_time']:.3f}秒"
|
||||
])
|
||||
|
||||
print(tabulate(
|
||||
|
|
@ -450,12 +428,9 @@ class AsyncPerformanceTester:
|
|||
|
||||
|
||||
async def main():
|
||||
# 创建性能测试器实例
|
||||
tester = AsyncPerformanceTester()
|
||||
# 运行测试
|
||||
await tester.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 运行主函数
|
||||
asyncio.run(main())
|
||||
|
|
@ -1,83 +1,21 @@
|
|||
# 用于处理 YAML 文件的库,版本 0.0.2
|
||||
# YAML 是一种常用的配置文件格式,pyyml 提供了对 YAML 文件的读写支持
|
||||
pyyml==0.0.2
|
||||
|
||||
# PyTorch 是一个开源的机器学习框架,版本 2.2.2
|
||||
# 提供了张量计算、自动求导和神经网络构建等功能
|
||||
torch==2.2.2
|
||||
|
||||
# Silero VAD 是一个语音活动检测(Voice Activity Detection)库,版本 5.1.2
|
||||
# 用于检测音频中是否有语音活动
|
||||
silero_vad==5.1.2
|
||||
|
||||
# WebSockets 是一个用于实现 WebSocket 协议的库,版本 14.2
|
||||
# 支持异步通信,适用于实时数据传输场景
|
||||
websockets==14.2
|
||||
|
||||
# Opuslib_next 是一个用于编解码 Opus 音频格式的库,版本 1.1.2
|
||||
# Opus 是一种高效的音频压缩格式,常用于语音通信
|
||||
opuslib_next==1.1.2
|
||||
|
||||
# NumPy 是一个用于科学计算的库,版本 1.26.4
|
||||
# 提供了高效的数组操作和数学函数支持
|
||||
numpy==1.26.4
|
||||
|
||||
# Pydub 是一个用于音频处理的库,版本 0.25.1
|
||||
# 支持音频文件的读取、格式转换和简单编辑
|
||||
pydub==0.25.1
|
||||
|
||||
# FunASR 是一个自动语音识别(ASR)工具包,版本 1.2.3
|
||||
# 提供了语音转文本的功能,支持多种模型和语言
|
||||
funasr==1.2.3
|
||||
|
||||
# Torchaudio 是 PyTorch 的音频处理库,版本 2.2.2
|
||||
# 提供了音频加载、处理和转换的功能
|
||||
torchaudio==2.2.2
|
||||
|
||||
# OpenAI 是 OpenAI API 的官方 Python 客户端库,版本 1.61.0
|
||||
# 用于与 OpenAI 的 GPT 模型进行交互
|
||||
openai==1.61.0
|
||||
|
||||
# Google Generative AI 是 Google 生成式 AI 的 Python 客户端库,版本 0.8.4
|
||||
# 用于与 Google 的生成式 AI 模型进行交互
|
||||
google-generativeai==0.8.4
|
||||
|
||||
# Edge TTS 是一个用于文本转语音(TTS)的库,版本 7.0.0
|
||||
# 支持多种语音和语言,适用于语音合成场景
|
||||
edge_tts==7.0.0
|
||||
|
||||
# HTTPX 是一个现代化的 HTTP 客户端库,版本 0.27.2
|
||||
# 支持同步和异步请求,适用于 HTTP API 调用
|
||||
httpx==0.27.2
|
||||
|
||||
# AIOHTTP 是一个异步 HTTP 客户端/服务器库,版本 3.9.3
|
||||
# 支持异步 Web 服务和客户端请求
|
||||
aiohttp==3.9.3
|
||||
|
||||
# AIOHTTP CORS 是一个为 AIOHTTP 提供跨域资源共享(CORS)支持的库,版本 0.7.0
|
||||
# 用于处理 Web 服务的跨域请求
|
||||
aiohttp_cors==0.7.0
|
||||
|
||||
# ormsgpack 是一个高效的 MessagePack 序列化库,版本 1.7.0
|
||||
# MessagePack 是一种二进制序列化格式,比 JSON 更高效
|
||||
ormsgpack==1.7.0
|
||||
|
||||
# ruamel.yaml 是一个用于处理 YAML 文件的库,版本 0.18.10
|
||||
# 支持 YAML 文件的读写和解析,功能比 pyyml 更强大
|
||||
ruamel.yaml==0.18.10
|
||||
|
||||
# Loguru 是一个简单易用的日志库,版本 0.7.3
|
||||
# 提供了丰富的日志功能和友好的输出格式
|
||||
loguru==0.7.3
|
||||
|
||||
# Requests 是一个常用的 HTTP 客户端库,版本 2.32.3
|
||||
# 支持同步 HTTP 请求,适用于简单的 API 调用
|
||||
requests==2.32.3
|
||||
|
||||
# Cozepy 是一个与 Coze 平台交互的 Python 库,版本 0.12.0
|
||||
# 提供了与 Coze 平台 API 的集成支持
|
||||
cozepy==0.12.0
|
||||
|
||||
# Mem0ai 是一个与 Mem0 平台交互的 Python 库,版本 0.1.62
|
||||
# 提供了与 Mem0 平台 API 的集成支持
|
||||
mem0ai==0.1.62
|
||||
Loading…
Reference in a new issue