From a66deddc5794ff3357e417fef446824767c10f38 Mon Sep 17 00:00:00 2001 From: Harold Date: Fri, 19 Dec 2025 10:35:04 +0800 Subject: [PATCH] feat: delete xiaozhi-web xiaozhi-manager-api --- main/docker-compose_dokploy.yml | 72 +- main/docker-compose_local_all.yml | 117 - main/manager-api/README.md | 18 - main/manager-api/pom.xml | 283 - .../main/java/xiaozhi/AdminApplication.java | 13 - .../xiaozhi/common/annotation/DataFilter.java | 33 - .../common/annotation/LogOperation.java | 20 - .../xiaozhi/common/aspect/RedisAspect.java | 41 - .../xiaozhi/common/config/AsyncConfig.java | 40 - .../common/config/MybatisPlusConfig.java | 36 - .../common/config/RestTemplateConfig.java | 17 - .../xiaozhi/common/config/SwaggerConfig.java | 90 - .../xiaozhi/common/constant/Constant.java | 323 - .../xiaozhi/common/convert/DateConverter.java | 73 - .../main/java/xiaozhi/common/dao/BaseDao.java | 12 - .../xiaozhi/common/entity/BaseEntity.java | 34 - .../xiaozhi/common/exception/ErrorCode.java | 201 - .../common/exception/RenException.java | 65 - .../common/exception/RenExceptionHandler.java | 85 - .../handler/FieldMetaObjectHandler.java | 57 - .../interceptor/DataFilterInterceptor.java | 85 - .../xiaozhi/common/interceptor/DataScope.java | 27 - .../java/xiaozhi/common/page/PageData.java | 33 - .../java/xiaozhi/common/page/TokenDTO.java | 25 - .../xiaozhi/common/redis/RedisConfig.java | 33 - .../java/xiaozhi/common/redis/RedisKeys.java | 155 - .../java/xiaozhi/common/redis/RedisUtils.java | 195 - .../xiaozhi/common/service/BaseService.java | 109 - .../xiaozhi/common/service/CrudService.java | 28 - .../common/service/impl/BaseServiceImpl.java | 230 - .../common/service/impl/CrudServiceImpl.java | 75 - .../java/xiaozhi/common/user/UserDetail.java | 19 - .../java/xiaozhi/common/utils/AESUtils.java | 78 - .../xiaozhi/common/utils/ConvertUtils.java | 51 - .../java/xiaozhi/common/utils/DateUtils.java | 116 - .../common/utils/HashEncryptionUtil.java | 52 - .../common/utils/HttpContextUtils.java | 110 - .../java/xiaozhi/common/utils/IpUtils.java | 48 - .../java/xiaozhi/common/utils/JsonRpcTwo.java | 21 - .../java/xiaozhi/common/utils/JsonUtils.java | 70 - .../xiaozhi/common/utils/MessageUtils.java | 25 - .../xiaozhi/common/utils/PropertiesUtils.java | 11 - .../xiaozhi/common/utils/ResourcesUtils.java | 45 - .../java/xiaozhi/common/utils/Result.java | 63 - .../xiaozhi/common/utils/ResultUtils.java | 31 - .../java/xiaozhi/common/utils/SM2Utils.java | 130 - .../common/utils/SensitiveDataUtils.java | 164 - .../xiaozhi/common/utils/Sm2DecryptUtil.java | 61 - .../common/utils/SpringContextUtils.java | 45 - .../java/xiaozhi/common/utils/TreeNode.java | 30 - .../java/xiaozhi/common/utils/TreeUtils.java | 71 - .../xiaozhi/common/validator/AssertUtils.java | 90 - .../common/validator/ValidatorUtils.java | 77 - .../common/validator/group/AddGroup.java | 8 - .../common/validator/group/DefaultGroup.java | 8 - .../common/validator/group/UpdateGroup.java | 8 - .../java/xiaozhi/common/xss/SqlFilter.java | 46 - .../java/xiaozhi/common/xss/XssConfig.java | 33 - .../java/xiaozhi/common/xss/XssFilter.java | 55 - .../xss/XssHttpServletRequestWrapper.java | 118 - .../xiaozhi/common/xss/XssProperties.java | 26 - .../java/xiaozhi/common/xss/XssUtils.java | 67 - .../agent/Enums/AgentChatHistoryType.java | 21 - .../agent/Enums/XiaoZhiMcpJsonRpcJson.java | 44 - .../AgentChatHistoryController.java | 246 - .../agent/controller/AgentController.java | 246 - .../AgentMcpAccessPointController.java | 66 - .../controller/AgentTemplateController.java | 158 - .../controller/AgentVoicePrintController.java | 87 - .../xiaozhi/modules/agent/dao/AgentDao.java | 39 - .../agent/dao/AgentPluginMappingMapper.java | 22 - .../modules/agent/dao/AgentTemplateDao.java | 17 - .../modules/agent/dao/AgentVoicePrintDao.java | 20 - .../agent/dao/AiAgentChatAudioDao.java | 18 - .../agent/dao/AiAgentChatHistoryDao.java | 38 - .../agent/dto/AgentChatHistoryDTO.java | 28 - .../agent/dto/AgentChatHistoryReportDTO.java | 33 - .../agent/dto/AgentChatSessionDTO.java | 26 - .../modules/agent/dto/AgentCreateDTO.java | 21 - .../xiaozhi/modules/agent/dto/AgentDTO.java | 48 - .../modules/agent/dto/AgentMemoryDTO.java | 19 - .../modules/agent/dto/AgentUpdateDTO.java | 83 - .../agent/dto/AgentVoicePrintSaveDTO.java | 28 - .../agent/dto/AgentVoicePrintUpdateDTO.java | 28 - .../agent/dto/IdentifyVoicePrintResponse.java | 21 - .../modules/agent/dto/McpJsonRpcResponse.java | 48 - .../agent/entity/AgentChatAudioEntity.java | 29 - .../agent/entity/AgentChatHistoryEntity.java | 81 - .../modules/agent/entity/AgentEntity.java | 84 - .../agent/entity/AgentPluginMapping.java | 54 - .../agent/entity/AgentTemplateEntity.java | 128 - .../agent/entity/AgentVoicePrintEntity.java | 64 - .../agent/service/AgentChatAudioService.java | 30 - .../service/AgentChatHistoryService.java | 74 - .../service/AgentMcpAccessPointService.java | 25 - .../service/AgentPluginMappingService.java | 29 - .../modules/agent/service/AgentService.java | 101 - .../agent/service/AgentTemplateService.java | 42 - .../agent/service/AgentVoicePrintService.java | 50 - .../biz/AgentChatHistoryBizService.java | 22 - .../impl/AgentChatHistoryBizServiceImpl.java | 126 - .../impl/AgentChatAudioServiceImpl.java | 34 - .../impl/AgentChatHistoryServiceImpl.java | 171 - .../impl/AgentMcpAccessPointServiceImpl.java | 234 - .../impl/AgentPluginMappingServiceImpl.java | 37 - .../agent/service/impl/AgentServiceImpl.java | 440 - .../impl/AgentTemplateServiceImpl.java | 121 - .../impl/AgentVoicePrintServiceImpl.java | 411 - .../agent/vo/AgentChatHistoryUserVO.java | 16 - .../xiaozhi/modules/agent/vo/AgentInfoVO.java | 24 - .../modules/agent/vo/AgentTemplateVO.java | 15 - .../modules/agent/vo/AgentVoicePrintVO.java | 33 - .../config/controller/ConfigController.java | 44 - .../modules/config/dto/AgentModelsDTO.java | 25 - .../modules/config/init/SystemInitConfig.java | 41 - .../modules/config/service/ConfigService.java | 22 - .../service/impl/ConfigServiceImpl.java | 472 - .../device/controller/DeviceController.java | 211 - .../device/controller/OTAController.java | 122 - .../device/controller/OTAMagController.java | 291 - .../xiaozhi/modules/device/dao/DeviceDao.java | 21 - .../xiaozhi/modules/device/dao/OtaDao.java | 15 - .../modules/device/dto/DeviceBindDTO.java | 27 - .../device/dto/DeviceManualAddDTO.java | 11 - .../modules/device/dto/DevicePageUserDTO.java | 27 - .../modules/device/dto/DeviceRegisterDTO.java | 23 - .../device/dto/DeviceReportReqDTO.java | 148 - .../device/dto/DeviceReportRespDTO.java | 95 - .../modules/device/dto/DeviceUnBindDTO.java | 20 - .../modules/device/dto/DeviceUpdateDTO.java | 29 - .../modules/device/entity/DeviceEntity.java | 67 - .../modules/device/entity/OtaEntity.java | 61 - .../modules/device/service/DeviceService.java | 101 - .../modules/device/service/OtaService.java | 22 - .../service/impl/DeviceServiceImpl.java | 550 - .../device/service/impl/OtaServiceImpl.java | 85 - .../modules/device/vo/DeviceOtaVO.java | 59 - .../device/vo/UserShowDeviceListVO.java | 31 - .../model/controller/ModelController.java | 170 - .../controller/ModelProviderController.java | 75 - .../modules/model/dao/ModelConfigDao.java | 24 - .../modules/model/dao/ModelProviderDao.java | 15 - .../model/dto/LlmModelBasicInfoDTO.java | 13 - .../modules/model/dto/ModelBasicInfoDTO.java | 9 - .../modules/model/dto/ModelConfigBodyDTO.java | 42 - .../modules/model/dto/ModelConfigDTO.java | 46 - .../modules/model/dto/ModelProviderDTO.java | 59 - .../xiaozhi/modules/model/dto/VoiceDTO.java | 22 - .../model/entity/ModelConfigEntity.java | 68 - .../model/entity/ModelProviderEntity.java | 47 - .../model/service/ModelConfigService.java | 58 - .../model/service/ModelProviderService.java | 30 - .../service/impl/ModelConfigServiceImpl.java | 498 - .../impl/ModelProviderServiceImpl.java | 153 - .../modules/security/config/FilterConfig.java | 27 - .../modules/security/config/ShiroConfig.java | 112 - .../modules/security/config/WebMvcConfig.java | 146 - .../security/controller/LoginController.java | 242 - .../modules/security/dao/SysUserTokenDao.java | 24 - .../modules/security/dto/LoginDTO.java | 31 - .../security/dto/SmsVerificationDTO.java | 28 - .../security/entity/SysUserTokenEntity.java | 47 - .../modules/security/oauth2/Oauth2Filter.java | 109 - .../modules/security/oauth2/Oauth2Realm.java | 108 - .../modules/security/oauth2/Oauth2Token.java | 26 - .../security/oauth2/TokenGenerator.java | 45 - .../modules/security/password/BCrypt.java | 691 - .../password/BCryptPasswordEncoder.java | 81 - .../security/password/PasswordEncoder.java | 33 - .../security/password/PasswordUtils.java | 40 - .../security/secret/ServerSecretFilter.java | 105 - .../security/secret/ServerSecretToken.java | 25 - .../security/service/CaptchaService.java | 45 - .../security/service/ShiroService.java | 22 - .../security/service/SysUserTokenService.java | 41 - .../service/impl/CaptchaServiceImpl.java | 183 - .../service/impl/ShiroServiceImpl.java | 27 - .../service/impl/SysUserTokenServiceImpl.java | 116 - .../modules/security/user/SecurityUser.java | 50 - .../modules/sms/service/SmsService.java | 17 - .../sms/service/imp/ALiYunSmsService.java | 77 - .../sys/controller/AdminController.java | 109 - .../ServerSideManageController.java | 122 - .../sys/controller/SysDictDataController.java | 105 - .../sys/controller/SysDictTypeController.java | 92 - .../sys/controller/SysParamsController.java | 296 - .../modules/sys/dao/SysDictDataDao.java | 26 - .../modules/sys/dao/SysDictTypeDao.java | 14 - .../xiaozhi/modules/sys/dao/SysParamsDao.java | 39 - .../xiaozhi/modules/sys/dao/SysUserDao.java | 14 - .../modules/sys/dto/AdminPageUserDTO.java | 27 - .../modules/sys/dto/EmitSeverActionDTO.java | 26 - .../xiaozhi/modules/sys/dto/PasswordDTO.java | 24 - .../modules/sys/dto/RetrievePasswordDTO.java | 34 - .../sys/dto/ServerActionPayloadDTO.java | 36 - .../sys/dto/ServerActionResponseDTO.java | 34 - .../modules/sys/dto/SysDictDataDTO.java | 59 - .../modules/sys/dto/SysDictTypeDTO.java | 56 - .../xiaozhi/modules/sys/dto/SysParamsDTO.java | 58 - .../xiaozhi/modules/sys/dto/SysUserDTO.java | 87 - .../modules/sys/entity/SysDictDataEntity.java | 50 - .../modules/sys/entity/SysDictTypeEntity.java | 46 - .../modules/sys/entity/SysParamsEntity.java | 51 - .../modules/sys/entity/SysUserEntity.java | 47 - .../modules/sys/enums/ServerActionEnum.java | 33 - .../sys/enums/ServerActionResponseEnum.java | 45 - .../modules/sys/enums/SuperAdminEnum.java | 19 - .../modules/sys/redis/SysParamsRedis.java | 35 - .../sys/service/SysDictDataService.java | 70 - .../sys/service/SysDictTypeService.java | 60 - .../modules/sys/service/SysParamsService.java | 56 - .../modules/sys/service/SysUserService.java | 75 - .../sys/service/SysUserUtilService.java | 19 - .../modules/sys/service/TokenService.java | 11 - .../service/impl/SysDictDataServiceImpl.java | 184 - .../service/impl/SysDictTypeServiceImpl.java | 154 - .../service/impl/SysParamsServiceImpl.java | 273 - .../sys/service/impl/SysUserServiceImpl.java | 250 - .../service/impl/SysUserUtilServiceImpl.java | 37 - .../sys/service/impl/TokenServiceImpl.java | 19 - .../sys/utils/WebSocketClientManager.java | 372 - .../sys/utils/WebSocketTestHandler.java | 46 - .../modules/sys/utils/WebSocketValidator.java | 60 - .../modules/sys/vo/AdminPageUserVO.java | 31 - .../modules/sys/vo/SysDictDataItem.java | 20 - .../xiaozhi/modules/sys/vo/SysDictDataVO.java | 50 - .../xiaozhi/modules/sys/vo/SysDictTypeVO.java | 47 - .../timbre/controller/TimbreController.java | 92 - .../xiaozhi/modules/timbre/dao/TimbreDao.java | 17 - .../modules/timbre/dto/TimbreDataDTO.java | 49 - .../modules/timbre/dto/TimbrePageDTO.java | 29 - .../modules/timbre/entity/TimbreEntity.java | 71 - .../modules/timbre/service/TimbreService.java | 76 - .../service/impl/TimbreServiceImpl.java | 210 - .../modules/timbre/vo/TimbreDetailsVO.java | 46 - .../controller/VoiceCloneController.java | 193 - .../controller/VoiceResourceController.java | 116 - .../modules/voiceclone/dao/VoiceCloneDao.java | 26 - .../modules/voiceclone/dto/VoiceCloneDTO.java | 20 - .../voiceclone/dto/VoiceCloneResponseDTO.java | 48 - .../voiceclone/entity/VoiceCloneEntity.java | 53 - .../voiceclone/service/VoiceCloneService.java | 78 - .../service/impl/VoiceCloneServiceImpl.java | 374 - .../src/main/resources/application-dev.yml | 51 - .../src/main/resources/application.yml | 66 - .../resources/db/changelog/202503141335.sql | 83 - .../resources/db/changelog/202503141346.sql | 185 - .../resources/db/changelog/202504082211.sql | 50 - .../resources/db/changelog/202504092335.sql | 75 - .../resources/db/changelog/202504112044.sql | 55 - .../resources/db/changelog/202504112058.sql | 61 - .../resources/db/changelog/202504151206.sql | 28 - .../resources/db/changelog/202504181536.sql | 7 - .../resources/db/changelog/202504221135.sql | 88 - .../resources/db/changelog/202504221555.sql | 49 - .../resources/db/changelog/202504251422.sql | 30 - .../resources/db/changelog/202504291043.sql | 504 - .../resources/db/changelog/202504301341.sql | 85 - .../resources/db/changelog/202505022134.sql | 27 - .../resources/db/changelog/202505081146.sql | 43 - .../resources/db/changelog/202505091555.sql | 25 - .../resources/db/changelog/202505111914.sql | 6 - .../resources/db/changelog/202505122348.sql | 6 - .../resources/db/changelog/202505142037.sql | 7 - .../resources/db/changelog/202505151451.sql | 18 - .../resources/db/changelog/202505182234.sql | 65 - .../resources/db/changelog/202505201744.sql | 3 - .../resources/db/changelog/202505271414.sql | 51 - .../resources/db/changelog/202505292203.sql | 189 - .../resources/db/changelog/202506010920.sql | 29 - .../resources/db/changelog/202506031639.sql | 45 - .../resources/db/changelog/202506032232.sql | 14 - .../resources/db/changelog/202506051538.sql | 20 - .../resources/db/changelog/202506080955.sql | 3 - .../resources/db/changelog/202506091720.sql | 3 - .../resources/db/changelog/202506161101.sql | 1 - .../resources/db/changelog/202506191643.sql | 19 - .../resources/db/changelog/202506251620.sql | 18 - .../resources/db/changelog/202506261637.sql | 2 - .../resources/db/changelog/202507031602.sql | 4 - .../resources/db/changelog/202507041018.sql | 12 - .../resources/db/changelog/202507071130.sql | 26 - .../resources/db/changelog/202507071530.sql | 56 - .../resources/db/changelog/202507081646.sql | 3 - .../resources/db/changelog/202507101203.sql | 38 - .../resources/db/changelog/202508081701.sql | 32 - .../resources/db/changelog/202508111734.sql | 16 - .../resources/db/changelog/202508131557.sql | 26 - .../resources/db/changelog/202508271113.sql | 24 - .../resources/db/changelog/202509051745.sql | 45 - .../resources/db/changelog/202509080922.sql | 8 - .../resources/db/changelog/202509081140.sql | 4 - .../resources/db/changelog/202509091042.sql | 10 - .../resources/db/changelog/202509091633.sql | 16 - .../resources/db/changelog/202509161610.sql | 3 - .../resources/db/changelog/202509161701.sql | 54 - .../resources/db/changelog/202509191545.sql | 41 - .../resources/db/changelog/202509220926.sql | 26 - .../resources/db/changelog/202509220958.sql | 19 - .../resources/db/changelog/202509221530.sql | 7 - .../resources/db/changelog/202510071522.sql | 19 - .../resources/db/changelog/202510191042.sql | 2 - .../resources/db/changelog/202511051120.sql | 68 - .../resources/db/changelog/202511061415.sql | 26 - .../resources/db/changelog/202511071245.sql | 43 - .../db/changelog/db.changelog-master.yaml | 425 - .../main/resources/i18n/messages.properties | 171 - .../resources/i18n/messages_en_US.properties | 171 - .../resources/i18n/messages_zh_CN.properties | 171 - .../resources/i18n/messages_zh_TW.properties | 172 - .../main/resources/i18n/validation.properties | 35 - .../i18n/validation_en_US.properties | 34 - .../i18n/validation_zh_CN.properties | 34 - .../i18n/validation_zh_TW.properties | 34 - .../src/main/resources/logback-spring.xml | 139 - .../src/main/resources/lua/emptyAll.lua | 1 - .../src/main/resources/lua/getKeyOrCreate.lua | 11 - .../main/resources/mapper/agent/AgentDao.xml | 76 - .../mapper/agent/AgentPluginMappingMapper.xml | 48 - .../mapper/agent/AgentTemplateMapper.xml | 6 - .../mapper/agent/AiAgentChatHistoryDao.xml | 44 - .../resources/mapper/device/DeviceDao.xml | 12 - .../resources/mapper/model/ModelConfigDao.xml | 33 - .../mapper/model/ModelProviderDao.xml | 9 - .../mapper/security/SysUserTokenDao.xml | 17 - .../resources/mapper/sys/SysDictDataDao.xml | 18 - .../resources/mapper/sys/SysDictTypeDao.xml | 6 - .../resources/mapper/sys/SysParamsDao.xml | 23 - .../main/resources/mapper/sys/SysUserDao.xml | 6 - .../mapper/voiceclone/VoiceCloneDao.xml | 10 - .../xiaozhi/common/utils/AESUtilsTest.java | 85 - .../xiaozhi/modules/device/DeviceTest.java | 73 - .../modules/sys/loginControllerTest.java | 57 - .../src/test/resources/application.yml | 22 - main/manager-mobile/.commitlintrc.cjs | 3 - main/manager-mobile/.editorconfig | 13 - main/manager-mobile/.gitignore | 44 - main/manager-mobile/.npmrc | 8 - main/manager-mobile/LICENSE | 21 - main/manager-mobile/README.md | 170 - main/manager-mobile/env/.env | 19 - main/manager-mobile/env/.env.development | 6 - main/manager-mobile/env/.env.production | 6 - main/manager-mobile/env/.env.test | 4 - main/manager-mobile/eslint.config.mjs | 43 - main/manager-mobile/favicon.ico | Bin 162423 -> 0 bytes main/manager-mobile/index.html | 26 - main/manager-mobile/manifest.config.ts | 155 - main/manager-mobile/package.json | 162 - main/manager-mobile/pages.config.ts | 23 - .../patches/@dcloudio__uni-h5.patch | 13 - main/manager-mobile/pnpm-lock.yaml | 14866 ---------------- main/manager-mobile/pnpm-workspace.yaml | 6 - main/manager-mobile/scripts/postupgrade.js | 35 - main/manager-mobile/src/App.vue | 94 - main/manager-mobile/src/api/agent/agent.ts | 185 - main/manager-mobile/src/api/agent/types.ts | 107 - main/manager-mobile/src/api/auth.ts | 143 - .../src/api/chat-history/chat-history.ts | 60 - .../src/api/chat-history/index.ts | 2 - .../src/api/chat-history/types.ts | 38 - main/manager-mobile/src/api/device/device.ts | 55 - main/manager-mobile/src/api/device/index.ts | 2 - main/manager-mobile/src/api/device/types.ts | 21 - .../src/api/voiceprint/index.ts | 2 - .../src/api/voiceprint/types.ts | 29 - .../src/api/voiceprint/voiceprint.ts | 62 - main/manager-mobile/src/components/.gitkeep | 0 .../src/components/custom-tabs/index.vue | 131 - main/manager-mobile/src/env.d.ts | 34 - main/manager-mobile/src/hooks/.gitkeep | 0 main/manager-mobile/src/hooks/usePageAuth.ts | 50 - main/manager-mobile/src/hooks/useRequest.ts | 51 - main/manager-mobile/src/hooks/useUpload.ts | 160 - main/manager-mobile/src/http/README.md | 36 - main/manager-mobile/src/http/request/alova.ts | 120 - main/manager-mobile/src/http/request/enum.ts | 66 - main/manager-mobile/src/http/request/types.ts | 22 - main/manager-mobile/src/i18n/en.ts | 440 - main/manager-mobile/src/i18n/index.ts | 70 - main/manager-mobile/src/i18n/zh_CN.ts | 440 - main/manager-mobile/src/i18n/zh_TW.ts | 444 - main/manager-mobile/src/layouts/default.vue | 17 - .../src/layouts/fg-tabbar/fg-tabbar.vue | 68 - .../src/layouts/fg-tabbar/tabbar.md | 17 - .../src/layouts/fg-tabbar/tabbar.ts | 11 - .../src/layouts/fg-tabbar/tabbarList.ts | 76 - main/manager-mobile/src/layouts/tabbar.vue | 19 - main/manager-mobile/src/main.ts | 26 - main/manager-mobile/src/manifest.json | 124 - .../src/pages-sub/demo/index.vue | 27 - main/manager-mobile/src/pages.json | 167 - main/manager-mobile/src/pages/agent/edit.vue | 703 - main/manager-mobile/src/pages/agent/index.vue | 214 - main/manager-mobile/src/pages/agent/tools.vue | 585 - .../src/pages/chat-history/detail.vue | 332 - .../src/pages/chat-history/index.vue | 400 - .../components/ultrasonic-config.vue | 685 - .../device-config/components/wifi-config.vue | 231 - .../components/wifi-selector.vue | 557 - .../src/pages/device-config/index.vue | 155 - .../manager-mobile/src/pages/device/index.vue | 334 - .../src/pages/forgot-password/index.vue | 848 - main/manager-mobile/src/pages/index/index.vue | 585 - main/manager-mobile/src/pages/login/index.vue | 971 - .../src/pages/register/index.vue | 908 - .../src/pages/settings/index.vue | 464 - .../src/pages/voiceprint/index.vue | 536 - main/manager-mobile/src/router/interceptor.ts | 66 - .../src/static/app/icons/1024x1024.png | Bin 458242 -> 0 bytes .../src/static/app/icons/120x120.png | Bin 17805 -> 0 bytes .../src/static/app/icons/144x144.png | Bin 24176 -> 0 bytes .../src/static/app/icons/152x152.png | Bin 26428 -> 0 bytes .../src/static/app/icons/167x167.png | Bin 30883 -> 0 bytes .../src/static/app/icons/180x180.png | Bin 35063 -> 0 bytes .../src/static/app/icons/192x192.png | Bin 38903 -> 0 bytes .../src/static/app/icons/20x20.png | Bin 1330 -> 0 bytes .../src/static/app/icons/29x29.png | Bin 1471 -> 0 bytes .../src/static/app/icons/40x40.png | Bin 1709 -> 0 bytes .../src/static/app/icons/58x58.png | Bin 2210 -> 0 bytes .../src/static/app/icons/60x60.png | Bin 2275 -> 0 bytes .../src/static/app/icons/72x72.png | Bin 2708 -> 0 bytes .../src/static/app/icons/76x76.png | Bin 2833 -> 0 bytes .../src/static/app/icons/80x80.png | Bin 2962 -> 0 bytes .../src/static/app/icons/87x87.png | Bin 3266 -> 0 bytes .../src/static/app/icons/96x96.png | Bin 3680 -> 0 bytes .../manager-mobile/src/static/images/.gitkeep | 0 .../src/static/images/default-avatar.png | Bin 560 -> 0 bytes .../src/static/images/home/main-top-bg.png | Bin 978384 -> 0 bytes main/manager-mobile/src/static/logo.png | Bin 13372 -> 0 bytes main/manager-mobile/src/static/logo.svg | 33 - .../manager-mobile/src/static/tabbar/chat.png | Bin 2153 -> 0 bytes .../src/static/tabbar/chat_activate.png | Bin 2155 -> 0 bytes .../src/static/tabbar/device.png | Bin 4058 -> 0 bytes .../src/static/tabbar/device_activate.png | Bin 4040 -> 0 bytes .../src/static/tabbar/example.png | Bin 1371 -> 0 bytes .../src/static/tabbar/exampleHL.png | Bin 1398 -> 0 bytes .../manager-mobile/src/static/tabbar/home.png | Bin 1346 -> 0 bytes .../src/static/tabbar/homeHL.png | Bin 1415 -> 0 bytes .../src/static/tabbar/microphone.png | Bin 3189 -> 0 bytes .../src/static/tabbar/microphone_activate.png | Bin 3273 -> 0 bytes .../src/static/tabbar/network.png | Bin 6593 -> 0 bytes .../src/static/tabbar/network_activate.png | Bin 6289 -> 0 bytes .../src/static/tabbar/personal.png | Bin 2457 -> 0 bytes .../src/static/tabbar/personalHL.png | Bin 2534 -> 0 bytes .../src/static/tabbar/robot.png | Bin 3471 -> 0 bytes .../src/static/tabbar/robot_activate.png | Bin 3508 -> 0 bytes .../src/static/tabbar/system.png | Bin 3391 -> 0 bytes .../src/static/tabbar/system_activate.png | Bin 3566 -> 0 bytes main/manager-mobile/src/store/config.ts | 66 - main/manager-mobile/src/store/index.ts | 19 - main/manager-mobile/src/store/lang.ts | 41 - main/manager-mobile/src/store/plugin.ts | 58 - main/manager-mobile/src/store/user.ts | 83 - main/manager-mobile/src/style/iconfont.css | 28 - main/manager-mobile/src/style/index.scss | 19 - main/manager-mobile/src/typings.d.ts | 28 - main/manager-mobile/src/typings.ts | 15 - main/manager-mobile/src/uni.scss | 77 - main/manager-mobile/src/utils/index.ts | 255 - main/manager-mobile/src/utils/platform.ts | 24 - main/manager-mobile/src/utils/toast.ts | 65 - main/manager-mobile/src/utils/uploadFile.ts | 327 - main/manager-mobile/tsconfig.json | 41 - main/manager-mobile/uno.config.ts | 65 - .../unpackage/res/icons/1024x1024.png | Bin 458242 -> 0 bytes .../unpackage/res/icons/120x120.png | Bin 17805 -> 0 bytes .../unpackage/res/icons/144x144.png | Bin 24176 -> 0 bytes .../unpackage/res/icons/152x152.png | Bin 26428 -> 0 bytes .../unpackage/res/icons/167x167.png | Bin 30883 -> 0 bytes .../unpackage/res/icons/180x180.png | Bin 35063 -> 0 bytes .../unpackage/res/icons/192x192.png | Bin 38903 -> 0 bytes .../unpackage/res/icons/20x20.png | Bin 1330 -> 0 bytes .../unpackage/res/icons/29x29.png | Bin 1471 -> 0 bytes .../unpackage/res/icons/40x40.png | Bin 1709 -> 0 bytes .../unpackage/res/icons/58x58.png | Bin 2210 -> 0 bytes .../unpackage/res/icons/60x60.png | Bin 2275 -> 0 bytes .../unpackage/res/icons/72x72.png | Bin 2708 -> 0 bytes .../unpackage/res/icons/76x76.png | Bin 2833 -> 0 bytes .../unpackage/res/icons/80x80.png | Bin 2962 -> 0 bytes .../unpackage/res/icons/87x87.png | Bin 3266 -> 0 bytes .../unpackage/res/icons/96x96.png | Bin 3680 -> 0 bytes main/manager-mobile/vite.config.ts | 182 - main/manager-web/.env | 1 - main/manager-web/.env.development | 5 - main/manager-web/.env.production | 4 - main/manager-web/.npmrc | 1 - main/manager-web/README.md | 27 - main/manager-web/babel.config.js | 12 - main/manager-web/jsconfig.json | 19 - main/manager-web/package-lock.json | 12117 ------------- main/manager-web/package.json | 50 - main/manager-web/public/favicon.ico | Bin 4286 -> 0 bytes main/manager-web/public/index.html | 33 - main/manager-web/public/offline.html | 70 - main/manager-web/src/App.vue | 175 - main/manager-web/src/apis/api.js | 43 - main/manager-web/src/apis/httpRequest.js | 172 - main/manager-web/src/apis/module/admin.js | 170 - main/manager-web/src/apis/module/agent.js | 385 - main/manager-web/src/apis/module/device.js | 105 - main/manager-web/src/apis/module/dict.js | 227 - main/manager-web/src/apis/module/model.js | 340 - main/manager-web/src/apis/module/ota.js | 123 - main/manager-web/src/apis/module/timbre.js | 96 - main/manager-web/src/apis/module/user.js | 204 - .../manager-web/src/apis/module/voiceClone.js | 107 - .../src/apis/module/voiceResource.js | 103 - .../src/assets/header/model_config.png | Bin 54780 -> 0 bytes .../src/assets/header/param_management.png | Bin 6904 -> 0 bytes main/manager-web/src/assets/header/robot.png | Bin 13467 -> 0 bytes .../src/assets/header/user_management.png | Bin 32843 -> 0 bytes main/manager-web/src/assets/header/voice.png | Bin 1813 -> 0 bytes main/manager-web/src/assets/home/avatar.png | Bin 2240 -> 0 bytes main/manager-web/src/assets/home/close.png | Bin 635 -> 0 bytes main/manager-web/src/assets/home/delete.png | Bin 1514 -> 0 bytes .../manager-web/src/assets/home/equipment.png | Bin 907 -> 0 bytes main/manager-web/src/assets/home/info.png | Bin 1399 -> 0 bytes .../src/assets/home/main-top-bg.png | Bin 978384 -> 0 bytes main/manager-web/src/assets/home/red-info.png | Bin 1185 -> 0 bytes main/manager-web/src/assets/home/search.png | Bin 1025 -> 0 bytes .../src/assets/home/setting-user.png | Bin 1860 -> 0 bytes .../src/assets/login/down-arrow.png | Bin 455 -> 0 bytes main/manager-web/src/assets/login/hi.png | Bin 2988 -> 0 bytes .../src/assets/login/login-person.png | Bin 103575 -> 0 bytes .../manager-web/src/assets/login/password.png | Bin 1424 -> 0 bytes main/manager-web/src/assets/login/phone.png | Bin 1121 -> 0 bytes .../src/assets/login/register-person.png | Bin 164494 -> 0 bytes main/manager-web/src/assets/login/shield.png | Bin 2136 -> 0 bytes .../manager-web/src/assets/login/username.png | Bin 2125 -> 0 bytes .../src/assets/model/inner_conf.png | Bin 3962 -> 0 bytes main/manager-web/src/assets/model/model.png | Bin 90263 -> 0 bytes .../src/assets/model/output_conf.png | Bin 5162 -> 0 bytes main/manager-web/src/assets/user-avatar1.png | Bin 10906 -> 0 bytes main/manager-web/src/assets/user-avatar2.png | Bin 10720 -> 0 bytes main/manager-web/src/assets/user-avatar3.png | Bin 11231 -> 0 bytes main/manager-web/src/assets/user-avatar4.png | Bin 10297 -> 0 bytes main/manager-web/src/assets/user-avatar5.png | Bin 8330 -> 0 bytes main/manager-web/src/assets/xiaozhi-ai.png | Bin 1946 -> 0 bytes main/manager-web/src/assets/xiaozhi-logo.png | Bin 13372 -> 0 bytes .../src/components/AddDeviceDialog.vue | 126 - .../src/components/AddModelDialog.vue | 419 - .../src/components/AddWisdomBodyDialog.vue | 113 - .../src/components/AudioPlayer.vue | 379 - .../src/components/CacheViewer.vue | 207 - .../src/components/ChangePasswordDialog.vue | 161 - .../src/components/ChatHistoryDialog.vue | 522 - .../manager-web/src/components/DeviceItem.vue | 151 - .../src/components/DictDataDialog.vue | 116 - .../src/components/DictTypeDialog.vue | 97 - .../src/components/EditVoiceDialog.vue | 149 - .../src/components/FirmwareDialog.vue | 237 - .../src/components/FunctionDialog.vue | 838 - main/manager-web/src/components/HeaderBar.vue | 945 - .../src/components/ManualAddDeviceDialog.vue | 158 - .../src/components/ModelEditDialog.vue | 647 - .../src/components/ParamDialog.vue | 355 - .../src/components/ProviderDialog.vue | 439 - main/manager-web/src/components/TtsModel.vue | 735 - .../src/components/VersionFooter.vue | 74 - .../src/components/ViewPasswordDialog.vue | 91 - .../src/components/VoiceCloneDialog.vue | 694 - .../src/components/VoicePrintDialog.vue | 420 - .../src/components/VoiceResourceDialog.vue | 154 - main/manager-web/src/i18n/en.js | 1119 -- main/manager-web/src/i18n/index.js | 43 - main/manager-web/src/i18n/zh_CN.js | 1119 -- main/manager-web/src/i18n/zh_TW.js | 1119 -- main/manager-web/src/main.js | 28 - main/manager-web/src/registerServiceWorker.js | 113 - main/manager-web/src/router/index.js | 210 - main/manager-web/src/service-worker.js | 174 - main/manager-web/src/store/index.js | 87 - main/manager-web/src/styles/global.scss | 18 - main/manager-web/src/utils/cacheViewer.js | 142 - main/manager-web/src/utils/constant.js | 22 - main/manager-web/src/utils/date.js | 60 - main/manager-web/src/utils/format.js | 21 - main/manager-web/src/utils/index.js | 259 - .../src/views/AgentTemplateManagement.vue | 633 - .../src/views/DeviceManagement.vue | 825 - main/manager-web/src/views/DictManagement.vue | 912 - main/manager-web/src/views/ModelConfig.vue | 1131 -- main/manager-web/src/views/OtaManagement.vue | 767 - .../src/views/ParamsManagement.vue | 742 - .../src/views/ProviderManagement.vue | 926 - .../src/views/ServerSideManager.vue | 463 - .../src/views/TemplateQuickConfig.vue | 478 - main/manager-web/src/views/UserManagement.vue | 751 - .../src/views/VoiceCloneManagement.vue | 881 - main/manager-web/src/views/VoicePrint.vue | 563 - .../src/views/VoiceResourceManagement.vue | 704 - main/manager-web/src/views/auth.scss | 131 - main/manager-web/src/views/home.vue | 361 - main/manager-web/src/views/login.vue | 396 - main/manager-web/src/views/register.vue | 346 - .../src/views/retrievePassword.vue | 292 - main/manager-web/src/views/roleConfig.vue | 876 - main/manager-web/vue.config.js | 181 - 599 files changed, 1 insertion(+), 92974 deletions(-) delete mode 100644 main/manager-api/README.md delete mode 100644 main/manager-api/pom.xml delete mode 100644 main/manager-api/src/main/java/xiaozhi/AdminApplication.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/annotation/DataFilter.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/annotation/LogOperation.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/aspect/RedisAspect.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/config/AsyncConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/config/MybatisPlusConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/config/RestTemplateConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/config/SwaggerConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/convert/DateConverter.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/dao/BaseDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/entity/BaseEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/exception/ErrorCode.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/exception/RenException.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/exception/RenExceptionHandler.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/handler/FieldMetaObjectHandler.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/interceptor/DataFilterInterceptor.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/interceptor/DataScope.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/page/PageData.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/page/TokenDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/redis/RedisConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/redis/RedisKeys.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/redis/RedisUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/service/BaseService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/service/CrudService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/service/impl/BaseServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/service/impl/CrudServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/user/UserDetail.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/AESUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/ConvertUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/DateUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/HashEncryptionUtil.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/HttpContextUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/IpUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/JsonRpcTwo.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/JsonUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/MessageUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/PropertiesUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/ResourcesUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/Result.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/ResultUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/SM2Utils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/SensitiveDataUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/Sm2DecryptUtil.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/SpringContextUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/TreeNode.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/utils/TreeUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/validator/AssertUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/validator/ValidatorUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/validator/group/AddGroup.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/validator/group/DefaultGroup.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/validator/group/UpdateGroup.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/xss/SqlFilter.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/xss/XssConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/xss/XssFilter.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/xss/XssHttpServletRequestWrapper.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/xss/XssProperties.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/common/xss/XssUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/AgentChatHistoryType.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/XiaoZhiMcpJsonRpcJson.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentMcpAccessPointController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentTemplateController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentVoicePrintController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentPluginMappingMapper.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentTemplateDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentVoicePrintDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatAudioDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatHistoryDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryReportDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSessionDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentCreateDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentMemoryDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentUpdateDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintSaveDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintUpdateDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/IdentifyVoicePrintResponse.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/dto/McpJsonRpcResponse.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatAudioEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatHistoryEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentPluginMapping.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTemplateEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentVoicePrintEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatAudioService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatHistoryService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentMcpAccessPointService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentPluginMappingService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentTemplateService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentVoicePrintService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/AgentChatHistoryBizService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/impl/AgentChatHistoryBizServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatAudioServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatHistoryServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentMcpAccessPointServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentPluginMappingServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentTemplateServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentVoicePrintServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentChatHistoryUserVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentInfoVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentTemplateVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentVoicePrintVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/config/controller/ConfigController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/config/dto/AgentModelsDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/config/init/SystemInitConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/config/service/ConfigService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/controller/OTAController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/controller/OTAMagController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dao/DeviceDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dao/OtaDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceBindDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceManualAddDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dto/DevicePageUserDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceRegisterDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportReqDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportRespDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceUnBindDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceUpdateDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/entity/DeviceEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/entity/OtaEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/service/DeviceService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/service/OtaService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/DeviceServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/OtaServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/vo/DeviceOtaVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/device/vo/UserShowDeviceListVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelProviderController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/dao/ModelConfigDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/dao/ModelProviderDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/dto/LlmModelBasicInfoDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelBasicInfoDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelConfigBodyDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelConfigDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelProviderDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/entity/ModelConfigEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/entity/ModelProviderEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/service/ModelConfigService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/service/ModelProviderService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/service/impl/ModelConfigServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/model/service/impl/ModelProviderServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/config/FilterConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/config/ShiroConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/config/WebMvcConfig.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/controller/LoginController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/dao/SysUserTokenDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/dto/LoginDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/dto/SmsVerificationDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/entity/SysUserTokenEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Filter.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Realm.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Token.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/TokenGenerator.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/password/BCrypt.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/password/BCryptPasswordEncoder.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/password/PasswordEncoder.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/password/PasswordUtils.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/secret/ServerSecretFilter.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/secret/ServerSecretToken.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/service/CaptchaService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/service/ShiroService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/service/SysUserTokenService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/CaptchaServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/ShiroServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/SysUserTokenServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/security/user/SecurityUser.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sms/service/SmsService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sms/service/imp/ALiYunSmsService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/controller/AdminController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/controller/ServerSideManageController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysDictDataController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysDictTypeController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysParamsController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysDictDataDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysDictTypeDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysParamsDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysUserDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/AdminPageUserDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/EmitSeverActionDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/PasswordDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/RetrievePasswordDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/ServerActionPayloadDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/ServerActionResponseDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysDictDataDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysDictTypeDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysParamsDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysUserDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysDictDataEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysDictTypeEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysParamsEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysUserEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/enums/ServerActionEnum.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/enums/ServerActionResponseEnum.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/enums/SuperAdminEnum.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/redis/SysParamsRedis.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysDictDataService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysDictTypeService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysParamsService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysUserService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysUserUtilService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/TokenService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysDictDataServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysDictTypeServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysParamsServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysUserServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysUserUtilServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/TokenServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketClientManager.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketTestHandler.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketValidator.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/vo/AdminPageUserVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictDataItem.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictDataVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictTypeVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/timbre/controller/TimbreController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/timbre/dao/TimbreDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/timbre/dto/TimbreDataDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/timbre/dto/TimbrePageDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/timbre/entity/TimbreEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/timbre/service/TimbreService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/timbre/vo/TimbreDetailsVO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceCloneController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceResourceController.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dao/VoiceCloneDao.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dto/VoiceCloneDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dto/VoiceCloneResponseDTO.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/voiceclone/entity/VoiceCloneEntity.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/VoiceCloneService.java delete mode 100644 main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/impl/VoiceCloneServiceImpl.java delete mode 100644 main/manager-api/src/main/resources/application-dev.yml delete mode 100644 main/manager-api/src/main/resources/application.yml delete mode 100644 main/manager-api/src/main/resources/db/changelog/202503141335.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202503141346.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504082211.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504092335.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504112044.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504112058.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504151206.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504181536.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504221135.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504221555.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504251422.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504291043.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202504301341.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505022134.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505081146.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505091555.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505111914.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505122348.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505142037.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505151451.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505182234.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505201744.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505271414.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202505292203.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506010920.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506031639.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506032232.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506051538.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506080955.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506091720.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506161101.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506191643.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506251620.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202506261637.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202507031602.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202507041018.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202507071130.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202507071530.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202507081646.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202507101203.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202508081701.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202508111734.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202508131557.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202508271113.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509051745.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509080922.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509081140.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509091042.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509091633.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509161610.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509161701.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509191545.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509220926.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509220958.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202509221530.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202510071522.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202510191042.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202511051120.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202511061415.sql delete mode 100644 main/manager-api/src/main/resources/db/changelog/202511071245.sql delete mode 100755 main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml delete mode 100644 main/manager-api/src/main/resources/i18n/messages.properties delete mode 100644 main/manager-api/src/main/resources/i18n/messages_en_US.properties delete mode 100644 main/manager-api/src/main/resources/i18n/messages_zh_CN.properties delete mode 100644 main/manager-api/src/main/resources/i18n/messages_zh_TW.properties delete mode 100644 main/manager-api/src/main/resources/i18n/validation.properties delete mode 100644 main/manager-api/src/main/resources/i18n/validation_en_US.properties delete mode 100644 main/manager-api/src/main/resources/i18n/validation_zh_CN.properties delete mode 100644 main/manager-api/src/main/resources/i18n/validation_zh_TW.properties delete mode 100644 main/manager-api/src/main/resources/logback-spring.xml delete mode 100644 main/manager-api/src/main/resources/lua/emptyAll.lua delete mode 100644 main/manager-api/src/main/resources/lua/getKeyOrCreate.lua delete mode 100644 main/manager-api/src/main/resources/mapper/agent/AgentDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/agent/AgentPluginMappingMapper.xml delete mode 100644 main/manager-api/src/main/resources/mapper/agent/AgentTemplateMapper.xml delete mode 100644 main/manager-api/src/main/resources/mapper/agent/AiAgentChatHistoryDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/device/DeviceDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/model/ModelConfigDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/model/ModelProviderDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/security/SysUserTokenDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/sys/SysDictDataDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/sys/SysDictTypeDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/sys/SysParamsDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/sys/SysUserDao.xml delete mode 100644 main/manager-api/src/main/resources/mapper/voiceclone/VoiceCloneDao.xml delete mode 100644 main/manager-api/src/test/java/xiaozhi/common/utils/AESUtilsTest.java delete mode 100644 main/manager-api/src/test/java/xiaozhi/modules/device/DeviceTest.java delete mode 100644 main/manager-api/src/test/java/xiaozhi/modules/sys/loginControllerTest.java delete mode 100644 main/manager-api/src/test/resources/application.yml delete mode 100644 main/manager-mobile/.commitlintrc.cjs delete mode 100644 main/manager-mobile/.editorconfig delete mode 100644 main/manager-mobile/.gitignore delete mode 100644 main/manager-mobile/.npmrc delete mode 100644 main/manager-mobile/LICENSE delete mode 100644 main/manager-mobile/README.md delete mode 100644 main/manager-mobile/env/.env delete mode 100644 main/manager-mobile/env/.env.development delete mode 100644 main/manager-mobile/env/.env.production delete mode 100644 main/manager-mobile/env/.env.test delete mode 100644 main/manager-mobile/eslint.config.mjs delete mode 100644 main/manager-mobile/favicon.ico delete mode 100644 main/manager-mobile/index.html delete mode 100644 main/manager-mobile/manifest.config.ts delete mode 100644 main/manager-mobile/package.json delete mode 100644 main/manager-mobile/pages.config.ts delete mode 100644 main/manager-mobile/patches/@dcloudio__uni-h5.patch delete mode 100644 main/manager-mobile/pnpm-lock.yaml delete mode 100644 main/manager-mobile/pnpm-workspace.yaml delete mode 100644 main/manager-mobile/scripts/postupgrade.js delete mode 100644 main/manager-mobile/src/App.vue delete mode 100644 main/manager-mobile/src/api/agent/agent.ts delete mode 100644 main/manager-mobile/src/api/agent/types.ts delete mode 100644 main/manager-mobile/src/api/auth.ts delete mode 100644 main/manager-mobile/src/api/chat-history/chat-history.ts delete mode 100644 main/manager-mobile/src/api/chat-history/index.ts delete mode 100644 main/manager-mobile/src/api/chat-history/types.ts delete mode 100644 main/manager-mobile/src/api/device/device.ts delete mode 100644 main/manager-mobile/src/api/device/index.ts delete mode 100644 main/manager-mobile/src/api/device/types.ts delete mode 100644 main/manager-mobile/src/api/voiceprint/index.ts delete mode 100644 main/manager-mobile/src/api/voiceprint/types.ts delete mode 100644 main/manager-mobile/src/api/voiceprint/voiceprint.ts delete mode 100644 main/manager-mobile/src/components/.gitkeep delete mode 100644 main/manager-mobile/src/components/custom-tabs/index.vue delete mode 100644 main/manager-mobile/src/env.d.ts delete mode 100644 main/manager-mobile/src/hooks/.gitkeep delete mode 100644 main/manager-mobile/src/hooks/usePageAuth.ts delete mode 100644 main/manager-mobile/src/hooks/useRequest.ts delete mode 100644 main/manager-mobile/src/hooks/useUpload.ts delete mode 100644 main/manager-mobile/src/http/README.md delete mode 100644 main/manager-mobile/src/http/request/alova.ts delete mode 100644 main/manager-mobile/src/http/request/enum.ts delete mode 100644 main/manager-mobile/src/http/request/types.ts delete mode 100644 main/manager-mobile/src/i18n/en.ts delete mode 100644 main/manager-mobile/src/i18n/index.ts delete mode 100644 main/manager-mobile/src/i18n/zh_CN.ts delete mode 100644 main/manager-mobile/src/i18n/zh_TW.ts delete mode 100644 main/manager-mobile/src/layouts/default.vue delete mode 100644 main/manager-mobile/src/layouts/fg-tabbar/fg-tabbar.vue delete mode 100644 main/manager-mobile/src/layouts/fg-tabbar/tabbar.md delete mode 100644 main/manager-mobile/src/layouts/fg-tabbar/tabbar.ts delete mode 100644 main/manager-mobile/src/layouts/fg-tabbar/tabbarList.ts delete mode 100644 main/manager-mobile/src/layouts/tabbar.vue delete mode 100644 main/manager-mobile/src/main.ts delete mode 100644 main/manager-mobile/src/manifest.json delete mode 100644 main/manager-mobile/src/pages-sub/demo/index.vue delete mode 100644 main/manager-mobile/src/pages.json delete mode 100644 main/manager-mobile/src/pages/agent/edit.vue delete mode 100644 main/manager-mobile/src/pages/agent/index.vue delete mode 100644 main/manager-mobile/src/pages/agent/tools.vue delete mode 100644 main/manager-mobile/src/pages/chat-history/detail.vue delete mode 100644 main/manager-mobile/src/pages/chat-history/index.vue delete mode 100644 main/manager-mobile/src/pages/device-config/components/ultrasonic-config.vue delete mode 100644 main/manager-mobile/src/pages/device-config/components/wifi-config.vue delete mode 100644 main/manager-mobile/src/pages/device-config/components/wifi-selector.vue delete mode 100644 main/manager-mobile/src/pages/device-config/index.vue delete mode 100644 main/manager-mobile/src/pages/device/index.vue delete mode 100644 main/manager-mobile/src/pages/forgot-password/index.vue delete mode 100644 main/manager-mobile/src/pages/index/index.vue delete mode 100644 main/manager-mobile/src/pages/login/index.vue delete mode 100644 main/manager-mobile/src/pages/register/index.vue delete mode 100644 main/manager-mobile/src/pages/settings/index.vue delete mode 100644 main/manager-mobile/src/pages/voiceprint/index.vue delete mode 100644 main/manager-mobile/src/router/interceptor.ts delete mode 100644 main/manager-mobile/src/static/app/icons/1024x1024.png delete mode 100644 main/manager-mobile/src/static/app/icons/120x120.png delete mode 100644 main/manager-mobile/src/static/app/icons/144x144.png delete mode 100644 main/manager-mobile/src/static/app/icons/152x152.png delete mode 100644 main/manager-mobile/src/static/app/icons/167x167.png delete mode 100644 main/manager-mobile/src/static/app/icons/180x180.png delete mode 100644 main/manager-mobile/src/static/app/icons/192x192.png delete mode 100644 main/manager-mobile/src/static/app/icons/20x20.png delete mode 100644 main/manager-mobile/src/static/app/icons/29x29.png delete mode 100644 main/manager-mobile/src/static/app/icons/40x40.png delete mode 100644 main/manager-mobile/src/static/app/icons/58x58.png delete mode 100644 main/manager-mobile/src/static/app/icons/60x60.png delete mode 100644 main/manager-mobile/src/static/app/icons/72x72.png delete mode 100644 main/manager-mobile/src/static/app/icons/76x76.png delete mode 100644 main/manager-mobile/src/static/app/icons/80x80.png delete mode 100644 main/manager-mobile/src/static/app/icons/87x87.png delete mode 100644 main/manager-mobile/src/static/app/icons/96x96.png delete mode 100644 main/manager-mobile/src/static/images/.gitkeep delete mode 100644 main/manager-mobile/src/static/images/default-avatar.png delete mode 100644 main/manager-mobile/src/static/images/home/main-top-bg.png delete mode 100644 main/manager-mobile/src/static/logo.png delete mode 100644 main/manager-mobile/src/static/logo.svg delete mode 100644 main/manager-mobile/src/static/tabbar/chat.png delete mode 100644 main/manager-mobile/src/static/tabbar/chat_activate.png delete mode 100644 main/manager-mobile/src/static/tabbar/device.png delete mode 100644 main/manager-mobile/src/static/tabbar/device_activate.png delete mode 100644 main/manager-mobile/src/static/tabbar/example.png delete mode 100644 main/manager-mobile/src/static/tabbar/exampleHL.png delete mode 100644 main/manager-mobile/src/static/tabbar/home.png delete mode 100644 main/manager-mobile/src/static/tabbar/homeHL.png delete mode 100644 main/manager-mobile/src/static/tabbar/microphone.png delete mode 100644 main/manager-mobile/src/static/tabbar/microphone_activate.png delete mode 100644 main/manager-mobile/src/static/tabbar/network.png delete mode 100644 main/manager-mobile/src/static/tabbar/network_activate.png delete mode 100644 main/manager-mobile/src/static/tabbar/personal.png delete mode 100644 main/manager-mobile/src/static/tabbar/personalHL.png delete mode 100644 main/manager-mobile/src/static/tabbar/robot.png delete mode 100644 main/manager-mobile/src/static/tabbar/robot_activate.png delete mode 100644 main/manager-mobile/src/static/tabbar/system.png delete mode 100644 main/manager-mobile/src/static/tabbar/system_activate.png delete mode 100644 main/manager-mobile/src/store/config.ts delete mode 100644 main/manager-mobile/src/store/index.ts delete mode 100644 main/manager-mobile/src/store/lang.ts delete mode 100644 main/manager-mobile/src/store/plugin.ts delete mode 100644 main/manager-mobile/src/store/user.ts delete mode 100644 main/manager-mobile/src/style/iconfont.css delete mode 100644 main/manager-mobile/src/style/index.scss delete mode 100644 main/manager-mobile/src/typings.d.ts delete mode 100644 main/manager-mobile/src/typings.ts delete mode 100644 main/manager-mobile/src/uni.scss delete mode 100644 main/manager-mobile/src/utils/index.ts delete mode 100644 main/manager-mobile/src/utils/platform.ts delete mode 100644 main/manager-mobile/src/utils/toast.ts delete mode 100644 main/manager-mobile/src/utils/uploadFile.ts delete mode 100644 main/manager-mobile/tsconfig.json delete mode 100644 main/manager-mobile/uno.config.ts delete mode 100644 main/manager-mobile/unpackage/res/icons/1024x1024.png delete mode 100644 main/manager-mobile/unpackage/res/icons/120x120.png delete mode 100644 main/manager-mobile/unpackage/res/icons/144x144.png delete mode 100644 main/manager-mobile/unpackage/res/icons/152x152.png delete mode 100644 main/manager-mobile/unpackage/res/icons/167x167.png delete mode 100644 main/manager-mobile/unpackage/res/icons/180x180.png delete mode 100644 main/manager-mobile/unpackage/res/icons/192x192.png delete mode 100644 main/manager-mobile/unpackage/res/icons/20x20.png delete mode 100644 main/manager-mobile/unpackage/res/icons/29x29.png delete mode 100644 main/manager-mobile/unpackage/res/icons/40x40.png delete mode 100644 main/manager-mobile/unpackage/res/icons/58x58.png delete mode 100644 main/manager-mobile/unpackage/res/icons/60x60.png delete mode 100644 main/manager-mobile/unpackage/res/icons/72x72.png delete mode 100644 main/manager-mobile/unpackage/res/icons/76x76.png delete mode 100644 main/manager-mobile/unpackage/res/icons/80x80.png delete mode 100644 main/manager-mobile/unpackage/res/icons/87x87.png delete mode 100644 main/manager-mobile/unpackage/res/icons/96x96.png delete mode 100644 main/manager-mobile/vite.config.ts delete mode 100644 main/manager-web/.env delete mode 100644 main/manager-web/.env.development delete mode 100644 main/manager-web/.env.production delete mode 100644 main/manager-web/.npmrc delete mode 100644 main/manager-web/README.md delete mode 100644 main/manager-web/babel.config.js delete mode 100644 main/manager-web/jsconfig.json delete mode 100644 main/manager-web/package-lock.json delete mode 100644 main/manager-web/package.json delete mode 100644 main/manager-web/public/favicon.ico delete mode 100644 main/manager-web/public/index.html delete mode 100644 main/manager-web/public/offline.html delete mode 100644 main/manager-web/src/App.vue delete mode 100755 main/manager-web/src/apis/api.js delete mode 100755 main/manager-web/src/apis/httpRequest.js delete mode 100644 main/manager-web/src/apis/module/admin.js delete mode 100644 main/manager-web/src/apis/module/agent.js delete mode 100644 main/manager-web/src/apis/module/device.js delete mode 100644 main/manager-web/src/apis/module/dict.js delete mode 100644 main/manager-web/src/apis/module/model.js delete mode 100644 main/manager-web/src/apis/module/ota.js delete mode 100644 main/manager-web/src/apis/module/timbre.js delete mode 100755 main/manager-web/src/apis/module/user.js delete mode 100644 main/manager-web/src/apis/module/voiceClone.js delete mode 100644 main/manager-web/src/apis/module/voiceResource.js delete mode 100644 main/manager-web/src/assets/header/model_config.png delete mode 100644 main/manager-web/src/assets/header/param_management.png delete mode 100644 main/manager-web/src/assets/header/robot.png delete mode 100644 main/manager-web/src/assets/header/user_management.png delete mode 100644 main/manager-web/src/assets/header/voice.png delete mode 100644 main/manager-web/src/assets/home/avatar.png delete mode 100644 main/manager-web/src/assets/home/close.png delete mode 100644 main/manager-web/src/assets/home/delete.png delete mode 100644 main/manager-web/src/assets/home/equipment.png delete mode 100644 main/manager-web/src/assets/home/info.png delete mode 100644 main/manager-web/src/assets/home/main-top-bg.png delete mode 100644 main/manager-web/src/assets/home/red-info.png delete mode 100644 main/manager-web/src/assets/home/search.png delete mode 100644 main/manager-web/src/assets/home/setting-user.png delete mode 100644 main/manager-web/src/assets/login/down-arrow.png delete mode 100644 main/manager-web/src/assets/login/hi.png delete mode 100644 main/manager-web/src/assets/login/login-person.png delete mode 100644 main/manager-web/src/assets/login/password.png delete mode 100644 main/manager-web/src/assets/login/phone.png delete mode 100644 main/manager-web/src/assets/login/register-person.png delete mode 100644 main/manager-web/src/assets/login/shield.png delete mode 100644 main/manager-web/src/assets/login/username.png delete mode 100644 main/manager-web/src/assets/model/inner_conf.png delete mode 100644 main/manager-web/src/assets/model/model.png delete mode 100644 main/manager-web/src/assets/model/output_conf.png delete mode 100644 main/manager-web/src/assets/user-avatar1.png delete mode 100644 main/manager-web/src/assets/user-avatar2.png delete mode 100644 main/manager-web/src/assets/user-avatar3.png delete mode 100644 main/manager-web/src/assets/user-avatar4.png delete mode 100644 main/manager-web/src/assets/user-avatar5.png delete mode 100644 main/manager-web/src/assets/xiaozhi-ai.png delete mode 100644 main/manager-web/src/assets/xiaozhi-logo.png delete mode 100644 main/manager-web/src/components/AddDeviceDialog.vue delete mode 100644 main/manager-web/src/components/AddModelDialog.vue delete mode 100644 main/manager-web/src/components/AddWisdomBodyDialog.vue delete mode 100644 main/manager-web/src/components/AudioPlayer.vue delete mode 100644 main/manager-web/src/components/CacheViewer.vue delete mode 100644 main/manager-web/src/components/ChangePasswordDialog.vue delete mode 100644 main/manager-web/src/components/ChatHistoryDialog.vue delete mode 100644 main/manager-web/src/components/DeviceItem.vue delete mode 100644 main/manager-web/src/components/DictDataDialog.vue delete mode 100644 main/manager-web/src/components/DictTypeDialog.vue delete mode 100644 main/manager-web/src/components/EditVoiceDialog.vue delete mode 100644 main/manager-web/src/components/FirmwareDialog.vue delete mode 100644 main/manager-web/src/components/FunctionDialog.vue delete mode 100644 main/manager-web/src/components/HeaderBar.vue delete mode 100644 main/manager-web/src/components/ManualAddDeviceDialog.vue delete mode 100644 main/manager-web/src/components/ModelEditDialog.vue delete mode 100644 main/manager-web/src/components/ParamDialog.vue delete mode 100644 main/manager-web/src/components/ProviderDialog.vue delete mode 100644 main/manager-web/src/components/TtsModel.vue delete mode 100644 main/manager-web/src/components/VersionFooter.vue delete mode 100644 main/manager-web/src/components/ViewPasswordDialog.vue delete mode 100644 main/manager-web/src/components/VoiceCloneDialog.vue delete mode 100644 main/manager-web/src/components/VoicePrintDialog.vue delete mode 100644 main/manager-web/src/components/VoiceResourceDialog.vue delete mode 100644 main/manager-web/src/i18n/en.js delete mode 100644 main/manager-web/src/i18n/index.js delete mode 100644 main/manager-web/src/i18n/zh_CN.js delete mode 100644 main/manager-web/src/i18n/zh_TW.js delete mode 100644 main/manager-web/src/main.js delete mode 100644 main/manager-web/src/registerServiceWorker.js delete mode 100644 main/manager-web/src/router/index.js delete mode 100644 main/manager-web/src/service-worker.js delete mode 100644 main/manager-web/src/store/index.js delete mode 100644 main/manager-web/src/styles/global.scss delete mode 100644 main/manager-web/src/utils/cacheViewer.js delete mode 100755 main/manager-web/src/utils/constant.js delete mode 100755 main/manager-web/src/utils/date.js delete mode 100644 main/manager-web/src/utils/format.js delete mode 100755 main/manager-web/src/utils/index.js delete mode 100644 main/manager-web/src/views/AgentTemplateManagement.vue delete mode 100644 main/manager-web/src/views/DeviceManagement.vue delete mode 100644 main/manager-web/src/views/DictManagement.vue delete mode 100644 main/manager-web/src/views/ModelConfig.vue delete mode 100644 main/manager-web/src/views/OtaManagement.vue delete mode 100644 main/manager-web/src/views/ParamsManagement.vue delete mode 100644 main/manager-web/src/views/ProviderManagement.vue delete mode 100644 main/manager-web/src/views/ServerSideManager.vue delete mode 100644 main/manager-web/src/views/TemplateQuickConfig.vue delete mode 100644 main/manager-web/src/views/UserManagement.vue delete mode 100644 main/manager-web/src/views/VoiceCloneManagement.vue delete mode 100644 main/manager-web/src/views/VoicePrint.vue delete mode 100644 main/manager-web/src/views/VoiceResourceManagement.vue delete mode 100644 main/manager-web/src/views/auth.scss delete mode 100644 main/manager-web/src/views/home.vue delete mode 100644 main/manager-web/src/views/login.vue delete mode 100644 main/manager-web/src/views/register.vue delete mode 100644 main/manager-web/src/views/retrievePassword.vue delete mode 100644 main/manager-web/src/views/roleConfig.vue delete mode 100644 main/manager-web/vue.config.js diff --git a/main/docker-compose_dokploy.yml b/main/docker-compose_dokploy.yml index 4692c6ee7..8d97ec8c8 100644 --- a/main/docker-compose_dokploy.yml +++ b/main/docker-compose_dokploy.yml @@ -73,77 +73,7 @@ services: - /home/ubuntu/live-agent/main/xiaozhi-server/music:/opt/xiaozhi-esp32-server/music # Logs (optional, for debugging) - /home/ubuntu/live-agent/main/xiaozhi-server/logs:/opt/xiaozhi-esp32-server/logs - - # ============================================================================ - # MySQL Database (for xiaozhi-esp32-server) - # ============================================================================ - xiaozhi-esp32-server-db: - image: mysql:8.0 - container_name: xiaozhi-esp32-server-db - restart: unless-stopped - networks: - - xiaozhi-network - ports: - # Expose MySQL port for debugging (optional) - - "3307:3306" - volumes: - # Persistent database storage - - /home/ubuntu/live-agent/main/xiaozhi-server/mysql/data:/var/lib/mysql - # MySQL configuration (optional) - # - /home/ubuntu/live-agent/main/xiaozhi-server/mysql/conf:/etc/mysql/conf.d - environment: - - TZ=Asia/Shanghai - - MYSQL_ROOT_PASSWORD=123456 - - MYSQL_DATABASE=xiaozhi_esp32_server - - MYSQL_INITDB_ARGS=--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci - command: - - --character-set-server=utf8mb4 - - --collation-server=utf8mb4_unicode_ci - - --default-authentication-plugin=mysql_native_password - - --max_connections=1000 - - --max_allowed_packet=256M - logging: - driver: "json-file" - options: - max-size: "10m" - max-file: "3" - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p123456"] - timeout: 45s - interval: 10s - retries: 10 - start_period: 60s - - # ============================================================================ - # Redis Cache (for xiaozhi-esp32-server) - # ============================================================================ - xiaozhi-esp32-server-redis: - image: redis:7-alpine - container_name: xiaozhi-esp32-server-redis - restart: unless-stopped - networks: - - xiaozhi-network - ports: - # Expose Redis port for debugging (optional) - - "6380:6379" - volumes: - # Persistent Redis data (optional) - - /home/ubuntu/live-agent/main/xiaozhi-server/redis/data:/data - environment: - - TZ=Asia/Shanghai - command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru - logging: - driver: "json-file" - options: - max-size: "5m" - max-file: "3" - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 10s - timeout: 5s - retries: 3 - start_period: 10s - + # ============================================================================ # live-agent-api Dependencies: Postgres + Minio # ============================================================================ diff --git a/main/docker-compose_local_all.yml b/main/docker-compose_local_all.yml index 641e5cf69..737018521 100644 --- a/main/docker-compose_local_all.yml +++ b/main/docker-compose_local_all.yml @@ -47,126 +47,9 @@ services: # Logs (optional, for debugging) - ./xiaozhi-server/logs:/opt/xiaozhi-esp32-server/logs - # ============================================================================ - # manager-web (Management Console + API) - # ============================================================================ - xiaozhi-esp32-server-web: - # Build from local source (supports ARM64/Apple Silicon) - build: - context: ../ - dockerfile: Dockerfile-web - image: xiaozhi-esp32-server-web:local - - # Option: Use pre-built image from registry (x86 only) - # image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest - # platform: linux/amd64 # Uncomment to force x86 emulation on ARM64 - - container_name: xiaozhi-esp32-server-web - restart: unless-stopped - networks: - - xiaozhi-network - depends_on: - xiaozhi-esp32-server-db: - condition: service_healthy - xiaozhi-esp32-server-redis: - condition: service_healthy - ports: - # Management console and API - - "8002:8002" - environment: - - TZ=Asia/Shanghai - - SPRING_PROFILES_ACTIVE=dev - # Database connection - - SPRING_DATASOURCE_DRUID_URL=jdbc:mysql://xiaozhi-esp32-server-db:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&connectTimeout=30000&socketTimeout=30000&autoReconnect=true&failOverReadOnly=false&maxReconnects=10 - - SPRING_DATASOURCE_DRUID_USERNAME=root - - SPRING_DATASOURCE_DRUID_PASSWORD=123456 - # Redis connection - - SPRING_DATA_REDIS_HOST=xiaozhi-esp32-server-redis - - SPRING_DATA_REDIS_PORT=6379 - - SPRING_DATA_REDIS_PASSWORD= - volumes: - # Upload files directory - - ./xiaozhi-server/uploadfile:/uploadfile - logging: - driver: "json-file" - options: - max-size: "10m" - max-file: "3" - - # ============================================================================ - # MySQL Database - # ============================================================================ - xiaozhi-esp32-server-db: - image: mysql:8.0 - container_name: xiaozhi-esp32-server-db - restart: unless-stopped - networks: - - xiaozhi-network - ports: - # Expose MySQL port for local debugging (optional) - - "3307:3306" - volumes: - # Persistent database storage - - ./xiaozhi-server/mysql/data:/var/lib/mysql - # MySQL configuration (optional) - # - ./xiaozhi-server/mysql/conf:/etc/mysql/conf.d - environment: - - TZ=Asia/Shanghai - - MYSQL_ROOT_PASSWORD=123456 - - MYSQL_DATABASE=xiaozhi_esp32_server - - MYSQL_INITDB_ARGS=--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci - command: - - --character-set-server=utf8mb4 - - --collation-server=utf8mb4_unicode_ci - - --default-authentication-plugin=mysql_native_password - - --max_connections=1000 - - --max_allowed_packet=256M - logging: - driver: "json-file" - options: - max-size: "10m" - max-file: "3" - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p123456"] - timeout: 45s - interval: 10s - retries: 10 - start_period: 60s - - # ============================================================================ - # Redis Cache - # ============================================================================ - xiaozhi-esp32-server-redis: - image: redis:7-alpine - container_name: xiaozhi-esp32-server-redis - restart: unless-stopped - networks: - - xiaozhi-network - ports: - # Expose Redis port for local debugging (optional) - - "6380:6379" - volumes: - # Persistent Redis data (optional) - - ./xiaozhi-server/redis/data:/data - environment: - - TZ=Asia/Shanghai - command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru - logging: - driver: "json-file" - options: - max-size: "5m" - max-file: "3" - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 10s - timeout: 5s - retries: 3 - start_period: 10s - # ============================================================================ # live-agent-api Services # ============================================================================ - live-agent-postgres: image: postgres:16-alpine container_name: live-agent-postgres diff --git a/main/manager-api/README.md b/main/manager-api/README.md deleted file mode 100644 index 484c28dc0..000000000 --- a/main/manager-api/README.md +++ /dev/null @@ -1,18 +0,0 @@ -本文档是开发类文档,如需部署小智服务端,[点击这里查看部署教程](../../README.md#%E9%83%A8%E7%BD%B2%E6%96%87%E6%A1%A3) - -# 项目介绍 - -manager-api 该项目基于SpringBoot框架开发。 - -开发使用代码编辑器,导入项目时,选择`manager-api`文件夹作为项目目录 - -# 开发环境 -JDK 21 -Maven 3.8+ -MySQL 8.0+ -Redis 5.0+ -Vue 3.x - -# 接口文档 -启动后打开:http://localhost:8002/xiaozhi/doc.html - diff --git a/main/manager-api/pom.xml b/main/manager-api/pom.xml deleted file mode 100644 index b3798571c..000000000 --- a/main/manager-api/pom.xml +++ /dev/null @@ -1,283 +0,0 @@ - - 4.0.0 - xiaozhi - xiaozhi-esp32-api - jar - 0.0.1 - xiaozhi-esp32-api - 小智后台管理系统 - - - org.springframework.boot - spring-boot-starter-parent - 3.4.3 - - - - UTF-8 - UTF-8 - 21 - 5.10.1 - 1.2.20 - 3.5.5 - 5.8.24 - 1.19.1 - 4.6.0 - 2.8.8 - 3.18.0 - 2.0.2 - 1.6.2 - 33.0.0-jre - 4.20.0 - 4.1.0 - 3.4.0 - - - - - org.apache.shiro - shiro-core - jakarta - ${shiro.version} - - - - org.apache.shiro - shiro-spring - jakarta - ${shiro.version} - - - org.apache.shiro - shiro-core - - - org.apache.shiro - shiro-web - - - - - org.apache.shiro - shiro-web - jakarta - ${shiro.version} - - - org.apache.shiro - shiro-core - - - - - - com.github.whvcse - easy-captcha - ${captcha.version} - - - - - org.springframework.boot - spring-boot-starter-websocket - - - com.google.guava - guava - ${guava.version} - - - org.junit.jupiter - junit-jupiter-api - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit.version} - test - - - org.junit.platform - junit-platform-launcher - 1.10.1 - test - - - org.junit.platform - junit-platform-commons - 1.10.1 - test - - - org.junit.platform - junit-platform-engine - 1.10.1 - test - - - org.springframework.boot - spring-boot-starter-test - test - - - jakarta.servlet - jakarta.servlet-api - provided - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-aop - - - org.springframework - spring-context-support - - - org.springframework.boot - spring-boot-starter-data-redis - - - org.springframework.boot - spring-boot-starter-validation - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - com.mysql - mysql-connector-j - - - com.alibaba - druid-spring-boot-3-starter - ${druid.version} - - - org.liquibase - liquibase-core - ${liquibase-core.version} - - - com.baomidou - mybatis-plus-boot-starter - ${mybatisplus.version} - - - org.mybatis - mybatis-spring - 3.0.3 - - - cn.hutool - hutool-all - ${hutool.version} - - - org.jsoup - jsoup - ${jsoup.version} - - - - com.github.xingfudeshi - knife4j-openapi3-jakarta-spring-boot-starter - ${knife4j.version} - - - - org.bouncycastle - bcprov-jdk18on - 1.78 - - - - org.springdoc - springdoc-openapi-starter-webmvc-ui - ${springdoc.version} - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.projectlombok - lombok - true - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - - - com.aliyun - dysmsapi20170525 - ${aliyun-sms-version} - - - - com.squareup.okio - okio - ${okio-version} - - - - - - - public - aliyun nexus - https://maven.aliyun.com/repository/public/ - - true - - - - - - public - aliyun nexus - https://maven.aliyun.com/repository/public/ - - true - - - false - - - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - diff --git a/main/manager-api/src/main/java/xiaozhi/AdminApplication.java b/main/manager-api/src/main/java/xiaozhi/AdminApplication.java deleted file mode 100644 index 84e30123d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/AdminApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package xiaozhi; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class AdminApplication { - - public static void main(String[] args) { - SpringApplication.run(AdminApplication.class, args); - System.out.println("http://localhost:8002/xiaozhi/doc.html"); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/annotation/DataFilter.java b/main/manager-api/src/main/java/xiaozhi/common/annotation/DataFilter.java deleted file mode 100644 index 9bd6cb9db..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/annotation/DataFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -package xiaozhi.common.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 数据过滤注解 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface DataFilter { - /** - * 表的别名 - */ - String tableAlias() default ""; - - /** - * 用户ID - */ - String userId() default "creator"; - - /** - * 部门ID - */ - String deptId() default "dept_id"; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/annotation/LogOperation.java b/main/manager-api/src/main/java/xiaozhi/common/annotation/LogOperation.java deleted file mode 100644 index 6f6f778da..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/annotation/LogOperation.java +++ /dev/null @@ -1,20 +0,0 @@ -package xiaozhi.common.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 操作日志注解 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface LogOperation { - - String value() default ""; -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/aspect/RedisAspect.java b/main/manager-api/src/main/java/xiaozhi/common/aspect/RedisAspect.java deleted file mode 100644 index d4233e72b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/aspect/RedisAspect.java +++ /dev/null @@ -1,41 +0,0 @@ -package xiaozhi.common.aspect; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; - -/** - * Redis切面处理类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Slf4j -@Aspect -@Component -public class RedisAspect { - /** - * 是否开启redis缓存 true开启 false关闭 - */ - @Value("${renren.redis.open}") - private boolean open; - - @Around("execution(* xiaozhi.common.redis.RedisUtils.*(..))") - public Object around(ProceedingJoinPoint point) throws Throwable { - Object result = null; - if (open) { - try { - result = point.proceed(); - } catch (Exception e) { - log.error("redis error", e); - throw new RenException(ErrorCode.REDIS_ERROR); - } - } - return result; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/config/AsyncConfig.java b/main/manager-api/src/main/java/xiaozhi/common/config/AsyncConfig.java deleted file mode 100644 index d0cc2dfce..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/config/AsyncConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package xiaozhi.common.config; - -import java.util.concurrent.Executor; -import java.util.concurrent.RejectedExecutionHandler; -import java.util.concurrent.ThreadPoolExecutor; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -@Configuration -@EnableAsync -@EnableAspectJAutoProxy(exposeProxy = true) -public class AsyncConfig { - - @Bean(name = "taskExecutor") - public Executor taskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(2); - executor.setMaxPoolSize(4); - executor.setQueueCapacity(1000); - executor.setThreadNamePrefix("AsyncThread-"); - // 设置拒绝策略:由调用线程执行 - executor.setRejectedExecutionHandler(new RejectedExecutionHandler() { - @Override - public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { - try { - // 如果线程池已满,则由调用线程执行 - r.run(); - } catch (Exception e) { - throw new RuntimeException("执行异步任务失败", e); - } - } - }); - executor.initialize(); - return executor; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/config/MybatisPlusConfig.java b/main/manager-api/src/main/java/xiaozhi/common/config/MybatisPlusConfig.java deleted file mode 100644 index 250e0d070..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/config/MybatisPlusConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package xiaozhi.common.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; -import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; -import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; -import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; - -import xiaozhi.common.interceptor.DataFilterInterceptor; - -/** - * mybatis-plus配置 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Configuration -public class MybatisPlusConfig { - - @Bean - public MybatisPlusInterceptor mybatisPlusInterceptor() { - MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); - // 数据权限 - mybatisPlusInterceptor.addInnerInterceptor(new DataFilterInterceptor()); - // 分页插件 - mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); - // 乐观锁 - mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); - // 防止全表更新与删除 - mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); - - return mybatisPlusInterceptor; - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/config/RestTemplateConfig.java b/main/manager-api/src/main/java/xiaozhi/common/config/RestTemplateConfig.java deleted file mode 100644 index ecfaa3597..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/config/RestTemplateConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package xiaozhi.common.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; - -/** - * RestTemplate配置 - */ -@Configuration -public class RestTemplateConfig { - - @Bean - public RestTemplate restTemplate() { - return new RestTemplate(); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/config/SwaggerConfig.java b/main/manager-api/src/main/java/xiaozhi/common/config/SwaggerConfig.java deleted file mode 100644 index 8fb316419..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/config/SwaggerConfig.java +++ /dev/null @@ -1,90 +0,0 @@ -package xiaozhi.common.config; - -import org.springdoc.core.models.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; - -/** - * Swagger配置 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Configuration -public class SwaggerConfig { - - @Bean - public GroupedOpenApi deviceApi() { - return GroupedOpenApi.builder() - .group("device") - .pathsToMatch("/device/**") - .build(); - } - - @Bean - public GroupedOpenApi agentApi() { - return GroupedOpenApi.builder() - .group("agent") - .pathsToMatch("/agent/**") - .build(); - } - - @Bean - public GroupedOpenApi modelApi() { - return GroupedOpenApi.builder() - .group("models") - .pathsToMatch("/models/**") - .build(); - } - - @Bean - public GroupedOpenApi oatApi() { - return GroupedOpenApi.builder() - .group("ota") - .pathsToMatch("/ota/**") - .build(); - } - - @Bean - public GroupedOpenApi timbreApi() { - return GroupedOpenApi.builder() - .group("timbre") - .pathsToMatch("/ttsVoice/**") - .build(); - } - - @Bean - public GroupedOpenApi sysApi() { - return GroupedOpenApi.builder() - .group("admin") - .pathsToMatch("/admin/**") - .build(); - } - - @Bean - public GroupedOpenApi userApi() { - return GroupedOpenApi.builder() - .group("user") - .pathsToMatch("/user/**") - .build(); - } - - @Bean - public GroupedOpenApi configApi() { - return GroupedOpenApi.builder() - .group("config") - .pathsToMatch("/config/**") - .build(); - } - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI().info(new Info() - .title("xiaozhi-esp32-manager-api") - .description("xiaozhi-esp32-manager-api文档") - .version("3.0") - .termsOfService("https://127.0.0.1")); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java b/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java deleted file mode 100644 index 4987afc3b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java +++ /dev/null @@ -1,323 +0,0 @@ -package xiaozhi.common.constant; - -import lombok.Getter; - -/** - * 常量 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public interface Constant { - /** - * 成功 - */ - int SUCCESS = 1; - /** - * 失败 - */ - int FAIL = 0; - /** - * OK - */ - String OK = "OK"; - /** - * 用户标识 - */ - String USER_KEY = "userId"; - /** - * 菜单根节点标识 - */ - Long MENU_ROOT = 0L; - /** - * 部门根节点标识 - */ - Long DEPT_ROOT = 0L; - /** - * 数据字典根节点标识 - */ - Long DICT_ROOT = 0L; - /** - * 升序 - */ - String ASC = "asc"; - /** - * 降序 - */ - String DESC = "desc"; - /** - * 创建时间字段名 - */ - String CREATE_DATE = "create_date"; - - /** - * 创建时间字段名 - */ - String ID = "id"; - - /** - * 数据权限过滤 - */ - String SQL_FILTER = "sqlFilter"; - - /** - * 当前页码 - */ - String PAGE = "page"; - /** - * 每页显示记录数 - */ - String LIMIT = "limit"; - /** - * 排序字段 - */ - String ORDER_FIELD = "orderField"; - /** - * 排序方式 - */ - String ORDER = "order"; - - /** - * 请求头授权标识 - */ - String AUTHORIZATION = "Authorization"; - - /** - * 服务器密钥 - */ - String SERVER_SECRET = "server.secret"; - - /** - * SM2公钥 - */ - String SM2_PUBLIC_KEY = "server.public_key"; - - /** - * SM2私钥 - */ - String SM2_PRIVATE_KEY = "server.private_key"; - - /** - * websocket地址 - */ - String SERVER_WEBSOCKET = "server.websocket"; - - /** - * mqtt gateway 配置 - */ - String SERVER_MQTT_GATEWAY = "server.mqtt_gateway"; - - /** - * ota地址 - */ - String SERVER_OTA = "server.ota"; - - /** - * 是否允许用户注册 - */ - String SERVER_ALLOW_USER_REGISTER = "server.allow_user_register"; - - /** - * 下发六位验证码时显示的控制面板地址 - */ - String SERVER_FRONTED_URL = "server.fronted_url"; - - /** - * 路径分割符 - */ - String FILE_EXTENSION_SEG = "."; - - /** - * mcp接入点路径 - */ - String SERVER_MCP_ENDPOINT = "server.mcp_endpoint"; - - /** - * mcp接入点路径 - */ - String SERVER_VOICE_PRINT = "server.voice_print"; - - /** - * mqtt密钥 - */ - String SERVER_MQTT_SECRET = "server.mqtt_signature_key"; - - /** - * 无记忆 - */ - String MEMORY_NO_MEM = "Memory_nomem"; - - /** - * 火山引擎双声道语音克隆 - */ - String VOICE_CLONE_HUOSHAN_DOUBLE_STREAM = "huoshan_double_stream"; - - enum SysBaseParam { - /** - * ICP备案号 - */ - BEIAN_ICP_NUM("server.beian_icp_num"), - /** - * GA备案号 - */ - BEIAN_GA_NUM("server.beian_ga_num"), - /** - * 系统名称 - */ - SERVER_NAME("server.name"); - - private String value; - - SysBaseParam(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } - - /** - * 训练状态 - */ - enum TrainStatus { - /** - * 未训练 - */ - NOT_TRAINED(0), - /** - * 训练中 - */ - TRAINING(1), - /** - * 已训练 - */ - TRAINED(2), - /** - * 训练失败 - */ - TRAIN_FAILED(3); - - private final int code; - - TrainStatus(int code) { - this.code = code; - } - - public int getCode() { - return code; - } - } - - /** - * 系统短信 - */ - enum SysMSMParam { - /** - * 阿里云授权keyID - */ - ALIYUN_SMS_ACCESS_KEY_ID("aliyun.sms.access_key_id"), - /** - * 阿里云授权密钥 - */ - ALIYUN_SMS_ACCESS_KEY_SECRET("aliyun.sms.access_key_secret"), - /** - * 阿里云短信签名 - */ - ALIYUN_SMS_SIGN_NAME("aliyun.sms.sign_name"), - /** - * 阿里云短信模板 - */ - ALIYUN_SMS_SMS_CODE_TEMPLATE_CODE("aliyun.sms.sms_code_template_code"), - /** - * 单号码最大短信发送条数 - */ - SERVER_SMS_MAX_SEND_COUNT("server.sms_max_send_count"), - /** - * 是否开启手机注册 - */ - SERVER_ENABLE_MOBILE_REGISTER("server.enable_mobile_register"); - - private String value; - - SysMSMParam(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } - - /** - * 数据状态 - */ - enum DataOperation { - /** - * 插入 - */ - INSERT("I"), - /** - * 已修改 - */ - UPDATE("U"), - /** - * 已删除 - */ - DELETE("D"); - - private String value; - - DataOperation(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } - - @Getter - enum ChatHistoryConfEnum { - IGNORE(0, "不记录"), - RECORD_TEXT(1, "记录文本"), - RECORD_TEXT_AUDIO(2, "文本音频都记录"); - - private final int code; - private final String name; - - ChatHistoryConfEnum(int code, String name) { - this.code = code; - this.name = name; - } - } - - /** - * 版本号 - */ - public static final String VERSION = "0.8.6"; - - /** - * 无效固件URL - */ - String INVALID_FIRMWARE_URL = "http://xiaozhi.server.com:8002/xiaozhi/otaMag/download/NOT_ACTIVATED_FIRMWARE_THIS_IS_A_INVALID_URL"; - - /** - * 字典类型 - */ - enum DictType { - /** - * 手机区号 - */ - MOBILE_AREA("MOBILE_AREA"); - - private String value; - - DictType(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/convert/DateConverter.java b/main/manager-api/src/main/java/xiaozhi/common/convert/DateConverter.java deleted file mode 100644 index fd0f74c29..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/convert/DateConverter.java +++ /dev/null @@ -1,73 +0,0 @@ -package xiaozhi.common.convert; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.convert.converter.Converter; -import org.springframework.stereotype.Component; - -/** - * 日期转换 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Component -public class DateConverter implements Converter { - private static final Logger logger = LoggerFactory.getLogger(DateConverter.class); - private static final List formatList = new ArrayList<>(5); - - static { - formatList.add("yyyy-MM"); - formatList.add("yyyy-MM-dd"); - formatList.add("yyyy-MM-dd hh:mm"); - formatList.add("yyyy-MM-dd hh:mm:ss"); - formatList.add("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); - } - - @Override - public Date convert(String source) { - String value = source.trim(); - if (StringUtils.isEmpty(value)) { - return null; - } - - if (source.matches("^\\d{4}-\\d{1,2}$")) { - return parseDate(source, formatList.get(0)); - } else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) { - return parseDate(source, formatList.get(1)); - } else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$")) { - return parseDate(source, formatList.get(2)); - } else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$")) { - return parseDate(source, formatList.get(3)); - } else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2}.*T.*\\d{1,2}:\\d{1,2}:\\d{1,2}.*..*$")) { - return parseDate(source, formatList.get(4)); - } else { - throw new IllegalArgumentException("Invalid boolean value '" + source + "'"); - } - } - - /** - * 格式化日期 - * - * @param dateStr String 字符型日期 - * @param format String 格式 - * @return Date 日期 - */ - public Date parseDate(String dateStr, String format) { - Date date = null; - try { - DateFormat dateFormat = new SimpleDateFormat(format); - date = dateFormat.parse(dateStr); - } catch (Exception e) { - logger.error("Formatted date with date: {} and format : {} ", dateStr, format); - } - return date; - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/dao/BaseDao.java b/main/manager-api/src/main/java/xiaozhi/common/dao/BaseDao.java deleted file mode 100644 index d65e78305..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/dao/BaseDao.java +++ /dev/null @@ -1,12 +0,0 @@ -package xiaozhi.common.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - * 基础Dao - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public interface BaseDao extends BaseMapper { - -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/entity/BaseEntity.java b/main/manager-api/src/main/java/xiaozhi/common/entity/BaseEntity.java deleted file mode 100644 index ce267babc..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/entity/BaseEntity.java +++ /dev/null @@ -1,34 +0,0 @@ -package xiaozhi.common.entity; - -import java.io.Serializable; -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; - -import lombok.Data; - -/** - * 基础实体类,所有实体都需要继承 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Data -public abstract class BaseEntity implements Serializable { - /** - * id - */ - @TableId - private Long id; - /** - * 创建者 - */ - @TableField(fill = FieldFill.INSERT) - private Long creator; - /** - * 创建时间 - */ - @TableField(fill = FieldFill.INSERT) - private Date createDate; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/exception/ErrorCode.java b/main/manager-api/src/main/java/xiaozhi/common/exception/ErrorCode.java deleted file mode 100644 index 82b16ec5e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/exception/ErrorCode.java +++ /dev/null @@ -1,201 +0,0 @@ -package xiaozhi.common.exception; - -/** - * 错误编码,由5位数字组成,前2位为模块编码,后3位为业务编码 - *

- * 如:10001(10代表系统模块,001代表业务代码) - *

- * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public interface ErrorCode { - int INTERNAL_SERVER_ERROR = 500; - int UNAUTHORIZED = 401; - int FORBIDDEN = 403; - - int NOT_NULL = 10001; - int DB_RECORD_EXISTS = 10002; - int PARAMS_GET_ERROR = 10003; - int ACCOUNT_PASSWORD_ERROR = 10004; - int ACCOUNT_DISABLE = 10005; - int IDENTIFIER_NOT_NULL = 10006; - int CAPTCHA_ERROR = 10007; - int PHONE_NOT_NULL = 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 DEVICE_CAPTCHA_ERROR = 10033; - - // 参数校验相关错误码 - int PARAM_VALUE_NULL = 10034; - int PARAM_TYPE_NULL = 10035; - int PARAM_TYPE_INVALID = 10036; - int PARAM_NUMBER_INVALID = 10037; - int PARAM_BOOLEAN_INVALID = 10038; - int PARAM_ARRAY_INVALID = 10039; - int PARAM_JSON_INVALID = 10040; - - int OTA_DEVICE_NOT_FOUND = 10041; - int OTA_DEVICE_NEED_BIND = 10042; - - // 新增错误编码 - int DELETE_DATA_FAILED = 10043; - int USER_NOT_LOGIN = 10044; - int WEB_SOCKET_CONNECT_FAILED = 10045; - int VOICE_PRINT_SAVE_ERROR = 10046; - int TODAY_SMS_LIMIT_REACHED = 10047; - int OLD_PASSWORD_ERROR = 10048; - int INVALID_LLM_TYPE = 10049; - int TOKEN_GENERATE_ERROR = 10050; - int RESOURCE_NOT_FOUND = 10051; - - // 新增错误编码 - int DEFAULT_AGENT_NOT_FOUND = 10052; - int AGENT_NOT_FOUND = 10053; - int VOICEPRINT_API_NOT_CONFIGURED = 10054; - int SMS_SEND_FAILED = 10055; - int SMS_CONNECTION_FAILED = 10056; - int AGENT_VOICEPRINT_CREATE_FAILED = 10057; - int AGENT_VOICEPRINT_UPDATE_FAILED = 10058; - int AGENT_VOICEPRINT_DELETE_FAILED = 10059; - int SMS_SEND_TOO_FREQUENTLY = 10060; - int ACTIVATION_CODE_EMPTY = 10061; - int ACTIVATION_CODE_ERROR = 10062; - int DEVICE_ALREADY_ACTIVATED = 10063; - // 默认模型删除错误 - int DEFAULT_MODEL_DELETE_ERROR = 10064; - // 登录相关错误码 - int ADD_DATA_FAILED = 10065; // 新增数据失败 - int UPDATE_DATA_FAILED = 10066; // 修改数据失败 - int SMS_CAPTCHA_ERROR = 10067; // 短信验证码错误 - int MOBILE_REGISTER_DISABLED = 10068; // 未开启手机注册 - int USERNAME_NOT_PHONE = 10069; // 用户名不是手机号码 - int PHONE_ALREADY_REGISTERED = 10070; // 手机号码已注册 - int PHONE_NOT_REGISTERED = 10071; // 手机号码未注册 - int USER_REGISTER_DISABLED = 10072; // 不允许用户注册 - int RETRIEVE_PASSWORD_DISABLED = 10073; // 未开启找回密码功能 - int PHONE_FORMAT_ERROR = 10074; // 手机号码格式不正确 - int SMS_CODE_ERROR = 10075; // 手机验证码错误 - - // 字典类型相关错误码 - int DICT_TYPE_NOT_EXIST = 10076; // 字典类型不存在 - int DICT_TYPE_DUPLICATE = 10077; // 字典类型编码重复 - - // 资源处理相关错误码 - int RESOURCE_READ_ERROR = 10078; // 读取资源失败 - - // 智能体相关错误码 - int LLM_INTENT_PARAMS_MISMATCH = 10079; // LLM大模型和Intent意图识别,选择参数不匹配 - - // 声纹相关错误码 - int VOICEPRINT_ALREADY_REGISTERED = 10080; // 此声音声纹已经注册 - int VOICEPRINT_DELETE_ERROR = 10081; // 删除声纹出现错误 - int VOICEPRINT_UPDATE_NOT_ALLOWED = 10082; // 声纹修改不允许,声音已注册 - int VOICEPRINT_UPDATE_ADMIN_ERROR = 10083; // 修改声纹错误,请联系管理员 - int VOICEPRINT_API_URI_ERROR = 10084; // 声纹接口地址错误 - int VOICEPRINT_AUDIO_NOT_BELONG_AGENT = 10085; // 音频数据不属于智能体 - int VOICEPRINT_AUDIO_EMPTY = 10086; // 音频数据为空 - int VOICEPRINT_REGISTER_REQUEST_ERROR = 10087; // 声纹保存请求失败 - int VOICEPRINT_REGISTER_PROCESS_ERROR = 10088; // 声纹保存处理失败 - int VOICEPRINT_UNREGISTER_REQUEST_ERROR = 10089; // 声纹注销请求失败 - int VOICEPRINT_UNREGISTER_PROCESS_ERROR = 10090; // 声纹注销处理失败 - int VOICEPRINT_IDENTIFY_REQUEST_ERROR = 10091; // 声纹识别请求失败 - - // 设备相关错误码 - int MAC_ADDRESS_ALREADY_EXISTS = 10161; // Mac地址已存在 - // 模型相关错误码 - int MODEL_PROVIDER_NOT_EXIST = 10162; // 供应器不存在 - int LLM_NOT_EXIST = 10092; // 设置的LLM不存在 - int MODEL_REFERENCED_BY_AGENT = 10093; // 该模型配置已被智能体引用,无法删除 - int LLM_REFERENCED_BY_INTENT = 10094; // 该LLM模型已被意图识别配置引用,无法删除 - - // 服务端管理相关错误码 - int INVALID_SERVER_ACTION = 10095; // 无效服务端操作 - int SERVER_WEBSOCKET_NOT_CONFIGURED = 10096; // 未配置服务端WebSocket地址 - int TARGET_WEBSOCKET_NOT_EXIST = 10097; // 目标WebSocket地址不存在 - - // 参数验证相关错误码 - int WEBSOCKET_URLS_EMPTY = 10098; // WebSocket地址列表不能为空 - int WEBSOCKET_URL_LOCALHOST = 10099; // WebSocket地址不能使用localhost或127.0.0.1 - int WEBSOCKET_URL_FORMAT_ERROR = 10100; // WebSocket地址格式不正确 - int WEBSOCKET_CONNECTION_FAILED = 10101; // WebSocket连接测试失败 - int OTA_URL_EMPTY = 10102; // OTA地址不能为空 - int OTA_URL_LOCALHOST = 10103; // OTA地址不能使用localhost或127.0.0.1 - int OTA_URL_PROTOCOL_ERROR = 10104; // OTA地址必须以http或https开头 - int OTA_URL_FORMAT_ERROR = 10105; // OTA地址必须以/ota/结尾 - int OTA_INTERFACE_ACCESS_FAILED = 10106; // OTA接口访问失败 - int OTA_INTERFACE_FORMAT_ERROR = 10107; // OTA接口返回内容格式不正确 - int OTA_INTERFACE_VALIDATION_FAILED = 10108; // OTA接口验证失败 - int MCP_URL_EMPTY = 10109; // MCP地址不能为空 - int MCP_URL_LOCALHOST = 10110; // MCP地址不能使用localhost或127.0.0.1 - int MCP_URL_INVALID = 10111; // 不是正确的MCP地址 - int MCP_INTERFACE_ACCESS_FAILED = 10112; // MCP接口访问失败 - int MCP_INTERFACE_FORMAT_ERROR = 10113; // MCP接口返回内容格式不正确 - int MCP_INTERFACE_VALIDATION_FAILED = 10114; // MCP接口验证失败 - int VOICEPRINT_URL_EMPTY = 10115; // 声纹接口地址不能为空 - int VOICEPRINT_URL_LOCALHOST = 10116; // 声纹接口地址不能使用localhost或127.0.0.1 - int VOICEPRINT_URL_INVALID = 10117; // 不是正确的声纹接口地址 - int VOICEPRINT_URL_PROTOCOL_ERROR = 10118; // 声纹接口地址必须以http或https开头 - int VOICEPRINT_INTERFACE_ACCESS_FAILED = 10119; // 声纹接口访问失败 - int VOICEPRINT_INTERFACE_FORMAT_ERROR = 10120; // 声纹接口返回内容格式不正确 - int VOICEPRINT_INTERFACE_VALIDATION_FAILED = 10121; // 声纹接口验证失败 - int MQTT_SECRET_EMPTY = 10122; // mqtt密钥不能为空 - int MQTT_SECRET_LENGTH_INSECURE = 10123; // mqtt密钥长度不安全 - int MQTT_SECRET_CHARACTER_INSECURE = 10124; // mqtt密钥必须同时包含大小写字母 - int MQTT_SECRET_WEAK_PASSWORD = 10125; // mqtt密钥包含弱密码 - int DICT_LABEL_DUPLICATE = 10128; // 字典标签重复 - int SM2_KEY_NOT_CONFIGURED = 10129; // SM2密钥未配置 - int SM2_DECRYPT_ERROR = 10130; // SM2解密失败 - int MODEL_TYPE_PROVIDE_CODE_NOT_NULL = 10131; // modelType和provideCode不能为空 - - // 聊天记录相关错误码 - int CHAT_HISTORY_NO_PERMISSION = 10132; // 没有权限查看该智能体的聊天记录 - int CHAT_HISTORY_SESSION_ID_NOT_NULL = 10133; // 会话ID不能为空 - int CHAT_HISTORY_AGENT_ID_NOT_NULL = 10134; // 智能体ID不能为空 - int CHAT_HISTORY_DOWNLOAD_FAILED = 10135; // 聊天记录下载失败 - int DOWNLOAD_LINK_EXPIRED = 10136; // 下载链接已过期或无效 - int DOWNLOAD_LINK_INVALID = 10137; // 下载链接无效 - int CHAT_ROLE_USER = 10138; // 用户角色 - int CHAT_ROLE_AGENT = 10139; // 智能体角色 - - // 声音克隆相关错误码 - int VOICE_CLONE_AUDIO_EMPTY = 10140; // 音频文件不能为空 - int VOICE_CLONE_NOT_AUDIO_FILE = 10141; // 只支持音频文件 - int VOICE_CLONE_AUDIO_TOO_LARGE = 10142; // 音频文件大小不能超过10MB - int VOICE_CLONE_UPLOAD_FAILED = 10143; // 上传失败 - int VOICE_CLONE_RECORD_NOT_EXIST = 10144; // 声音克隆记录不存在 - int VOICE_RESOURCE_INFO_EMPTY = 10145; // 音色资源信息不能为空 - int VOICE_RESOURCE_PLATFORM_NAME_EMPTY = 10146; // 平台名称不能为空 - int VOICE_RESOURCE_ID_EMPTY = 10147; // 音色ID不能为空 - int VOICE_RESOURCE_ACCOUNT_EMPTY = 10148; // 归属账号不能为空 - int VOICE_RESOURCE_DELETE_ID_EMPTY = 10149; // 删除的音色资源ID不能为空 - int VOICE_RESOURCE_NO_PERMISSION = 10150; // 您没有权限操作该记录 - int VOICE_CLONE_AUDIO_NOT_UPLOADED = 10151; // 请先上传音频文件 - int VOICE_CLONE_MODEL_CONFIG_NOT_FOUND = 10152; // 模型配置未找到 - int VOICE_CLONE_MODEL_TYPE_NOT_FOUND = 10153; // 模型类型未找到 - int VOICE_CLONE_TRAINING_FAILED = 10154; // 训练失败 - int VOICE_CLONE_HUOSHAN_CONFIG_MISSING = 10155; // 火山引擎缺少配置 - int VOICE_CLONE_RESPONSE_FORMAT_ERROR = 10156; // 响应格式错误 - int VOICE_CLONE_REQUEST_FAILED = 10157; // 请求失败 - int VOICE_CLONE_PREFIX = 10158; // 复刻音色前缀 - int VOICE_ID_ALREADY_EXISTS = 10159; // 音色ID已存在 - int VOICE_CLONE_HUOSHAN_VOICE_ID_ERROR = 10160; // 火山引擎音色ID格式错误 -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/exception/RenException.java b/main/manager-api/src/main/java/xiaozhi/common/exception/RenException.java deleted file mode 100644 index 9b928d5c2..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/exception/RenException.java +++ /dev/null @@ -1,65 +0,0 @@ -package xiaozhi.common.exception; - -import xiaozhi.common.utils.MessageUtils; - -/** - * 自定义异常 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class RenException extends RuntimeException { - - private int code; - private String msg; - - public RenException(int code) { - this.code = code; - this.msg = MessageUtils.getMessage(code); - } - - public RenException(int code, String... params) { - this.code = code; - this.msg = MessageUtils.getMessage(code, params); - } - - public RenException(int code, Throwable e) { - super(e); - this.code = code; - this.msg = MessageUtils.getMessage(code); - } - - public RenException(int code, Throwable e, String... params) { - super(e); - this.code = code; - this.msg = MessageUtils.getMessage(code, params); - } - - public RenException(String msg) { - super(msg); - this.code = ErrorCode.INTERNAL_SERVER_ERROR; - this.msg = msg; - } - - public RenException(String msg, Throwable e) { - super(msg, e); - this.code = ErrorCode.INTERNAL_SERVER_ERROR; - this.msg = msg; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/exception/RenExceptionHandler.java b/main/manager-api/src/main/java/xiaozhi/common/exception/RenExceptionHandler.java deleted file mode 100644 index e016bc095..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/exception/RenExceptionHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -package xiaozhi.common.exception; - -import java.util.List; -import java.util.Objects; - -import org.apache.shiro.authz.UnauthorizedException; -import org.springframework.dao.DuplicateKeyException; -import org.springframework.validation.ObjectError; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.servlet.resource.NoResourceFoundException; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.utils.MessageUtils; -import xiaozhi.common.utils.Result; - -/** - * 异常处理器 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Slf4j -@AllArgsConstructor -@RestControllerAdvice -public class RenExceptionHandler { - - /** - * 处理自定义异常 - */ - @ExceptionHandler(RenException.class) - public Result handleRenException(RenException ex) { - Result result = new Result<>(); - result.error(ex.getCode(), ex.getMsg()); - - return result; - } - - @ExceptionHandler(DuplicateKeyException.class) - public Result handleDuplicateKeyException(DuplicateKeyException ex) { - Result result = new Result<>(); - result.error(ErrorCode.DB_RECORD_EXISTS); - - return result; - } - - @ExceptionHandler(UnauthorizedException.class) - public Result handleUnauthorizedException(UnauthorizedException ex) { - Result result = new Result<>(); - result.error(ErrorCode.FORBIDDEN); - - return result; - } - - @ExceptionHandler(Exception.class) - public Result handleException(Exception ex) { - log.error(ex.getMessage(), ex); - - return new Result().error(); - } - - @ExceptionHandler(NoResourceFoundException.class) - public Result handleNoResourceFoundException(NoResourceFoundException ex) { - log.warn("Resource not found: {}", ex.getMessage()); - return new Result().error(404, MessageUtils.getMessage(ErrorCode.RESOURCE_NOT_FOUND)); - } - - @ExceptionHandler(MethodArgumentNotValidException.class) - public Result handleMethodArgumentNotValidException(MethodArgumentNotValidException ex) { - List allErrors = ex.getBindingResult().getAllErrors(); - String errorMsg = allErrors.stream() - .filter(Objects::nonNull) - .map(err -> { - String msg = err.getDefaultMessage(); - return (msg != null && !msg.trim().isEmpty()) ? msg : null; - }) - .filter(Objects::nonNull) - .findFirst() - .orElse(MessageUtils.getMessage(ErrorCode.PARAM_VALUE_NULL)); - - return new Result().error(ErrorCode.PARAM_VALUE_NULL, errorMsg); - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/handler/FieldMetaObjectHandler.java b/main/manager-api/src/main/java/xiaozhi/common/handler/FieldMetaObjectHandler.java deleted file mode 100644 index a6b33b620..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/handler/FieldMetaObjectHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -package xiaozhi.common.handler; - -import java.util.Date; - -import org.apache.ibatis.reflection.MetaObject; -import org.springframework.stereotype.Component; - -import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; - -import xiaozhi.common.constant.Constant; -import xiaozhi.common.user.UserDetail; -import xiaozhi.modules.security.user.SecurityUser; - -/** - * 公共字段,自动填充值 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Component -public class FieldMetaObjectHandler implements MetaObjectHandler { - private final static String CREATE_DATE = "createDate"; - private final static String CREATOR = "creator"; - private final static String UPDATE_DATE = "updateDate"; - private final static String UPDATER = "updater"; - - private final static String DATA_OPERATION = "dataOperation"; - - @Override - public void insertFill(MetaObject metaObject) { - UserDetail user = SecurityUser.getUser(); - Date date = new Date(); - - // 创建者 - strictInsertFill(metaObject, CREATOR, Long.class, user.getId()); - // 创建时间 - strictInsertFill(metaObject, CREATE_DATE, Date.class, date); - - // 更新者 - strictInsertFill(metaObject, UPDATER, Long.class, user.getId()); - // 更新时间 - strictInsertFill(metaObject, UPDATE_DATE, Date.class, date); - - // 数据标识 - strictInsertFill(metaObject, DATA_OPERATION, String.class, Constant.DataOperation.INSERT.getValue()); - } - - @Override - public void updateFill(MetaObject metaObject) { - // 更新者 - strictUpdateFill(metaObject, UPDATER, Long.class, SecurityUser.getUserId()); - // 更新时间 - strictUpdateFill(metaObject, UPDATE_DATE, Date.class, new Date()); - - // 数据标识 - strictInsertFill(metaObject, DATA_OPERATION, String.class, Constant.DataOperation.UPDATE.getValue()); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/interceptor/DataFilterInterceptor.java b/main/manager-api/src/main/java/xiaozhi/common/interceptor/DataFilterInterceptor.java deleted file mode 100644 index 0457686b1..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/interceptor/DataFilterInterceptor.java +++ /dev/null @@ -1,85 +0,0 @@ -package xiaozhi.common.interceptor; - -import java.util.Map; - -import org.apache.ibatis.executor.Executor; -import org.apache.ibatis.mapping.BoundSql; -import org.apache.ibatis.mapping.MappedStatement; -import org.apache.ibatis.session.ResultHandler; -import org.apache.ibatis.session.RowBounds; - -import com.baomidou.mybatisplus.core.toolkit.PluginUtils; -import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; - -import cn.hutool.core.util.StrUtil; -import net.sf.jsqlparser.JSQLParserException; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.StringValue; -import net.sf.jsqlparser.expression.operators.conditional.AndExpression; -import net.sf.jsqlparser.parser.CCJSqlParserUtil; -import net.sf.jsqlparser.statement.select.PlainSelect; -import net.sf.jsqlparser.statement.select.Select; - -/** - * 数据过滤 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class DataFilterInterceptor implements InnerInterceptor { - - @SuppressWarnings("rawtypes") - @Override - public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, - ResultHandler resultHandler, BoundSql boundSql) { - DataScope scope = getDataScope(parameter); - // 不进行数据过滤 - if (scope == null || StrUtil.isBlank(scope.getSqlFilter())) { - return; - } - - // 拼接新SQL - String buildSql = getSelect(boundSql.getSql(), scope); - - // 重写SQL - PluginUtils.mpBoundSql(boundSql).sql(buildSql); - } - - private DataScope getDataScope(Object parameter) { - if (parameter == null) { - return null; - } - - // 判断参数里是否有DataScope对象 - if (parameter instanceof Map) { - Map parameterMap = (Map) parameter; - for (Map.Entry entry : parameterMap.entrySet()) { - if (entry.getValue() != null && entry.getValue() instanceof DataScope) { - return (DataScope) entry.getValue(); - } - } - } else if (parameter instanceof DataScope) { - return (DataScope) parameter; - } - - return null; - } - - private String getSelect(String buildSql, DataScope scope) { - try { - Select select = (Select) CCJSqlParserUtil.parse(buildSql); - PlainSelect plainSelect = (PlainSelect) select.getSelectBody(); - - Expression expression = plainSelect.getWhere(); - if (expression == null) { - plainSelect.setWhere(new StringValue(scope.getSqlFilter())); - } else { - AndExpression andExpression = new AndExpression(expression, new StringValue(scope.getSqlFilter())); - plainSelect.setWhere(andExpression); - } - - return select.toString().replaceAll("'", ""); - } catch (JSQLParserException e) { - return buildSql; - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/interceptor/DataScope.java b/main/manager-api/src/main/java/xiaozhi/common/interceptor/DataScope.java deleted file mode 100644 index b59de67b0..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/interceptor/DataScope.java +++ /dev/null @@ -1,27 +0,0 @@ -package xiaozhi.common.interceptor; - -/** - * 数据范围 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class DataScope { - private String sqlFilter; - - public DataScope(String sqlFilter) { - this.sqlFilter = sqlFilter; - } - - public String getSqlFilter() { - return sqlFilter; - } - - public void setSqlFilter(String sqlFilter) { - this.sqlFilter = sqlFilter; - } - - @Override - public String toString() { - return this.sqlFilter; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/page/PageData.java b/main/manager-api/src/main/java/xiaozhi/common/page/PageData.java deleted file mode 100644 index 83e93c119..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/page/PageData.java +++ /dev/null @@ -1,33 +0,0 @@ -package xiaozhi.common.page; - -import java.io.Serializable; -import java.util.List; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 分页工具类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Data -@Schema(description = "分页数据") -public class PageData implements Serializable { - @Schema(description = "总记录数") - private int total; - - @Schema(description = "列表数据") - private List list; - - /** - * 分页 - * - * @param list 列表数据 - * @param total 总记录数 - */ - public PageData(List list, long total) { - this.list = list; - this.total = (int) total; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/page/TokenDTO.java b/main/manager-api/src/main/java/xiaozhi/common/page/TokenDTO.java deleted file mode 100644 index cce1a6df8..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/page/TokenDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package xiaozhi.common.page; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 令牌信息 - * - * @author Jack - */ -@Data -@Schema(description = "令牌信息") -public class TokenDTO implements Serializable { - - @Schema(description = "密码") - private String token; - - @Schema(description = "过期时间") - private int expire; - - @Schema(description = "客户端指纹") - private String clientHash; -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/redis/RedisConfig.java b/main/manager-api/src/main/java/xiaozhi/common/redis/RedisConfig.java deleted file mode 100644 index 703a84925..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/redis/RedisConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package xiaozhi.common.redis; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.RedisSerializer; -import org.springframework.data.redis.serializer.StringRedisSerializer; - -import jakarta.annotation.Resource; - -/** - * Redis配置 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Configuration -public class RedisConfig { - @Resource - private RedisConnectionFactory factory; - - @Bean - public RedisTemplate redisTemplate() { - RedisTemplate redisTemplate = new RedisTemplate<>(); - redisTemplate.setKeySerializer(new StringRedisSerializer()); - redisTemplate.setValueSerializer(RedisSerializer.json()); - redisTemplate.setHashKeySerializer(new StringRedisSerializer()); - redisTemplate.setHashValueSerializer(RedisSerializer.json()); - redisTemplate.setConnectionFactory(factory); - - return redisTemplate; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/redis/RedisKeys.java b/main/manager-api/src/main/java/xiaozhi/common/redis/RedisKeys.java deleted file mode 100644 index d25c72b6f..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/redis/RedisKeys.java +++ /dev/null @@ -1,155 +0,0 @@ -package xiaozhi.common.redis; - -/** - * Redis Key 常量类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class RedisKeys { - /** - * 系统参数Key - */ - public static String getSysParamsKey() { - return "sys:params"; - } - - /** - * 验证码Key - */ - public static String getCaptchaKey(String uuid) { - return "sys:captcha:" + uuid; - } - - /** - * 未注册设备验证码Key - */ - public static String getDeviceCaptchaKey(String captcha) { - return "sys:device:captcha:" + captcha; - } - - /** - * 用户id的Key - */ - public static String getUserIdKey(Long userid) { - return "sys:username:id:" + userid; - } - - /** - * 模型名称的Key - */ - public static String getModelNameById(String id) { - return "model:name:" + id; - } - - /** - * 模型配置的Key - */ - public static String getModelConfigById(String id) { - return "model:data:" + id; - } - - /** - * 获取音色名称缓存key - */ - public static String getTimbreNameById(String id) { - return "timbre:name:" + id; - } - - /** - * 获取设备数量缓存key - */ - public static String getAgentDeviceCountById(String id) { - return "agent:device:count:" + id; - } - - /** - * 获取智能体最后连接时间缓存key - */ - public static String getAgentDeviceLastConnectedAtById(String id) { - return "agent:device:lastConnected:" + id; - } - - /** - * 获取系统配置缓存key - */ - public static String getServerConfigKey() { - return "server:config"; - } - - /** - * 获取音色详情缓存key - */ - public static String getTimbreDetailsKey(String id) { - return "timbre:details:" + id; - } - - /** - * 获取版本号Key - */ - public static String getVersionKey() { - return "sys:version"; - } - - /** - * OTA固件ID的Key - */ - public static String getOtaIdKey(String uuid) { - return "ota:id:" + uuid; - } - - /** - * OTA固件下载次数的Key - */ - public static String getOtaDownloadCountKey(String uuid) { - return "ota:download:count:" + uuid; - } - - /** - * 获取字典数据的缓存key - */ - public static String getDictDataByTypeKey(String dictType) { - return "sys:dict:data:" + dictType; - } - - /** - * 获取智能体音频ID的缓存key - */ - public static String getAgentAudioIdKey(String uuid) { - return "agent:audio:id:" + uuid; - } - - /** - * 获取短信验证码的缓存key - */ - public static String getSMSValidateCodeKey(String phone) { - return "sms:Validate:Code:" + phone; - } - - /** - * 获取短信验证码最后发送时间的缓存key - */ - public static String getSMSLastSendTimeKey(String phone) { - return "sms:Validate:Code:" + phone + ":last_send_time"; - } - - /** - * 获取短信验证码今日发送次数的缓存key - */ - public static String getSMSTodayCountKey(String phone) { - return "sms:Validate:Code:" + phone + ":today_count"; - } - - /** - * 聊天记录UUID映射的Key - */ - public static String getChatHistoryKey(String uuid) { - return "agent:chat:history:" + uuid; - } - - /** - * 获取音色克隆音频ID的缓存key - */ - public static String getVoiceCloneAudioIdKey(String uuid) { - return "voiceClone:audio:id:" + uuid; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/redis/RedisUtils.java b/main/manager-api/src/main/java/xiaozhi/common/redis/RedisUtils.java deleted file mode 100644 index c81677e99..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/redis/RedisUtils.java +++ /dev/null @@ -1,195 +0,0 @@ -package xiaozhi.common.redis; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.HashOperations; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.script.DefaultRedisScript; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import xiaozhi.common.utils.ResourcesUtils; - -/** - * Redis工具类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Component -public class RedisUtils { - @Resource - private RedisTemplate redisTemplate; - - @Autowired - private ResourcesUtils resourceUtils; - - /** - * 默认过期时长为24小时,单位:秒 - */ - public final static long DEFAULT_EXPIRE = 60 * 60 * 24L; - /** - * 过期时长为1小时,单位:秒 - */ - public final static long HOUR_ONE_EXPIRE = (long) 60 * 60; - /** - * 过期时长为6小时,单位:秒 - */ - public final static long HOUR_SIX_EXPIRE = 60 * 60 * 6L; - /** - * 不设置过期时长 - */ - public final static long NOT_EXPIRE = -1L; - - public Long increment(String key, long expire) { - Long increment = redisTemplate.opsForValue().increment(key, 1L); - if (expire != NOT_EXPIRE) { - expire(key, expire); - } - return increment; - } - - public Long increment(String key) { - return redisTemplate.opsForValue().increment(key, 1L); - } - - public Long decrement(String key) { - return redisTemplate.opsForValue().decrement(key, 1L); - } - - - - public void set(String key, Object value, long expire) { - redisTemplate.opsForValue().set(key, value); - if (expire != NOT_EXPIRE) { - expire(key, expire); - } - } - - public void set(String key, Object value) { - set(key, value, DEFAULT_EXPIRE); - } - - public Object get(String key, long expire) { - Object value = redisTemplate.opsForValue().get(key); - if (expire != NOT_EXPIRE) { - expire(key, expire); - } - return value; - } - - public Object get(String key) { - return get(key, NOT_EXPIRE); - } - - public void delete(String key) { - redisTemplate.delete(key); - } - - public void delete(Collection keys) { - redisTemplate.delete(keys); - } - - public Object hGet(String key, String field) { - return redisTemplate.opsForHash().get(key, field); - } - - public Map hGetAll(String key) { - HashOperations hashOperations = redisTemplate.opsForHash(); - return hashOperations.entries(key); - } - - public void hMSet(String key, Map map) { - hMSet(key, map, DEFAULT_EXPIRE); - } - - public void hMSet(String key, Map map, long expire) { - redisTemplate.opsForHash().putAll(key, map); - - if (expire != NOT_EXPIRE) { - expire(key, expire); - } - } - - public void hSet(String key, String field, Object value) { - hSet(key, field, value, DEFAULT_EXPIRE); - } - - public void hSet(String key, String field, Object value, long expire) { - redisTemplate.opsForHash().put(key, field, value); - - if (expire != NOT_EXPIRE) { - expire(key, expire); - } - } - - public void expire(String key, long expire) { - redisTemplate.expire(key, expire, TimeUnit.SECONDS); - } - - public void hDel(String key, Object... fields) { - redisTemplate.opsForHash().delete(key, fields); - } - - public void leftPush(String key, Object value) { - leftPush(key, value, DEFAULT_EXPIRE); - } - - public void leftPush(String key, Object value, long expire) { - redisTemplate.opsForList().leftPush(key, value); - - if (expire != NOT_EXPIRE) { - expire(key, expire); - } - } - - public Object rightPop(String key) { - return redisTemplate.opsForList().rightPop(key); - } - - - /** - * 清空所有 Redis 数据库中的所有键 - */ - public void emptyAll() { - // Lua 脚本 FLUSHALL是redis清空所有库的命令 - String luaScript =resourceUtils.loadString("lua/emptyAll.lua"); - - // 创建 DefaultRedisScript 对象 - DefaultRedisScript redisScript = new DefaultRedisScript<>(); - redisScript.setScriptText(luaScript); // 设置 Lua 脚本内容 - redisScript.setResultType(Void.class); // 设置返回值类型 - - // 执行 Lua 脚本 - List keys = Collections.emptyList(); // 如果脚本不依赖 key,可以传入空列表 - redisTemplate.execute(redisScript, keys); - - } - - /** - * 获取在redis指定key的值,如果值为空,着设置key的默认值 - * @param key redis的key - * @param defaultValue 默认值 - * @param expiresInSecond 过期时间 - * @return 返回key的值 - */ - public String getKeyOrCreate(String key, String defaultValue,Long expiresInSecond) { - // Lua 脚本 - String luaScript = resourceUtils.loadString("lua/getKeyOrCreate.lua"); - - DefaultRedisScript redisScript = new DefaultRedisScript<>(); - redisScript.setScriptText(luaScript); - redisScript.setResultType(String.class); - - // 执行 Lua 脚本 - List keys = Collections.singletonList(key); - return redisTemplate.execute(redisScript, keys, defaultValue,expiresInSecond); - } - - - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/service/BaseService.java b/main/manager-api/src/main/java/xiaozhi/common/service/BaseService.java deleted file mode 100644 index 2feaefd11..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/service/BaseService.java +++ /dev/null @@ -1,109 +0,0 @@ -package xiaozhi.common.service; - -import java.io.Serializable; -import java.util.Collection; - -import com.baomidou.mybatisplus.core.conditions.Wrapper; - -/** - * 基础服务接口,所有Service接口都要继承 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public interface BaseService { - Class currentModelClass(); - - /** - *

- * 插入一条记录(选择字段,策略插入) - *

- * - * @param entity 实体对象 - */ - boolean insert(T entity); - - /** - *

- * 插入(批量),该方法不支持 Oracle、SQL Server - *

- * - * @param entityList 实体对象集合 - */ - boolean insertBatch(Collection entityList); - - /** - *

- * 插入(批量),该方法不支持 Oracle、SQL Server - *

- * - * @param entityList 实体对象集合 - * @param batchSize 插入批次数量 - */ - boolean insertBatch(Collection entityList, int batchSize); - - /** - *

- * 根据 ID 选择修改 - *

- * - * @param entity 实体对象 - */ - boolean updateById(T entity); - - /** - *

- * 根据 whereEntity 条件,更新记录 - *

- * - * @param entity 实体对象 - * @param updateWrapper 实体对象封装操作类 - * {@link com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper} - */ - boolean update(T entity, Wrapper updateWrapper); - - /** - *

- * 根据ID 批量更新 - *

- * - * @param entityList 实体对象集合 - */ - boolean updateBatchById(Collection entityList); - - /** - *

- * 根据ID 批量更新 - *

- * - * @param entityList 实体对象集合 - * @param batchSize 更新批次数量 - */ - boolean updateBatchById(Collection entityList, int batchSize); - - /** - *

- * 根据 ID 查询 - *

- * - * @param id 主键ID - */ - T selectById(Serializable id); - - /** - *

- * 根据 ID 删除 - *

- * - * @param id 主键ID - */ - boolean deleteById(Serializable id); - - /** - *

- * 删除(根据ID 批量删除) - *

- * - * @param idList 主键ID列表 - */ - boolean deleteBatchIds(Collection idList); -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/service/CrudService.java b/main/manager-api/src/main/java/xiaozhi/common/service/CrudService.java deleted file mode 100644 index 51f16bcb7..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/service/CrudService.java +++ /dev/null @@ -1,28 +0,0 @@ -package xiaozhi.common.service; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import xiaozhi.common.page.PageData; - -/** - * CRUD基础服务接口 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public interface CrudService extends BaseService { - - PageData page(Map params); - - List list(Map params); - - D get(Serializable id); - - void save(D dto); - - void update(D dto); - - void delete(Serializable[] ids); - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/service/impl/BaseServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/common/service/impl/BaseServiceImpl.java deleted file mode 100644 index 9d06c09a7..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/service/impl/BaseServiceImpl.java +++ /dev/null @@ -1,230 +0,0 @@ -package xiaozhi.common.service.impl; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.BiConsumer; - -import org.apache.ibatis.binding.MapperMethod; -import org.apache.ibatis.logging.Log; -import org.apache.ibatis.logging.LogFactory; -import org.apache.ibatis.session.SqlSession; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.enums.SqlMethod; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.metadata.OrderItem; -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; -import com.baomidou.mybatisplus.core.toolkit.Constants; -import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; - -import xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.common.utils.ConvertUtils; - -/** - * 基础服务类,所有Service都要继承 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public abstract class BaseServiceImpl, T> implements BaseService { - @Autowired - protected M baseDao; - protected Log log = LogFactory.getLog(getClass()); - - /** - * 获取分页对象 - * - * @param params 分页查询参数 - * @param defaultOrderField 默认排序字段 - * @param isAsc 排序方式 - * @see xiaozhi.common.constant.Constant - * params.put(Constant.PAGE, "1"); - * params.put(Constant.LIMIT, "10"); - * params.put(Constant.ORDER_FIELD, "field"); // 单个字段 - * params.put(Constant.ORDER_FIELD, List.of("field1", "field2")); // 多个字段 - * params.put(Constant.ORDER, "asc"); - */ - protected IPage getPage(Map params, String defaultOrderField, boolean isAsc) { - // 分页参数 - long curPage = 1; - long limit = 10; - - if (params.get(Constant.PAGE) != null) { - curPage = Long.parseLong((String) params.get(Constant.PAGE)); - } - if (params.get(Constant.LIMIT) != null) { - limit = Long.parseLong((String) params.get(Constant.LIMIT)); - } - - // 分页对象 - Page page = new Page<>(curPage, limit); - - // 分页参数 - params.put(Constant.PAGE, page); - - // 排序字段 - Object orderField = params.get(Constant.ORDER_FIELD); - String order = (String) params.get(Constant.ORDER); - - List orderFields = new ArrayList<>(); - - // 处理排序字段 - if (orderField instanceof String) { - orderFields.add((String) orderField); - } else if (orderField instanceof List) { - orderFields.addAll((List) orderField); - } - - // 有排序字段则排序 - if (CollectionUtils.isNotEmpty(orderFields)) { - if (StringUtils.isNotBlank(order) && Constant.ASC.equalsIgnoreCase(order)) { - return page.addOrder(OrderItem.ascs(orderFields.toArray(new String[0]))); - } else { - return page.addOrder(OrderItem.descs(orderFields.toArray(new String[0]))); - } - } - - // 没有排序字段,使用默认排序 - if (StringUtils.isNotBlank(defaultOrderField)) { - if (isAsc) { - page.addOrder(OrderItem.asc(defaultOrderField)); - } else { - page.addOrder(OrderItem.desc(defaultOrderField)); - } - } - - return page; - } - - protected PageData getPageData(List list, long total, Class target) { - List targetList = ConvertUtils.sourceToTarget(list, target); - - return new PageData<>(targetList, total); - } - - protected PageData getPageData(IPage page, Class target) { - return getPageData(page.getRecords(), page.getTotal(), target); - } - - protected void paramsToLike(Map params, String... likes) { - for (String like : likes) { - String val = (String) params.get(like); - if (StringUtils.isNotBlank(val)) { - params.put(like, "%" + val + "%"); - } else { - params.put(like, null); - } - } - } - - /** - *

- * 判断数据库操作是否成功 - *

- *

- * 注意!! 该方法为 Integer 判断,不可传入 int 基本类型 - *

- * - * @param result 数据库操作返回影响条数 - * @return boolean - */ - protected static boolean retBool(Integer result) { - return SqlHelper.retBool(result); - } - - protected Class currentMapperClass() { - return (Class) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseServiceImpl.class, 0); - } - - @Override - public Class currentModelClass() { - return (Class) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseServiceImpl.class, 1); - } - - protected String getSqlStatement(SqlMethod sqlMethod) { - return SqlHelper.getSqlStatement(this.currentMapperClass(), sqlMethod); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean insert(T entity) { - return BaseServiceImpl.retBool(baseDao.insert(entity)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean insertBatch(Collection entityList) { - return insertBatch(entityList, 100); - } - - /** - * 批量插入 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean insertBatch(Collection entityList, int batchSize) { - String sqlStatement = getSqlStatement(SqlMethod.INSERT_ONE); - return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity)); - } - - /** - * 执行批量操作 - */ - @SuppressWarnings("deprecation") - protected boolean executeBatch(Collection list, int batchSize, BiConsumer consumer) { - return SqlHelper.executeBatch(this.currentModelClass(), this.log, list, batchSize, consumer); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateById(T entity) { - return BaseServiceImpl.retBool(baseDao.updateById(entity)); - } - - @Override - public boolean update(T entity, Wrapper updateWrapper) { - return BaseServiceImpl.retBool(baseDao.update(entity, updateWrapper)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateBatchById(Collection entityList) { - return updateBatchById(entityList, 30); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateBatchById(Collection entityList, int batchSize) { - String sqlStatement = getSqlStatement(SqlMethod.UPDATE_BY_ID); - return executeBatch(entityList, batchSize, (sqlSession, entity) -> { - MapperMethod.ParamMap param = new MapperMethod.ParamMap<>(); - param.put(Constants.ENTITY, entity); - sqlSession.update(sqlStatement, param); - }); - } - - @Override - public T selectById(Serializable id) { - return baseDao.selectById(id); - } - - @Override - public boolean deleteById(Serializable id) { - return SqlHelper.retBool(baseDao.deleteById(id)); - } - - @Override - public boolean deleteBatchIds(Collection idList) { - return SqlHelper.retBool(baseDao.deleteBatchIds(idList)); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/service/impl/CrudServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/common/service/impl/CrudServiceImpl.java deleted file mode 100644 index 9a1bf39ed..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/service/impl/CrudServiceImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -package xiaozhi.common.service.impl; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.springframework.beans.BeanUtils; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.CrudService; -import xiaozhi.common.utils.ConvertUtils; - -/** - * CRUD基础服务类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public abstract class CrudServiceImpl, T, D> extends BaseServiceImpl - implements CrudService { - - protected Class currentDtoClass() { - return (Class) ReflectionKit.getSuperClassGenericType(getClass(), CrudServiceImpl.class, 2); - } - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, null, false), - getWrapper(params)); - - return getPageData(page, currentDtoClass()); - } - - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - - return ConvertUtils.sourceToTarget(entityList, currentDtoClass()); - } - - public abstract QueryWrapper getWrapper(Map params); - - @Override - public D get(Serializable id) { - T entity = baseDao.selectById(id); - - return ConvertUtils.sourceToTarget(entity, currentDtoClass()); - } - - @Override - public void save(D dto) { - T entity = ConvertUtils.sourceToTarget(dto, currentModelClass()); - insert(entity); - - // copy主键值到dto - BeanUtils.copyProperties(entity, dto); - } - - @Override - public void update(D dto) { - T entity = ConvertUtils.sourceToTarget(dto, currentModelClass()); - updateById(entity); - } - - @Override - public void delete(Serializable[] ids) { - baseDao.deleteBatchIds(Arrays.asList(ids)); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/user/UserDetail.java b/main/manager-api/src/main/java/xiaozhi/common/user/UserDetail.java deleted file mode 100644 index 0aa9210ba..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/user/UserDetail.java +++ /dev/null @@ -1,19 +0,0 @@ -package xiaozhi.common.user; - -import java.io.Serializable; - -import lombok.Data; - -/** - * 登录用户信息 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Data -public class UserDetail implements Serializable { - private Long id; - private String username; - private Integer superAdmin; - private String token; - private Integer status; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/AESUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/AESUtils.java deleted file mode 100644 index 660e3cba4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/AESUtils.java +++ /dev/null @@ -1,78 +0,0 @@ -package xiaozhi.common.utils; - -import java.nio.charset.StandardCharsets; -import java.util.Base64; - -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; - -public class AESUtils { - - private static final String ALGORITHM = "AES"; - private static final String TRANSFORMATION = "AES/ECB/PKCS5Padding"; - - /** - * AES加密 - * - * @param key 密钥(16位、24位或32位) - * @param plainText 待加密字符串 - * @return 加密后的Base64字符串 - */ - public static String encrypt(String key, String plainText) { - try { - // 确保密钥长度为16、24或32位 - byte[] keyBytes = padKey(key.getBytes(StandardCharsets.UTF_8)); - SecretKeySpec secretKey = new SecretKeySpec(keyBytes, ALGORITHM); - - Cipher cipher = Cipher.getInstance(TRANSFORMATION); - cipher.init(Cipher.ENCRYPT_MODE, secretKey); - - byte[] encryptedBytes = cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8)); - return Base64.getEncoder().encodeToString(encryptedBytes); - } catch (Exception e) { - throw new RuntimeException("AES加密失败", e); - } - } - - /** - * AES解密 - * - * @param key 密钥(16位、24位或32位) - * @param encryptedText 待解密的Base64字符串 - * @return 解密后的字符串 - */ - public static String decrypt(String key, String encryptedText) { - try { - // 确保密钥长度为16、24或32位 - byte[] keyBytes = padKey(key.getBytes(StandardCharsets.UTF_8)); - SecretKeySpec secretKey = new SecretKeySpec(keyBytes, ALGORITHM); - - Cipher cipher = Cipher.getInstance(TRANSFORMATION); - cipher.init(Cipher.DECRYPT_MODE, secretKey); - - byte[] encryptedBytes = Base64.getDecoder().decode(encryptedText); - byte[] decryptedBytes = cipher.doFinal(encryptedBytes); - return new String(decryptedBytes, StandardCharsets.UTF_8); - } catch (Exception e) { - throw new RuntimeException("AES解密失败", e); - } - } - - /** - * 填充密钥到指定长度(16、24或32位) - * - * @param keyBytes 原始密钥字节数组 - * @return 填充后的密钥字节数组 - */ - private static byte[] padKey(byte[] keyBytes) { - int keyLength = keyBytes.length; - if (keyLength == 16 || keyLength == 24 || keyLength == 32) { - return keyBytes; - } - - // 如果密钥长度不足,用0填充;如果超过,截取前32位 - byte[] paddedKey = new byte[32]; - System.arraycopy(keyBytes, 0, paddedKey, 0, Math.min(keyLength, 32)); - return paddedKey; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/ConvertUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/ConvertUtils.java deleted file mode 100644 index 07ade50f3..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/ConvertUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -package xiaozhi.common.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.springframework.beans.BeanUtils; - -import lombok.extern.slf4j.Slf4j; - -/** - * 转换工具类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Slf4j -public class ConvertUtils { - public static T sourceToTarget(Object source, Class target) { - if (source == null) { - return null; - } - T targetObject = null; - try { - targetObject = target.getDeclaredConstructor().newInstance(); - BeanUtils.copyProperties(source, targetObject); - } catch (Exception e) { - log.error("convert error ", e); - } - - return targetObject; - } - - public static List sourceToTarget(Collection sourceList, Class target) { - if (sourceList == null) { - return null; - } - - List targetList = new ArrayList<>(sourceList.size()); - try { - for (Object source : sourceList) { - T targetObject = target.getDeclaredConstructor().newInstance(); - BeanUtils.copyProperties(source, targetObject); - targetList.add(targetObject); - } - } catch (Exception e) { - log.error("convert error ", e); - } - - return targetList; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/DateUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/DateUtils.java deleted file mode 100644 index 800733c11..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/DateUtils.java +++ /dev/null @@ -1,116 +0,0 @@ -package xiaozhi.common.utils; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.temporal.ChronoUnit; -import java.util.Date; - -/** - * 日期处理 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class DateUtils { - /** - * 时间格式(yyyy-MM-dd) - */ - public final static String DATE_PATTERN = "yyyy-MM-dd"; - /** - * 时间格式(yyyy-MM-dd HH:mm:ss) - */ - public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; - public final static String DATE_TIME_MILLIS_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS"; - - - /** - * 日期格式化 日期格式为:yyyy-MM-dd - * - * @param date 日期 - * @return 返回yyyy-MM-dd格式日期 - */ - public static String format(Date date) { - return format(date, DATE_PATTERN); - } - - /** - * 日期格式化 日期格式为:yyyy-MM-dd - * - * @param date 日期 - * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN - * @return 返回yyyy-MM-dd格式日期 - */ - public static String format(Date date, String pattern) { - if (date != null) { - SimpleDateFormat df = new SimpleDateFormat(pattern); - return df.format(date); - } - return null; - } - - /** - * 日期解析 - * - * @param date 日期 - * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN - * @return 返回Date - */ - public static Date parse(String date, String pattern) { - try { - return new SimpleDateFormat(pattern).parse(date); - } catch (ParseException e) { - e.printStackTrace(); - } - return null; - } - - - public static String getDateTimeNow() { - return getDateTimeNow(DATE_TIME_PATTERN); - } - - public static String getDateTimeNow(String pattern) { - return format(new Date(), pattern); - } - - public static String millsToSecond(long mills) { - return String.format("%.3f", mills / 1000.0); - } - - /** - * 获取简短的时间字符串:10秒前返回刚刚,多少秒前,几小时前,超过一周返回年月日时分秒 - * @param date - * @return - */ - public static String getShortTime(Date date) { - if (date == null) { - return null; - } - // 将 Date 转换为 Instant - LocalDateTime localDateTime = date.toInstant() - // 获取系统默认时区 - .atZone(ZoneId.systemDefault()) - // 转换为 LocalDateTime - .toLocalDateTime(); - // 当前时间 - LocalDateTime now = LocalDateTime.now(); - // 时间差,单位为秒 - long secondsBetween = ChronoUnit.SECONDS.between(localDateTime, now); - - if (secondsBetween <= 10) { - return "刚刚"; - } else if (secondsBetween < 60) { - return secondsBetween + "秒前"; - } else if (secondsBetween < 60 * 60) { - return secondsBetween / 60 + "分钟前"; - } else if (secondsBetween < 86400) { - return secondsBetween / 3600 + "小时前"; - } else if (secondsBetween < 604800) { - return secondsBetween / 86400 + "天前"; - } else { - // 超过一周,显示完整日期时间 - return format(date,DATE_TIME_PATTERN); - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/HashEncryptionUtil.java b/main/manager-api/src/main/java/xiaozhi/common/utils/HashEncryptionUtil.java deleted file mode 100644 index 79b051927..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/HashEncryptionUtil.java +++ /dev/null @@ -1,52 +0,0 @@ -package xiaozhi.common.utils; - -import lombok.extern.slf4j.Slf4j; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * 哈希加密算法的工具类 - * @author zjy - */ -@Slf4j -public class HashEncryptionUtil { - /** - * 使用md5进行加密 - * @param context 被加密的内容 - * @return 哈希值 - */ - public static String Md5hexDigest(String context){ - return hexDigest(context,"MD5"); - } - - /** - * 指定哈希算法进行加密 - * @param context 被加密的内容 - * @param algorithm 哈希算法 - * @return 哈希值 - */ - public static String hexDigest(String context,String algorithm ){ - // 获取MD5算法实例 - MessageDigest md = null; - try { - md = MessageDigest.getInstance(algorithm); - } catch (NoSuchAlgorithmException e) { - log.error("加密失败的算法:{}",algorithm); - throw new RuntimeException("加密失败,"+ algorithm +"哈希算法系统不支持"); - } - // 计算智能体id的MD5值 - byte[] messageDigest = md.digest(context.getBytes()); - // 将字节数组转换为十六进制字符串 - StringBuilder hexString = new StringBuilder(); - for (byte b : messageDigest) { - String hex = Integer.toHexString(0xFF & b); - if (hex.length() == 1) { - hexString.append('0'); - } - hexString.append(hex); - } - return hexString.toString(); - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/HttpContextUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/HttpContextUtils.java deleted file mode 100644 index 0e46acf16..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/HttpContextUtils.java +++ /dev/null @@ -1,110 +0,0 @@ -package xiaozhi.common.utils; - -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.http.HttpHeaders; -import org.springframework.util.DigestUtils; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import jakarta.servlet.http.HttpServletRequest; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; - -/** - * Http - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class HttpContextUtils { - - public static HttpServletRequest getHttpServletRequest() { - RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); - if (requestAttributes == null) { - return null; - } - - return ((ServletRequestAttributes) requestAttributes).getRequest(); - } - - public static String getToken(String authorization) { - String token; - if (StringUtils.isBlank(authorization) && authorization.contains("Bearer ")) { - throw new RenException(ErrorCode.UNAUTHORIZED); - } - token = authorization.replace("Bearer ", ""); - if (StringUtils.isBlank(token)) { - throw new RenException(ErrorCode.TOKEN_NOT_EMPTY); - } - return token; - } - - public static Map getParameterMap(HttpServletRequest request) { - Enumeration parameters = request.getParameterNames(); - - Map params = new HashMap<>(); - while (parameters.hasMoreElements()) { - String parameter = parameters.nextElement(); - String value = request.getParameter(parameter); - if (StringUtils.isNotBlank(value)) { - params.put(parameter, value); - } - } - - return params; - } - - public static String getDomain() { - HttpServletRequest request = getHttpServletRequest(); - StringBuffer url = request.getRequestURL(); - return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString(); - } - - public static String getOrigin() { - HttpServletRequest request = getHttpServletRequest(); - return request.getHeader(HttpHeaders.ORIGIN); - } - - public static String getLanguage() { - // 默认语言 - String defaultLanguage = "zh-CN"; - // request - HttpServletRequest request = getHttpServletRequest(); - if (request == null) { - return defaultLanguage; - } - - // 请求语言 - defaultLanguage = request.getHeader(HttpHeaders.ACCEPT_LANGUAGE); - - return defaultLanguage; - } - - /** - * 获取客户端的唯一标识 - * - * @return - */ - public static String getClientCode() { - HttpServletRequest request = getHttpServletRequest(); - if (request == null) { - return null; - } - String reqId = request.getHeader("User-Agent").toLowerCase(); - String ipAddr = IpUtils.getIpAddr(request); - String date = DateUtils.format(new Date()); - reqId = DigestUtils.md5DigestAsHex((ipAddr + date + reqId).getBytes()); - return reqId; - } - - public static String getRequestURI() { - HttpServletRequest request = getHttpServletRequest(); - String url = request.getRequestURI(); - return url; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/IpUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/IpUtils.java deleted file mode 100644 index fef7972f2..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/IpUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -package xiaozhi.common.utils; - -import org.apache.commons.lang3.StringUtils; - -import jakarta.servlet.http.HttpServletRequest; -import lombok.extern.slf4j.Slf4j; - -/** - * IP地址 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Slf4j -public class IpUtils { - /** - * 获取IP地址 - *

- * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址 - * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址 - */ - public static String getIpAddr(HttpServletRequest request) { - String unknown = "unknown"; - String ip = null; - try { - ip = request.getHeader("x-forwarded-for"); - if (StringUtils.isEmpty(ip) || unknown.equalsIgnoreCase(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if (StringUtils.isEmpty(ip) || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (StringUtils.isEmpty(ip) || unknown.equalsIgnoreCase(ip)) { - ip = request.getHeader("HTTP_CLIENT_IP"); - } - if (StringUtils.isEmpty(ip) || unknown.equalsIgnoreCase(ip)) { - ip = request.getHeader("HTTP_X_FORWARDED_FOR"); - } - if (StringUtils.isEmpty(ip) || unknown.equalsIgnoreCase(ip)) { - ip = request.getRemoteAddr(); - } - } catch (Exception e) { - log.error("IPUtils ERROR ", e); - } - - return ip; - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/JsonRpcTwo.java b/main/manager-api/src/main/java/xiaozhi/common/utils/JsonRpcTwo.java deleted file mode 100644 index c522a61dc..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/JsonRpcTwo.java +++ /dev/null @@ -1,21 +0,0 @@ -package xiaozhi.common.utils; - -import lombok.Data; -/** - * JSON-RPC2.0 格式规范对象 - */ -@Data -public class JsonRpcTwo { - private String jsonrpc = "2.0"; - private String method; - private Object params; - private Integer id; - - public JsonRpcTwo(String method, Object params, Integer id) { - this.method = method; - this.params = params; - this.id = id; - } - - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/JsonUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/JsonUtils.java deleted file mode 100644 index 288dae9ab..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/JsonUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -package xiaozhi.common.utils; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.StrUtil; - -/** - * JSON 工具类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class JsonUtils { - private static final ObjectMapper objectMapper = new ObjectMapper(); - - public static String toJsonString(Object object) { - try { - return objectMapper.writeValueAsString(object); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static T parseObject(String text, Class clazz) { - if (StrUtil.isEmpty(text)) { - return null; - } - try { - return objectMapper.readValue(text, clazz); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static T parseObject(byte[] bytes, Class clazz) { - if (ArrayUtil.isEmpty(bytes)) { - return null; - } - try { - return objectMapper.readValue(bytes, clazz); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static T parseObject(String text, TypeReference typeReference) { - try { - return objectMapper.readValue(text, typeReference); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static List parseArray(String text, Class clazz) { - if (StrUtil.isEmpty(text)) { - return new ArrayList<>(); - } - try { - return objectMapper.readValue(text, - objectMapper.getTypeFactory().constructCollectionType(List.class, clazz)); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/MessageUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/MessageUtils.java deleted file mode 100644 index abcc2cb3d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/MessageUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package xiaozhi.common.utils; - -import org.springframework.context.MessageSource; -import org.springframework.context.i18n.LocaleContextHolder; - -/** - * 国际化 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class MessageUtils { - private static MessageSource messageSource; - - public static String getMessage(int code) { - return getMessage(code, new String[0]); - } - - public static String getMessage(int code, String... params) { - if (messageSource == null) { - // 延迟初始化,确保Spring上下文已完全初始化 - messageSource = (MessageSource) SpringContextUtils.getBean("messageSource"); - } - return messageSource.getMessage(code + "", params, LocaleContextHolder.getLocale()); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/PropertiesUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/PropertiesUtils.java deleted file mode 100644 index 1064299be..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/PropertiesUtils.java +++ /dev/null @@ -1,11 +0,0 @@ -package xiaozhi.common.utils; - -import org.springframework.stereotype.Component; - -/** - * 获取配置文件信息 - * Copyright xin-nan.com - */ -@Component -public class PropertiesUtils { -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/ResourcesUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/ResourcesUtils.java deleted file mode 100644 index cf2d0bcc5..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/ResourcesUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -package xiaozhi.common.utils; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.io.Resource; -import org.springframework.stereotype.Component; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.exception.ErrorCode; - - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -/** - * 资源处理工具 - */ -@AllArgsConstructor -@Slf4j -@Component -public class ResourcesUtils { - private ResourceLoader resourceLoader; - - /** - * 读取资源,返回字符串 - * @param fileName 资源路径:resources下开始 - * @return 字符串 - */ - public String loadString(String fileName) { - Resource resource = resourceLoader.getResource("classpath:" + fileName); - StringBuilder luaScriptBuilder = new StringBuilder(); - try (BufferedReader reader = new BufferedReader( - new InputStreamReader(resource.getInputStream()))) { - String line; - while ((line = reader.readLine()) != null) { - luaScriptBuilder.append(line).append("\n"); - } - } catch (IOException e){ - log.error("方法:loadString()读取资源失败--{}",e.getMessage()); - throw new RenException(ErrorCode.RESOURCE_READ_ERROR); - } - return luaScriptBuilder.toString(); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/Result.java b/main/manager-api/src/main/java/xiaozhi/common/utils/Result.java deleted file mode 100644 index 9c326af70..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/Result.java +++ /dev/null @@ -1,63 +0,0 @@ -package xiaozhi.common.utils; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import xiaozhi.common.exception.ErrorCode; - -/** - * 响应数据 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Data -@Schema(description = "响应") -public class Result implements Serializable { - - /** - * 编码:0表示成功,其他值表示失败 - */ - @Schema(description = "编码:0表示成功,其他值表示失败") - private int code = 0; - /** - * 消息内容 - */ - @Schema(description = "消息内容") - private String msg = "success"; - /** - * 响应数据 - */ - @Schema(description = "响应数据") - private T data; - - public Result ok(T data) { - this.setData(data); - return this; - } - - public Result error() { - this.code = ErrorCode.INTERNAL_SERVER_ERROR; - this.msg = MessageUtils.getMessage(this.code); - return this; - } - - public Result error(int code) { - this.code = code; - this.msg = MessageUtils.getMessage(this.code); - return this; - } - - public Result error(int code, String msg) { - this.code = code; - this.msg = msg; - return this; - } - - public Result error(String msg) { - this.code = ErrorCode.INTERNAL_SERVER_ERROR; - this.msg = msg; - return this; - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/ResultUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/ResultUtils.java deleted file mode 100644 index 3f9fe27dc..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/ResultUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -package xiaozhi.common.utils; - -/** - * 返回响应体工具类 - */ -public class ResultUtils -{ - public static Result success(T data) { - return new Result().ok(data); - } - - public static Result error() { - return new Result().error(); - } - - public static Result error(String msg) { - return new Result().error(msg); - } - - public static Result error(int errorCode, String msg) { - return new Result().error(errorCode, msg); - } - - public static Result error(int errorCode) { - return new Result().error(errorCode); - } - - public static Result empty() { - return new Result(); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/SM2Utils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/SM2Utils.java deleted file mode 100644 index cf0ed9c5b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/SM2Utils.java +++ /dev/null @@ -1,130 +0,0 @@ -package xiaozhi.common.utils; - -import org.bouncycastle.asn1.gm.GMNamedCurves; -import org.bouncycastle.asn1.x9.X9ECParameters; -import org.bouncycastle.crypto.engines.SM2Engine; -import org.bouncycastle.crypto.params.ECDomainParameters; -import org.bouncycastle.crypto.params.ECPrivateKeyParameters; -import org.bouncycastle.crypto.params.ECPublicKeyParameters; -import org.bouncycastle.crypto.params.ParametersWithRandom; -import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey; -import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.bouncycastle.math.ec.ECPoint; -import org.bouncycastle.util.encoders.Hex; - -import java.math.BigInteger; -import java.security.*; -import java.security.spec.ECGenParameterSpec; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - -/** - * SM2加密工具类(采用十六进制格式,与chancheng-archive-service项目保持一致) - */ -public class SM2Utils { - - /** - * 公钥常量 - */ - public static final String KEY_PUBLIC_KEY = "publicKey"; - /** - * 私钥返回值常量 - */ - public static final String KEY_PRIVATE_KEY = "privateKey"; - - static { - Security.addProvider(new BouncyCastleProvider()); - } - - /** - * SM2加密算法 - * - * @param publicKey 十六进制公钥 - * @param data 明文数据 - * @return 十六进制密文 - */ - public static String encrypt(String publicKey, String data) { - try { - // 获取一条SM2曲线参数 - X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1"); - // 构造ECC算法参数,曲线方程、椭圆曲线G点、大整数N - ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(), sm2ECParameters.getN()); - //提取公钥点 - ECPoint pukPoint = sm2ECParameters.getCurve().decodePoint(Hex.decode(publicKey)); - // 公钥前面的02或者03表示是压缩公钥,04表示未压缩公钥, 04的时候,可以去掉前面的04 - ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters); - - SM2Engine sm2Engine = new SM2Engine(SM2Engine.Mode.C1C3C2); - // 设置sm2为加密模式 - sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom())); - - byte[] in = data.getBytes(StandardCharsets.UTF_8); - byte[] arrayOfBytes = sm2Engine.processBlock(in, 0, in.length); - return Hex.toHexString(arrayOfBytes); - } catch (Exception e) { - throw new RuntimeException("SM2加密失败", e); - } - } - - /** - * SM2解密算法 - * - * @param privateKey 十六进制私钥 - * @param cipherData 十六进制密文数据 - * @return 明文 - */ - public static String decrypt(String privateKey, String cipherData) { - try { - // 使用BC库加解密时密文以04开头,传入的密文前面没有04则补上 - if (!cipherData.startsWith("04")) { - cipherData = "04" + cipherData; - } - byte[] cipherDataByte = Hex.decode(cipherData); - BigInteger privateKeyD = new BigInteger(privateKey, 16); - //获取一条SM2曲线参数 - X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1"); - //构造domain参数 - ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(), sm2ECParameters.getN()); - ECPrivateKeyParameters privateKeyParameters = new ECPrivateKeyParameters(privateKeyD, domainParameters); - - SM2Engine sm2Engine = new SM2Engine(SM2Engine.Mode.C1C3C2); - // 设置sm2为解密模式 - sm2Engine.init(false, privateKeyParameters); - - byte[] arrayOfBytes = sm2Engine.processBlock(cipherDataByte, 0, cipherDataByte.length); - return new String(arrayOfBytes, StandardCharsets.UTF_8); - } catch (Exception e) { - throw new RuntimeException("SM2解密失败", e); - } - } - - /** - * 生成密钥对 - */ - public static Map createKey() { - try { - ECGenParameterSpec sm2Spec = new ECGenParameterSpec("sm2p256v1"); - // 获取一个椭圆曲线类型的密钥对生成器 - KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", new BouncyCastleProvider()); - // 使用SM2参数初始化生成器 - kpg.initialize(sm2Spec); - // 获取密钥对 - KeyPair keyPair = kpg.generateKeyPair(); - PublicKey publicKey = keyPair.getPublic(); - BCECPublicKey p = (BCECPublicKey) publicKey; - PrivateKey privateKey = keyPair.getPrivate(); - BCECPrivateKey s = (BCECPrivateKey) privateKey; - - Map result = new HashMap<>(); - result.put(KEY_PUBLIC_KEY, Hex.toHexString(p.getQ().getEncoded(false))); - result.put(KEY_PRIVATE_KEY, Hex.toHexString(s.getD().toByteArray())); - return result; - } catch (Exception e) { - throw new RuntimeException("生成SM2密钥对失败", e); - } - } - - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/SensitiveDataUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/SensitiveDataUtils.java deleted file mode 100644 index 05f4853a0..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/SensitiveDataUtils.java +++ /dev/null @@ -1,164 +0,0 @@ -package xiaozhi.common.utils; - -import cn.hutool.json.JSONObject; -import org.apache.commons.lang3.StringUtils; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.HashMap; -import java.util.Set; - -/** - * 敏感数据处理工具类 - */ -public class SensitiveDataUtils { - - // 敏感字段列表 - private static final Set SENSITIVE_FIELDS = new HashSet<>(Arrays.asList( - "api_key", "personal_access_token", "access_token", "token", - "secret", "access_key_secret", "secret_key")); - - /** - * 检查字段是否为敏感字段 - */ - public static boolean isSensitiveField(String fieldName) { - return StringUtils.isNotBlank(fieldName) && SENSITIVE_FIELDS.contains(fieldName.toLowerCase()); - } - - /** - * 隐藏字符串中间部分 - */ - public static String maskMiddle(String value) { - if (StringUtils.isBlank(value)) { - return value; - } - - int length = value.length(); - if (length <= 8) { - // 短字符串保留前2后2 - return value.substring(0, 2) + "****" + value.substring(length - 2); - } else { - // 长字符串保留前4后4 - int maskLength = length - 8; - StringBuilder maskBuilder = new StringBuilder(); - for (int i = 0; i < maskLength; i++) { - maskBuilder.append('*'); - } - return value.substring(0, 4) + maskBuilder.toString() + value.substring(length - 4); - } - } - - /** - * 判断字符串是否是被掩码处理过的值 - */ - public static boolean isMaskedValue(String value) { - if (StringUtils.isBlank(value)) { - return false; - } - // 掩码值至少包含4个连续的* - return value.contains("****"); - } - - /** - * 处理JSONObject中的敏感字段 - */ - public static JSONObject maskSensitiveFields(JSONObject jsonObject) { - if (jsonObject == null) { - return null; - } - - JSONObject result = new JSONObject(); - - for (String key : jsonObject.keySet()) { - Object value = jsonObject.get(key); - - if (SENSITIVE_FIELDS.contains(key.toLowerCase()) && value instanceof String) { - result.put(key, maskMiddle((String) value)); - } else if (value instanceof JSONObject) { - result.put(key, maskSensitiveFields((JSONObject) value)); - } else { - result.put(key, value); - } - } - - return result; - } - - /** - * 比较两个JSONObject的敏感字段是否相同 - * 特别针对api_key等敏感字段进行单独比较 - */ - public static boolean isSensitiveDataEqual(JSONObject original, JSONObject updated) { - if (original == null && updated == null) { - return true; - } - if (original == null || updated == null) { - return false; - } - - // 提取并比较特定敏感字段 - return compareSpecificSensitiveFields(original, updated, "api_key") && - compareSpecificSensitiveFields(original, updated, "personal_access_token") && - compareSpecificSensitiveFields(original, updated, "access_token") && - compareSpecificSensitiveFields(original, updated, "token") && - compareSpecificSensitiveFields(original, updated, "secret") && - compareSpecificSensitiveFields(original, updated, "access_key_secret") && - compareSpecificSensitiveFields(original, updated, "secret_key"); - } - - /** - * 比较两个JSON对象中特定敏感字段是否相同 - * 遍历整个JSON对象树,查找并比较指定敏感字段 - */ - private static boolean compareSpecificSensitiveFields(JSONObject original, JSONObject updated, String fieldName) { - // 提取原始对象中的指定敏感字段 - Map originalFields = new HashMap<>(); - extractSpecificSensitiveField(original, originalFields, fieldName, ""); - - // 提取更新对象中的指定敏感字段 - Map updatedFields = new HashMap<>(); - extractSpecificSensitiveField(updated, updatedFields, fieldName, ""); - - // 如果字段数量不同,说明有增删 - if (originalFields.size() != updatedFields.size()) { - return false; - } - - // 比较每个字段的值 - for (Map.Entry entry : originalFields.entrySet()) { - String key = entry.getKey(); - String originalValue = entry.getValue(); - String updatedValue = updatedFields.get(key); - - if (updatedValue == null || !updatedValue.equals(originalValue)) { - return false; - } - } - - return true; - } - - /** - * 递归提取JSON对象中指定名称的敏感字段 - */ - private static void extractSpecificSensitiveField(JSONObject jsonObject, Map fieldsMap, - String targetFieldName, String parentPath) { - if (jsonObject == null) { - return; - } - - for (String key : jsonObject.keySet()) { - String fullPath = parentPath.isEmpty() ? key : parentPath + "." + key; - Object value = jsonObject.get(key); - - if (value instanceof JSONObject) { - // 递归处理嵌套JSON对象 - extractSpecificSensitiveField((JSONObject) value, fieldsMap, targetFieldName, fullPath); - } else if (value instanceof String && key.equalsIgnoreCase(targetFieldName)) { - // 找到目标敏感字段,保存其路径和值 - fieldsMap.put(fullPath, (String) value); - } - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/Sm2DecryptUtil.java b/main/manager-api/src/main/java/xiaozhi/common/utils/Sm2DecryptUtil.java deleted file mode 100644 index 5dd1a3128..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/Sm2DecryptUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -package xiaozhi.common.utils; - -import org.apache.commons.lang3.StringUtils; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.modules.security.service.CaptchaService; -import xiaozhi.modules.sys.service.SysParamsService; - -/** - * SM2解密和验证码验证工具类 - * 封装了重复的SM2解密、验证码提取和验证逻辑 - */ -public class Sm2DecryptUtil { - - /** - * 验证码长度 - */ - private static final int CAPTCHA_LENGTH = 5; - - /** - * 解密SM2加密内容,提取验证码并验证 - * @param encryptedPassword SM2加密的密码字符串 - * @param captchaId 验证码ID - * @param captchaService 验证码服务 - * @param sysParamsService 系统参数服务 - * @return 解密后的实际密码 - */ - public static String decryptAndValidateCaptcha(String encryptedPassword, String captchaId, - CaptchaService captchaService, SysParamsService sysParamsService) { - // 获取SM2私钥 - String privateKeyStr = sysParamsService.getValue(Constant.SM2_PRIVATE_KEY, true); - if (StringUtils.isBlank(privateKeyStr)) { - throw new RenException(ErrorCode.SM2_KEY_NOT_CONFIGURED); - } - - // 使用SM2私钥解密密码 - String decryptedContent; - try { - decryptedContent = SM2Utils.decrypt(privateKeyStr, encryptedPassword); - } catch (Exception e) { - throw new RenException(ErrorCode.SM2_DECRYPT_ERROR); - } - - // 分离验证码和密码:前5位是验证码,后面是密码 - if (decryptedContent.length() > CAPTCHA_LENGTH) { - String embeddedCaptcha = decryptedContent.substring(0, CAPTCHA_LENGTH); - String actualPassword = decryptedContent.substring(CAPTCHA_LENGTH); - - // 验证嵌入的验证码是否正确 - boolean embeddedCaptchaValid = captchaService.validate(captchaId, embeddedCaptcha, true); - if (!embeddedCaptchaValid) { - throw new RenException(ErrorCode.SMS_CAPTCHA_ERROR); - } - - return actualPassword; - } else { - throw new RenException(ErrorCode.SM2_DECRYPT_ERROR); - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/SpringContextUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/SpringContextUtils.java deleted file mode 100644 index 52aec0b72..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/SpringContextUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -package xiaozhi.common.utils; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -/** - * Spring Context 工具类 - */ -@Component -public class SpringContextUtils implements ApplicationContextAware { - public static ApplicationContext applicationContext; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) - throws BeansException { - SpringContextUtils.applicationContext = applicationContext; - } - - public static Object getBean(String name) { - return applicationContext.getBean(name); - } - - public static T getBean(Class requiredType) { - return applicationContext.getBean(requiredType); - } - - public static T getBean(String name, Class requiredType) { - return applicationContext.getBean(name, requiredType); - } - - public static boolean containsBean(String name) { - return applicationContext.containsBean(name); - } - - public static boolean isSingleton(String name) { - return applicationContext.isSingleton(name); - } - - public static Class getType(String name) { - return applicationContext.getType(name); - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/TreeNode.java b/main/manager-api/src/main/java/xiaozhi/common/utils/TreeNode.java deleted file mode 100644 index 5fdb5985e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/TreeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -package xiaozhi.common.utils; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import lombok.Data; - -/** - * 树节点,所有需要实现树节点的,都需要继承该类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Data -public class TreeNode implements Serializable { - - /** - * 主键 - */ - private Long id; - /** - * 上级ID - */ - private Long pid; - /** - * 子节点列表 - */ - private List children = new ArrayList<>(); - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/utils/TreeUtils.java b/main/manager-api/src/main/java/xiaozhi/common/utils/TreeUtils.java deleted file mode 100644 index e76190eba..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/utils/TreeUtils.java +++ /dev/null @@ -1,71 +0,0 @@ -package xiaozhi.common.utils; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import xiaozhi.common.validator.AssertUtils; - -/** - * 树形结构工具类,如:菜单、部门等 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class TreeUtils { - - /** - * 根据pid,构建树节点 - */ - public static > List build(List treeNodes, Long pid) { - // pid不能为空 - AssertUtils.isNull(pid, "pid"); - - List treeList = new ArrayList<>(); - for (T treeNode : treeNodes) { - if (pid.equals(treeNode.getPid())) { - treeList.add(findChildren(treeNodes, treeNode)); - } - } - - return treeList; - } - - /** - * 查找子节点 - */ - private static > T findChildren(List treeNodes, T rootNode) { - for (T treeNode : treeNodes) { - if (rootNode.getId().equals(treeNode.getPid())) { - rootNode.getChildren().add(findChildren(treeNodes, treeNode)); - } - } - return rootNode; - } - - /** - * 构建树节点 - */ - public static > List build(List treeNodes) { - List result = new ArrayList<>(); - - // list转map - Map nodeMap = new LinkedHashMap<>(treeNodes.size()); - for (T treeNode : treeNodes) { - nodeMap.put(treeNode.getId(), treeNode); - } - - for (T node : nodeMap.values()) { - T parent = nodeMap.get(node.getPid()); - if (parent != null && !(node.getId().equals(parent.getId()))) { - parent.getChildren().add(node); - continue; - } - - result.add(node); - } - - return result; - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/AssertUtils.java b/main/manager-api/src/main/java/xiaozhi/common/validator/AssertUtils.java deleted file mode 100644 index c86aa5176..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/validator/AssertUtils.java +++ /dev/null @@ -1,90 +0,0 @@ -package xiaozhi.common.validator; - -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ArrayUtil; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; - -/** - * 校验工具类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class AssertUtils { - - public static void isBlank(String str, String... params) { - isBlank(str, ErrorCode.NOT_NULL, params); - } - - public static void isBlank(String str, Integer code, String... params) { - if (code == null) { - throw new RenException(ErrorCode.NOT_NULL, "code"); - } - - if (StringUtils.isBlank(str)) { - throw new RenException(code, params); - } - } - - public static void isNull(Object object, String... params) { - isNull(object, ErrorCode.NOT_NULL, params); - } - - public static void isNull(Object object, Integer code, String... params) { - if (code == null) { - throw new RenException(ErrorCode.NOT_NULL, "code"); - } - - if (object == null) { - throw new RenException(code, params); - } - } - - public static void isArrayEmpty(Object[] array, String... params) { - isArrayEmpty(array, ErrorCode.NOT_NULL, params); - } - - public static void isArrayEmpty(Object[] array, Integer code, String... params) { - if (code == null) { - throw new RenException(ErrorCode.NOT_NULL, "code"); - } - - if (ArrayUtil.isEmpty(array)) { - throw new RenException(code, params); - } - } - - public static void isListEmpty(List list, String... params) { - isListEmpty(list, ErrorCode.NOT_NULL, params); - } - - public static void isListEmpty(List list, Integer code, String... params) { - if (code == null) { - throw new RenException(ErrorCode.NOT_NULL, "code"); - } - - if (CollUtil.isEmpty(list)) { - throw new RenException(code, params); - } - } - - public static void isMapEmpty(Map map, String... params) { - isMapEmpty(map, ErrorCode.NOT_NULL, params); - } - - public static void isMapEmpty(Map map, Integer code, String... params) { - if (code == null) { - throw new RenException(ErrorCode.NOT_NULL, "code"); - } - - if (MapUtil.isEmpty(map)) { - throw new RenException(code, params); - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/ValidatorUtils.java b/main/manager-api/src/main/java/xiaozhi/common/validator/ValidatorUtils.java deleted file mode 100644 index 364da0d99..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/validator/ValidatorUtils.java +++ /dev/null @@ -1,77 +0,0 @@ -package xiaozhi.common.validator; - -import java.util.Locale; -import java.util.Set; -import java.util.regex.Pattern; - -import org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.validation.beanvalidation.MessageSourceResourceBundleLocator; - -import jakarta.validation.ConstraintViolation; -import jakarta.validation.Validation; -import jakarta.validation.Validator; -import xiaozhi.common.exception.RenException; - -/** - * hibernate-validator校验工具类 - * 参考文档:http://docs.jboss.org/hibernate/validator/6.0/reference/en-US/html_single/ - */ -public class ValidatorUtils { - - private static ResourceBundleMessageSource getMessageSource() { - ResourceBundleMessageSource bundleMessageSource = new ResourceBundleMessageSource(); - bundleMessageSource.setDefaultEncoding("UTF-8"); - bundleMessageSource.setBasenames("i18n/validation"); - return bundleMessageSource; - } - - /** - * 校验对象 - * - * @param object 待校验对象 - * @param groups 待校验的组 - */ - public static void validateEntity(Object object, Class... groups) - throws RenException { - Locale.setDefault(LocaleContextHolder.getLocale()); - Validator validator = Validation.byDefaultProvider().configure().messageInterpolator( - new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(getMessageSource()))) - .buildValidatorFactory().getValidator(); - - Set> constraintViolations = validator.validate(object, groups); - if (!constraintViolations.isEmpty()) { - ConstraintViolation constraint = constraintViolations.iterator().next(); - throw new RenException(constraint.getMessage()); - } - } - - /** - * 国际手机号正则表达式 - * 要求必须带国际区号,格式:+[国家代码][手机号] - * 例如: - * - +8613800138000 - * - +12345678900 - * - +447123456789 - */ - private static final String INTERNATIONAL_PHONE_REGEX = "^\\+[1-9]\\d{0,3}[1-9]\\d{4,14}$"; - - /** - * 校验手机号是否有效 - * 要求必须带国际区号,格式:+[国家代码][手机号] - * 例如:+8613800138000 - * - * @param phone 手机号 - * @return boolean - */ - public static boolean isValidPhone(String phone) { - if (phone == null || phone.isEmpty()) { - return false; - } - - // 验证必须带国际区号的手机号格式 - Pattern pattern = Pattern.compile(INTERNATIONAL_PHONE_REGEX); - return pattern.matcher(phone).matches(); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/group/AddGroup.java b/main/manager-api/src/main/java/xiaozhi/common/validator/group/AddGroup.java deleted file mode 100644 index fd8290fde..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/validator/group/AddGroup.java +++ /dev/null @@ -1,8 +0,0 @@ -package xiaozhi.common.validator.group; - -/** - * 新增 Group - */ -public interface AddGroup { - -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/group/DefaultGroup.java b/main/manager-api/src/main/java/xiaozhi/common/validator/group/DefaultGroup.java deleted file mode 100644 index 60ddb7305..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/validator/group/DefaultGroup.java +++ /dev/null @@ -1,8 +0,0 @@ -package xiaozhi.common.validator.group; - -/** - * 默认 Group - */ -public interface DefaultGroup { - -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/validator/group/UpdateGroup.java b/main/manager-api/src/main/java/xiaozhi/common/validator/group/UpdateGroup.java deleted file mode 100644 index 220fda333..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/validator/group/UpdateGroup.java +++ /dev/null @@ -1,8 +0,0 @@ -package xiaozhi.common.validator.group; - -/** - * 修改 Group - */ -public interface UpdateGroup { - -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/SqlFilter.java b/main/manager-api/src/main/java/xiaozhi/common/xss/SqlFilter.java deleted file mode 100644 index 2bf4ab928..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/xss/SqlFilter.java +++ /dev/null @@ -1,46 +0,0 @@ -package xiaozhi.common.xss; - -import org.apache.commons.lang3.StringUtils; - -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; - -/** - * SQL过滤 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class SqlFilter { - - /** - * SQL注入过滤 - * - * @param str 待验证的字符串 - */ - public static String sqlInject(String str) { - if (StringUtils.isBlank(str)) { - return null; - } - // 去掉'|"|;|\字符 - str = StringUtils.replace(str, "'", ""); - str = StringUtils.replace(str, "\"", ""); - str = StringUtils.replace(str, ";", ""); - str = StringUtils.replace(str, "\\", ""); - - // 转换成小写 - str = str.toLowerCase(); - - // 非法字符 - String[] keywords = { "master", "truncate", "insert", "select", "delete", "update", "declare", "alter", - "drop" }; - - // 判断是否包含非法字符 - for (String keyword : keywords) { - if (str.contains(keyword)) { - throw new RenException(ErrorCode.INVALID_SYMBOL); - } - } - - return str; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssConfig.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssConfig.java deleted file mode 100644 index e4b654659..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package xiaozhi.common.xss; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.PathMatcher; - -import jakarta.servlet.DispatcherType; - -/** - * XSS 配置文件 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Configuration -@EnableConfigurationProperties(XssProperties.class) -@ConditionalOnProperty(prefix = "renren.xss", value = "enabled") -public class XssConfig { - - @Bean - public FilterRegistrationBean xssFilter(XssProperties properties, PathMatcher pathMatcher) { - FilterRegistrationBean bean = new FilterRegistrationBean<>(); - bean.setDispatcherTypes(DispatcherType.REQUEST); - bean.setFilter(new XssFilter(properties, pathMatcher)); - bean.addUrlPatterns("/*"); - bean.setOrder(Integer.MAX_VALUE); - bean.setName("xssFilter"); - - return bean; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssFilter.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssFilter.java deleted file mode 100644 index db7699897..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -package xiaozhi.common.xss; - -import java.io.IOException; - -import org.springframework.util.PathMatcher; - -import jakarta.servlet.Filter; -import jakarta.servlet.FilterChain; -import jakarta.servlet.FilterConfig; -import jakarta.servlet.ServletException; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; -import jakarta.servlet.http.HttpServletRequest; -import lombok.AllArgsConstructor; - -/** - * XSS过滤 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@AllArgsConstructor -public class XssFilter implements Filter { - private final XssProperties properties; - private final PathMatcher pathMatcher; - - @Override - public void init(FilterConfig config) throws ServletException { - } - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - HttpServletRequest httpServletRequest = (HttpServletRequest) request; - - // 放行 - if (shouldNotFilter(httpServletRequest)) { - chain.doFilter(request, response); - - return; - } - - chain.doFilter(new XssHttpServletRequestWrapper(httpServletRequest), response); - } - - private boolean shouldNotFilter(HttpServletRequest request) { - // 放行不过滤的URL - return properties.getExcludeUrls().stream() - .anyMatch(excludeUrl -> pathMatcher.match(excludeUrl, request.getServletPath())); - } - - @Override - public void destroy() { - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssHttpServletRequestWrapper.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssHttpServletRequestWrapper.java deleted file mode 100644 index ecb364061..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssHttpServletRequestWrapper.java +++ /dev/null @@ -1,118 +0,0 @@ -package xiaozhi.common.xss; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; - -import cn.hutool.core.io.IoUtil; -import jakarta.servlet.ReadListener; -import jakarta.servlet.ServletInputStream; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletRequestWrapper; - -/** - * XSS过滤处理 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { - - public XssHttpServletRequestWrapper(HttpServletRequest request) { - super(request); - } - - @Override - public ServletInputStream getInputStream() throws IOException { - // 非json类型,直接返回 - if (!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))) { - return super.getInputStream(); - } - - // 为空,直接返回 - String json = IoUtil.readUtf8(super.getInputStream()); - if (StringUtils.isBlank(json)) { - return super.getInputStream(); - } - - // xss过滤 - json = xssEncode(json); - final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)); - return new ServletInputStream() { - @Override - public boolean isFinished() { - return true; - } - - @Override - public boolean isReady() { - return true; - } - - @Override - public void setReadListener(ReadListener readListener) { - - } - - @Override - public int read() { - return bis.read(); - } - }; - } - - @Override - public String getParameter(String name) { - String value = super.getParameter(xssEncode(name)); - if (StringUtils.isNotBlank(value)) { - value = xssEncode(value); - } - return value; - } - - @Override - public String[] getParameterValues(String name) { - String[] parameters = super.getParameterValues(name); - if (parameters == null || parameters.length == 0) { - return null; - } - - for (int i = 0; i < parameters.length; i++) { - parameters[i] = xssEncode(parameters[i]); - } - return parameters; - } - - @Override - public Map getParameterMap() { - Map map = new LinkedHashMap<>(); - Map parameters = super.getParameterMap(); - for (String key : parameters.keySet()) { - String[] values = parameters.get(key); - for (int i = 0; i < values.length; i++) { - values[i] = xssEncode(values[i]); - } - map.put(key, values); - } - return map; - } - - @Override - public String getHeader(String name) { - String value = super.getHeader(xssEncode(name)); - if (StringUtils.isNotBlank(value)) { - value = xssEncode(value); - } - return value; - } - - private String xssEncode(String input) { - return XssUtils.filter(input); - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssProperties.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssProperties.java deleted file mode 100644 index 5d9b8b01d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssProperties.java +++ /dev/null @@ -1,26 +0,0 @@ -package xiaozhi.common.xss; - -import java.util.Collections; -import java.util.List; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -import lombok.Data; - -/** - * XSS 配置项 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Data -@ConfigurationProperties(prefix = "renren.xss") -public class XssProperties { - /** - * 是否开启 XSS - */ - private boolean enabled; - /** - * 排除的URL列表 - */ - private List excludeUrls = Collections.emptyList(); -} diff --git a/main/manager-api/src/main/java/xiaozhi/common/xss/XssUtils.java b/main/manager-api/src/main/java/xiaozhi/common/xss/XssUtils.java deleted file mode 100644 index 165883924..000000000 --- a/main/manager-api/src/main/java/xiaozhi/common/xss/XssUtils.java +++ /dev/null @@ -1,67 +0,0 @@ -package xiaozhi.common.xss; - -import org.jsoup.Jsoup; -import org.jsoup.safety.Safelist; - -/** - * XSS过滤工具类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class XssUtils extends Safelist { - - /** - * XSS过滤 - */ - public static String filter(String html) { - return Jsoup.clean(html, xssWhitelist()); - } - - /** - * XSS过滤白名单 - */ - private static Safelist xssWhitelist() { - return new Safelist() - // 支持的标签 - .addTags("a", "b", "blockquote", "br", "caption", "cite", "code", "col", "colgroup", "dd", "div", "dl", - "dt", "em", "h1", "h2", "h3", "h4", "h5", "h6", "i", "img", "li", "ol", "p", "pre", "q", - "small", - "strike", "strong", "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "u", - "ul", - "embed", "object", "param", "span") - - // 支持的标签属性 - .addAttributes("a", "href", "class", "style", "target", "rel", "nofollow") - .addAttributes("blockquote", "cite") - .addAttributes("code", "class", "style") - .addAttributes("col", "span", "width") - .addAttributes("colgroup", "span", "width") - .addAttributes("img", "align", "alt", "height", "src", "title", "width", "class", "style") - .addAttributes("ol", "start", "type") - .addAttributes("q", "cite") - .addAttributes("table", "summary", "width", "class", "style") - .addAttributes("tr", "abbr", "axis", "colspan", "rowspan", "width", "style") - .addAttributes("td", "abbr", "axis", "colspan", "rowspan", "width", "style") - .addAttributes("th", "abbr", "axis", "colspan", "rowspan", "scope", "width", "style") - .addAttributes("ul", "type", "style") - .addAttributes("pre", "class", "style") - .addAttributes("div", "class", "id", "style") - .addAttributes("embed", "src", "wmode", "flashvars", "pluginspage", "allowFullScreen", - "allowfullscreen", - "quality", "width", "height", "align", "allowScriptAccess", "allowscriptaccess", - "allownetworking", "type") - .addAttributes("object", "type", "id", "name", "data", "width", "height", "style", "classid", - "codebase") - .addAttributes("param", "name", "value") - .addAttributes("span", "class", "style") - - // 标签属性对应的协议 - .addProtocols("a", "href", "ftp", "http", "https", "mailto") - .addProtocols("img", "src", "http", "https") - .addProtocols("blockquote", "cite", "http", "https") - .addProtocols("cite", "cite", "http", "https") - .addProtocols("q", "cite", "http", "https") - .addProtocols("embed", "src", "http", "https"); - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/AgentChatHistoryType.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/AgentChatHistoryType.java deleted file mode 100644 index 49ed2dce7..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/AgentChatHistoryType.java +++ /dev/null @@ -1,21 +0,0 @@ -package xiaozhi.modules.agent.Enums; - - -import lombok.Getter; - -/** - * 智能体聊天记录类型 - */ -@Getter -public enum AgentChatHistoryType { - - USER((byte) 1), - AGENT((byte) 2); - - private final byte value; - - AgentChatHistoryType(byte i) { - this.value = i; - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/XiaoZhiMcpJsonRpcJson.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/XiaoZhiMcpJsonRpcJson.java deleted file mode 100644 index 114b1ab95..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/Enums/XiaoZhiMcpJsonRpcJson.java +++ /dev/null @@ -1,44 +0,0 @@ -package xiaozhi.modules.agent.Enums; - -import xiaozhi.common.utils.JsonUtils; -import xiaozhi.common.utils.JsonRpcTwo; - -import java.util.Map; - - -/** - * 小智MCP JSON-RPC 请求json - */ -public class XiaoZhiMcpJsonRpcJson { - //小智初始化mcp请求json - private static final String INITIALIZE_JSON; - //小智mcp初始化成功,返回通知请求json - private static final String NOTIFICATIONS_INITIALIZED_JSON; - //小智mcp获取mcp工具集合请求json - private static final String TOOLS_LIST_REQUEST; - // 延迟加载 - static { - INITIALIZE_JSON = JsonUtils.toJsonString(new JsonRpcTwo("initialize", - Map.of( - "protocolVersion", "2024-11-05", - "capabilities", Map.of( - "roots", Map.of("listChanged", false), - "sampling", Map.of()), - "clientInfo", Map.of( - "name", "xz-mcp-broker", - "version", "0.0.1")), - 1)); - NOTIFICATIONS_INITIALIZED_JSON = "{\"jsonrpc\":\"2.0\",\"method\":\"notifications/initialized\"}"; - TOOLS_LIST_REQUEST = JsonUtils.toJsonString(new JsonRpcTwo("tools/list", null, 2)); - } - public static String getInitializeJson(){ - return INITIALIZE_JSON; - } - public static String getNotificationsInitializedJson(){ - return NOTIFICATIONS_INITIALIZED_JSON; - } - public static String getToolsListJson(){ - return TOOLS_LIST_REQUEST; - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java deleted file mode 100644 index 53c85d72a..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java +++ /dev/null @@ -1,246 +0,0 @@ -package xiaozhi.modules.agent.controller; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import lombok.RequiredArgsConstructor; -import xiaozhi.common.constant.Constant; -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.user.UserDetail; -import xiaozhi.common.utils.DateUtils; -import xiaozhi.common.utils.MessageUtils; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.agent.dto.AgentChatHistoryDTO; -import xiaozhi.modules.agent.dto.AgentChatHistoryReportDTO; -import xiaozhi.modules.agent.dto.AgentChatSessionDTO; -import xiaozhi.modules.agent.service.AgentChatHistoryService; -import xiaozhi.modules.agent.service.AgentService; -import xiaozhi.modules.agent.service.biz.AgentChatHistoryBizService; -import xiaozhi.modules.security.user.SecurityUser; - -@Tag(name = "智能体聊天历史管理") -@RequiredArgsConstructor -@RestController -@RequestMapping("/agent/chat-history") -public class AgentChatHistoryController { - private final AgentChatHistoryBizService agentChatHistoryBizService; - private final AgentChatHistoryService agentChatHistoryService; - private final AgentService agentService; - private final RedisUtils redisUtils; - - /** - * 小智服务聊天上报请求 - *

- * 小智服务聊天上报请求,包含Base64编码的音频数据和相关信息。 - * - * @param request 包含上传文件及相关信息的请求对象 - */ - @Operation(summary = "小智服务聊天上报请求") - @PostMapping("/report") - public Result uploadFile(@Valid @RequestBody AgentChatHistoryReportDTO request) { - Boolean result = agentChatHistoryBizService.report(request); - return new Result().ok(result); - } - - /** - * 获取聊天记录下载链接 - * - * @param agentId 智能体ID - * @param sessionId 会话ID - * @return UUID作为下载标识 - */ - @Operation(summary = "获取聊天记录下载链接") - @RequiresPermissions("sys:role:normal") - @PostMapping("/getDownloadUrl/{agentId}/{sessionId}") - public Result getDownloadUrl(@PathVariable("agentId") String agentId, - @PathVariable("sessionId") String sessionId) { - // 获取当前用户 - UserDetail user = SecurityUser.getUser(); - // 检查权限 - if (!agentService.checkAgentPermission(agentId, user.getId())) { - throw new RenException(ErrorCode.CHAT_HISTORY_NO_PERMISSION); - } - - // 生成UUID - String uuid = UUID.randomUUID().toString(); - // 存储agentId和sessionId到Redis,格式为agentId:sessionId - redisUtils.set(RedisKeys.getChatHistoryKey(uuid), agentId + ":" + sessionId); - - return new Result().ok(uuid); - } - - /** - * 下载本会话聊天记录 - * - * @param uuid 下载标识 - * @param response HTTP响应 - */ - @Operation(summary = "下载本会话聊天记录") - @GetMapping("/download/{uuid}/current") - public void downloadCurrentSession(@PathVariable("uuid") String uuid, - HttpServletResponse response) { - // 从Redis获取agentId和sessionId - String agentSessionInfo = (String) redisUtils.get(RedisKeys.getChatHistoryKey(uuid)); - if (StringUtils.isBlank(agentSessionInfo)) { - throw new RenException(ErrorCode.DOWNLOAD_LINK_EXPIRED); - } - - try { - // 解析agentId和sessionId - String[] parts = agentSessionInfo.split(":"); - if (parts.length != 2) { - throw new RenException(ErrorCode.DOWNLOAD_LINK_INVALID); - } - String agentId = parts[0]; - String sessionId = parts[1]; - - // 执行下载 - downloadChatHistory(agentId, List.of(sessionId), response); - } finally { - // 下载完成后删除UUID,防止盗刷 - redisUtils.delete(RedisKeys.getChatHistoryKey(uuid)); - } - } - - /** - * 下载本会话及前20条会话聊天记录 - * - * @param uuid 下载标识 - * @param response HTTP响应 - */ - @Operation(summary = "下载本会话及前20条会话聊天记录") - @GetMapping("/download/{uuid}/previous") - public void downloadCurrentSessionWithPrevious(@PathVariable("uuid") String uuid, - HttpServletResponse response) { - // 从Redis获取agentId和sessionId - String agentSessionInfo = (String) redisUtils.get(RedisKeys.getChatHistoryKey(uuid)); - if (StringUtils.isBlank(agentSessionInfo)) { - throw new RenException("下载链接已过期或无效"); - } - - try { - // 解析agentId和sessionId - String[] parts = agentSessionInfo.split(":"); - if (parts.length != 2) { - throw new RenException("下载链接无效"); - } - String agentId = parts[0]; - String sessionId = parts[1]; - - // 获取所有会话列表 - Map params = Map.of( - "agentId", agentId, - Constant.PAGE, 1, - Constant.LIMIT, 1000 // 获取足够多的会话 - ); - PageData sessionPage = agentChatHistoryService.getSessionListByAgentId(params); - List allSessions = sessionPage.getList(); - - // 查找当前会话在列表中的位置 - int currentIndex = -1; - for (int i = 0; i < allSessions.size(); i++) { - if (allSessions.get(i).getSessionId().equals(sessionId)) { - currentIndex = i; - break; - } - } - - // 如果找到了当前会话,收集当前会话及前20条会话ID - List sessionIdsToDownload = new ArrayList<>(); - if (currentIndex != -1) { - // 从当前会话开始,向后(数组后面)取最多20条会话(包括当前会话) - int endIndex = Math.min(allSessions.size() - 1, currentIndex + 20); // 确保不越界 - for (int i = currentIndex; i <= endIndex; i++) { - sessionIdsToDownload.add(allSessions.get(i).getSessionId()); - } - } - - // 如果没有找到当前会话,至少下载当前会话 - if (sessionIdsToDownload.isEmpty()) { - sessionIdsToDownload.add(sessionId); - } - downloadChatHistory(agentId, sessionIdsToDownload, response); - } finally { - // 下载完成后删除UUID,防止盗刷 - redisUtils.delete(RedisKeys.getChatHistoryKey(uuid)); - } - } - - /** - * 下载指定会话的聊天记录 - * - * @param agentId 智能体ID - * @param sessionIds 会话ID列表 - * @param response HTTP响应 - */ - private void downloadChatHistory(String agentId, List sessionIds, HttpServletResponse response) { - try { - // 设置响应头 - response.setContentType("text/plain;charset=UTF-8"); - String fileName = URLEncoder.encode("history.txt", StandardCharsets.UTF_8.toString()); - response.setHeader("Content-Disposition", "attachment;filename=" + fileName); - - // 获取聊天记录并写入响应流 - try (OutputStream out = response.getOutputStream()) { - // 为每个会话生成聊天记录 - for (String sessionId : sessionIds) { - // 获取该会话的所有聊天记录 - List chatHistoryList = agentChatHistoryService - .getChatHistoryBySessionId(agentId, sessionId); - - // 从聊天记录中获取第一条消息的创建时间作为会话时间 - if (!chatHistoryList.isEmpty()) { - Date firstMessageTime = chatHistoryList.get(0).getCreatedAt(); - String sessionTimeStr = DateUtils.format(firstMessageTime, DateUtils.DATE_TIME_PATTERN); - out.write((sessionTimeStr + "\n").getBytes(StandardCharsets.UTF_8)); - } - - for (AgentChatHistoryDTO message : chatHistoryList) { - String role = message.getChatType() == 1 ? MessageUtils.getMessage(ErrorCode.CHAT_ROLE_USER) - : MessageUtils.getMessage(ErrorCode.CHAT_ROLE_AGENT); - String direction = message.getChatType() == 1 ? ">>" : "<<"; - Date messageTime = message.getCreatedAt(); - String messageTimeStr = DateUtils.format(messageTime, DateUtils.DATE_TIME_PATTERN); - String content = message.getContent(); - - String line = "[" + role + "]-[" + messageTimeStr + "]" + direction + ":" + content + "\n"; - out.write(line.getBytes(StandardCharsets.UTF_8)); - } - - // 会话之间添加空行分隔 - if (sessionIds.indexOf(sessionId) < sessionIds.size() - 1) { - out.write("\n".getBytes(StandardCharsets.UTF_8)); - } - } - - out.flush(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java deleted file mode 100644 index a4ad08632..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java +++ /dev/null @@ -1,246 +0,0 @@ -package xiaozhi.modules.agent.controller; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; - -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 jakarta.validation.Valid; -import lombok.AllArgsConstructor; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.common.user.UserDetail; -import xiaozhi.common.utils.Result; -import xiaozhi.common.utils.ResultUtils; -import xiaozhi.modules.agent.dto.AgentChatHistoryDTO; -import xiaozhi.modules.agent.dto.AgentChatSessionDTO; -import xiaozhi.modules.agent.dto.AgentCreateDTO; -import xiaozhi.modules.agent.dto.AgentDTO; -import xiaozhi.modules.agent.dto.AgentMemoryDTO; -import xiaozhi.modules.agent.dto.AgentUpdateDTO; -import xiaozhi.modules.agent.entity.AgentEntity; -import xiaozhi.modules.agent.entity.AgentTemplateEntity; -import xiaozhi.modules.agent.service.AgentChatAudioService; -import xiaozhi.modules.agent.service.AgentChatHistoryService; -import xiaozhi.modules.agent.service.AgentPluginMappingService; -import xiaozhi.modules.agent.service.AgentService; -import xiaozhi.modules.agent.service.AgentTemplateService; -import xiaozhi.modules.agent.vo.AgentChatHistoryUserVO; -import xiaozhi.modules.agent.vo.AgentInfoVO; -import xiaozhi.modules.device.entity.DeviceEntity; -import xiaozhi.modules.device.service.DeviceService; -import xiaozhi.modules.security.user.SecurityUser; - -@Tag(name = "智能体管理") -@AllArgsConstructor -@RestController -@RequestMapping("/agent") -public class AgentController { - private final AgentService agentService; - private final AgentTemplateService agentTemplateService; - private final DeviceService deviceService; - private final AgentChatHistoryService agentChatHistoryService; - private final AgentChatAudioService agentChatAudioService; - private final AgentPluginMappingService agentPluginMappingService; - private final RedisUtils redisUtils; - - @GetMapping("/list") - @Operation(summary = "获取用户智能体列表") - @RequiresPermissions("sys:role:normal") - public Result> getUserAgents() { - UserDetail user = SecurityUser.getUser(); - List agents = agentService.getUserAgents(user.getId()); - return new Result>().ok(agents); - } - - @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> adminAgentList( - @Parameter(hidden = true) @RequestParam Map params) { - PageData page = agentService.adminAgentList(params); - return new Result>().ok(page); - } - - @GetMapping("/{id}") - @Operation(summary = "获取智能体详情") - @RequiresPermissions("sys:role:normal") - public Result getAgentById(@PathVariable("id") String id) { - AgentInfoVO agent = agentService.getAgentById(id); - return ResultUtils.success(agent); - } - - @PostMapping - @Operation(summary = "创建智能体") - @RequiresPermissions("sys:role:normal") - public Result save(@RequestBody @Valid AgentCreateDTO dto) { - String agentId = agentService.createAgent(dto); - return new Result().ok(agentId); - } - - @PutMapping("/saveMemory/{macAddress}") - @Operation(summary = "根据设备id更新智能体") - public Result updateByDeviceId(@PathVariable String macAddress, @RequestBody @Valid AgentMemoryDTO dto) { - DeviceEntity device = deviceService.getDeviceByMacAddress(macAddress); - if (device == null) { - return new Result<>(); - } - AgentUpdateDTO agentUpdateDTO = new AgentUpdateDTO(); - agentUpdateDTO.setSummaryMemory(dto.getSummaryMemory()); - agentService.updateAgentById(device.getAgentId(), agentUpdateDTO); - return new Result<>(); - } - - @PutMapping("/{id}") - @Operation(summary = "更新智能体") - @RequiresPermissions("sys:role:normal") - public Result update(@PathVariable String id, @RequestBody @Valid AgentUpdateDTO dto) { - agentService.updateAgentById(id, dto); - return new Result<>(); - } - - @DeleteMapping("/{id}") - @Operation(summary = "删除智能体") - @RequiresPermissions("sys:role:normal") - public Result delete(@PathVariable String id) { - // 先删除关联的设备 - deviceService.deleteByAgentId(id); - // 删除关联的聊天记录 - agentChatHistoryService.deleteByAgentId(id, true, true); - // 删除关联的插件 - agentPluginMappingService.deleteByAgentId(id); - // 再删除智能体 - agentService.deleteById(id); - return new Result<>(); - } - - @GetMapping("/template") - @Operation(summary = "智能体模板模板列表") - @RequiresPermissions("sys:role:normal") - public Result> templateList() { - List list = agentTemplateService - .list(new QueryWrapper().orderByAsc("sort")); - return new Result>().ok(list); - } - - @GetMapping("/{id}/sessions") - @Operation(summary = "获取智能体会话列表") - @RequiresPermissions("sys:role:normal") - @Parameters({ - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), - }) - public Result> getAgentSessions( - @PathVariable("id") String id, - @Parameter(hidden = true) @RequestParam Map params) { - params.put("agentId", id); - PageData page = agentChatHistoryService.getSessionListByAgentId(params); - return new Result>().ok(page); - } - - @GetMapping("/{id}/chat-history/{sessionId}") - @Operation(summary = "获取智能体聊天记录") - @RequiresPermissions("sys:role:normal") - public Result> getAgentChatHistory( - @PathVariable("id") String id, - @PathVariable("sessionId") String sessionId) { - // 获取当前用户 - UserDetail user = SecurityUser.getUser(); - - // 检查权限 - if (!agentService.checkAgentPermission(id, user.getId())) { - return new Result>().error("没有权限查看该智能体的聊天记录"); - } - - // 查询聊天记录 - List result = agentChatHistoryService.getChatHistoryBySessionId(id, sessionId); - return new Result>().ok(result); - } - @GetMapping("/{id}/chat-history/user") - @Operation(summary = "获取智能体聊天记录(用户)") - @RequiresPermissions("sys:role:normal") - public Result> getRecentlyFiftyByAgentId( - @PathVariable("id") String id) { - // 获取当前用户 - UserDetail user = SecurityUser.getUser(); - - // 检查权限 - if (!agentService.checkAgentPermission(id, user.getId())) { - return new Result>().error("没有权限查看该智能体的聊天记录"); - } - - // 查询聊天记录 - List data = agentChatHistoryService.getRecentlyFiftyByAgentId(id); - return new Result>().ok(data); - } - - @GetMapping("/{id}/chat-history/audio") - @Operation(summary = "获取音频内容") - @RequiresPermissions("sys:role:normal") - public Result getContentByAudioId( - @PathVariable("id") String id) { - // 查询聊天记录 - String data = agentChatHistoryService.getContentByAudioId(id); - return new Result().ok(data); - } - - @PostMapping("/audio/{audioId}") - @Operation(summary = "获取音频下载ID") - @RequiresPermissions("sys:role:normal") - public Result getAudioId(@PathVariable("audioId") String audioId) { - byte[] audioData = agentChatAudioService.getAudio(audioId); - if (audioData == null) { - return new Result().error("音频不存在"); - } - String uuid = UUID.randomUUID().toString(); - redisUtils.set(RedisKeys.getAgentAudioIdKey(uuid), audioId); - return new Result().ok(uuid); - } - - @GetMapping("/play/{uuid}") - @Operation(summary = "播放音频") - public ResponseEntity playAudio(@PathVariable("uuid") String uuid) { - - String audioId = (String) redisUtils.get(RedisKeys.getAgentAudioIdKey(uuid)); - if (StringUtils.isBlank(audioId)) { - return ResponseEntity.notFound().build(); - } - - byte[] audioData = agentChatAudioService.getAudio(audioId); - if (audioData == null) { - return ResponseEntity.notFound().build(); - } - redisUtils.delete(RedisKeys.getAgentAudioIdKey(uuid)); - return ResponseEntity.ok() - .contentType(MediaType.APPLICATION_OCTET_STREAM) - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"play.wav\"") - .body(audioData); - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentMcpAccessPointController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentMcpAccessPointController.java deleted file mode 100644 index 3f369774c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentMcpAccessPointController.java +++ /dev/null @@ -1,66 +0,0 @@ -package xiaozhi.modules.agent.controller; - -import java.util.List; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import xiaozhi.common.user.UserDetail; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.agent.service.AgentMcpAccessPointService; -import xiaozhi.modules.agent.service.AgentService; -import xiaozhi.modules.security.user.SecurityUser; - -@Tag(name = "智能体Mcp接入点管理") -@RequiredArgsConstructor -@RestController -@RequestMapping("/agent/mcp") -public class AgentMcpAccessPointController { - private final AgentMcpAccessPointService agentMcpAccessPointService; - private final AgentService agentService; - - /** - * 获取智能体的Mcp接入点地址 - * - * @param audioId 智能体id - * @return 返回错误提醒或者Mcp接入点地址 - */ - @Operation(summary = "获取智能体的Mcp接入点地址") - @GetMapping("/address/{agentId}") - @RequiresPermissions("sys:role:normal") - public Result getAgentMcpAccessAddress(@PathVariable("agentId") String agentId) { - // 获取当前用户 - UserDetail user = SecurityUser.getUser(); - - // 检查权限 - if (!agentService.checkAgentPermission(agentId, user.getId())) { - return new Result().error("没有权限查看该智能体的MCP接入点地址"); - } - String agentMcpAccessAddress = agentMcpAccessPointService.getAgentMcpAccessAddress(agentId); - if (agentMcpAccessAddress == null) { - return new Result().ok("请联系管理员进入参数管理配置mcp接入点地址"); - } - return new Result().ok(agentMcpAccessAddress); - } - - @Operation(summary = "获取智能体的Mcp工具列表") - @GetMapping("/tools/{agentId}") - @RequiresPermissions("sys:role:normal") - public Result> getAgentMcpToolsList(@PathVariable("agentId") String agentId) { - // 获取当前用户 - UserDetail user = SecurityUser.getUser(); - - // 检查权限 - if (!agentService.checkAgentPermission(agentId, user.getId())) { - return new Result>().error("没有权限查看该智能体的MCP工具列表"); - } - List agentMcpToolsList = agentMcpAccessPointService.getAgentMcpToolsList(agentId); - return new Result>().ok(agentMcpToolsList); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentTemplateController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentTemplateController.java deleted file mode 100644 index 9c8366ed6..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentTemplateController.java +++ /dev/null @@ -1,158 +0,0 @@ -package xiaozhi.modules.agent.controller; - -import java.util.List; -import java.util.Map; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - -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 jakarta.validation.Valid; -import lombok.AllArgsConstructor; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.common.utils.Result; -import xiaozhi.common.utils.ResultUtils; -import xiaozhi.modules.agent.entity.AgentTemplateEntity; -import xiaozhi.modules.agent.service.AgentTemplateService; -import xiaozhi.modules.agent.vo.AgentTemplateVO; - -@Tag(name = "智能体模板管理") -@AllArgsConstructor -@RestController -@RequestMapping("/agent/template") -public class AgentTemplateController { - - private final AgentTemplateService agentTemplateService; - - @GetMapping("/page") - @Operation(summary = "获取模板分页列表") - @RequiresPermissions("sys:role:superAdmin") - @Parameters({ - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), - @Parameter(name = "agentName", description = "模板名称,模糊查询") - }) - public Result> getAgentTemplatesPage( - @Parameter(hidden = true) @RequestParam Map params) { - - // 创建分页对象 - int page = Integer.parseInt(params.getOrDefault(Constant.PAGE, "1").toString()); - int limit = Integer.parseInt(params.getOrDefault(Constant.LIMIT, "10").toString()); - Page pageInfo = new Page<>(page, limit); - - // 创建查询条件 - QueryWrapper wrapper = new QueryWrapper<>(); - String agentName = (String) params.get("agentName"); - if (agentName != null && !agentName.isEmpty()) { - wrapper.like("agent_name", agentName); - } - wrapper.orderByAsc("sort"); - - // 执行分页查询 - IPage pageResult = agentTemplateService.page(pageInfo, wrapper); - - // 使用ConvertUtils转换为VO列表 - List voList = ConvertUtils.sourceToTarget(pageResult.getRecords(), AgentTemplateVO.class); - - // 修复:使用构造函数创建PageData对象,而不是无参构造+setter - PageData pageData = new PageData<>(voList, pageResult.getTotal()); - - return new Result>().ok(pageData); - } - - @GetMapping("/{id}") - @Operation(summary = "获取模板详情") - @RequiresPermissions("sys:role:superAdmin") - public Result getAgentTemplateById(@PathVariable("id") String id) { - AgentTemplateEntity template = agentTemplateService.getById(id); - if (template == null) { - return ResultUtils.error("模板不存在"); - } - - // 使用ConvertUtils转换为VO - AgentTemplateVO vo = ConvertUtils.sourceToTarget(template, AgentTemplateVO.class); - - return ResultUtils.success(vo); - } - - @PostMapping - @Operation(summary = "创建模板") - @RequiresPermissions("sys:role:superAdmin") - public Result createAgentTemplate(@Valid @RequestBody AgentTemplateEntity template) { - // 设置排序值为下一个可用的序号 - template.setSort(agentTemplateService.getNextAvailableSort()); - - boolean saved = agentTemplateService.save(template); - if (saved) { - return ResultUtils.success(template); - } else { - return ResultUtils.error("创建模板失败"); - } - } - - @PutMapping - @Operation(summary = "更新模板") - @RequiresPermissions("sys:role:superAdmin") - public Result updateAgentTemplate(@Valid @RequestBody AgentTemplateEntity template) { - boolean updated = agentTemplateService.updateById(template); - if (updated) { - return ResultUtils.success(template); - } else { - return ResultUtils.error("更新模板失败"); - } - } - - @DeleteMapping("/{id}") - @Operation(summary = "删除模板") - @RequiresPermissions("sys:role:superAdmin") - public Result deleteAgentTemplate(@PathVariable("id") String id) { - // 先查询要删除的模板信息,获取其排序值 - AgentTemplateEntity template = agentTemplateService.getById(id); - if (template == null) { - return ResultUtils.error("模板不存在"); - } - - Integer deletedSort = template.getSort(); - - // 执行删除操作 - boolean deleted = agentTemplateService.removeById(id); - if (deleted) { - // 删除成功后,重新排序剩余模板 - agentTemplateService.reorderTemplatesAfterDelete(deletedSort); - return ResultUtils.success("删除模板成功"); - } else { - return ResultUtils.error("删除模板失败"); - } - } - - - // 添加新的批量删除方法,使用不同的URL - @PostMapping("/batch-remove") - @Operation(summary = "批量删除模板") - @RequiresPermissions("sys:role:superAdmin") - public Result batchRemoveAgentTemplates(@RequestBody List ids) { - boolean deleted = agentTemplateService.removeByIds(ids); - if (deleted) { - return ResultUtils.success("批量删除成功"); - } else { - return ResultUtils.error("批量删除模板失败"); - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentVoicePrintController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentVoicePrintController.java deleted file mode 100644 index 9b7555eb4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentVoicePrintController.java +++ /dev/null @@ -1,87 +0,0 @@ -package xiaozhi.modules.agent.controller; - -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import lombok.AllArgsConstructor; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.agent.dto.AgentVoicePrintSaveDTO; -import xiaozhi.modules.agent.dto.AgentVoicePrintUpdateDTO; -import xiaozhi.modules.agent.service.AgentVoicePrintService; -import xiaozhi.modules.agent.vo.AgentVoicePrintVO; -import xiaozhi.modules.security.user.SecurityUser; -import xiaozhi.modules.sys.service.SysParamsService; - -@Tag(name = "智能体声纹管理") -@AllArgsConstructor -@RestController -@RequestMapping("/agent/voice-print") -public class AgentVoicePrintController { - private final AgentVoicePrintService agentVoicePrintService; - private final SysParamsService sysParamsService; - - @PostMapping - @Operation(summary = "创建智能体的声纹") - @RequiresPermissions("sys:role:normal") - public Result save(@RequestBody @Valid AgentVoicePrintSaveDTO dto) { - boolean b = agentVoicePrintService.insert(dto); - if (b) { - return new Result<>(); - } - return new Result().error(ErrorCode.AGENT_VOICEPRINT_CREATE_FAILED); - } - - @PutMapping - @Operation(summary = "更新智能体的对应声纹") - @RequiresPermissions("sys:role:normal") - public Result update(@RequestBody @Valid AgentVoicePrintUpdateDTO dto) { - Long userId = SecurityUser.getUserId(); - boolean b = agentVoicePrintService.update(userId, dto); - if (b) { - return new Result<>(); - } - return new Result().error(ErrorCode.AGENT_VOICEPRINT_UPDATE_FAILED); - } - - @DeleteMapping("/{id}") - @Operation(summary = "删除智能体对应声纹") - @RequiresPermissions("sys:role:normal") - public Result delete(@PathVariable String id) { - Long userId = SecurityUser.getUserId(); - // 先删除关联的设备 - boolean delete = agentVoicePrintService.delete(userId, id); - if (delete) { - return new Result<>(); - } - return new Result().error(ErrorCode.AGENT_VOICEPRINT_DELETE_FAILED); - } - - @GetMapping("/list/{id}") - @Operation(summary = "获取用户指定智能体声纹列表") - @RequiresPermissions("sys:role:normal") - public Result> list(@PathVariable String id) { - String voiceprintUrl = sysParamsService.getValue("server.voice_print", true); - if (StringUtils.isBlank(voiceprintUrl) || "null".equals(voiceprintUrl)) { - throw new RenException(ErrorCode.VOICEPRINT_API_NOT_CONFIGURED); - } - Long userId = SecurityUser.getUserId(); - List list = agentVoicePrintService.list(userId, id); - return new Result>().ok(list); - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentDao.java deleted file mode 100644 index 03e569cdc..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentDao.java +++ /dev/null @@ -1,39 +0,0 @@ -package xiaozhi.modules.agent.dao; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import org.apache.ibatis.annotations.Select; -import xiaozhi.common.dao.BaseDao; -import xiaozhi.modules.agent.entity.AgentEntity; -import xiaozhi.modules.agent.vo.AgentInfoVO; - -@Mapper -public interface AgentDao extends BaseDao { - /** - * 获取智能体的设备数量 - * - * @param agentId 智能体ID - * @return 设备数量 - */ - Integer getDeviceCountByAgentId(@Param("agentId") String agentId); - - /** - * 根据设备MAC地址查询对应设备的默认智能体信息 - * - * @param macAddress 设备MAC地址 - * @return 默认智能体信息 - */ - @Select(" SELECT a.* FROM ai_device d " + - " LEFT JOIN ai_agent a ON d.agent_id = a.id " + - " WHERE d.mac_address = #{macAddress} " + - " ORDER BY d.id DESC LIMIT 1") - AgentEntity getDefaultAgentByMacAddress(@Param("macAddress") String macAddress); - - /** - * 根据id查询agent信息,包括插件信息 - * - * @param agentId 智能体ID - */ - AgentInfoVO selectAgentInfoById(@Param("agentId") String agentId); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentPluginMappingMapper.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentPluginMappingMapper.java deleted file mode 100644 index 2fe817533..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentPluginMappingMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package xiaozhi.modules.agent.dao; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import xiaozhi.modules.agent.entity.AgentPluginMapping; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import java.util.List; - -/** -* @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Mapper -* @createDate 2025-05-25 22:33:17 -* @Entity xiaozhi.modules.agent.entity.AgentPluginMapping -*/ -@Mapper -public interface AgentPluginMappingMapper extends BaseMapper { - List selectPluginsByAgentId(@Param("agentId") String agentId); -} - - - - diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentTemplateDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentTemplateDao.java deleted file mode 100644 index 48d95bef0..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentTemplateDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package xiaozhi.modules.agent.dao; - -import org.apache.ibatis.annotations.Mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import xiaozhi.modules.agent.entity.AgentTemplateEntity; - -/** - * @author chenerlei - * @description 针对表【ai_agent_template(智能体配置模板表)】的数据库操作Mapper - * @createDate 2025-03-22 11:48:18 - */ -@Mapper -public interface AgentTemplateDao extends BaseMapper { - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentVoicePrintDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentVoicePrintDao.java deleted file mode 100644 index 1a5ee3649..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AgentVoicePrintDao.java +++ /dev/null @@ -1,20 +0,0 @@ -package xiaozhi.modules.agent.dao; - -import org.apache.ibatis.annotations.Mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import xiaozhi.modules.agent.entity.AgentChatHistoryEntity; -import xiaozhi.modules.agent.entity.AgentVoicePrintEntity; - -/** - * {@link AgentChatHistoryEntity} 智能体聊天历史记录Dao对象 - * - * @author Goody - * @version 1.0, 2025/4/30 - * @since 1.0.0 - */ -@Mapper -public interface AgentVoicePrintDao extends BaseMapper { - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatAudioDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatAudioDao.java deleted file mode 100644 index 355b25acf..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatAudioDao.java +++ /dev/null @@ -1,18 +0,0 @@ -package xiaozhi.modules.agent.dao; - -import org.apache.ibatis.annotations.Mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import xiaozhi.modules.agent.entity.AgentChatAudioEntity; - -/** - * {@link AgentChatAudioEntity} 智能体聊天音频数据Dao对象 - * - * @author Goody - * @version 1.0, 2025/5/8 - * @since 1.0.0 - */ -@Mapper -public interface AiAgentChatAudioDao extends BaseMapper { -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatHistoryDao.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatHistoryDao.java deleted file mode 100644 index b75312d29..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dao/AiAgentChatHistoryDao.java +++ /dev/null @@ -1,38 +0,0 @@ -package xiaozhi.modules.agent.dao; - -import org.apache.ibatis.annotations.Mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import xiaozhi.modules.agent.entity.AgentChatHistoryEntity; - -/** - * {@link AgentChatHistoryEntity} 智能体聊天历史记录Dao对象 - * - * @author Goody - * @version 1.0, 2025/4/30 - * @since 1.0.0 - */ -@Mapper -public interface AiAgentChatHistoryDao extends BaseMapper { - /** - * 根据智能体ID删除音频 - * - * @param agentId 智能体ID - */ - void deleteAudioByAgentId(String agentId); - - /** - * 根据智能体ID删除聊天历史记录 - * - * @param agentId 智能体ID - */ - void deleteHistoryByAgentId(String agentId); - - /** - * 根据智能体ID删除音频ID - * - * @param agentId 智能体ID - */ - void deleteAudioIdByAgentId(String agentId); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryDTO.java deleted file mode 100644 index fd49e52b4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import java.util.Date; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 智能体聊天记录DTO - */ -@Data -@Schema(description = "智能体聊天记录") -public class AgentChatHistoryDTO { - @Schema(description = "创建时间") - private Date createdAt; - - @Schema(description = "消息类型: 1-用户, 2-智能体") - private Byte chatType; - - @Schema(description = "聊天内容") - private String content; - - @Schema(description = "音频ID") - private String audioId; - - @Schema(description = "MAC地址") - private String macAddress; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryReportDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryReportDTO.java deleted file mode 100644 index ae58783f3..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatHistoryReportDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.Data; - -/** - * 小智设备聊天上报请求 - * - * @author Haotian - * @version 1.0, 2025/5/8 - */ -@Data -@Schema(description = "小智设备聊天上报请求") -public class AgentChatHistoryReportDTO { - @Schema(description = "MAC地址", example = "00:11:22:33:44:55") - @NotBlank - private String macAddress; - @Schema(description = "会话ID", example = "79578c31-f1fb-426a-900e-1e934215f05a") - @NotBlank - private String sessionId; - @Schema(description = "消息类型: 1-用户, 2-智能体", example = "1") - @NotNull - private Byte chatType; - @Schema(description = "聊天内容", example = "你好呀") - @NotBlank - private String content; - @Schema(description = "base64编码的opus音频数据", example = "") - private String audioBase64; - @Schema(description = "上报时间,十位时间戳,空时默认使用当前时间", example = "1745657732") - private Long reportTime; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSessionDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSessionDTO.java deleted file mode 100644 index c65f05c66..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentChatSessionDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import java.time.LocalDateTime; - -import lombok.Data; - -/** - * 智能体会话列表DTO - */ -@Data -public class AgentChatSessionDTO { - /** - * 会话ID - */ - private String sessionId; - - /** - * 会话时间 - */ - private LocalDateTime createdAt; - - /** - * 聊天条数 - */ - private Integer chatCount; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentCreateDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentCreateDTO.java deleted file mode 100644 index 59e770075..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentCreateDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -/** - * 智能体创建DTO - * 专用于新增智能体,不包含id、agentCode和sort字段,这些字段由系统自动生成/设置默认值 - */ -@Data -@Schema(description = "智能体创建对象") -public class AgentCreateDTO implements Serializable { - private static final long serialVersionUID = 1L; - - @Schema(description = "智能体名称", example = "客服助手") - @NotBlank(message = "智能体名称不能为空") - private String agentName; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentDTO.java deleted file mode 100644 index 218ee1ebf..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import java.util.Date; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 智能体数据传输对象 - * 用于在服务层和控制器层之间传递智能体相关的数据 - */ -@Data -@Schema(description = "智能体对象") -public class AgentDTO { - @Schema(description = "智能体编码", example = "AGT_1234567890") - private String id; - - @Schema(description = "智能体名称", example = "客服助手") - private String agentName; - - @Schema(description = "语音合成模型名称", example = "tts_model_01") - private String ttsModelName; - - @Schema(description = "音色名称", example = "voice_01") - private String ttsVoiceName; - - @Schema(description = "大语言模型名称", example = "llm_model_01") - private String llmModelName; - - @Schema(description = "视觉模型名称", example = "vllm_model_01") - private String vllmModelName; - - @Schema(description = "记忆模型ID", example = "mem_model_01") - private String memModelId; - - @Schema(description = "角色设定参数", example = "你是一个专业的客服助手,负责回答用户问题并提供帮助") - private String systemPrompt; - - @Schema(description = "总结记忆", example = "构建可生长的动态记忆网络,在有限空间内保留关键信息的同时,智能维护信息演变轨迹\n" + - "根据对话记录,总结user的重要信息,以便在未来的对话中提供更个性化的服务", required = false) - private String summaryMemory; - - @Schema(description = "最后连接时间", example = "2024-03-20 10:00:00") - private Date lastConnectedAt; - - @Schema(description = "设备数量", example = "10") - private Integer deviceCount; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentMemoryDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentMemoryDTO.java deleted file mode 100644 index ed210c60a..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentMemoryDTO.java +++ /dev/null @@ -1,19 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 智能体记忆更新DTO - */ -@Data -@Schema(description = "智能体记忆更新对象") -public class AgentMemoryDTO implements Serializable { - private static final long serialVersionUID = 1L; - - @Schema(description = "总结记忆", example = "构建可生长的动态记忆网络,在有限空间内保留关键信息的同时,智能维护信息演变轨迹\n" + - "根据对话记录,总结user的重要信息,以便在未来的对话中提供更个性化的服务", required = false) - private String summaryMemory; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentUpdateDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentUpdateDTO.java deleted file mode 100644 index 0e3d9bc3d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentUpdateDTO.java +++ /dev/null @@ -1,83 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 智能体更新DTO - * 专用于更新智能体,id字段是必需的,用于标识要更新的智能体 - * 其他字段均为非必填,只更新提供的字段 - */ -@Data -@Schema(description = "智能体更新对象") -public class AgentUpdateDTO implements Serializable { - private static final long serialVersionUID = 1L; - - @Schema(description = "智能体编码", example = "AGT_1234567890", nullable = true) - private String agentCode; - - @Schema(description = "智能体名称", example = "客服助手", nullable = true) - private String agentName; - - @Schema(description = "语音识别模型标识", example = "asr_model_02", nullable = true) - private String asrModelId; - - @Schema(description = "语音活动检测标识", example = "vad_model_02", nullable = true) - private String vadModelId; - - @Schema(description = "大语言模型标识", example = "llm_model_02", nullable = true) - private String llmModelId; - - @Schema(description = "VLLM模型标识", example = "vllm_model_02", required = false) - private String vllmModelId; - - @Schema(description = "语音合成模型标识", example = "tts_model_02", required = false) - private String ttsModelId; - - @Schema(description = "音色标识", example = "voice_02", nullable = true) - private String ttsVoiceId; - - @Schema(description = "记忆模型标识", example = "mem_model_02", nullable = true) - private String memModelId; - - @Schema(description = "意图模型标识", example = "intent_model_02", nullable = true) - private String intentModelId; - - @Schema(description = "插件函数信息", nullable = true) - private List functions; - - @Schema(description = "角色设定参数", example = "你是一个专业的客服助手,负责回答用户问题并提供帮助", nullable = true) - private String systemPrompt; - - @Schema(description = "总结记忆", example = "构建可生长的动态记忆网络,在有限空间内保留关键信息的同时,智能维护信息演变轨迹\n" - + "根据对话记录,总结user的重要信息,以便在未来的对话中提供更个性化的服务", nullable = true) - private String summaryMemory; - - @Schema(description = "聊天记录配置(0不记录 1仅记录文本 2记录文本和语音)", example = "3", nullable = true) - private Integer chatHistoryConf; - - @Schema(description = "语言编码", example = "zh_CN", nullable = true) - private String langCode; - - @Schema(description = "交互语种", example = "中文", nullable = true) - private String language; - - @Schema(description = "排序", example = "1", nullable = true) - private Integer sort; - - @Data - @Schema(description = "插件函数信息") - public static class FunctionInfo implements Serializable { - @Schema(description = "插件ID", example = "plugin_01") - private String pluginId; - - @Schema(description = "函数参数信息", nullable = true) - private HashMap paramInfo; - - private static final long serialVersionUID = 1L; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintSaveDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintSaveDTO.java deleted file mode 100644 index 0ff3b0cad..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintSaveDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import lombok.Data; - -/** - * 保存智能体声纹的dto - * - * @author zjy - */ -@Data -public class AgentVoicePrintSaveDTO { - /** - * 关联的智能体id - */ - private String agentId; - /** - * 音频文件id - */ - private String audioId; - /** - * 声纹来源的人姓名 - */ - private String sourceName; - /** - * 描述声纹来源的人 - */ - private String introduce; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintUpdateDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintUpdateDTO.java deleted file mode 100644 index 60643e294..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/AgentVoicePrintUpdateDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import lombok.Data; - -/** - * 修改智能体声纹的dto - * - * @author zjy - */ -@Data -public class AgentVoicePrintUpdateDTO { - /** - * 智能体声纹id - */ - private String id; - /** - * 音频文件id - */ - private String audioId; - /** - * 声纹来源的人姓名 - */ - private String sourceName; - /** - * 描述声纹来源的人 - */ - private String introduce; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/IdentifyVoicePrintResponse.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/IdentifyVoicePrintResponse.java deleted file mode 100644 index 14ce57c2b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/IdentifyVoicePrintResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - -/** - * 声纹识别接口返回的对象 - */ -@Data -public class IdentifyVoicePrintResponse { - /** - * 最匹配的声纹id - */ - @JsonProperty("speaker_id") - private String speakerId; - /** - * 声纹的分数 - */ - private Double score; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/McpJsonRpcResponse.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/McpJsonRpcResponse.java deleted file mode 100644 index 1bd667e6d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/dto/McpJsonRpcResponse.java +++ /dev/null @@ -1,48 +0,0 @@ -package xiaozhi.modules.agent.dto; - -import lombok.Data; - -/** - * MCP JSON-RPC 响应 DTO - */ -@Data -public class McpJsonRpcResponse { - private String jsonrpc = "2.0"; - private Integer id; - private McpResult result; - private McpError error; - - public McpJsonRpcResponse() { - } - - @Data - public static class McpResult { - private String type; - private String message; - private String agent_id; - private McpTool[] tools; - - public McpResult() { - } - } - - @Data - public static class McpTool { - private String name; - private String description; - private Object inputSchema; - - public McpTool() { - } - } - - @Data - public static class McpError { - private Integer code; - private String message; - private Object data; - - public McpError() { - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatAudioEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatAudioEntity.java deleted file mode 100644 index ac30d9d49..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatAudioEntity.java +++ /dev/null @@ -1,29 +0,0 @@ -package xiaozhi.modules.agent.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -/** - * 智能体聊天音频数据表 - * - * @author Goody - * @version 1.0, 2025/5/8 - * @since 1.0.0 - */ -@Data -@TableName("ai_agent_chat_audio") -public class AgentChatAudioEntity { - /** - * 主键ID - */ - @TableId(type = IdType.ASSIGN_UUID) - private String id; - - /** - * 音频opus数据 - */ - private byte[] audio; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatHistoryEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatHistoryEntity.java deleted file mode 100644 index 679c814ab..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentChatHistoryEntity.java +++ /dev/null @@ -1,81 +0,0 @@ -package xiaozhi.modules.agent.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 智能体聊天记录表 - * - * @author Goody - * @version 1.0, 2025/4/30 - * @since 1.0.0 - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -@TableName(value = "ai_agent_chat_history") -public class AgentChatHistoryEntity { - /** - * 主键ID - */ - @TableId(type = IdType.AUTO) - private Long id; - - /** - * MAC地址 - */ - @TableField(value = "mac_address") - private String macAddress; - - /** - * 智能体id - */ - @TableField(value = "agent_id") - private String agentId; - - /** - * 会话ID - */ - @TableField(value = "session_id") - private String sessionId; - - /** - * 消息类型: 1-用户, 2-智能体 - */ - @TableField(value = "chat_type") - private Byte chatType; - - /** - * 聊天内容 - */ - @TableField(value = "content") - private String content; - - /** - * 音频base64数据 - */ - @TableField(value = "audio_id") - private String audioId; - - /** - * 创建时间 - */ - @TableField(value = "created_at") - private Date createdAt; - - /** - * 更新时间 - */ - @TableField(value = "updated_at") - private Date updatedAt; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentEntity.java deleted file mode 100644 index d92d49b82..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentEntity.java +++ /dev/null @@ -1,84 +0,0 @@ -package xiaozhi.modules.agent.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -@TableName("ai_agent") -@Schema(description = "智能体信息") -public class AgentEntity { - - @TableId(type = IdType.ASSIGN_UUID) - @Schema(description = "智能体唯一标识") - private String id; - - @Schema(description = "所属用户ID") - private Long userId; - - @Schema(description = "智能体编码") - private String agentCode; - - @Schema(description = "智能体名称") - private String agentName; - - @Schema(description = "语音识别模型标识") - private String asrModelId; - - @Schema(description = "语音活动检测标识") - private String vadModelId; - - @Schema(description = "大语言模型标识") - private String llmModelId; - - @Schema(description = "VLLM模型标识") - private String vllmModelId; - - @Schema(description = "语音合成模型标识") - private String ttsModelId; - - @Schema(description = "音色标识") - private String ttsVoiceId; - - @Schema(description = "记忆模型标识") - private String memModelId; - - @Schema(description = "意图模型标识") - private String intentModelId; - - @Schema(description = "聊天记录配置(0不记录 1仅记录文本 2记录文本和语音)") - private Integer chatHistoryConf; - - @Schema(description = "角色设定参数") - private String systemPrompt; - - @Schema(description = "总结记忆", example = "构建可生长的动态记忆网络,在有限空间内保留关键信息的同时,智能维护信息演变轨迹\n" + - "根据对话记录,总结user的重要信息,以便在未来的对话中提供更个性化的服务", required = false) - private String summaryMemory; - - @Schema(description = "语言编码") - private String langCode; - - @Schema(description = "交互语种") - private String language; - - @Schema(description = "排序") - private Integer sort; - - @Schema(description = "创建者") - private Long creator; - - @Schema(description = "创建时间") - private Date createdAt; - - @Schema(description = "更新者") - private Long updater; - - @Schema(description = "更新时间") - private Date updatedAt; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentPluginMapping.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentPluginMapping.java deleted file mode 100644 index ae99b0ebf..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentPluginMapping.java +++ /dev/null @@ -1,54 +0,0 @@ -package xiaozhi.modules.agent.entity; - -import java.io.Serializable; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * Agent与插件的唯一映射表 - * - * @TableName ai_agent_plugin_mapping - */ -@Data -@TableName(value = "ai_agent_plugin_mapping") -@Schema(description = "Agent与插件的唯一映射表") -public class AgentPluginMapping implements Serializable { - /** - * 主键 - */ - @TableId(type = IdType.ASSIGN_ID) - @Schema(description = "映射信息主键ID") - private Long id; - - /** - * 智能体ID - */ - @Schema(description = "智能体ID") - private String agentId; - - /** - * 插件ID - */ - @Schema(description = "插件ID") - private String pluginId; - - /** - * 插件参数(Json)格式 - */ - @Schema(description = "插件参数(Json)格式") - private String paramInfo; - - // 冗余字段,用于方便在根据id查询插件时,对照查出插件的Provider_code,详见dao层xml文件 - @TableField(exist = false) - @Schema(description = "插件provider_code, 对应表ai_model_provider") - private String providerCode; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTemplateEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTemplateEntity.java deleted file mode 100644 index a7704e5bb..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentTemplateEntity.java +++ /dev/null @@ -1,128 +0,0 @@ -package xiaozhi.modules.agent.entity; - -import java.io.Serializable; -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -/** - * 智能体配置模板表 - * - * @TableName ai_agent_template - */ -@TableName(value = "ai_agent_template") -@Data -public class AgentTemplateEntity implements Serializable { - /** - * 智能体唯一标识 - */ - @TableId(type = IdType.ASSIGN_UUID) - private String id; - - /** - * 智能体编码 - */ - private String agentCode; - - /** - * 智能体名称 - */ - private String agentName; - - /** - * 语音识别模型标识 - */ - private String asrModelId; - - /** - * 语音活动检测标识 - */ - private String vadModelId; - - /** - * 大语言模型标识 - */ - private String llmModelId; - - /** - * VLLM模型标识 - */ - private String vllmModelId; - - /** - * 语音合成模型标识 - */ - private String ttsModelId; - - /** - * 音色标识 - */ - private String ttsVoiceId; - - /** - * 记忆模型标识 - */ - private String memModelId; - - /** - * 意图模型标识 - */ - private String intentModelId; - - /** - * 聊天记录配置(0不记录 1仅记录文本 2记录文本和语音) - */ - private Integer chatHistoryConf; - - /** - * 角色设定参数 - */ - private String systemPrompt; - - /** - * 总结记忆 - */ - private String summaryMemory; - /** - * 语言编码 - */ - private String langCode; - - /** - * 交互语种 - */ - private String language; - - /** - * 排序权重 - */ - private Integer sort; - - /** - * 创建者 ID - */ - private Long creator; - - /** - * 创建时间 - */ - private Date createdAt; - - /** - * 更新者 ID - */ - private Long updater; - - /** - * 更新时间 - */ - private Date updatedAt; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentVoicePrintEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentVoicePrintEntity.java deleted file mode 100644 index 4998b2888..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/entity/AgentVoicePrintEntity.java +++ /dev/null @@ -1,64 +0,0 @@ -package xiaozhi.modules.agent.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -/** - * 智能体声纹表 - * - * @author zjy - */ -@TableName(value = "ai_agent_voice_print") -@Data -public class AgentVoicePrintEntity { - /** - * 主键id - */ - @TableId(type = IdType.ASSIGN_UUID) - private String id; - /** - * 关联的智能体id - */ - private String agentId; - /** - * 关联的音频id - */ - private String audioId; - /** - * 声纹来源的人姓名 - */ - private String sourceName; - /** - * 描述声纹来源的人 - */ - private String introduce; - - /** - * 创建者 - */ - @TableField(fill = FieldFill.INSERT) - private Long creator; - /** - * 创建时间 - */ - @TableField(fill = FieldFill.INSERT) - private Date createDate; - - /** - * 更新者 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updater; - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateDate; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatAudioService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatAudioService.java deleted file mode 100644 index 04be9f360..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatAudioService.java +++ /dev/null @@ -1,30 +0,0 @@ -package xiaozhi.modules.agent.service; - -import com.baomidou.mybatisplus.extension.service.IService; - -import xiaozhi.modules.agent.entity.AgentChatAudioEntity; - -/** - * 智能体聊天音频数据表处理service - * - * @author Goody - * @version 1.0, 2025/5/8 - * @since 1.0.0 - */ -public interface AgentChatAudioService extends IService { - /** - * 保存音频数据 - * - * @param audioData 音频数据 - * @return 音频ID - */ - String saveAudio(byte[] audioData); - - /** - * 获取音频数据 - * - * @param audioId 音频ID - * @return 音频数据 - */ - byte[] getAudio(String audioId); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatHistoryService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatHistoryService.java deleted file mode 100644 index 459b5a5a1..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentChatHistoryService.java +++ /dev/null @@ -1,74 +0,0 @@ -package xiaozhi.modules.agent.service; - -import java.util.List; -import java.util.Map; - -import com.baomidou.mybatisplus.extension.service.IService; - -import xiaozhi.common.page.PageData; -import xiaozhi.modules.agent.dto.AgentChatHistoryDTO; -import xiaozhi.modules.agent.dto.AgentChatSessionDTO; -import xiaozhi.modules.agent.entity.AgentChatHistoryEntity; -import xiaozhi.modules.agent.vo.AgentChatHistoryUserVO; - -/** - * 智能体聊天记录表处理service - * - * @author Goody - * @version 1.0, 2025/4/30 - * @since 1.0.0 - */ -public interface AgentChatHistoryService extends IService { - - /** - * 根据智能体ID获取会话列表 - * - * @param params 查询参数,包含agentId、page、limit - * @return 分页的会话列表 - */ - PageData getSessionListByAgentId(Map params); - - /** - * 根据会话ID获取聊天记录列表 - * - * @param agentId 智能体ID - * @param sessionId 会话ID - * @return 聊天记录列表 - */ - List getChatHistoryBySessionId(String agentId, String sessionId); - - /** - * 根据智能体ID删除聊天记录 - * - * @param agentId 智能体ID - * @param deleteAudio 是否删除音频 - * @param deleteText 是否删除文本 - */ - void deleteByAgentId(String agentId, Boolean deleteAudio, Boolean deleteText); - - /** - * 根据智能体ID获取最近50条用户的聊天记录数据(带音频数据) - * - * @param agentId 智能体id - * @return 聊天记录列表(只有用户) - */ - List getRecentlyFiftyByAgentId(String agentId); - - /** - * 根据音频数据ID获取聊天内容 - * - * @param audioId 音频id - * @return 聊天内容 - */ - String getContentByAudioId(String audioId); - - - /** - * 查询此音频id是否属于此智能体 - * - * @param audioId 音频id - * @param agentId 音频id - * @return T:属于 F:不属于 - */ - boolean isAudioOwnedByAgent(String audioId,String agentId); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentMcpAccessPointService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentMcpAccessPointService.java deleted file mode 100644 index 336ade653..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentMcpAccessPointService.java +++ /dev/null @@ -1,25 +0,0 @@ -package xiaozhi.modules.agent.service; - - -import java.util.List; - -/** - * 智能体Mcp接入点处理service - * - * @author zjy - */ -public interface AgentMcpAccessPointService { - /** - * 获取智能体的mcp接入点地址 - * @param id 智能体id - * @return mcp接入点地址 - */ - String getAgentMcpAccessAddress(String id); - - /** - * 获取智能体的mcp接入点已有的工具列表 - * @param id 智能体id - * @return 工具列表 - */ - List getAgentMcpToolsList(String id); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentPluginMappingService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentPluginMappingService.java deleted file mode 100644 index 79d97d2ed..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentPluginMappingService.java +++ /dev/null @@ -1,29 +0,0 @@ -package xiaozhi.modules.agent.service; - -import java.util.List; - -import com.baomidou.mybatisplus.extension.service.IService; - -import xiaozhi.modules.agent.entity.AgentPluginMapping; - -/** - * @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Service - * @createDate 2025-05-25 22:33:17 - */ -public interface AgentPluginMappingService extends IService { - - /** - * 根据智能体id获取插件参数 - * - * @param agentId - * @return - */ - List agentPluginParamsByAgentId(String agentId); - - /** - * 根据智能体id删除插件参数 - * - * @param agentId - */ - void deleteByAgentId(String agentId); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentService.java deleted file mode 100644 index a9d4e5bb2..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentService.java +++ /dev/null @@ -1,101 +0,0 @@ -package xiaozhi.modules.agent.service; - -import java.util.List; -import java.util.Map; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.agent.dto.AgentCreateDTO; -import xiaozhi.modules.agent.dto.AgentDTO; -import xiaozhi.modules.agent.dto.AgentUpdateDTO; -import xiaozhi.modules.agent.entity.AgentEntity; -import xiaozhi.modules.agent.vo.AgentInfoVO; - -/** - * 智能体表处理service - * - * @author Goody - * @version 1.0, 2025/4/30 - * @since 1.0.0 - */ -public interface AgentService extends BaseService { - /** - * 获取管理员智能体列表 - * - * @param params 查询参数 - * @return 分页数据 - */ - PageData adminAgentList(Map params); - - /** - * 根据ID获取智能体 - * - * @param id 智能体ID - * @return 智能体实体 - */ - AgentInfoVO getAgentById(String id); - - /** - * 插入智能体 - * - * @param entity 智能体实体 - * @return 是否成功 - */ - boolean insert(AgentEntity entity); - - /** - * 根据用户ID删除智能体 - * - * @param userId 用户ID - */ - void deleteAgentByUserId(Long userId); - - /** - * 获取用户智能体列表 - * - * @param userId 用户ID - * @return 智能体列表 - */ - List getUserAgents(Long userId); - - /** - * 根据智能体ID获取设备数量 - * - * @param agentId 智能体ID - * @return 设备数量 - */ - Integer getDeviceCountByAgentId(String agentId); - - /** - * 根据设备MAC地址查询对应设备的默认智能体信息 - * - * @param macAddress 设备MAC地址 - * @return 默认智能体信息,不存在时返回null - */ - AgentEntity getDefaultAgentByMacAddress(String macAddress); - - /** - * 检查用户是否有权限访问智能体 - * - * @param agentId 智能体ID - * @param userId 用户ID - * @return 是否有权限 - */ - boolean checkAgentPermission(String agentId, Long userId); - - /** - * 更新智能体 - * - * @param agentId 智能体ID - * @param dto 更新智能体所需的信息 - */ - void updateAgentById(String agentId, AgentUpdateDTO dto); - - /** - * 创建智能体 - * - * @param dto 创建智能体所需的信息 - * @return 创建的智能体ID - */ - String createAgent(AgentCreateDTO dto); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentTemplateService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentTemplateService.java deleted file mode 100644 index b10a67f99..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentTemplateService.java +++ /dev/null @@ -1,42 +0,0 @@ -package xiaozhi.modules.agent.service; - -import com.baomidou.mybatisplus.extension.service.IService; - -import xiaozhi.modules.agent.entity.AgentTemplateEntity; - -/** - * @author chenerlei - * @description 针对表【ai_agent_template(智能体配置模板表)】的数据库操作Service - * @createDate 2025-03-22 11:48:18 - */ -public interface AgentTemplateService extends IService { - - /** - * 获取默认模板 - * - * @return 默认模板实体 - */ - AgentTemplateEntity getDefaultTemplate(); - - /** - * 更新默认模板中的模型ID - * - * @param modelType 模型类型 - * @param modelId 模型ID - */ - void updateDefaultTemplateModelId(String modelType, String modelId); - - /** - * 删除模板后重新排序剩余模板 - * - * @param deletedSort 被删除模板的排序值 - */ - void reorderTemplatesAfterDelete(Integer deletedSort); - - /** - * 获取下一个可用的排序序号(寻找最小的未使用序号) - * - * @return 下一个可用的排序序号 - */ - Integer getNextAvailableSort(); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentVoicePrintService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentVoicePrintService.java deleted file mode 100644 index c9d38abd4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/AgentVoicePrintService.java +++ /dev/null @@ -1,50 +0,0 @@ -package xiaozhi.modules.agent.service; - -import java.util.List; - -import xiaozhi.modules.agent.dto.AgentVoicePrintSaveDTO; -import xiaozhi.modules.agent.dto.AgentVoicePrintUpdateDTO; -import xiaozhi.modules.agent.vo.AgentVoicePrintVO; - -/** - * 智能体声纹处理service - * - * @author zjy - */ -public interface AgentVoicePrintService { - /** - * 添加智能体新的声纹 - * - * @param dto 保存智能体声纹的数据 - * @return T:成功 F:失败 - */ - boolean insert(AgentVoicePrintSaveDTO dto); - - /** - * 删除智能体的指的声纹 - * - * @param userId 当前登录的用户id - * @param voicePrintId 声纹id - * @return 是否成功 T:成功 F:失败 - */ - boolean delete(Long userId, String voicePrintId); - - /** - * 获取指定智能体的所有声纹数据 - * - * @param userId 当前登录的用户id - * @param agentId 智能体id - * @return 声纹数据集合 - */ - List list(Long userId, String agentId); - - /** - * 更新智能体的指的声纹数据 - * - * @param userId 当前登录的用户id - * @param dto 修改的声纹的数据 - * @return 是否成功 T:成功 F:失败 - */ - boolean update(Long userId, AgentVoicePrintUpdateDTO dto); - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/AgentChatHistoryBizService.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/AgentChatHistoryBizService.java deleted file mode 100644 index 191b231b4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/AgentChatHistoryBizService.java +++ /dev/null @@ -1,22 +0,0 @@ -package xiaozhi.modules.agent.service.biz; - -import xiaozhi.modules.agent.dto.AgentChatHistoryReportDTO; - -/** - * 智能体聊天历史业务逻辑层 - * - * @author Goody - * @version 1.0, 2025/4/30 - * @since 1.0.0 - */ -public interface AgentChatHistoryBizService { - - /** - * 聊天上报方法 - * - * @param agentChatHistoryReportDTO 包含聊天上报所需信息的输入对象 - * 例如:设备MAC地址、文件类型、内容等 - * @return 上传结果,true表示成功,false表示失败 - */ - Boolean report(AgentChatHistoryReportDTO agentChatHistoryReportDTO); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/impl/AgentChatHistoryBizServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/impl/AgentChatHistoryBizServiceImpl.java deleted file mode 100644 index 36b59993e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/biz/impl/AgentChatHistoryBizServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package xiaozhi.modules.agent.service.biz.impl; - -import java.util.Base64; -import java.util.Date; -import java.util.Objects; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.modules.agent.dto.AgentChatHistoryReportDTO; -import xiaozhi.modules.agent.entity.AgentChatHistoryEntity; -import xiaozhi.modules.agent.entity.AgentEntity; -import xiaozhi.modules.agent.service.AgentChatAudioService; -import xiaozhi.modules.agent.service.AgentChatHistoryService; -import xiaozhi.modules.agent.service.AgentService; -import xiaozhi.modules.agent.service.biz.AgentChatHistoryBizService; -import xiaozhi.modules.device.entity.DeviceEntity; -import xiaozhi.modules.device.service.DeviceService; - -/** - * {@link AgentChatHistoryBizService} impl - * - * @author Goody - * @version 1.0, 2025/4/30 - * @since 1.0.0 - */ -@Service -@Slf4j -@RequiredArgsConstructor -public class AgentChatHistoryBizServiceImpl implements AgentChatHistoryBizService { - private final AgentService agentService; - private final AgentChatHistoryService agentChatHistoryService; - private final AgentChatAudioService agentChatAudioService; - private final RedisUtils redisUtils; - private final DeviceService deviceService; - - /** - * 处理聊天记录上报,包括文件上传和相关信息记录 - * - * @param report 包含聊天上报所需信息的输入对象 - * @return 上传结果,true表示成功,false表示失败 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Boolean report(AgentChatHistoryReportDTO report) { - String macAddress = report.getMacAddress(); - Byte chatType = report.getChatType(); - Long reportTimeMillis = null != report.getReportTime() ? report.getReportTime() * 1000 : System.currentTimeMillis(); - log.info("小智设备聊天上报请求: macAddress={}, type={} reportTime={}", macAddress, chatType, reportTimeMillis); - - // 根据设备MAC地址查询对应的默认智能体,判断是否需要上报 - AgentEntity agentEntity = agentService.getDefaultAgentByMacAddress(macAddress); - if (agentEntity == null) { - return Boolean.FALSE; - } - - Integer chatHistoryConf = agentEntity.getChatHistoryConf(); - String agentId = agentEntity.getId(); - - if (Objects.equals(chatHistoryConf, Constant.ChatHistoryConfEnum.RECORD_TEXT.getCode())) { - saveChatText(report, agentId, macAddress, null, reportTimeMillis); - } else if (Objects.equals(chatHistoryConf, Constant.ChatHistoryConfEnum.RECORD_TEXT_AUDIO.getCode())) { - String audioId = saveChatAudio(report); - saveChatText(report, agentId, macAddress, audioId, reportTimeMillis); - } - - // 更新设备最后对话时间 - redisUtils.set(RedisKeys.getAgentDeviceLastConnectedAtById(agentId), new Date()); - - // 更新设备最后连接时间 - DeviceEntity device = deviceService.getDeviceByMacAddress(macAddress); - if (device != null) { - deviceService.updateDeviceConnectionInfo(agentId, device.getId(), null); - } else { - log.warn("聊天记录上报时,未找到mac地址为 {} 的设备", macAddress); - } - - return Boolean.TRUE; - } - - /** - * base64解码report.getOpusDataBase64(),存入ai_agent_chat_audio表 - */ - private String saveChatAudio(AgentChatHistoryReportDTO report) { - String audioId = null; - - if (report.getAudioBase64() != null && !report.getAudioBase64().isEmpty()) { - try { - byte[] audioData = Base64.getDecoder().decode(report.getAudioBase64()); - audioId = agentChatAudioService.saveAudio(audioData); - log.info("音频数据保存成功,audioId={}", audioId); - } catch (Exception e) { - log.error("音频数据保存失败", e); - return null; - } - } - return audioId; - } - - /** - * 组装上报数据 - */ - private void saveChatText(AgentChatHistoryReportDTO report, String agentId, String macAddress, String audioId, Long reportTime) { - // 构建聊天记录实体 - AgentChatHistoryEntity entity = AgentChatHistoryEntity.builder() - .macAddress(macAddress) - .agentId(agentId) - .sessionId(report.getSessionId()) - .chatType(report.getChatType()) - .content(report.getContent()) - .audioId(audioId) - .createdAt(new Date(reportTime)) - // NOTE(haotian): 2025/5/26 updateAt可以不设置,重点是createAt,而且这样可以看到上报延迟 - .build(); - - // 保存数据 - agentChatHistoryService.save(entity); - - log.info("设备 {} 对应智能体 {} 上报成功", macAddress, agentId); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatAudioServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatAudioServiceImpl.java deleted file mode 100644 index efcae485b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatAudioServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package xiaozhi.modules.agent.service.impl; - -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import xiaozhi.modules.agent.dao.AiAgentChatAudioDao; -import xiaozhi.modules.agent.entity.AgentChatAudioEntity; -import xiaozhi.modules.agent.service.AgentChatAudioService; - -/** - * 智能体聊天音频数据表处理service {@link AgentChatAudioService} impl - * - * @author Goody - * @version 1.0, 2025/5/8 - * @since 1.0.0 - */ -@Service -public class AgentChatAudioServiceImpl extends ServiceImpl - implements AgentChatAudioService { - @Override - public String saveAudio(byte[] audioData) { - AgentChatAudioEntity entity = new AgentChatAudioEntity(); - entity.setAudio(audioData); - save(entity); - return entity.getId(); - } - - @Override - public byte[] getAudio(String audioId) { - AgentChatAudioEntity entity = getById(audioId); - return entity != null ? entity.getAudio() : null; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatHistoryServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatHistoryServiceImpl.java deleted file mode 100644 index 76da2fc83..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentChatHistoryServiceImpl.java +++ /dev/null @@ -1,171 +0,0 @@ -package xiaozhi.modules.agent.service.impl; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.common.utils.JsonUtils; -import xiaozhi.modules.agent.Enums.AgentChatHistoryType; -import xiaozhi.modules.agent.dao.AiAgentChatHistoryDao; -import xiaozhi.modules.agent.dto.AgentChatHistoryDTO; -import xiaozhi.modules.agent.dto.AgentChatSessionDTO; -import xiaozhi.modules.agent.entity.AgentChatHistoryEntity; -import xiaozhi.modules.agent.service.AgentChatHistoryService; -import xiaozhi.modules.agent.vo.AgentChatHistoryUserVO; - -/** - * 智能体聊天记录表处理service {@link AgentChatHistoryService} impl - * - * @author Goody - * @version 1.0, 2025/4/30 - * @since 1.0.0 - */ -@Service -public class AgentChatHistoryServiceImpl extends ServiceImpl - implements AgentChatHistoryService { - - @Override - public PageData getSessionListByAgentId(Map params) { - String agentId = (String) params.get("agentId"); - int page = Integer.parseInt(params.get(Constant.PAGE).toString()); - int limit = Integer.parseInt(params.get(Constant.LIMIT).toString()); - - // 构建查询条件 - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.select("session_id", "MAX(created_at) as created_at", "COUNT(*) as chat_count") - .eq("agent_id", agentId) - .groupBy("session_id") - .orderByDesc("created_at"); - - // 执行分页查询 - Page> pageParam = new Page<>(page, limit); - IPage> result = this.baseMapper.selectMapsPage(pageParam, wrapper); - - List records = result.getRecords().stream().map(map -> { - AgentChatSessionDTO dto = new AgentChatSessionDTO(); - dto.setSessionId((String) map.get("session_id")); - dto.setCreatedAt((LocalDateTime) map.get("created_at")); - dto.setChatCount(((Number) map.get("chat_count")).intValue()); - return dto; - }).collect(Collectors.toList()); - - return new PageData<>(records, result.getTotal()); - } - - @Override - public List getChatHistoryBySessionId(String agentId, String sessionId) { - // 构建查询条件 - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("agent_id", agentId) - .eq("session_id", sessionId) - .orderByAsc("created_at"); - - // 查询聊天记录 - List historyList = list(wrapper); - - // 转换为DTO - return ConvertUtils.sourceToTarget(historyList, AgentChatHistoryDTO.class); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteByAgentId(String agentId, Boolean deleteAudio, Boolean deleteText) { - if (deleteAudio) { - baseMapper.deleteAudioByAgentId(agentId); - } - if (deleteAudio && !deleteText) { - baseMapper.deleteAudioIdByAgentId(agentId); - } - if (deleteText) { - baseMapper.deleteHistoryByAgentId(agentId); - } - - } - - @Override - public List getRecentlyFiftyByAgentId(String agentId) { - // 构建查询条件(不添加按照创建时间排序,数据本来就是主键越大创建时间越大 - // 不添加这样可以减少排序全部数据在分页的全盘扫描消耗) - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.select(AgentChatHistoryEntity::getContent, AgentChatHistoryEntity::getAudioId) - .eq(AgentChatHistoryEntity::getAgentId, agentId) - .eq(AgentChatHistoryEntity::getChatType, AgentChatHistoryType.USER.getValue()) - .isNotNull(AgentChatHistoryEntity::getAudioId) - // 添加此行,确保查询结果按照创建时间降序排列 - // 使用id的原因:数据形式,id越大的创建时间就越晚,所以使用id的结果和创建时间降序排列结果一样 - // id作为降序排列的优势,性能高,有主键索引,不用在排序的时候重新进行排除扫描比较 - .orderByDesc(AgentChatHistoryEntity::getId); - - // 构建分页查询,查询前50页数据 - Page pageParam = new Page<>(0, 50); - IPage result = this.baseMapper.selectPage(pageParam, wrapper); - return result.getRecords().stream().map(item -> { - AgentChatHistoryUserVO vo = ConvertUtils.sourceToTarget(item, AgentChatHistoryUserVO.class); - // 处理 content 字段,确保只返回聊天内容 - if (vo != null && vo.getContent() != null) { - vo.setContent(extractContentFromString(vo.getContent())); - } - return vo; - }).toList(); - } - - /** - * 从 content 字段中提取聊天内容 - * 如果 content 是 JSON 格式(如 {"speaker": "未知说话人", "content": "现在几点了。"}),则提取 content - * 字段 - * 如果 content 是普通字符串,则直接返回 - * - * @param content 原始内容 - * @return 提取的聊天内容 - */ - private String extractContentFromString(String content) { - if (content == null || content.trim().isEmpty()) { - return content; - } - - // 尝试解析为 JSON - try { - Map jsonMap = JsonUtils.parseObject(content, Map.class); - if (jsonMap != null && jsonMap.containsKey("content")) { - Object contentObj = jsonMap.get("content"); - return contentObj != null ? contentObj.toString() : content; - } - } catch (Exception e) { - // 如果不是有效的 JSON,直接返回原内容 - } - - // 如果不是 JSON 格式或没有 content 字段,直接返回原内容 - return content; - } - - @Override - public String getContentByAudioId(String audioId) { - AgentChatHistoryEntity agentChatHistoryEntity = baseMapper - .selectOne(new LambdaQueryWrapper() - .select(AgentChatHistoryEntity::getContent) - .eq(AgentChatHistoryEntity::getAudioId, audioId)); - return agentChatHistoryEntity == null ? null : agentChatHistoryEntity.getContent(); - } - - @Override - public boolean isAudioOwnedByAgent(String audioId, String agentId) { - // 查询是否有指定音频id和智能体id的数据,如果有且只有一条说明此数据属性此智能体 - Long row = baseMapper.selectCount(new LambdaQueryWrapper() - .eq(AgentChatHistoryEntity::getAudioId, audioId) - .eq(AgentChatHistoryEntity::getAgentId, agentId)); - return row == 1; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentMcpAccessPointServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentMcpAccessPointServiceImpl.java deleted file mode 100644 index 7d96f748c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentMcpAccessPointServiceImpl.java +++ /dev/null @@ -1,234 +0,0 @@ -package xiaozhi.modules.agent.service.impl; - -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.utils.AESUtils; -import xiaozhi.common.utils.HashEncryptionUtil; -import xiaozhi.common.utils.JsonUtils; -import xiaozhi.modules.agent.Enums.XiaoZhiMcpJsonRpcJson; -import xiaozhi.modules.agent.service.AgentMcpAccessPointService; -import xiaozhi.modules.sys.service.SysParamsService; -import xiaozhi.modules.sys.utils.WebSocketClientManager; - -@AllArgsConstructor -@Service -@Slf4j -public class AgentMcpAccessPointServiceImpl implements AgentMcpAccessPointService { - private SysParamsService sysParamsService; - - @Override - public String getAgentMcpAccessAddress(String id) { - // 获取到mcp的地址 - String url = sysParamsService.getValue(Constant.SERVER_MCP_ENDPOINT, true); - if (StringUtils.isBlank(url) || "null".equals(url)) { - return null; - } - URI uri = getURI(url); - // 获取智能体mcp的url前缀 - String agentMcpUrl = getAgentMcpUrl(uri); - // 获取密钥 - String key = getSecretKey(uri); - // 获取加密的token - String encryptToken = encryptToken(id, key); - // 对token进行URL编码 - String encodedToken = URLEncoder.encode(encryptToken, StandardCharsets.UTF_8); - // 返回智能体Mcp路径的格式 - agentMcpUrl = "%s/mcp/?token=%s".formatted(agentMcpUrl, encodedToken); - return agentMcpUrl; - } - - @Override - public List getAgentMcpToolsList(String id) { - String wsUrl = getAgentMcpAccessAddress(id); - if (StringUtils.isBlank(wsUrl)) { - return List.of(); - } - - // 将 /mcp 替换为 /call - wsUrl = wsUrl.replace("/mcp/", "/call/"); - - try { - // 创建 WebSocket 连接,增加超时时间到15秒 - try (WebSocketClientManager client = WebSocketClientManager.build( - new WebSocketClientManager.Builder() - .uri(wsUrl) - .bufferSize(1024 * 1024) - .connectTimeout(8, TimeUnit.SECONDS) - .maxSessionDuration(10, TimeUnit.SECONDS))) { - - // 步骤1: 发送初始化消息并等待响应 - log.info("发送MCP初始化消息,智能体ID: {}", id); - client.sendText(XiaoZhiMcpJsonRpcJson.getInitializeJson()); - - // 等待初始化响应 (id=1) - 移除固定延迟,改为响应驱动 - List initResponses = client.listenerWithoutClose(response -> { - try { - Map jsonMap = JsonUtils.parseObject(response, Map.class); - if (jsonMap != null && Integer.valueOf(1).equals(jsonMap.get("id"))) { - // 检查是否有result字段,表示初始化成功 - return jsonMap.containsKey("result") && !jsonMap.containsKey("error"); - } - return false; - } catch (Exception e) { - log.warn("解析初始化响应失败: {}", response, e); - return false; - } - }); - - // 验证初始化响应 - boolean initSucceeded = false; - for (String response : initResponses) { - try { - Map jsonMap = JsonUtils.parseObject(response, Map.class); - if (jsonMap != null && Integer.valueOf(1).equals(jsonMap.get("id"))) { - if (jsonMap.containsKey("result")) { - log.info("MCP初始化成功,智能体ID: {}", id); - initSucceeded = true; - break; - } else if (jsonMap.containsKey("error")) { - log.error("MCP初始化失败,智能体ID: {}, 错误: {}", id, jsonMap.get("error")); - return List.of(); - } - } - } catch (Exception e) { - log.warn("处理初始化响应失败: {}", response, e); - } - } - - if (!initSucceeded) { - log.error("未收到有效的MCP初始化响应,智能体ID: {}", id); - return List.of(); - } - - // 步骤2: 发送初始化完成通知 - 只有在收到initialize响应后才发送 - log.info("发送MCP初始化完成通知,智能体ID: {}", id); - client.sendText(XiaoZhiMcpJsonRpcJson.getNotificationsInitializedJson()); - // 步骤3: 发送工具列表请求 - 立即发送,无需额外延迟 - log.info("发送MCP工具列表请求,智能体ID: {}", id); - client.sendText(XiaoZhiMcpJsonRpcJson.getToolsListJson()); - - // 等待工具列表响应 (id=2) - List toolsResponses = client.listener(response -> { - try { - Map jsonMap = JsonUtils.parseObject(response, Map.class); - return jsonMap != null && Integer.valueOf(2).equals(jsonMap.get("id")); - } catch (Exception e) { - log.warn("解析工具列表响应失败: {}", response, e); - return false; - } - }); - - // 处理工具列表响应 - for (String response : toolsResponses) { - try { - Map jsonMap = JsonUtils.parseObject(response, Map.class); - if (jsonMap != null && Integer.valueOf(2).equals(jsonMap.get("id"))) { - // 检查是否有result字段 - Object resultObj = jsonMap.get("result"); - if (resultObj instanceof Map) { - Map resultMap = (Map) resultObj; - Object toolsObj = resultMap.get("tools"); - if (toolsObj instanceof List) { - List> toolsList = (List>) toolsObj; - // 提取工具名称列表 - List result = toolsList.stream() - .map(tool -> (String) tool.get("name")) - .filter(name -> name != null) - .collect(Collectors.toList()); - log.info("成功获取MCP工具列表,智能体ID: {}, 工具数量: {}", id, result.size()); - return result; - } - } else if (jsonMap.containsKey("error")) { - log.error("获取工具列表失败,智能体ID: {}, 错误: {}", id, jsonMap.get("error")); - return List.of(); - } - } - } catch (Exception e) { - log.warn("处理工具列表响应失败: {}", response, e); - } - } - - log.warn("未找到有效的工具列表响应,智能体ID: {}", id); - return List.of(); - - } - } catch (Exception e) { - log.error("获取智能体 MCP 工具列表失败,智能体ID: {},错误原因:{}", id, e.getMessage()); - return List.of(); - } - } - - /** - * 获取URI对象 - * - * @param url 路径 - * @return URI对象 - */ - private static URI getURI(String url) { - try { - return new URI(url); - } catch (URISyntaxException e) { - log.error("路径格式不正确路径:{},\n错误信息:{}", url, e.getMessage()); - throw new RuntimeException("mcp的地址存在错误,请进入参数管理修改mcp接入点地址"); - } - } - - /** - * 获取密钥 - * - * @param uri mcp地址 - * @return 密钥 - */ - private static String getSecretKey(URI uri) { - // 获取参数 - String query = uri.getQuery(); - // 获取aes加密密钥 - String str = "key="; - return query.substring(query.indexOf(str) + str.length()); - } - - /** - * 获取智能体mcp接入点url - * - * @param uri mcp地址 - * @return 智能体mcp接入点url - */ - private String getAgentMcpUrl(URI uri) { - // 获取协议 - String wsScheme = (uri.getScheme().equals("https")) ? "wss" : "ws"; - // 获取主机,端口,路径 - String path = uri.getSchemeSpecificPart(); - // 获取到最后一个/前的path - path = path.substring(0, path.lastIndexOf("/")); - return wsScheme + ":" + path; - } - - /** - * 获取对智能体id加密的token - * - * @param agentId 智能体id - * @param key 加密密钥 - * @return 加密后token - */ - private static String encryptToken(String agentId, String key) { - // 使用md5对智能体id进行加密 - String md5 = HashEncryptionUtil.Md5hexDigest(agentId); - // aes需要加密文本 - String json = "{\"agentId\": \"%s\"}".formatted(md5); - // 加密后成token值 - return AESUtils.encrypt(key, json); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentPluginMappingServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentPluginMappingServiceImpl.java deleted file mode 100644 index 2a53d4748..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentPluginMappingServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package xiaozhi.modules.agent.service.impl; - -import java.util.List; - -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import lombok.RequiredArgsConstructor; -import xiaozhi.modules.agent.dao.AgentPluginMappingMapper; -import xiaozhi.modules.agent.entity.AgentPluginMapping; -import xiaozhi.modules.agent.service.AgentPluginMappingService; - -/** - * @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Service实现 - * @createDate 2025-05-25 22:33:17 - */ -@Service -@RequiredArgsConstructor -public class AgentPluginMappingServiceImpl extends ServiceImpl - implements AgentPluginMappingService { - private final AgentPluginMappingMapper agentPluginMappingMapper; - - @Override - public List agentPluginParamsByAgentId(String agentId) { - return agentPluginMappingMapper.selectPluginsByAgentId(agentId); - } - - @Override - public void deleteByAgentId(String agentId) { - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("agent_id", agentId); - agentPluginMappingMapper.delete(updateWrapper); - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentServiceImpl.java deleted file mode 100644 index 3556877d1..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentServiceImpl.java +++ /dev/null @@ -1,440 +0,0 @@ -package xiaozhi.modules.agent.service.impl; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import lombok.AllArgsConstructor; -import xiaozhi.common.constant.Constant; -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.common.utils.JsonUtils; -import xiaozhi.modules.agent.dao.AgentDao; -import xiaozhi.modules.agent.dto.AgentCreateDTO; -import xiaozhi.modules.agent.dto.AgentDTO; -import xiaozhi.modules.agent.dto.AgentUpdateDTO; -import xiaozhi.modules.agent.entity.AgentEntity; -import xiaozhi.modules.agent.entity.AgentPluginMapping; -import xiaozhi.modules.agent.entity.AgentTemplateEntity; -import xiaozhi.modules.agent.service.AgentChatHistoryService; -import xiaozhi.modules.agent.service.AgentPluginMappingService; -import xiaozhi.modules.agent.service.AgentService; -import xiaozhi.modules.agent.service.AgentTemplateService; -import xiaozhi.modules.agent.vo.AgentInfoVO; -import xiaozhi.modules.device.service.DeviceService; -import xiaozhi.modules.model.dto.ModelProviderDTO; -import xiaozhi.modules.model.dto.VoiceDTO; -import xiaozhi.modules.model.entity.ModelConfigEntity; -import xiaozhi.modules.model.service.ModelConfigService; -import xiaozhi.modules.model.service.ModelProviderService; -import xiaozhi.modules.security.user.SecurityUser; -import xiaozhi.modules.sys.enums.SuperAdminEnum; -import xiaozhi.modules.timbre.service.TimbreService; - -@Service -@AllArgsConstructor -public class AgentServiceImpl extends BaseServiceImpl implements AgentService { - private final AgentDao agentDao; - private final TimbreService timbreModelService; - private final ModelConfigService modelConfigService; - private final RedisUtils redisUtils; - private final DeviceService deviceService; - private final AgentPluginMappingService agentPluginMappingService; - private final AgentChatHistoryService agentChatHistoryService; - private final AgentTemplateService agentTemplateService; - private final ModelProviderService modelProviderService; - - @Override - public PageData adminAgentList(Map params) { - IPage page = agentDao.selectPage( - getPage(params, "agent_name", true), - new QueryWrapper<>()); - return new PageData<>(page.getRecords(), page.getTotal()); - } - - @Override - public AgentInfoVO getAgentById(String id) { - AgentInfoVO agent = agentDao.selectAgentInfoById(id); - - if (agent == null) { - throw new RenException(ErrorCode.AGENT_NOT_FOUND); - } - - if (agent.getMemModelId() != null && agent.getMemModelId().equals(Constant.MEMORY_NO_MEM)) { - agent.setChatHistoryConf(Constant.ChatHistoryConfEnum.IGNORE.getCode()); - if (agent.getChatHistoryConf() == null) { - agent.setChatHistoryConf(Constant.ChatHistoryConfEnum.RECORD_TEXT_AUDIO.getCode()); - } - } - // 无需额外查询插件列表,已通过SQL查询出来 - return agent; - } - - @Override - public boolean insert(AgentEntity entity) { - // 如果ID为空,自动生成一个UUID作为ID - if (entity.getId() == null || entity.getId().trim().isEmpty()) { - entity.setId(UUID.randomUUID().toString().replace("-", "")); - } - - // 如果智能体编码为空,自动生成一个带前缀的编码 - if (entity.getAgentCode() == null || entity.getAgentCode().trim().isEmpty()) { - entity.setAgentCode("AGT_" + System.currentTimeMillis()); - } - - // 如果排序字段为空,设置默认值0 - if (entity.getSort() == null) { - entity.setSort(0); - } - - return super.insert(entity); - } - - @Override - public void deleteAgentByUserId(Long userId) { - UpdateWrapper wrapper = new UpdateWrapper<>(); - wrapper.eq("user_id", userId); - baseDao.delete(wrapper); - } - - @Override - public List getUserAgents(Long userId) { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("user_id", userId); - List agents = agentDao.selectList(wrapper); - return agents.stream().map(agent -> { - AgentDTO dto = new AgentDTO(); - dto.setId(agent.getId()); - dto.setAgentName(agent.getAgentName()); - dto.setSystemPrompt(agent.getSystemPrompt()); - - // 获取 TTS 模型名称 - dto.setTtsModelName(modelConfigService.getModelNameById(agent.getTtsModelId())); - - // 获取 LLM 模型名称 - dto.setLlmModelName(modelConfigService.getModelNameById(agent.getLlmModelId())); - - // 获取 VLLM 模型名称 - dto.setVllmModelName(modelConfigService.getModelNameById(agent.getVllmModelId())); - - // 获取记忆模型名称 - dto.setMemModelId(agent.getMemModelId()); - - // 获取 TTS 音色名称 - dto.setTtsVoiceName(timbreModelService.getTimbreNameById(agent.getTtsVoiceId())); - - // 获取智能体最近的最后连接时长 - dto.setLastConnectedAt(deviceService.getLatestLastConnectionTime(agent.getId())); - - // 获取设备数量 - dto.setDeviceCount(getDeviceCountByAgentId(agent.getId())); - return dto; - }).collect(Collectors.toList()); - } - - @Override - public Integer getDeviceCountByAgentId(String agentId) { - if (StringUtils.isBlank(agentId)) { - return 0; - } - - // 先从Redis中获取 - Integer cachedCount = (Integer) redisUtils.get(RedisKeys.getAgentDeviceCountById(agentId)); - if (cachedCount != null) { - return cachedCount; - } - - // 如果Redis中没有,则从数据库查询 - Integer deviceCount = agentDao.getDeviceCountByAgentId(agentId); - - // 将结果存入Redis - if (deviceCount != null) { - redisUtils.set(RedisKeys.getAgentDeviceCountById(agentId), deviceCount, 60); - } - - return deviceCount != null ? deviceCount : 0; - } - - @Override - public AgentEntity getDefaultAgentByMacAddress(String macAddress) { - if (StringUtils.isEmpty(macAddress)) { - return null; - } - return agentDao.getDefaultAgentByMacAddress(macAddress); - } - - @Override - public boolean checkAgentPermission(String agentId, Long userId) { - if (SecurityUser.getUser() == null || SecurityUser.getUser().getId() == null) { - return false; - } - // 获取智能体信息 - AgentEntity agent = getAgentById(agentId); - if (agent == null) { - return false; - } - - // 如果是超级管理员,直接返回true - if (SecurityUser.getUser().getSuperAdmin() == SuperAdminEnum.YES.value()) { - return true; - } - - // 检查是否是智能体的所有者 - return userId.equals(agent.getUserId()); - } - - // 根据id更新智能体信息 - @Override - @Transactional(rollbackFor = Exception.class) - public void updateAgentById(String agentId, AgentUpdateDTO dto) { - // 先查询现有实体 - AgentEntity existingEntity = this.getAgentById(agentId); - if (existingEntity == null) { - throw new RenException(ErrorCode.AGENT_NOT_FOUND); - } - - // 只更新提供的非空字段 - if (dto.getAgentName() != null) { - existingEntity.setAgentName(dto.getAgentName()); - } - if (dto.getAgentCode() != null) { - existingEntity.setAgentCode(dto.getAgentCode()); - } - if (dto.getAsrModelId() != null) { - existingEntity.setAsrModelId(dto.getAsrModelId()); - } - if (dto.getVadModelId() != null) { - existingEntity.setVadModelId(dto.getVadModelId()); - } - if (dto.getLlmModelId() != null) { - existingEntity.setLlmModelId(dto.getLlmModelId()); - } - if (dto.getVllmModelId() != null) { - existingEntity.setVllmModelId(dto.getVllmModelId()); - } - if (dto.getTtsModelId() != null) { - existingEntity.setTtsModelId(dto.getTtsModelId()); - } - if (dto.getTtsVoiceId() != null) { - existingEntity.setTtsVoiceId(dto.getTtsVoiceId()); - } - if (dto.getMemModelId() != null) { - existingEntity.setMemModelId(dto.getMemModelId()); - } - if (dto.getIntentModelId() != null) { - existingEntity.setIntentModelId(dto.getIntentModelId()); - } - if (dto.getSystemPrompt() != null) { - existingEntity.setSystemPrompt(dto.getSystemPrompt()); - } - if (dto.getSummaryMemory() != null) { - existingEntity.setSummaryMemory(dto.getSummaryMemory()); - } - if (dto.getChatHistoryConf() != null) { - existingEntity.setChatHistoryConf(dto.getChatHistoryConf()); - } - if (dto.getLangCode() != null) { - existingEntity.setLangCode(dto.getLangCode()); - } - if (dto.getLanguage() != null) { - existingEntity.setLanguage(dto.getLanguage()); - } - if (dto.getSort() != null) { - existingEntity.setSort(dto.getSort()); - } - - // 更新函数插件信息 - List functions = dto.getFunctions(); - if (functions != null) { - // 1. 收集本次提交的 pluginId - List newPluginIds = functions.stream() - .map(AgentUpdateDTO.FunctionInfo::getPluginId) - .toList(); - - // 2. 查询当前agent现有的所有映射 - List existing = agentPluginMappingService.list( - new QueryWrapper() - .eq("agent_id", agentId)); - Map existMap = existing.stream() - .collect(Collectors.toMap(AgentPluginMapping::getPluginId, Function.identity())); - - // 3. 构造所有要 保存或更新 的实体 - List allToPersist = functions.stream().map(info -> { - AgentPluginMapping m = new AgentPluginMapping(); - m.setAgentId(agentId); - m.setPluginId(info.getPluginId()); - m.setParamInfo(JsonUtils.toJsonString(info.getParamInfo())); - AgentPluginMapping old = existMap.get(info.getPluginId()); - if (old != null) { - // 已存在,设置id表示更新 - m.setId(old.getId()); - } - return m; - }).toList(); - - // 4. 拆分:已有ID的走更新,无ID的走插入 - List toUpdate = allToPersist.stream() - .filter(m -> m.getId() != null) - .toList(); - List toInsert = allToPersist.stream() - .filter(m -> m.getId() == null) - .toList(); - - if (!toUpdate.isEmpty()) { - agentPluginMappingService.updateBatchById(toUpdate); - } - if (!toInsert.isEmpty()) { - agentPluginMappingService.saveBatch(toInsert); - } - - // 5. 删除本次不在提交列表里的插件映射 - List toDelete = existing.stream() - .filter(old -> !newPluginIds.contains(old.getPluginId())) - .map(AgentPluginMapping::getId) - .toList(); - if (!toDelete.isEmpty()) { - agentPluginMappingService.removeBatchByIds(toDelete); - } - } - - // 设置更新者信息 - UserDetail user = SecurityUser.getUser(); - existingEntity.setUpdater(user.getId()); - existingEntity.setUpdatedAt(new Date()); - - // 更新记忆策略 - if (existingEntity.getMemModelId() == null || existingEntity.getMemModelId().equals(Constant.MEMORY_NO_MEM)) { - // 删除所有记录 - agentChatHistoryService.deleteByAgentId(existingEntity.getId(), true, true); - existingEntity.setSummaryMemory(""); - } else if (existingEntity.getChatHistoryConf() != null && existingEntity.getChatHistoryConf() == 1) { - // 删除音频数据 - agentChatHistoryService.deleteByAgentId(existingEntity.getId(), true, false); - } - - boolean b = validateLLMIntentParams(dto.getLlmModelId(), dto.getIntentModelId()); - if (!b) { - throw new RenException(ErrorCode.LLM_INTENT_PARAMS_MISMATCH); - } - this.updateById(existingEntity); - } - - /** - * 验证大语言模型和意图识别的参数是否符合匹配 - * - * @param llmModelId 大语言模型id - * @param intentModelId 意图识别id - * @return T 匹配 : F 不匹配 - */ - private boolean validateLLMIntentParams(String llmModelId, String intentModelId) { - if (StringUtils.isBlank(llmModelId)) { - return true; - } - ModelConfigEntity llmModelData = modelConfigService.selectById(llmModelId); - String type = llmModelData.getConfigJson().get("type").toString(); - // 如果查询大语言模型是openai或者ollama,意图识别选参数都可以 - if ("openai".equals(type) || "ollama".equals(type)) { - return true; - } - // 除了openai和ollama的类型,不可以选择id为Intent_function_call(函数调用)的意图识别 - return !"Intent_function_call".equals(intentModelId); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public String createAgent(AgentCreateDTO dto) { - // 转换为实体 - AgentEntity entity = ConvertUtils.sourceToTarget(dto, AgentEntity.class); - - // 获取默认模板 - AgentTemplateEntity template = agentTemplateService.getDefaultTemplate(); - if (template != null) { - // 设置模板中的默认值 - entity.setAsrModelId(template.getAsrModelId()); - entity.setVadModelId(template.getVadModelId()); - entity.setLlmModelId(template.getLlmModelId()); - entity.setVllmModelId(template.getVllmModelId()); - entity.setTtsModelId(template.getTtsModelId()); - - if (template.getTtsVoiceId() == null && template.getTtsModelId() != null) { - ModelConfigEntity ttsModel = modelConfigService.selectById(template.getTtsModelId()); - if (ttsModel != null && ttsModel.getConfigJson() != null) { - Map config = ttsModel.getConfigJson(); - String voice = (String) config.get("voice"); - if (StringUtils.isBlank(voice)) { - voice = (String) config.get("speaker"); - } - VoiceDTO timbre = timbreModelService.getByVoiceCode(template.getTtsModelId(), voice); - if (timbre != null) { - template.setTtsVoiceId(timbre.getId()); - } - } - } - - entity.setTtsVoiceId(template.getTtsVoiceId()); - entity.setMemModelId(template.getMemModelId()); - entity.setIntentModelId(template.getIntentModelId()); - entity.setSystemPrompt(template.getSystemPrompt()); - entity.setSummaryMemory(template.getSummaryMemory()); - entity.setChatHistoryConf(template.getChatHistoryConf()); - entity.setLangCode(template.getLangCode()); - entity.setLanguage(template.getLanguage()); - } - - // 设置用户ID和创建者信息 - UserDetail user = SecurityUser.getUser(); - entity.setUserId(user.getId()); - entity.setCreator(user.getId()); - entity.setCreatedAt(new Date()); - - // 保存智能体 - insert(entity); - - // 设置默认插件 - List toInsert = new ArrayList<>(); - // 播放音乐、查天气、查新闻 - String[] pluginIds = new String[] { "SYSTEM_PLUGIN_MUSIC", "SYSTEM_PLUGIN_WEATHER", - "SYSTEM_PLUGIN_NEWS_NEWSNOW" }; - for (String pluginId : pluginIds) { - ModelProviderDTO provider = modelProviderService.getById(pluginId); - if (provider == null) { - continue; - } - AgentPluginMapping mapping = new AgentPluginMapping(); - mapping.setPluginId(pluginId); - - Map paramInfo = new HashMap<>(); - List> fields = JsonUtils.parseObject(provider.getFields(), List.class); - if (fields != null) { - for (Map field : fields) { - paramInfo.put((String) field.get("key"), field.get("default")); - } - } - mapping.setParamInfo(JsonUtils.toJsonString(paramInfo)); - mapping.setAgentId(entity.getId()); - toInsert.add(mapping); - } - // 保存默认插件 - agentPluginMappingService.saveBatch(toInsert); - return entity.getId(); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentTemplateServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentTemplateServiceImpl.java deleted file mode 100644 index 8c562edb9..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentTemplateServiceImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -package xiaozhi.modules.agent.service.impl; - -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import xiaozhi.modules.agent.dao.AgentTemplateDao; -import xiaozhi.modules.agent.entity.AgentTemplateEntity; -import xiaozhi.modules.agent.service.AgentTemplateService; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; - -/** - * @author chenerlei - * @description 针对表【ai_agent_template(智能体配置模板表)】的数据库操作Service实现 - * @createDate 2025-03-22 11:48:18 - */ -@Service -public class AgentTemplateServiceImpl extends ServiceImpl - implements AgentTemplateService { - - /** - * 获取默认模板 - * - * @return 默认模板实体 - */ - public AgentTemplateEntity getDefaultTemplate() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.orderByAsc(AgentTemplateEntity::getSort) - .last("LIMIT 1"); - return this.getOne(wrapper); - } - - /** - * 更新默认模板中的模型ID - * - * @param modelType 模型类型 - * @param modelId 模型ID - */ - @Override - public void updateDefaultTemplateModelId(String modelType, String modelId) { - modelType = modelType.toUpperCase(); - - UpdateWrapper wrapper = new UpdateWrapper<>(); - switch (modelType) { - case "ASR": - wrapper.set("asr_model_id", modelId); - break; - case "VAD": - wrapper.set("vad_model_id", modelId); - break; - case "LLM": - wrapper.set("llm_model_id", modelId); - break; - case "TTS": - wrapper.set("tts_model_id", modelId); - wrapper.set("tts_voice_id", null); - break; - case "VLLM": - wrapper.set("vllm_model_id", modelId); - break; - case "MEMORY": - wrapper.set("mem_model_id", modelId); - break; - case "INTENT": - wrapper.set("intent_model_id", modelId); - break; - } - wrapper.ge("sort", 0); - update(wrapper); - } - - @Override - public void reorderTemplatesAfterDelete(Integer deletedSort) { - if (deletedSort == null) { - return; - } - - // 查询所有排序值大于被删除模板的记录 - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.gt("sort", deletedSort) - .setSql("sort = sort - 1"); - - // 执行批量更新,将这些记录的排序值减1 - this.update(updateWrapper); - } - - @Override - public Integer getNextAvailableSort() { - // 查询所有已存在的排序值并按升序排序 - List sortValues = baseMapper.selectList(new QueryWrapper()) - .stream() - .map(AgentTemplateEntity::getSort) - .filter(Objects::nonNull) - .sorted() - .collect(Collectors.toList()); - - // 如果没有排序值,返回1 - if (sortValues.isEmpty()) { - return 1; - } - - // 寻找最小的未使用序号 - int expectedSort = 1; - for (Integer sort : sortValues) { - if (sort > expectedSort) { - // 找到空缺的序号 - return expectedSort; - } - expectedSort = sort + 1; - } - - // 如果没有空缺,返回最大序号+1 - return expectedSort; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentVoicePrintServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentVoicePrintServiceImpl.java deleted file mode 100644 index 088e46635..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/AgentVoicePrintServiceImpl.java +++ /dev/null @@ -1,411 +0,0 @@ -package xiaozhi.modules.agent.service.impl; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.concurrent.Executor; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.core.io.ByteArrayResource; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.transaction.support.TransactionTemplate; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.common.utils.JsonUtils; -import xiaozhi.modules.agent.dao.AgentVoicePrintDao; -import xiaozhi.modules.agent.dto.AgentVoicePrintSaveDTO; -import xiaozhi.modules.agent.dto.AgentVoicePrintUpdateDTO; -import xiaozhi.modules.agent.dto.IdentifyVoicePrintResponse; -import xiaozhi.modules.agent.entity.AgentVoicePrintEntity; -import xiaozhi.modules.agent.service.AgentChatAudioService; -import xiaozhi.modules.agent.service.AgentChatHistoryService; -import xiaozhi.modules.agent.service.AgentVoicePrintService; -import xiaozhi.modules.agent.vo.AgentVoicePrintVO; -import xiaozhi.modules.sys.service.SysParamsService; - -/** - * @author zjy - */ -@Service -@Slf4j -public class AgentVoicePrintServiceImpl extends ServiceImpl - implements AgentVoicePrintService { - private final AgentChatAudioService agentChatAudioService; - private final RestTemplate restTemplate; - private final SysParamsService sysParamsService; - private final AgentChatHistoryService agentChatHistoryService; - // Springboot提供的编程事务类 - private final TransactionTemplate transactionTemplate; - // 识别度 - private final Double RECOGNITION = 0.5; - private final Executor taskExecutor; - - public AgentVoicePrintServiceImpl(AgentChatAudioService agentChatAudioService, RestTemplate restTemplate, - SysParamsService sysParamsService, AgentChatHistoryService agentChatHistoryService, - TransactionTemplate transactionTemplate, @Qualifier("taskExecutor") Executor taskExecutor) { - this.agentChatAudioService = agentChatAudioService; - this.restTemplate = restTemplate; - this.sysParamsService = sysParamsService; - this.agentChatHistoryService = agentChatHistoryService; - this.transactionTemplate = transactionTemplate; - this.taskExecutor = taskExecutor; - } - - @Override - public boolean insert(AgentVoicePrintSaveDTO dto) { - // 获取音频数据 - ByteArrayResource resource = getVoicePrintAudioWAV(dto.getAgentId(), dto.getAudioId()); - // 识别一下此声音是否注册过 - IdentifyVoicePrintResponse response = identifyVoicePrint(dto.getAgentId(), resource); - if (response != null && response.getScore() > RECOGNITION) { - // 根据识别出的声纹ID查询对应的用户信息 - AgentVoicePrintEntity existingVoicePrint = baseMapper.selectById(response.getSpeakerId()); - String existingUserName = existingVoicePrint != null ? existingVoicePrint.getSourceName() : "未知用户"; - throw new RenException(ErrorCode.VOICEPRINT_ALREADY_REGISTERED, existingUserName); - } - AgentVoicePrintEntity entity = ConvertUtils.sourceToTarget(dto, AgentVoicePrintEntity.class); - // 开启事务 - return Boolean.TRUE.equals(transactionTemplate.execute(status -> { - try { - // 保存声纹信息 - int row = baseMapper.insert(entity); - // 插入一条数据,影响的数据不等于1说明出现了,保存问题回滚 - if (row != 1) { - status.setRollbackOnly(); // 标记事务回滚 - return false; - } - // 发送注册声纹请求 - registerVoicePrint(entity.getId(), resource); - return true; - } catch (RenException e) { - status.setRollbackOnly(); // 标记事务回滚 - throw e; - } catch (Exception e) { - status.setRollbackOnly(); // 标记事务回滚 - log.error("保存声纹错误原因:{}", e.getMessage()); - throw new RenException(ErrorCode.VOICE_PRINT_SAVE_ERROR); - } - })); - } - - @Override - public boolean delete(Long userId, String voicePrintId) { - // 开启事务 - boolean b = Boolean.TRUE.equals(transactionTemplate.execute(status -> { - try { - // 删除声纹,按照指定当前登录用户和智能体 - int row = baseMapper.delete(new LambdaQueryWrapper() - .eq(AgentVoicePrintEntity::getId, voicePrintId) - .eq(AgentVoicePrintEntity::getCreator, userId)); - if (row != 1) { - status.setRollbackOnly(); // 标记事务回滚 - return false; - } - - return true; - } catch (Exception e) { - status.setRollbackOnly(); // 标记事务回滚 - log.error("删除声纹存在错误原因:{}", e.getMessage()); - throw new RenException(ErrorCode.VOICEPRINT_DELETE_ERROR); - } - })); - // 数据库声纹数据删除成功才继续执行删除声纹服务的数据 - if(b){ - taskExecutor.execute(()-> { - try { - cancelVoicePrint(voicePrintId); - }catch (RuntimeException e) { - log.error("删除声纹存在运行时错误原因:{},id:{}", e.getMessage(),voicePrintId); - } - }); - } - return b; - } - - @Override - public List list(Long userId, String agentId) { - // 按照指定当前登录用户和智能体查找数据 - List list = baseMapper.selectList(new LambdaQueryWrapper() - .eq(AgentVoicePrintEntity::getAgentId, agentId) - .eq(AgentVoicePrintEntity::getCreator, userId)); - return list.stream().map(entity -> { - // 遍历转换成AgentVoicePrintVO类型 - return ConvertUtils.sourceToTarget(entity, AgentVoicePrintVO.class); - }).toList(); - - } - - @Override - public boolean update(Long userId, AgentVoicePrintUpdateDTO dto) { - AgentVoicePrintEntity agentVoicePrintEntity = baseMapper - .selectOne(new LambdaQueryWrapper() - .eq(AgentVoicePrintEntity::getId, dto.getId()) - .eq(AgentVoicePrintEntity::getCreator, userId)); - if (agentVoicePrintEntity == null) { - return false; - } - // 获取音频Id - String audioId = dto.getAudioId(); - // 获取智能体id - String agentId = agentVoicePrintEntity.getAgentId(); - ByteArrayResource resource; - // audioId不等于空,且audioId和之前的保存的音频id不一样,则需要重新获取音频数据生成声纹 - if (!StringUtils.isEmpty(audioId) && !audioId.equals(agentVoicePrintEntity.getAudioId())) { - resource = getVoicePrintAudioWAV(agentId, audioId); - - // 识别一下此声音是否注册过 - IdentifyVoicePrintResponse response = identifyVoicePrint(agentId, resource); - // 返回分数高于RECOGNITION说明这个声纹已经有了 - if (response != null && response.getScore() > RECOGNITION) { - // 判断返回的id如果不是要修改的声纹id,说明这个声纹id,现在要注册的声音已经存在且不是原来的声纹,不允许修改 - if (!response.getSpeakerId().equals(dto.getId())) { - // 根据识别出的声纹ID查询对应的用户信息 - AgentVoicePrintEntity existingVoicePrint = baseMapper.selectById(response.getSpeakerId()); - String existingUserName = existingVoicePrint != null ? existingVoicePrint.getSourceName() : "未知用户"; - throw new RenException(ErrorCode.VOICEPRINT_UPDATE_NOT_ALLOWED, existingUserName); - } - } - } else { - resource = null; - } - // 开启事务 - return Boolean.TRUE.equals(transactionTemplate.execute(status -> { - try { - AgentVoicePrintEntity entity = ConvertUtils.sourceToTarget(dto, AgentVoicePrintEntity.class); - int row = baseMapper.updateById(entity); - if (row != 1) { - status.setRollbackOnly(); // 标记事务回滚 - return false; - } - if (resource != null) { - String id = entity.getId(); - // 先注销之前这个声纹id上的声纹向量 - cancelVoicePrint(id); - // 发送注册声纹请求 - registerVoicePrint(id, resource); - } - return true; - } catch (RenException e) { - status.setRollbackOnly(); // 标记事务回滚 - throw e; - } catch (Exception e) { - status.setRollbackOnly(); // 标记事务回滚 - log.error("修改声纹错误原因:{}", e.getMessage()); - throw new RenException(ErrorCode.VOICEPRINT_UPDATE_ADMIN_ERROR); - } - })); - } - - /** - * 获取生纹接口URI对象 - * - * @return URI对象 - */ - private URI getVoicePrintURI() { - // 获取声纹接口地址 - String voicePrint = sysParamsService.getValue(Constant.SERVER_VOICE_PRINT, true); - try { - return new URI(voicePrint); - } catch (URISyntaxException e) { - log.error("路径格式不正确路径:{},\n错误信息:{}", voicePrint, e.getMessage()); - throw new RenException(ErrorCode.VOICEPRINT_API_URI_ERROR); - } - } - - /** - * 获取声纹地址基础路径 - * - * @param uri 声纹地址uri - * @return 基础路径 - */ - private String getBaseUrl(URI uri) { - String protocol = uri.getScheme(); - String host = uri.getHost(); - int port = uri.getPort(); - if (port == -1) { - return "%s://%s".formatted(protocol, host); - } else { - return "%s://%s:%s".formatted(protocol, host, port); - } - } - - /** - * 获取验证Authorization - * - * @param uri 声纹地址uri - * @return Authorization值 - */ - private String getAuthorization(URI uri) { - // 获取参数 - String query = uri.getQuery(); - // 获取aes加密密钥 - String str = "key="; - return "Bearer " + query.substring(query.indexOf(str) + str.length()); - } - - /** - * 获取声纹音频资源数据 - * - * @param audioId 音频Id - * @return 声纹音频资源数据 - */ - private ByteArrayResource getVoicePrintAudioWAV(String agentId, String audioId) { - // 判断这个音频是否属于当前智能体 - boolean b = agentChatHistoryService.isAudioOwnedByAgent(audioId, agentId); - if (!b) { - throw new RenException(ErrorCode.VOICEPRINT_AUDIO_NOT_BELONG_AGENT); - } - // 获取到音频数据 - byte[] audio = agentChatAudioService.getAudio(audioId); - // 如果音频数据为空的直接报错不进行下去 - if (audio == null || audio.length == 0) { - throw new RenException(ErrorCode.VOICEPRINT_AUDIO_EMPTY); - } - // 将字节数组包装为资源,返回 - return new ByteArrayResource(audio) { - @Override - public String getFilename() { - return "VoicePrint.WAV"; // 设置文件名 - } - }; - } - - /** - * 发送注册声纹http请求 - * - * @param id 声纹id - * @param resource 声纹音频资源 - */ - private void registerVoicePrint(String id, ByteArrayResource resource) { - // 处理声纹接口地址,获取前缀 - URI uri = getVoicePrintURI(); - String baseUrl = getBaseUrl(uri); - String requestUrl = baseUrl + "/voiceprint/register"; - // 创建请求体 - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("speaker_id", id); - body.add("file", resource); - - // 创建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", getAuthorization(uri)); - headers.setContentType(MediaType.MULTIPART_FORM_DATA); - // 创建请求体 - HttpEntity> requestEntity = new HttpEntity<>(body, headers); - // 发送 POST 请求 - ResponseEntity response = restTemplate.postForEntity(requestUrl, requestEntity, String.class); - - if (response.getStatusCode() != HttpStatus.OK) { - log.error("声纹注册失败,请求路径:{}", requestUrl); - throw new RenException(ErrorCode.VOICEPRINT_REGISTER_REQUEST_ERROR); - } - // 检查响应内容 - String responseBody = response.getBody(); - if (responseBody == null || !responseBody.contains("true")) { - log.error("声纹注册失败,请求处理失败内容:{}", responseBody == null ? "空内容" : responseBody); - throw new RenException(ErrorCode.VOICEPRINT_REGISTER_PROCESS_ERROR); - } - } - - /** - * 发送注销声纹的请求 - * - * @param voicePrintId 声纹id - */ - private void cancelVoicePrint(String voicePrintId) { - URI uri = getVoicePrintURI(); - String baseUrl = getBaseUrl(uri); - String requestUrl = baseUrl + "/voiceprint/" + voicePrintId; - // 创建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", getAuthorization(uri)); - // 创建请求体 - HttpEntity> requestEntity = new HttpEntity<>(headers); - - // 发送 POST 请求 - ResponseEntity response = restTemplate.exchange(requestUrl, HttpMethod.DELETE, requestEntity, - String.class); - if (response.getStatusCode() != HttpStatus.OK) { - log.error("声纹注销失败,请求路径:{}", requestUrl); - throw new RenException(ErrorCode.VOICEPRINT_UNREGISTER_REQUEST_ERROR); - } - // 检查响应内容 - String responseBody = response.getBody(); - if (responseBody == null || !responseBody.contains("true")) { - log.error("声纹注销失败,请求处理失败内容:{}", responseBody == null ? "空内容" : responseBody); - throw new RenException(ErrorCode.VOICEPRINT_UNREGISTER_PROCESS_ERROR); - } - } - - /** - * 发送识别声纹http请求 - * - * @param agentId 智能体id - * @param resource 声纹音频资源 - * @return 返回识别数据 - */ - private IdentifyVoicePrintResponse identifyVoicePrint(String agentId, ByteArrayResource resource) { - - // 获取该智能体所有注册的声纹 - List agentVoicePrintList = baseMapper - .selectList(new LambdaQueryWrapper() - .select(AgentVoicePrintEntity::getId) - .eq(AgentVoicePrintEntity::getAgentId, agentId)); - - // 声纹数量为0,说明还没注册过声纹不需要发生识别请求 - if (agentVoicePrintList.isEmpty()) { - return null; - } - // 处理声纹接口地址,获取前缀 - URI uri = getVoicePrintURI(); - String baseUrl = getBaseUrl(uri); - String requestUrl = baseUrl + "/voiceprint/identify"; - // 创建请求体 - MultiValueMap body = new LinkedMultiValueMap<>(); - - // 创建speaker_id参数 - String speakerIds = agentVoicePrintList.stream() - .map(AgentVoicePrintEntity::getId) - .collect(Collectors.joining(",")); - body.add("speaker_ids", speakerIds); - body.add("file", resource); - - // 创建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", getAuthorization(uri)); - headers.setContentType(MediaType.MULTIPART_FORM_DATA); - // 创建请求体 - HttpEntity> requestEntity = new HttpEntity<>(body, headers); - // 发送 POST 请求 - ResponseEntity response = restTemplate.postForEntity(requestUrl, requestEntity, String.class); - - if (response.getStatusCode() != HttpStatus.OK) { - log.error("声纹识别请求失败,请求路径:{}", requestUrl); - throw new RenException(ErrorCode.VOICEPRINT_IDENTIFY_REQUEST_ERROR); - } - // 检查响应内容 - String responseBody = response.getBody(); - if (responseBody != null) { - return JsonUtils.parseObject(responseBody, IdentifyVoicePrintResponse.class); - } - return null; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentChatHistoryUserVO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentChatHistoryUserVO.java deleted file mode 100644 index cec0427bc..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentChatHistoryUserVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package xiaozhi.modules.agent.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 智能体用户个人聊天数据的VO - */ -@Data -public class AgentChatHistoryUserVO { - @Schema(description = "聊天内容") - private String content; - - @Schema(description = "音频ID") - private String audioId; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentInfoVO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentInfoVO.java deleted file mode 100644 index d56c8bb4d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentInfoVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package xiaozhi.modules.agent.vo; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import xiaozhi.modules.agent.entity.AgentEntity; -import xiaozhi.modules.agent.entity.AgentPluginMapping; - -import java.util.List; - -/** - * Agent信息返回体VO - * 这里直接extend了Agent实体类AgentEntity,后续需要规范返回字段可以copy字段出来 - */ -@EqualsAndHashCode(callSuper = true) -@Data -public class AgentInfoVO extends AgentEntity -{ - @Schema(description = "插件列表Id") - @TableField(typeHandler = JacksonTypeHandler.class) - private List functions; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentTemplateVO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentTemplateVO.java deleted file mode 100644 index a5302e5b6..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentTemplateVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package xiaozhi.modules.agent.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import xiaozhi.modules.agent.entity.AgentTemplateEntity; - -@Data -@EqualsAndHashCode(callSuper = true) -public class AgentTemplateVO extends AgentTemplateEntity { - // 角色音色 - private String ttsModelName; - - // 角色模型 - private String llmModelName; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentVoicePrintVO.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentVoicePrintVO.java deleted file mode 100644 index b647e8b8f..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/vo/AgentVoicePrintVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package xiaozhi.modules.agent.vo; - -import lombok.Data; - -import java.util.Date; - -/** - * 展示智能体声纹列表VO - */ -@Data -public class AgentVoicePrintVO { - - /** - * 主键id - */ - private String id; - /** - * 音频文件id - */ - private String audioId; - /** - * 声纹来源的人姓名 - */ - private String sourceName; - /** - * 描述声纹来源的人 - */ - private String introduce; - /** - * 创建时间 - */ - private Date createDate; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/config/controller/ConfigController.java b/main/manager-api/src/main/java/xiaozhi/modules/config/controller/ConfigController.java deleted file mode 100644 index f21795a3e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/config/controller/ConfigController.java +++ /dev/null @@ -1,44 +0,0 @@ -package xiaozhi.modules.config.controller; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import lombok.AllArgsConstructor; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.config.dto.AgentModelsDTO; -import xiaozhi.modules.config.service.ConfigService; - -/** - * xiaozhi-server 配置获取 - * - * @since 1.0.0 - */ -@RestController -@RequestMapping("config") -@Tag(name = "参数管理") -@AllArgsConstructor -public class ConfigController { - private final ConfigService configService; - - @PostMapping("server-base") - @Operation(summary = "服务端获取配置接口") - public Result getConfig() { - Object config = configService.getConfig(true); - return new Result().ok(config); - } - - @PostMapping("agent-models") - @Operation(summary = "获取智能体模型") - public Result getAgentModels(@Valid @RequestBody AgentModelsDTO dto) { - // 效验数据 - ValidatorUtils.validateEntity(dto); - Object models = configService.getAgentModels(dto.getMacAddress(), dto.getSelectedModule()); - return new Result().ok(models); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/config/dto/AgentModelsDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/config/dto/AgentModelsDTO.java deleted file mode 100644 index 47c08a818..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/config/dto/AgentModelsDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package xiaozhi.modules.config.dto; - -import java.util.Map; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.Data; - -@Data -@Schema(description = "获取智能体模型配置DTO") -public class AgentModelsDTO { - - @NotBlank(message = "设备MAC地址不能为空") - @Schema(description = "设备MAC地址") - private String macAddress; - - @NotBlank(message = "客户端ID不能为空") - @Schema(description = "客户端ID") - private String clientId; - - @NotNull(message = "客户端已实例化的模型不能为空") - @Schema(description = "客户端已实例化的模型") - private Map selectedModule; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/config/init/SystemInitConfig.java b/main/manager-api/src/main/java/xiaozhi/modules/config/init/SystemInitConfig.java deleted file mode 100644 index e47cd0c75..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/config/init/SystemInitConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package xiaozhi.modules.config.init; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; - -import jakarta.annotation.PostConstruct; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.modules.config.service.ConfigService; -import xiaozhi.modules.sys.service.SysParamsService; - -@Configuration -@DependsOn("liquibase") -public class SystemInitConfig { - - @Autowired - private SysParamsService sysParamsService; - - @Autowired - private ConfigService configService; - - @Autowired - private RedisUtils redisUtils; - - @PostConstruct - public void init() { - // 检查版本号 - String redisVersion = (String) redisUtils.get(RedisKeys.getVersionKey()); - if (!Constant.VERSION.equals(redisVersion)) { - // 如果版本不一致,清空Redis - redisUtils.emptyAll(); - // 存储新版本号 - redisUtils.set(RedisKeys.getVersionKey(), Constant.VERSION); - } - - sysParamsService.initServerSecret(); - configService.getConfig(false); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/config/service/ConfigService.java b/main/manager-api/src/main/java/xiaozhi/modules/config/service/ConfigService.java deleted file mode 100644 index 93845e8ec..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/config/service/ConfigService.java +++ /dev/null @@ -1,22 +0,0 @@ -package xiaozhi.modules.config.service; - -import java.util.Map; - -public interface ConfigService { - /** - * 获取服务器配置 - * - * @param isCache 是否缓存 - * @return 配置信息 - */ - Object getConfig(Boolean isCache); - - /** - * 获取智能体模型配置 - * - * @param macAddress MAC地址 - * @param selectedModule 客户端已实例化的模型 - * @return 模型配置信息 - */ - Map getAgentModels(String macAddress, Map selectedModule); -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java deleted file mode 100644 index a34c73ddd..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java +++ /dev/null @@ -1,472 +0,0 @@ -package xiaozhi.modules.config.service.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; - -import lombok.AllArgsConstructor; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.common.utils.JsonUtils; -import xiaozhi.modules.agent.dao.AgentVoicePrintDao; -import xiaozhi.modules.agent.entity.AgentEntity; -import xiaozhi.modules.agent.entity.AgentPluginMapping; -import xiaozhi.modules.agent.entity.AgentTemplateEntity; -import xiaozhi.modules.agent.entity.AgentVoicePrintEntity; -import xiaozhi.modules.agent.service.AgentMcpAccessPointService; -import xiaozhi.modules.agent.service.AgentPluginMappingService; -import xiaozhi.modules.agent.service.AgentService; -import xiaozhi.modules.agent.service.AgentTemplateService; -import xiaozhi.modules.agent.vo.AgentVoicePrintVO; -import xiaozhi.modules.config.service.ConfigService; -import xiaozhi.modules.device.entity.DeviceEntity; -import xiaozhi.modules.device.service.DeviceService; -import xiaozhi.modules.model.entity.ModelConfigEntity; -import xiaozhi.modules.model.service.ModelConfigService; -import xiaozhi.modules.sys.dto.SysParamsDTO; -import xiaozhi.modules.sys.service.SysParamsService; -import xiaozhi.modules.timbre.service.TimbreService; -import xiaozhi.modules.timbre.vo.TimbreDetailsVO; -import xiaozhi.modules.voiceclone.entity.VoiceCloneEntity; -import xiaozhi.modules.voiceclone.service.VoiceCloneService; - -@Service -@AllArgsConstructor -public class ConfigServiceImpl implements ConfigService { - private final SysParamsService sysParamsService; - private final DeviceService deviceService; - private final ModelConfigService modelConfigService; - private final AgentService agentService; - private final AgentTemplateService agentTemplateService; - private final RedisUtils redisUtils; - private final TimbreService timbreService; - private final AgentPluginMappingService agentPluginMappingService; - private final AgentMcpAccessPointService agentMcpAccessPointService; - private final VoiceCloneService cloneVoiceService; - private final AgentVoicePrintDao agentVoicePrintDao; - - @Override - public Object getConfig(Boolean isCache) { - if (isCache) { - // 先从Redis获取配置 - Object cachedConfig = redisUtils.get(RedisKeys.getServerConfigKey()); - if (cachedConfig != null) { - return cachedConfig; - } - } - - // 构建配置信息 - Map result = new HashMap<>(); - buildConfig(result); - - // 查询默认智能体 - AgentTemplateEntity agent = agentTemplateService.getDefaultTemplate(); - if (agent == null) { - throw new RenException("默认智能体未找到"); - } - - // 构建模块配置 - buildModuleConfig( - null, - null, - null, - null, - null, - null, - agent.getVadModelId(), - agent.getAsrModelId(), - null, - null, - null, - null, - null, - result, - isCache); - - // 将配置存入Redis - redisUtils.set(RedisKeys.getServerConfigKey(), result); - - return result; - } - - @Override - public Map getAgentModels(String macAddress, Map selectedModule) { - // 根据MAC地址查找设备 - DeviceEntity device = deviceService.getDeviceByMacAddress(macAddress); - if (device == null) { - // 如果设备,去redis里看看有没有需要连接的设备 - String cachedCode = deviceService.geCodeByDeviceId(macAddress); - if (StringUtils.isNotBlank(cachedCode)) { - throw new RenException(ErrorCode.OTA_DEVICE_NEED_BIND, cachedCode); - } - throw new RenException(ErrorCode.OTA_DEVICE_NOT_FOUND, "not found device"); - } - - // 获取智能体信息 - AgentEntity agent = agentService.getAgentById(device.getAgentId()); - if (agent == null) { - throw new RenException("智能体未找到"); - } - // 获取音色信息 - String voice = null; - String referenceAudio = null; - String referenceText = null; - TimbreDetailsVO timbre = timbreService.get(agent.getTtsVoiceId()); - if (timbre != null) { - voice = timbre.getTtsVoice(); - referenceAudio = timbre.getReferenceAudio(); - referenceText = timbre.getReferenceText(); - } else { - VoiceCloneEntity voice_print = cloneVoiceService.selectById(agent.getTtsVoiceId()); - if (voice_print != null) { - voice = voice_print.getVoiceId(); - } - } - // 构建返回数据 - Map result = new HashMap<>(); - // 获取单台设备每天最多输出字数 - String deviceMaxOutputSize = sysParamsService.getValue("device_max_output_size", true); - result.put("device_max_output_size", deviceMaxOutputSize); - - // 获取聊天记录配置 - Integer chatHistoryConf = agent.getChatHistoryConf(); - if (agent.getMemModelId() != null && agent.getMemModelId().equals(Constant.MEMORY_NO_MEM)) { - chatHistoryConf = Constant.ChatHistoryConfEnum.IGNORE.getCode(); - } else if (agent.getMemModelId() != null - && !agent.getMemModelId().equals(Constant.MEMORY_NO_MEM) - && agent.getChatHistoryConf() == null) { - chatHistoryConf = Constant.ChatHistoryConfEnum.RECORD_TEXT_AUDIO.getCode(); - } - result.put("chat_history_conf", chatHistoryConf); - // 如果客户端已实例化模型,则不返回 - String alreadySelectedVadModelId = (String) selectedModule.get("VAD"); - if (alreadySelectedVadModelId != null && alreadySelectedVadModelId.equals(agent.getVadModelId())) { - agent.setVadModelId(null); - } - String alreadySelectedAsrModelId = (String) selectedModule.get("ASR"); - if (alreadySelectedAsrModelId != null && alreadySelectedAsrModelId.equals(agent.getAsrModelId())) { - agent.setAsrModelId(null); - } - - // 添加函数调用参数信息 - if (!Objects.equals(agent.getIntentModelId(), "Intent_nointent")) { - String agentId = agent.getId(); - List pluginMappings = agentPluginMappingService.agentPluginParamsByAgentId(agentId); - if (pluginMappings != null && !pluginMappings.isEmpty()) { - Map pluginParams = new HashMap<>(); - for (AgentPluginMapping pluginMapping : pluginMappings) { - pluginParams.put(pluginMapping.getProviderCode(), pluginMapping.getParamInfo()); - } - result.put("plugins", pluginParams); - } - } - // 获取mcp接入点地址 - String mcpEndpoint = agentMcpAccessPointService.getAgentMcpAccessAddress(agent.getId()); - if (StringUtils.isNotBlank(mcpEndpoint) && mcpEndpoint.startsWith("ws")) { - mcpEndpoint = mcpEndpoint.replace("/mcp/", "/call/"); - result.put("mcp_endpoint", mcpEndpoint); - } - // 获取声纹信息 - buildVoiceprintConfig(agent.getId(), result); - - // 构建模块配置 - buildModuleConfig( - agent.getAgentName(), - agent.getSystemPrompt(), - agent.getSummaryMemory(), - voice, - referenceAudio, - referenceText, - agent.getVadModelId(), - agent.getAsrModelId(), - agent.getLlmModelId(), - agent.getVllmModelId(), - agent.getTtsModelId(), - agent.getMemModelId(), - agent.getIntentModelId(), - result, - true); - - return result; - } - - /** - * 构建配置信息 - * - * @param config 系统参数列表 - * @return 配置信息 - */ - private Object buildConfig(Map config) { - - // 查询所有系统参数 - List paramsList = sysParamsService.list(new HashMap<>()); - - for (SysParamsDTO param : paramsList) { - String[] keys = param.getParamCode().split("\\."); - Map current = config; - - // 遍历除最后一个key之外的所有key - for (int i = 0; i < keys.length - 1; i++) { - String key = keys[i]; - if (!current.containsKey(key)) { - current.put(key, new HashMap()); - } - current = (Map) current.get(key); - } - - // 处理最后一个key - String lastKey = keys[keys.length - 1]; - String value = param.getParamValue(); - - // 根据valueType转换值 - switch (param.getValueType().toLowerCase()) { - case "number": - try { - double doubleValue = Double.parseDouble(value); - // 如果数值是整数形式,则转换为Integer - if (doubleValue == (int) doubleValue) { - current.put(lastKey, (int) doubleValue); - } else { - current.put(lastKey, doubleValue); - } - } catch (NumberFormatException e) { - current.put(lastKey, value); - } - break; - case "boolean": - current.put(lastKey, Boolean.parseBoolean(value)); - break; - case "array": - // 将分号分隔的字符串转换为数字数组 - List list = new ArrayList<>(); - for (String num : value.split(";")) { - if (StringUtils.isNotBlank(num)) { - list.add(num.trim()); - } - } - current.put(lastKey, list); - break; - case "json": - try { - current.put(lastKey, JsonUtils.parseObject(value, Object.class)); - } catch (Exception e) { - current.put(lastKey, value); - } - break; - default: - current.put(lastKey, value); - } - } - - return config; - } - - /** - * 构建声纹配置信息 - * - * @param agentId 智能体ID - * @param result 结果Map - */ - private void buildVoiceprintConfig(String agentId, Map result) { - try { - // 获取声纹接口地址 - String voiceprintUrl = sysParamsService.getValue("server.voice_print", true); - if (StringUtils.isBlank(voiceprintUrl) || "null".equals(voiceprintUrl)) { - return; - } - - // 获取智能体关联的声纹信息(不需要用户权限验证) - List voiceprints = getVoiceprintsByAgentId(agentId); - if (voiceprints == null || voiceprints.isEmpty()) { - return; - } - - // 构建speakers列表 - List speakers = new ArrayList<>(); - for (AgentVoicePrintVO voiceprint : voiceprints) { - String speakerStr = String.format("%s,%s,%s", - voiceprint.getId(), - voiceprint.getSourceName(), - voiceprint.getIntroduce() != null ? voiceprint.getIntroduce() : ""); - speakers.add(speakerStr); - } - - // 构建声纹配置 - Map voiceprintConfig = new HashMap<>(); - voiceprintConfig.put("url", voiceprintUrl); - voiceprintConfig.put("speakers", speakers); - - // 获取声纹识别相似度阈值,默认0.4 - String thresholdStr = sysParamsService.getValue("server.voiceprint_similarity_threshold", true); - if (StringUtils.isNotBlank(thresholdStr) && !"null".equals(thresholdStr)) { - try { - double threshold = Double.parseDouble(thresholdStr); - voiceprintConfig.put("similarity_threshold", threshold); - } catch (NumberFormatException e) { - // 如果解析失败,使用默认值0.4 - voiceprintConfig.put("similarity_threshold", 0.4); - } - } else { - voiceprintConfig.put("similarity_threshold", 0.4); - } - - result.put("voiceprint", voiceprintConfig); - } catch (Exception e) { - // 声纹配置获取失败时不影响其他功能 - System.err.println("获取声纹配置失败: " + e.getMessage()); - } - } - - /** - * 获取智能体关联的声纹信息 - * - * @param agentId 智能体ID - * @return 声纹信息列表 - */ - private List getVoiceprintsByAgentId(String agentId) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(AgentVoicePrintEntity::getAgentId, agentId); - queryWrapper.orderByAsc(AgentVoicePrintEntity::getCreateDate); - List entities = agentVoicePrintDao.selectList(queryWrapper); - return ConvertUtils.sourceToTarget(entities, AgentVoicePrintVO.class); - } - - /** - * 构建模块配置 - * - * @param prompt 提示词 - * @param voice 音色 - * @param referenceAudio 参考音频路径 - * @param referenceText 参考文本 - * @param vadModelId VAD模型ID - * @param asrModelId ASR模型ID - * @param llmModelId LLM模型ID - * @param ttsModelId TTS模型ID - * @param memModelId 记忆模型ID - * @param intentModelId 意图模型ID - * @param result 结果Map - */ - private void buildModuleConfig( - String assistantName, - String prompt, - String summaryMemory, - String voice, - String referenceAudio, - String referenceText, - String vadModelId, - String asrModelId, - String llmModelId, - String vllmModelId, - String ttsModelId, - String memModelId, - String intentModelId, - Map result, - boolean isCache) { - Map selectedModule = new HashMap<>(); - - String[] modelTypes = { "VAD", "ASR", "TTS", "Memory", "Intent", "LLM", "VLLM" }; - String[] modelIds = { vadModelId, asrModelId, ttsModelId, memModelId, intentModelId, llmModelId, vllmModelId }; - String intentLLMModelId = null; - String memLocalShortLLMModelId = null; - - for (int i = 0; i < modelIds.length; i++) { - if (modelIds[i] == null) { - continue; - } - // 关键:第三个参数传false,确保获取原始密钥 - ModelConfigEntity model = modelConfigService.getModelByIdFromCache(modelIds[i]); - if (model == null) { - continue; - } - Map typeConfig = new HashMap<>(); - if (model.getConfigJson() != null) { - typeConfig.put(model.getId(), model.getConfigJson()); - // 如果是TTS类型,添加private_voice属性 - if ("TTS".equals(modelTypes[i])) { - if (voice != null) - ((Map) model.getConfigJson()).put("private_voice", voice); - if (referenceAudio != null) - ((Map) model.getConfigJson()).put("ref_audio", referenceAudio); - if (referenceText != null) - ((Map) model.getConfigJson()).put("ref_text", referenceText); - - // 火山引擎声音克隆需要替换resource_id - Map map = (Map) model.getConfigJson(); - if (Constant.VOICE_CLONE_HUOSHAN_DOUBLE_STREAM.equals(map.get("type"))) { - // 如果voice是”S_“开头的,使用seed-icl-1.0 - if (voice != null && voice.startsWith("S_")) { - map.put("resource_id", "seed-icl-1.0"); - } - } - } - // 如果是Intent类型,且type=intent_llm,则给他添加附加模型 - if ("Intent".equals(modelTypes[i])) { - Map map = (Map) model.getConfigJson(); - if ("intent_llm".equals(map.get("type"))) { - intentLLMModelId = (String) map.get("llm"); - if (StringUtils.isNotBlank(intentLLMModelId) && intentLLMModelId.equals(llmModelId)) { - intentLLMModelId = null; - } - } - if (map.get("functions") != null) { - String functionStr = (String) map.get("functions"); - if (StringUtils.isNotBlank(functionStr)) { - String[] functions = functionStr.split("\\;"); - map.put("functions", functions); - } - } - System.out.println("map: " + map); - } - if ("Memory".equals(modelTypes[i])) { - Map map = (Map) model.getConfigJson(); - if ("mem_local_short".equals(map.get("type"))) { - memLocalShortLLMModelId = (String) map.get("llm"); - if (StringUtils.isNotBlank(memLocalShortLLMModelId) - && memLocalShortLLMModelId.equals(llmModelId)) { - memLocalShortLLMModelId = null; - } - } - } - // 如果是LLM类型,且intentLLMModelId不为空,则添加附加模型 - if ("LLM".equals(modelTypes[i])) { - if (StringUtils.isNotBlank(intentLLMModelId)) { - if (!typeConfig.containsKey(intentLLMModelId)) { - // 修改这里:添加isMaskSensitive=false参数 - ModelConfigEntity intentLLM = modelConfigService.getModelByIdFromCache(intentLLMModelId); - typeConfig.put(intentLLM.getId(), intentLLM.getConfigJson()); - } - } - if (StringUtils.isNotBlank(memLocalShortLLMModelId)) { - if (!typeConfig.containsKey(memLocalShortLLMModelId)) { - // 修改这里:添加isMaskSensitive=false参数 - ModelConfigEntity memLocalShortLLM = modelConfigService - .getModelByIdFromCache(memLocalShortLLMModelId); - typeConfig.put(memLocalShortLLM.getId(), memLocalShortLLM.getConfigJson()); - } - } - } - } - result.put(modelTypes[i], typeConfig); - - selectedModule.put(modelTypes[i], model.getId()); - } - - result.put("selected_module", selectedModule); - if (StringUtils.isNotBlank(prompt)) { - prompt = prompt.replace("{{assistant_name}}", StringUtils.isBlank(assistantName) ? "小智" : assistantName); - } - result.put("prompt", prompt); - result.put("summaryMemory", summaryMemory); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java b/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java deleted file mode 100644 index a3f9d2366..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java +++ /dev/null @@ -1,211 +0,0 @@ -package xiaozhi.modules.device.controller; - -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.BeanUtils; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.common.user.UserDetail; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.device.dto.DeviceManualAddDTO; -import xiaozhi.modules.device.dto.DeviceRegisterDTO; -import xiaozhi.modules.device.dto.DeviceUnBindDTO; -import xiaozhi.modules.device.dto.DeviceUpdateDTO; -import xiaozhi.modules.device.entity.DeviceEntity; -import xiaozhi.modules.device.service.DeviceService; -import xiaozhi.modules.security.user.SecurityUser; -import xiaozhi.modules.sys.service.SysParamsService; - -@Tag(name = "设备管理") -@RestController -@RequestMapping("/device") -public class DeviceController { - private final DeviceService deviceService; - private final RedisUtils redisUtils; - private final SysParamsService sysParamsService; - private final RestTemplate restTemplate; - private final ObjectMapper objectMapper; - - public DeviceController(DeviceService deviceService, RedisUtils redisUtils, SysParamsService sysParamsService, - RestTemplate restTemplate, ObjectMapper objectMapper) { - this.deviceService = deviceService; - this.redisUtils = redisUtils; - this.sysParamsService = sysParamsService; - this.restTemplate = restTemplate; - this.objectMapper = objectMapper; - } - - @PostMapping("/bind/{agentId}/{deviceCode}") - @Operation(summary = "绑定设备") - @RequiresPermissions("sys:role:normal") - public Result bindDevice(@PathVariable String agentId, @PathVariable String deviceCode) { - deviceService.deviceActivation(agentId, deviceCode); - return new Result<>(); - } - - @PostMapping("/register") - @Operation(summary = "注册设备") - public Result registerDevice(@RequestBody DeviceRegisterDTO deviceRegisterDTO) { - String macAddress = deviceRegisterDTO.getMacAddress(); - if (StringUtils.isBlank(macAddress)) { - return new Result().error(ErrorCode.NOT_NULL, "mac地址不能为空"); - } - // 生成六位验证码 - String code = String.valueOf(Math.random()).substring(2, 8); - String key = RedisKeys.getDeviceCaptchaKey(code); - String existsMac = null; - do { - existsMac = (String) redisUtils.get(key); - } while (StringUtils.isNotBlank(existsMac)); - - redisUtils.set(key, macAddress); - return new Result().ok(code); - } - - @GetMapping("/bind/{agentId}") - @Operation(summary = "获取已绑定设备") - @RequiresPermissions("sys:role:normal") - public Result> getUserDevices(@PathVariable String agentId) { - UserDetail user = SecurityUser.getUser(); - List devices = deviceService.getUserDevices(user.getId(), agentId); - return new Result>().ok(devices); - } - - @PostMapping("/bind/{agentId}") - @Operation(summary = "设备在线接口") - @RequiresPermissions("sys:role:normal") - public Result forwardToMqttGateway(@PathVariable String agentId, @RequestBody String requestBody) { - try { - // 从系统参数中获取MQTT网关地址 - String mqttGatewayUrl = sysParamsService.getValue("server.mqtt_manager_api", true); - if (StringUtils.isBlank(mqttGatewayUrl) || "null".equals(mqttGatewayUrl)) { - return new Result<>(); - } - - // 获取当前用户的设备列表 - UserDetail user = SecurityUser.getUser(); - List devices = deviceService.getUserDevices(user.getId(), agentId); - - // 构建deviceIds数组 - java.util.List deviceIds = new java.util.ArrayList<>(); - for (DeviceEntity device : devices) { - String macAddress = device.getMacAddress() != null ? device.getMacAddress() : "unknown"; - String groupId = device.getBoard() != null ? device.getBoard() : "GID_default"; - - // 替换冒号为下划线 - groupId = groupId.replace(":", "_"); - macAddress = macAddress.replace(":", "_"); - - // 构建mqtt客户端ID格式:groupId@@@macAddress@@@macAddress - String mqttClientId = groupId + "@@@" + macAddress + "@@@" + macAddress; - deviceIds.add(mqttClientId); - } - - // 构建完整的URL - String url = "http://" + mqttGatewayUrl + "/api/devices/status"; - - // 设置请求头 - HttpHeaders headers = new HttpHeaders(); - headers.set("Content-Type", "application/json"); - - // 生成Bearer令牌 - String token = generateBearerToken(); - if (token == null) { - return new Result().error("令牌生成失败"); - } - headers.set("Authorization", "Bearer " + token); - - // 构建请求体JSON - String jsonBody = "{\"clientIds\":" + objectMapper.writeValueAsString(deviceIds) + "}"; - HttpEntity requestEntity = new HttpEntity<>(jsonBody, headers); - - // 发送POST请求 - ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); - - // 返回响应 - return new Result().ok(response.getBody()); - } catch (Exception e) { - return new Result().error("转发请求失败: " + e.getMessage()); - } - } - - private String generateBearerToken() { - try { - // 获取当前日期,格式为yyyy-MM-dd - String dateStr = java.time.LocalDate.now() - .format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")); - - // 获取MQTT签名密钥 - String signatureKey = sysParamsService.getValue("server.mqtt_signature_key", false); - if (StringUtils.isBlank(signatureKey)) { - return null; - } - - // 将日期字符串与MQTT_SIGNATURE_KEY连接 - String tokenContent = dateStr + signatureKey; - - // 对连接后的字符串进行SHA256哈希计算 - String token = org.apache.commons.codec.digest.DigestUtils.sha256Hex(tokenContent); - - return token; - } catch (Exception e) { - return null; - } - } - - @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(); - } - - @PutMapping("/update/{id}") - @Operation(summary = "更新设备信息") - @RequiresPermissions("sys:role:normal") - public Result updateDeviceInfo(@PathVariable String id, @Valid @RequestBody DeviceUpdateDTO deviceUpdateDTO) { - DeviceEntity entity = deviceService.selectById(id); - if (entity == null) { - return new Result().error("设备不存在"); - } - UserDetail user = SecurityUser.getUser(); - if (!entity.getUserId().equals(user.getId())) { - return new Result().error("设备不存在"); - } - BeanUtils.copyProperties(deviceUpdateDTO, entity); - deviceService.updateById(entity); - return new Result(); - } - - @PostMapping("/manual-add") - @Operation(summary = "手动添加设备") - @RequiresPermissions("sys:role:normal") - public Result manualAddDevice(@RequestBody @Valid DeviceManualAddDTO dto) { - UserDetail user = SecurityUser.getUser(); - deviceService.manualAddDevice(user.getId(), dto); - return new Result<>(); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/OTAController.java b/main/manager-api/src/main/java/xiaozhi/modules/device/controller/OTAController.java deleted file mode 100644 index 4a4bfee89..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/OTAController.java +++ /dev/null @@ -1,122 +0,0 @@ -package xiaozhi.modules.device.controller; - -import java.nio.charset.StandardCharsets; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -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.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.swagger.v3.oas.annotations.Hidden; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.modules.device.dto.DeviceReportReqDTO; -import xiaozhi.modules.device.dto.DeviceReportRespDTO; -import xiaozhi.modules.device.entity.DeviceEntity; -import xiaozhi.modules.device.service.DeviceService; -import xiaozhi.modules.sys.service.SysParamsService; - -@Tag(name = "设备管理", description = "OTA 相关接口") -@Slf4j -@RestController -@RequiredArgsConstructor -@RequestMapping("/ota/") -public class OTAController { - private final DeviceService deviceService; - private final SysParamsService sysParamsService; - - @Operation(summary = "OTA版本和设备激活状态检查") - @PostMapping - public ResponseEntity checkOTAVersion( - @RequestBody DeviceReportReqDTO deviceReportReqDTO, - @Parameter(name = "Device-Id", description = "设备唯一标识", required = true, in = ParameterIn.HEADER) @RequestHeader("Device-Id") String deviceId, - @Parameter(name = "Client-Id", description = "客户端标识", required = false, in = ParameterIn.HEADER) @RequestHeader(value = "Client-Id", required = false) String clientId) { - if (StringUtils.isBlank(deviceId)) { - return createResponse(DeviceReportRespDTO.createError("Device ID is required")); - } - if (StringUtils.isBlank(clientId)) { - clientId = deviceId; - } - boolean macAddressValid = isMacAddressValid(deviceId); - // 设备Id和Mac地址应是一致的, 并且必须需要application字段 - if (!macAddressValid) { - return createResponse(DeviceReportRespDTO.createError("Invalid device ID")); - } - return createResponse(deviceService.checkDeviceActive(deviceId, clientId, deviceReportReqDTO)); - } - - @Operation(summary = "设备快速检查激活状态") - @PostMapping("activate") - public ResponseEntity activateDevice( - @Parameter(name = "Device-Id", description = "设备唯一标识", required = true, in = ParameterIn.HEADER) @RequestHeader("Device-Id") String deviceId, - @Parameter(name = "Client-Id", description = "客户端标识", required = false, in = ParameterIn.HEADER) @RequestHeader(value = "Client-Id", required = false) String clientId) { - if (StringUtils.isBlank(deviceId)) { - return ResponseEntity.status(202).build(); - } - DeviceEntity device = deviceService.getDeviceByMacAddress(deviceId); - if (device == null) { - return ResponseEntity.status(202).build(); - } - return ResponseEntity.ok("success"); - } - - @GetMapping - @Hidden - public ResponseEntity getOTA() { - String mqttUdpConfig = sysParamsService.getValue(Constant.SERVER_MQTT_GATEWAY, false); - if (StringUtils.isBlank(mqttUdpConfig)) { - return ResponseEntity.ok("OTA接口不正常,缺少mqtt_gateway地址,请登录智控台,在参数管理找到【server.mqtt_gateway】配置"); - } - String wsUrl = sysParamsService.getValue(Constant.SERVER_WEBSOCKET, true); - if (StringUtils.isBlank(wsUrl) || wsUrl.equals("null")) { - return ResponseEntity.ok("OTA接口不正常,缺少websocket地址,请登录智控台,在参数管理找到【server.websocket】配置"); - } - String otaUrl = sysParamsService.getValue(Constant.SERVER_OTA, true); - if (StringUtils.isBlank(otaUrl) || otaUrl.equals("null")) { - return ResponseEntity.ok("OTA接口不正常,缺少ota地址,请登录智控台,在参数管理找到【server.ota】配置"); - } - return ResponseEntity.ok("OTA接口运行正常,websocket集群数量:" + wsUrl.split(";").length); - } - - @SneakyThrows - private ResponseEntity createResponse(DeviceReportRespDTO deviceReportRespDTO) { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - String json = objectMapper.writeValueAsString(deviceReportRespDTO); - byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8); - return ResponseEntity - .ok() - .contentType(MediaType.APPLICATION_JSON) - .contentLength(jsonBytes.length) - .body(json); - } - - /** - * 简单判断mac地址是否有效(非严格) - * - * @param macAddress - * @return - */ - private boolean isMacAddressValid(String macAddress) { - if (StringUtils.isBlank(macAddress)) { - return false; - } - // MAC地址通常为12位十六进制数字,可以包含冒号或连字符分隔符 - String macPattern = "^([0-9A-Za-z]{2}[:-]){5}([0-9A-Za-z]{2})$"; - return macAddress.matches(macPattern); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/OTAMagController.java b/main/manager-api/src/main/java/xiaozhi/modules/device/controller/OTAMagController.java deleted file mode 100644 index bbe0c66ae..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/OTAMagController.java +++ /dev/null @@ -1,291 +0,0 @@ -package xiaozhi.modules.device.controller; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -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.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.device.entity.OtaEntity; -import xiaozhi.modules.device.service.OtaService; - -@Tag(name = "设备管理", description = "OTA 相关接口") -@Slf4j -@RestController -@RequiredArgsConstructor -@RequestMapping("/otaMag") -public class OTAMagController { - private static final Logger logger = LoggerFactory.getLogger(OTAController.class); - private final OtaService otaService; - private final RedisUtils redisUtils; - - @GetMapping - @Operation(summary = "分页查询 OTA 固件信息") - @Parameters({ - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) - }) - @RequiresPermissions("sys:role:superAdmin") - public Result> page(@Parameter(hidden = true) @RequestParam Map params) { - ValidatorUtils.validateEntity(params); - PageData page = otaService.page(params); - return new Result>().ok(page); - } - - @GetMapping("{id}") - @Operation(summary = "信息 OTA 固件信息") - @RequiresPermissions("sys:role:superAdmin") - public Result get(@PathVariable("id") String id) { - OtaEntity data = otaService.selectById(id); - return new Result().ok(data); - } - - @PostMapping - @Operation(summary = "保存 OTA 固件信息") - @RequiresPermissions("sys:role:superAdmin") - public Result save(@RequestBody OtaEntity entity) { - if (entity == null) { - return new Result().error("固件信息不能为空"); - } - if (StringUtils.isBlank(entity.getFirmwareName())) { - return new Result().error("固件名称不能为空"); - } - if (StringUtils.isBlank(entity.getType())) { - return new Result().error("固件类型不能为空"); - } - if (StringUtils.isBlank(entity.getVersion())) { - return new Result().error("版本号不能为空"); - } - try { - otaService.save(entity); - return new Result(); - } catch (RuntimeException e) { - return new Result().error(e.getMessage()); - } - } - - @DeleteMapping("/{id}") - @Operation(summary = "OTA 删除") - @RequiresPermissions("sys:role:superAdmin") - public Result delete(@PathVariable("id") String[] ids) { - if (ids == null || ids.length == 0) { - return new Result().error("删除的固件ID不能为空"); - } - otaService.delete(ids); - return new Result(); - } - - @PutMapping("/{id}") - @Operation(summary = "修改 OTA 固件信息") - @RequiresPermissions("sys:role:superAdmin") - public Result update(@PathVariable("id") String id, @RequestBody OtaEntity entity) { - if (entity == null) { - return new Result<>().error("固件信息不能为空"); - } - entity.setId(id); - try { - otaService.update(entity); - return new Result<>(); - } catch (RuntimeException e) { - return new Result<>().error(e.getMessage()); - } - } - - @GetMapping("/getDownloadUrl/{id}") - @Operation(summary = "获取 OTA 固件下载链接") - @RequiresPermissions("sys:role:superAdmin") - public Result getDownloadUrl(@PathVariable("id") String id) { - String uuid = UUID.randomUUID().toString(); - redisUtils.set(RedisKeys.getOtaIdKey(uuid), id); - return new Result().ok(uuid); - } - - @GetMapping("/download/{uuid}") - @Operation(summary = "下载固件文件") - public ResponseEntity downloadFirmware(@PathVariable("uuid") String uuid) { - String id = (String) redisUtils.get(RedisKeys.getOtaIdKey(uuid)); - if (StringUtils.isBlank(id)) { - return ResponseEntity.notFound().build(); - } - - // 检查下载次数 - String downloadCountKey = RedisKeys.getOtaDownloadCountKey(uuid); - Integer downloadCount = (Integer) redisUtils.get(downloadCountKey); - if (downloadCount == null) { - downloadCount = 0; - } - - // 如果下载次数超过3次,返回404 - if (downloadCount >= 3) { - redisUtils.delete(downloadCountKey); - redisUtils.delete(RedisKeys.getOtaIdKey(uuid)); - logger.warn("Download limit exceeded for UUID: {}", uuid); - return ResponseEntity.notFound().build(); - } - - redisUtils.set(downloadCountKey, downloadCount + 1); - - try { - // 获取固件信息 - OtaEntity otaEntity = otaService.selectById(id); - if (otaEntity == null || StringUtils.isBlank(otaEntity.getFirmwarePath())) { - logger.warn("Firmware not found or path is empty for ID: {}", id); - return ResponseEntity.notFound().build(); - } - - // 获取文件路径 - 确保路径是绝对路径或正确的相对路径 - String firmwarePath = otaEntity.getFirmwarePath(); - Path path; - - // 检查是否是绝对路径 - if (Paths.get(firmwarePath).isAbsolute()) { - path = Paths.get(firmwarePath); - } else { - // 如果是相对路径,则从当前工作目录解析 - path = Paths.get(System.getProperty("user.dir"), firmwarePath); - } - - logger.info("Attempting to download firmware for ID: {}, DB path: {}, resolved path: {}", - id, firmwarePath, path.toAbsolutePath()); - - if (!Files.exists(path) || !Files.isRegularFile(path)) { - // 尝试直接从firmware目录下查找文件名 - String fileName = new File(firmwarePath).getName(); - Path altPath = Paths.get(System.getProperty("user.dir"), "firmware", fileName); - - logger.info("File not found at primary path, trying alternative path: {}", altPath.toAbsolutePath()); - - if (Files.exists(altPath) && Files.isRegularFile(altPath)) { - path = altPath; - } else { - logger.error("Firmware file not found at either path: {} or {}", - path.toAbsolutePath(), altPath.toAbsolutePath()); - return ResponseEntity.notFound().build(); - } - } - - // 读取文件内容 - byte[] fileContent = Files.readAllBytes(path); - - // 设置响应头 - String originalFilename = otaEntity.getType() + "_" + otaEntity.getVersion(); - if (firmwarePath.contains(".")) { - String extension = firmwarePath.substring(firmwarePath.lastIndexOf(".")); - originalFilename += extension; - } - - // 清理文件名,移除不安全字符 - String safeFilename = originalFilename.replaceAll("[^a-zA-Z0-9._-]", "_"); - - logger.info("Providing download for firmware ID: {}, filename: {}, size: {} bytes", - id, safeFilename, fileContent.length); - - return ResponseEntity.ok() - .contentType(MediaType.APPLICATION_OCTET_STREAM) - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + safeFilename + "\"") - .body(fileContent); - } catch (IOException e) { - logger.error("Error reading firmware file for ID: {}", id, e); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); - } catch (Exception e) { - logger.error("Unexpected error during firmware download for ID: {}", id, e); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); - } - } - - @PostMapping("/upload") - @Operation(summary = "上传固件文件") - @RequiresPermissions("sys:role:superAdmin") - public Result uploadFirmware(@RequestParam("file") MultipartFile file) { - if (file.isEmpty()) { - return new Result().error("上传文件不能为空"); - } - - // 检查文件扩展名 - String originalFilename = file.getOriginalFilename(); - if (originalFilename == null) { - return new Result().error("文件名不能为空"); - } - - String extension = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase(); - if (!extension.equals(".bin") && !extension.equals(".apk")) { - return new Result().error("只允许上传.bin和.apk格式的文件"); - } - - try { - // 计算文件的MD5值 - String md5 = calculateMD5(file); - - // 设置存储路径 - String uploadDir = "uploadfile"; - Path uploadPath = Paths.get(uploadDir); - - // 如果目录不存在,创建目录 - if (!Files.exists(uploadPath)) { - Files.createDirectories(uploadPath); - } - - // 使用MD5作为文件名,固定使用.bin扩展名 - String uniqueFileName = md5 + extension; - Path filePath = uploadPath.resolve(uniqueFileName); - - // 检查文件是否已存在 - if (Files.exists(filePath)) { - return new Result().ok(filePath.toString()); - } - - // 保存文件 - Files.copy(file.getInputStream(), filePath); - - // 返回文件路径 - return new Result().ok(filePath.toString()); - } catch (IOException | NoSuchAlgorithmException e) { - return new Result().error("文件上传失败:" + e.getMessage()); - } - } - - private String calculateMD5(MultipartFile file) throws IOException, NoSuchAlgorithmException { - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] digest = md.digest(file.getBytes()); - StringBuilder sb = new StringBuilder(); - for (byte b : digest) { - sb.append(String.format("%02x", b)); - } - return sb.toString(); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dao/DeviceDao.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dao/DeviceDao.java deleted file mode 100644 index f3fdb7a3e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dao/DeviceDao.java +++ /dev/null @@ -1,21 +0,0 @@ -package xiaozhi.modules.device.dao; - -import java.util.Date; - -import org.apache.ibatis.annotations.Mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import xiaozhi.modules.device.entity.DeviceEntity; - -@Mapper -public interface DeviceDao extends BaseMapper { - /** - * 获取此智能体全部设备的最后连接时间 - * - * @param agentId 智能体id - * @return - */ - Date getAllLastConnectedAtByAgentId(String agentId); - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dao/OtaDao.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dao/OtaDao.java deleted file mode 100644 index 975f69be1..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dao/OtaDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package xiaozhi.modules.device.dao; - -import org.apache.ibatis.annotations.Mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import xiaozhi.modules.device.entity.OtaEntity; - -/** - * OTA固件管理 - */ -@Mapper -public interface OtaDao extends BaseMapper { - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceBindDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceBindDTO.java deleted file mode 100644 index 3413c31b4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceBindDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package xiaozhi.modules.device.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; - -/** - * 设备绑定的DTO - * - * @author zjy - * @since 2025-3-28 - */ -@Data -@AllArgsConstructor -@Schema(description = "设备连接头信息") -public class DeviceBindDTO { - - @Schema(description = "mac地址") - private String macAddress; - - @Schema(description = "所属用户id") - private Long userId; - - @Schema(description = "智能体id") - private String agentId; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceManualAddDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceManualAddDTO.java deleted file mode 100644 index 369726b00..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceManualAddDTO.java +++ /dev/null @@ -1,11 +0,0 @@ -package xiaozhi.modules.device.dto; - -import lombok.Data; - -@Data -public class DeviceManualAddDTO { - private String agentId; - private String board; // 设备型号 - private String appVersion; // 固件版本 - private String macAddress; // Mac地址 -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DevicePageUserDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DevicePageUserDTO.java deleted file mode 100644 index 26bccbfd1..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DevicePageUserDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package xiaozhi.modules.device.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Min; -import lombok.Data; - -/** - * 查询所有设备的DTO - * - * @author zjy - * @since 2025-3-21 - */ -@Data -@Schema(description = "查询所有设备的DTO") -public class DevicePageUserDTO { - - @Schema(description = "设备关键词") - private String keywords; - - @Schema(description = "页数") - @Min(value = 0, message = "{page.number}") - private String page; - - @Schema(description = "显示列数") - @Min(value = 0, message = "{limit.number}") - private String limit; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceRegisterDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceRegisterDTO.java deleted file mode 100644 index ce37c517a..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceRegisterDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -package xiaozhi.modules.device.dto; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Getter; -import lombok.Setter; - -/** - * 设备注册头信息 - * - * @author zjy - * @since 2025-3-28 - */ -@Setter -@Getter -@Schema(description = "设备注册头信息") -public class DeviceRegisterDTO implements Serializable { - - @Schema(description = "mac地址") - private String macAddress; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportReqDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportReqDTO.java deleted file mode 100644 index fec5a297c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportReqDTO.java +++ /dev/null @@ -1,148 +0,0 @@ -package xiaozhi.modules.device.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; -import java.util.List; - -@Setter -@Getter -@Schema(description = "设备固件信息上报求请求体") -public class DeviceReportReqDTO implements Serializable { - private static final long serialVersionUID = 1L; - // region 实体属性 - @Schema(description = "板子固件版本号") - private Integer version; - - @Schema(description = "闪存大小(单位:字节)") - @JsonProperty("flash_size") - private Integer flashSize; - - @Schema(description = "最小空闲堆内存(字节)") - @JsonProperty("minimum_free_heap_size") - private Integer minimumFreeHeapSize; - - @Schema(description = "设备 MAC 地址") - @JsonProperty("mac_address") - private String macAddress; - - @Schema(description = "设备唯一标识 UUID") - private String uuid; - - @Schema(description = "芯片型号名称") - @JsonProperty("chip_model_name") - private String chipModelName; - - @Schema(description = "芯片详细信息") - @JsonProperty("chip_info") - private ChipInfo chipInfo; - - @Schema(description = "应用程序信息") - private Application application; - - @Schema(description = "分区表列表") - @JsonProperty("partition_table") - private List partitionTable; - - @Schema(description = "当前运行的 OTA 分区信息") - private OtaInfo ota; - - @Schema(description = "板子配置信息") - private BoardInfo board; - - // endregion - - @Getter - @Setter - @Schema(description = "芯片信息") - public static class ChipInfo { - @Schema(description = "芯片模型代码") - private Integer model; - - @Schema(description = "核心数") - private Integer cores; - - @Schema(description = "硬件修订版本") - private Integer revision; - - @Schema(description = "芯片功能标志位") - private Integer features; - } - - @Getter - @Setter - @Schema(description = "板子编译信息") - public static class Application { - @Schema(description = "名称") - private String name; - - @Schema(description = "应用版本号") - private String version; - - @Schema(description = "编译时间(UTC ISO格式)") - @JsonProperty("compile_time") - private String compileTime; - - @Schema(description = "ESP-IDF 版本号") - @JsonProperty("idf_version") - private String idfVersion; - - @Schema(description = "ELF 文件 SHA256 校验") - @JsonProperty("elf_sha256") - private String elfSha256; - } - - @Getter - @Setter - @Schema(description = "分区信息") - public static class Partition { - @Schema(description = "分区标签名") - private String label; - - @Schema(description = "分区类型") - private Integer type; - - @Schema(description = "子类型") - private Integer subtype; - - @Schema(description = "起始地址") - private Integer address; - - @Schema(description = "分区大小") - private Integer size; - } - - @Getter - @Setter - @Schema(description = "OTA信息") - public static class OtaInfo { - @Schema(description = "当前OTA标签") - private String label; - } - - @Getter - @Setter - @Schema(description = "板子连接和网络信息") - public static class BoardInfo { - @Schema(description = "板子类型") - private String type; - - @Schema(description = "连接的 Wi-Fi SSID") - private String ssid; - - @Schema(description = "Wi-Fi 信号强度(RSSI)") - private Integer rssi; - - @Schema(description = "Wi-Fi 信道") - private Integer channel; - - @Schema(description = "IP 地址") - private String ip; - - @Schema(description = "MAC 地址") - private String mac; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportRespDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportRespDTO.java deleted file mode 100644 index 85c8972af..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportRespDTO.java +++ /dev/null @@ -1,95 +0,0 @@ -package xiaozhi.modules.device.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; - -@Data -@Schema(description = "设备OTA检测版本返回体,包含激活码要求") -public class DeviceReportRespDTO { - @Schema(description = "服务器时间") - private ServerTime server_time; - - @Schema(description = "激活码") - private Activation activation; - - @Schema(description = "错误信息") - private String error; - - @Schema(description = "固件版本信息") - private Firmware firmware; - - @Schema(description = "WebSocket配置") - private Websocket websocket; - - @Schema(description = "MQTT Gateway配置") - private MQTT mqtt; - - @Getter - @Setter - public static class Firmware { - @Schema(description = "版本号") - private String version; - @Schema(description = "下载地址") - private String url; - } - - public static DeviceReportRespDTO createError(String message) { - DeviceReportRespDTO resp = new DeviceReportRespDTO(); - resp.setError(message); - return resp; - } - - @Setter - @Getter - public static class Activation { - @Schema(description = "激活码") - private String code; - - @Schema(description = "激活码信息: 激活地址") - private String message; - - @Schema(description = "挑战码") - private String challenge; - } - - @Getter - @Setter - public static class ServerTime { - @Schema(description = "时间戳") - private Long timestamp; - - @Schema(description = "时区") - private String timeZone; - - @Schema(description = "时区偏移量,单位为分钟") - private Integer timezone_offset; - } - - @Getter - @Setter - public static class Websocket { - @Schema(description = "WebSocket服务器地址") - private String url; - @Schema(description = "WebSocket 认证 token") - private String token; - } - - @Getter - @Setter - public static class MQTT { - @Schema(description = "MQTT 配置网址") - private String endpoint; - @Schema(description = "MQTT 客户端唯一标识符") - private String client_id; - @Schema(description = "MQTT 认证用户名") - private String username; - @Schema(description = "MQTT 认证密码") - private String password; - @Schema(description = "ESP32 发布消息的主题") - private String publish_topic; - @Schema(description = "ESP32 订阅的主题") - private String subscribe_topic; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceUnBindDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceUnBindDTO.java deleted file mode 100644 index f18df5d4e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceUnBindDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package xiaozhi.modules.device.dto; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -/** - * 设备解绑表单 - */ -@Data -@Schema(description = "设备解绑表单") -public class DeviceUnBindDTO implements Serializable { - - @Schema(description = "设备ID") - @NotBlank(message = "设备ID不能为空") - private String deviceId; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceUpdateDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceUpdateDTO.java deleted file mode 100644 index 2e9a47936..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceUpdateDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -package xiaozhi.modules.device.dto; - -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.Size; -import lombok.Data; - -import java.io.Serializable; - -/** - * 设备更新DTO - */ -@Data -public class DeviceUpdateDTO implements Serializable { - /** - * 自动更新状态 - */ - @Max(1) - @Min(0) - private Integer autoUpdate; - - /** - * 设备别名 - */ - @Size(max = 64) - private String alias; - - private static final long serialVersionUID = 1L; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/entity/DeviceEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/device/entity/DeviceEntity.java deleted file mode 100644 index 8ebdf9344..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/entity/DeviceEntity.java +++ /dev/null @@ -1,67 +0,0 @@ -package xiaozhi.modules.device.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("ai_device") -@Schema(description = "设备信息") -public class DeviceEntity { - - @TableId(type = IdType.ASSIGN_UUID) - @Schema(description = "ID") - private String 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 = "更新者") - @TableField(fill = FieldFill.UPDATE) - private Long updater; - - @Schema(description = "更新时间") - @TableField(fill = FieldFill.UPDATE) - private Date updateDate; - - @Schema(description = "创建者") - @TableField(fill = FieldFill.INSERT) - private Long creator; - - @Schema(description = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createDate; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/entity/OtaEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/device/entity/OtaEntity.java deleted file mode 100644 index b93c608bd..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/entity/OtaEntity.java +++ /dev/null @@ -1,61 +0,0 @@ -package xiaozhi.modules.device.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("ai_ota") -@Schema(description = "固件信息") -public class OtaEntity { - - @TableId(type = IdType.ASSIGN_UUID) - @Schema(description = "ID") - private String id; - - @Schema(description = "固件名称") - private String firmwareName; - - @Schema(description = "固件类型") - private String type; - - @Schema(description = "版本号") - private String version; - - @Schema(description = "文件大小(字节)") - private Long size; - - @Schema(description = "备注/说明") - private String remark; - - @Schema(description = "固件路径") - private String firmwarePath; - - @Schema(description = "排序") - private Integer sort; - - @Schema(description = "更新者") - @TableField(fill = FieldFill.UPDATE) - private Long updater; - - @Schema(description = "更新时间") - @TableField(fill = FieldFill.UPDATE) - private Date updateDate; - - @Schema(description = "创建者") - @TableField(fill = FieldFill.INSERT) - private Long creator; - - @Schema(description = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createDate; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/service/DeviceService.java b/main/manager-api/src/main/java/xiaozhi/modules/device/service/DeviceService.java deleted file mode 100644 index 3392c96ff..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/service/DeviceService.java +++ /dev/null @@ -1,101 +0,0 @@ -package xiaozhi.modules.device.service; - -import java.util.Date; -import java.util.List; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.device.dto.DevicePageUserDTO; -import xiaozhi.modules.device.dto.DeviceReportReqDTO; -import xiaozhi.modules.device.dto.DeviceReportRespDTO; -import xiaozhi.modules.device.dto.DeviceManualAddDTO; -import xiaozhi.modules.device.entity.DeviceEntity; -import xiaozhi.modules.device.vo.UserShowDeviceListVO; - -public interface DeviceService extends BaseService { - - /** - * 检查设备是否激活 - */ - DeviceReportRespDTO checkDeviceActive(String macAddress, String clientId, - DeviceReportReqDTO deviceReport); - - /** - * 获取用户指定智能体的设备列表, - */ - List getUserDevices(Long userId, String agentId); - - /** - * 解绑设备 - */ - void unbindDevice(Long userId, String deviceId); - - /** - * 设备激活 - */ - Boolean deviceActivation(String agentId, String activationCode); - - /** - * 删除此用户的所有设备 - * - * @param userId 用户id - */ - void deleteByUserId(Long userId); - - /** - * 删除指定智能体关联的所有设备 - * - * @param agentId 智能体id - */ - void deleteByAgentId(String agentId); - - /** - * 获取指定用户的设备数量 - * - * @param userId 用户id - * @return 设备数量 - */ - Long selectCountByUserId(Long userId); - - /** - * 分页获取全部设备信息 - * - * @param dto 分页查找参数 - * @return 用户列表分页数据 - */ - PageData page(DevicePageUserDTO dto); - - /** - * 根据MAC地址获取设备信息 - * - * @param macAddress MAC地址 - * @return 设备信息 - */ - DeviceEntity getDeviceByMacAddress(String macAddress); - - /** - * 根据设备ID获取激活码 - * - * @param deviceId 设备ID - * @return 激活码 - */ - String geCodeByDeviceId(String deviceId); - - /** - * 获取这个智能体设备理的最近的最后连接时间 - * @param agentId 智能体id - * @return 返回设备最近的最后连接时间 - */ - Date getLatestLastConnectionTime(String agentId); - - /** - * 手动添加设备 - */ - void manualAddDevice(Long userId, DeviceManualAddDTO dto); - - /** - * 更新设备连接信息 - */ - void updateDeviceConnectionInfo(String agentId, String deviceId, String appVersion); - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/service/OtaService.java b/main/manager-api/src/main/java/xiaozhi/modules/device/service/OtaService.java deleted file mode 100644 index cd35f6ae4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/service/OtaService.java +++ /dev/null @@ -1,22 +0,0 @@ -package xiaozhi.modules.device.service; - -import java.util.Map; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.device.entity.OtaEntity; - -/** - * OTA固件管理 - */ -public interface OtaService extends BaseService { - PageData page(Map params); - - boolean save(OtaEntity entity); - - void update(OtaEntity entity); - - void delete(String[] ids); - - OtaEntity getLatestOta(String type); -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/DeviceServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/DeviceServiceImpl.java deleted file mode 100644 index 5c3f854df..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/DeviceServiceImpl.java +++ /dev/null @@ -1,550 +0,0 @@ -package xiaozhi.modules.device.service.impl; - -import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.util.Base64; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TimeZone; -import java.util.UUID; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.aop.framework.AopContext; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import cn.hutool.core.util.RandomUtil; -import jakarta.servlet.http.HttpServletRequest; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -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.common.utils.DateUtils; -import xiaozhi.modules.device.dao.DeviceDao; -import xiaozhi.modules.device.dto.DeviceManualAddDTO; -import xiaozhi.modules.device.dto.DevicePageUserDTO; -import xiaozhi.modules.device.dto.DeviceReportReqDTO; -import xiaozhi.modules.device.dto.DeviceReportRespDTO; -import xiaozhi.modules.device.entity.DeviceEntity; -import xiaozhi.modules.device.entity.OtaEntity; -import xiaozhi.modules.device.service.DeviceService; -import xiaozhi.modules.device.service.OtaService; -import xiaozhi.modules.device.vo.UserShowDeviceListVO; -import xiaozhi.modules.security.user.SecurityUser; -import xiaozhi.modules.sys.service.SysParamsService; -import xiaozhi.modules.sys.service.SysUserUtilService; - -@Slf4j -@Service -@AllArgsConstructor -public class DeviceServiceImpl extends BaseServiceImpl implements DeviceService { - - private final DeviceDao deviceDao; - private final SysUserUtilService sysUserUtilService; - private final SysParamsService sysParamsService; - private final RedisUtils redisUtils; - private final OtaService otaService; - - @Async - public void updateDeviceConnectionInfo(String agentId, String deviceId, String appVersion) { - try { - DeviceEntity device = new DeviceEntity(); - device.setId(deviceId); - device.setLastConnectedAt(new Date()); - if (StringUtils.isNotBlank(appVersion)) { - device.setAppVersion(appVersion); - } - deviceDao.updateById(device); - if (StringUtils.isNotBlank(agentId)) { - redisUtils.set(RedisKeys.getAgentDeviceLastConnectedAtById(agentId), new Date()); - } - } catch (Exception e) { - log.error("异步更新设备连接信息失败", e); - } - } - - @Override - public Boolean deviceActivation(String agentId, String activationCode) { - if (StringUtils.isBlank(activationCode)) { - throw new RenException(ErrorCode.ACTIVATION_CODE_EMPTY); - } - String deviceKey = "ota:activation:code:" + activationCode; - Object cacheDeviceId = redisUtils.get(deviceKey); - if (cacheDeviceId == null) { - throw new RenException(ErrorCode.ACTIVATION_CODE_ERROR); - } - String deviceId = (String) cacheDeviceId; - String safeDeviceId = deviceId.replace(":", "_").toLowerCase(); - String cacheDeviceKey = String.format("ota:activation:data:%s", safeDeviceId); - Map cacheMap = (Map) redisUtils.get(cacheDeviceKey); - if (cacheMap == null) { - throw new RenException(ErrorCode.ACTIVATION_CODE_ERROR); - } - String cachedCode = (String) cacheMap.get("activation_code"); - if (!activationCode.equals(cachedCode)) { - throw new RenException(ErrorCode.ACTIVATION_CODE_ERROR); - } - // 检查设备有没有被激活 - if (selectById(deviceId) != null) { - throw new RenException(ErrorCode.DEVICE_ALREADY_ACTIVATED); - } - - String macAddress = (String) cacheMap.get("mac_address"); - String board = (String) cacheMap.get("board"); - String appVersion = (String) cacheMap.get("app_version"); - UserDetail user = SecurityUser.getUser(); - if (user.getId() == null) { - throw new RenException(ErrorCode.USER_NOT_LOGIN); - } - - Date currentTime = new Date(); - DeviceEntity deviceEntity = new DeviceEntity(); - deviceEntity.setId(deviceId); - deviceEntity.setBoard(board); - deviceEntity.setAgentId(agentId); - deviceEntity.setAppVersion(appVersion); - deviceEntity.setMacAddress(macAddress); - deviceEntity.setUserId(user.getId()); - deviceEntity.setCreator(user.getId()); - deviceEntity.setAutoUpdate(1); - deviceEntity.setCreateDate(currentTime); - deviceEntity.setUpdater(user.getId()); - deviceEntity.setUpdateDate(currentTime); - deviceEntity.setLastConnectedAt(currentTime); - deviceDao.insert(deviceEntity); - - // 清理redis缓存 - redisUtils.delete(cacheDeviceKey); - redisUtils.delete(deviceKey); - - // 添加:清除智能体设备数量缓存 - redisUtils.delete(RedisKeys.getAgentDeviceCountById(agentId)); - - return true; - } - - @Override - public DeviceReportRespDTO checkDeviceActive(String macAddress, String clientId, - DeviceReportReqDTO deviceReport) { - DeviceReportRespDTO response = new DeviceReportRespDTO(); - response.setServer_time(buildServerTime()); - - DeviceEntity deviceById = getDeviceByMacAddress(macAddress); - - // 设备未绑定,则返回当前上传的固件信息(不更新)以此兼容旧固件版本 - if (deviceById == null) { - DeviceReportRespDTO.Firmware firmware = new DeviceReportRespDTO.Firmware(); - firmware.setVersion(deviceReport.getApplication().getVersion()); - firmware.setUrl(Constant.INVALID_FIRMWARE_URL); - response.setFirmware(firmware); - } else { - // 只有在设备已绑定且autoUpdate不为0的情况下才返回固件升级信息 - if (deviceById.getAutoUpdate() != 0) { - String type = deviceReport.getBoard() == null ? null : deviceReport.getBoard().getType(); - DeviceReportRespDTO.Firmware firmware = buildFirmwareInfo(type, - deviceReport.getApplication() == null ? null : deviceReport.getApplication().getVersion()); - response.setFirmware(firmware); - } - } - - // 添加WebSocket配置 - DeviceReportRespDTO.Websocket websocket = new DeviceReportRespDTO.Websocket(); - // 从系统参数获取WebSocket URL,如果未配置则使用默认值 - String wsUrl = sysParamsService.getValue(Constant.SERVER_WEBSOCKET, true); - websocket.setToken(""); - if (StringUtils.isBlank(wsUrl) || wsUrl.equals("null")) { - log.error("WebSocket地址未配置,请登录智控台,在参数管理找到【server.websocket】配置"); - wsUrl = "ws://xiaozhi.server.com:8000/xiaozhi/v1/"; - websocket.setUrl(wsUrl); - } else { - String[] wsUrls = wsUrl.split("\\;"); - if (wsUrls.length > 0) { - // 随机选择一个WebSocket URL - websocket.setUrl(wsUrls[RandomUtil.randomInt(0, wsUrls.length)]); - } else { - log.error("WebSocket地址未配置,请登录智控台,在参数管理找到【server.websocket】配置"); - websocket.setUrl("ws://xiaozhi.server.com:8000/xiaozhi/v1/"); - } - } - - response.setWebsocket(websocket); - - // 添加MQTT UDP配置 - // 从系统参数获取MQTT Gateway地址,仅在配置有效时使用 - String mqttUdpConfig = sysParamsService.getValue(Constant.SERVER_MQTT_GATEWAY, false); - if (mqttUdpConfig != null && !mqttUdpConfig.equals("null") && !mqttUdpConfig.isEmpty()) { - try { - String groupId = deviceById != null && deviceById.getBoard() != null ? deviceById.getBoard() - : "GID_default"; - DeviceReportRespDTO.MQTT mqtt = buildMqttConfig(macAddress, groupId); - if (mqtt != null) { - mqtt.setEndpoint(mqttUdpConfig); - response.setMqtt(mqtt); - } - } catch (Exception e) { - log.error("生成MQTT配置失败: {}", e.getMessage()); - } - } - - if (deviceById != null) { - // 如果设备存在,则异步更新上次连接时间和版本信息 - String appVersion = deviceReport.getApplication() != null ? deviceReport.getApplication().getVersion() - : null; - // 通过Spring代理调用异步方法 - ((DeviceServiceImpl) AopContext.currentProxy()).updateDeviceConnectionInfo(deviceById.getAgentId(), - deviceById.getId(), appVersion); - } else { - // 如果设备不存在,则生成激活码 - DeviceReportRespDTO.Activation code = buildActivation(macAddress, deviceReport); - response.setActivation(code); - } - - return response; - } - - @Override - public List getUserDevices(Long userId, String agentId) { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("user_id", userId); - wrapper.eq("agent_id", agentId); - return baseDao.selectList(wrapper); - } - - @Override - public void unbindDevice(Long userId, String deviceId) { - // 先查询设备信息,获取agentId - DeviceEntity device = baseDao.selectById(deviceId); - if (device == null) { - return; - } - if (StringUtils.isNotBlank(device.getAgentId())) { - // 清除智能体设备数量缓存 - redisUtils.delete(RedisKeys.getAgentDeviceCountById(device.getAgentId())); - } - - UpdateWrapper wrapper = new UpdateWrapper<>(); - wrapper.eq("user_id", userId); - wrapper.eq("id", deviceId); - baseDao.delete(wrapper); - } - - @Override - public void deleteByUserId(Long userId) { - UpdateWrapper wrapper = new UpdateWrapper<>(); - wrapper.eq("user_id", userId); - baseDao.delete(wrapper); - } - - @Override - public Long selectCountByUserId(Long userId) { - UpdateWrapper wrapper = new UpdateWrapper<>(); - wrapper.eq("user_id", userId); - return baseDao.selectCount(wrapper); - } - - @Override - public void deleteByAgentId(String agentId) { - UpdateWrapper wrapper = new UpdateWrapper<>(); - wrapper.eq("agent_id", agentId); - baseDao.delete(wrapper); - } - - @Override - public PageData page(DevicePageUserDTO dto) { - Map params = new HashMap(); - params.put(Constant.PAGE, dto.getPage()); - params.put(Constant.LIMIT, dto.getLimit()); - IPage page = baseDao.selectPage( - getPage(params, "mac_address", true), - // 定义查询条件 - new QueryWrapper() - // 必须设备关键词查找 - .like(StringUtils.isNotBlank(dto.getKeywords()), "alias", dto.getKeywords())); - // 循环处理page获取回来的数据,返回需要的字段 - List list = page.getRecords().stream().map(device -> { - UserShowDeviceListVO vo = ConvertUtils.sourceToTarget(device, UserShowDeviceListVO.class); - // 把最后修改的时间,改为简短描述的时间 - vo.setRecentChatTime(DateUtils.getShortTime(device.getUpdateDate())); - sysUserUtilService.assignUsername(device.getUserId(), - vo::setBindUserName); - vo.setDeviceType(device.getBoard()); - return vo; - }).toList(); - // 计算页数 - return new PageData<>(list, page.getTotal()); - } - - @Override - public DeviceEntity getDeviceByMacAddress(String macAddress) { - if (StringUtils.isBlank(macAddress)) { - return null; - } - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("mac_address", macAddress); - return baseDao.selectOne(wrapper); - } - - private DeviceReportRespDTO.ServerTime buildServerTime() { - DeviceReportRespDTO.ServerTime serverTime = new DeviceReportRespDTO.ServerTime(); - TimeZone tz = TimeZone.getDefault(); - serverTime.setTimestamp(Instant.now().toEpochMilli()); - serverTime.setTimeZone(tz.getID()); - serverTime.setTimezone_offset(tz.getOffset(System.currentTimeMillis()) / (60 * 1000)); - return serverTime; - } - - @Override - public String geCodeByDeviceId(String deviceId) { - String dataKey = getDeviceCacheKey(deviceId); - - Map cacheMap = (Map) redisUtils.get(dataKey); - if (cacheMap != null && cacheMap.containsKey("activation_code")) { - String cachedCode = (String) cacheMap.get("activation_code"); - return cachedCode; - } - return null; - } - - @Override - public Date getLatestLastConnectionTime(String agentId) { - // 查询是否有缓存时间,有则返回 - Date cachedDate = (Date) redisUtils.get(RedisKeys.getAgentDeviceLastConnectedAtById(agentId)); - if (cachedDate != null) { - return cachedDate; - } - Date maxDate = deviceDao.getAllLastConnectedAtByAgentId(agentId); - if (maxDate != null) { - redisUtils.set(RedisKeys.getAgentDeviceLastConnectedAtById(agentId), maxDate); - } - return maxDate; - } - - private String getDeviceCacheKey(String deviceId) { - String safeDeviceId = deviceId.replace(":", "_").toLowerCase(); - String dataKey = String.format("ota:activation:data:%s", safeDeviceId); - return dataKey; - } - - public DeviceReportRespDTO.Activation buildActivation(String deviceId, DeviceReportReqDTO deviceReport) { - DeviceReportRespDTO.Activation code = new DeviceReportRespDTO.Activation(); - - String cachedCode = geCodeByDeviceId(deviceId); - - if (StringUtils.isNotBlank(cachedCode)) { - code.setCode(cachedCode); - String frontedUrl = sysParamsService.getValue(Constant.SERVER_FRONTED_URL, true); - code.setMessage(frontedUrl + "\n" + cachedCode); - code.setChallenge(deviceId); - } else { - String newCode = RandomUtil.randomNumbers(6); - code.setCode(newCode); - String frontedUrl = sysParamsService.getValue(Constant.SERVER_FRONTED_URL, true); - code.setMessage(frontedUrl + "\n" + newCode); - code.setChallenge(deviceId); - - Map dataMap = new HashMap<>(); - dataMap.put("id", deviceId); - dataMap.put("mac_address", deviceId); - - dataMap.put("board", (deviceReport.getBoard() != null && deviceReport.getBoard().getType() != null) - ? deviceReport.getBoard().getType() - : (deviceReport.getChipModelName() != null ? deviceReport.getChipModelName() : "unknown")); - dataMap.put("app_version", (deviceReport.getApplication() != null) - ? deviceReport.getApplication().getVersion() - : null); - - dataMap.put("deviceId", deviceId); - dataMap.put("activation_code", newCode); - - // 写入主数据 key - String dataKey = getDeviceCacheKey(deviceId); - redisUtils.set(dataKey, dataMap); - - // 写入反查激活码 key - String codeKey = "ota:activation:code:" + newCode; - redisUtils.set(codeKey, deviceId); - } - return code; - } - - private DeviceReportRespDTO.Firmware buildFirmwareInfo(String type, String currentVersion) { - if (StringUtils.isBlank(type)) { - return null; - } - if (StringUtils.isBlank(currentVersion)) { - currentVersion = "0.0.0"; - } - - OtaEntity ota = otaService.getLatestOta(type); - DeviceReportRespDTO.Firmware firmware = new DeviceReportRespDTO.Firmware(); - String downloadUrl = null; - - if (ota != null) { - // 如果设备没有版本信息,或者OTA版本比设备版本新,则返回下载地址 - if (compareVersions(ota.getVersion(), currentVersion) > 0) { - String otaUrl = sysParamsService.getValue(Constant.SERVER_OTA, true); - if (StringUtils.isBlank(otaUrl) || otaUrl.equals("null")) { - log.error("OTA地址未配置,请登录智控台,在参数管理找到【server.ota】配置"); - // 尝试从请求中获取 - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder - .getRequestAttributes()) - .getRequest(); - otaUrl = request.getRequestURL().toString(); - } - // 将URL中的/ota/替换为/otaMag/download/ - String uuid = UUID.randomUUID().toString(); - redisUtils.set(RedisKeys.getOtaIdKey(uuid), ota.getId()); - downloadUrl = otaUrl.replace("/ota/", "/otaMag/download/") + uuid; - } - } - - firmware.setVersion(ota == null ? currentVersion : ota.getVersion()); - firmware.setUrl(downloadUrl == null ? Constant.INVALID_FIRMWARE_URL : downloadUrl); - return firmware; - } - - /** - * 比较两个版本号 - * - * @param version1 版本1 - * @param version2 版本2 - * @return 如果version1 > version2返回1,version1 < version2返回-1,相等返回0 - */ - private static int compareVersions(String version1, String version2) { - if (version1 == null || version2 == null) { - return 0; - } - - String[] v1Parts = version1.split("\\."); - String[] v2Parts = version2.split("\\."); - - int length = Math.max(v1Parts.length, v2Parts.length); - for (int i = 0; i < length; i++) { - int v1 = i < v1Parts.length ? Integer.parseInt(v1Parts[i]) : 0; - int v2 = i < v2Parts.length ? Integer.parseInt(v2Parts[i]) : 0; - - if (v1 > v2) { - return 1; - } else if (v1 < v2) { - return -1; - } - } - return 0; - } - - @Override - public void manualAddDevice(Long userId, DeviceManualAddDTO dto) { - // 检查mac是否已存在 - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("mac_address", dto.getMacAddress()); - DeviceEntity exist = baseDao.selectOne(wrapper); - if (exist != null) { - throw new RenException(ErrorCode.MAC_ADDRESS_ALREADY_EXISTS); - } - Date now = new Date(); - DeviceEntity entity = new DeviceEntity(); - entity.setId(dto.getMacAddress()); - entity.setUserId(userId); - entity.setAgentId(dto.getAgentId()); - entity.setBoard(dto.getBoard()); - entity.setAppVersion(dto.getAppVersion()); - entity.setMacAddress(dto.getMacAddress()); - entity.setCreateDate(now); - entity.setUpdateDate(now); - entity.setLastConnectedAt(now); - entity.setCreator(userId); - entity.setUpdater(userId); - entity.setAutoUpdate(1); - baseDao.insert(entity); - - // 添加:清除智能体设备数量缓存 - redisUtils.delete(RedisKeys.getAgentDeviceCountById(dto.getAgentId())); - } - - /** - * 生成MQTT密码签名 - * - * @param content 签名内容 (clientId + '|' + username) - * @param secretKey 密钥 - * @return Base64编码的HMAC-SHA256签名 - */ - private String generatePasswordSignature(String content, String secretKey) throws Exception { - Mac hmac = Mac.getInstance("HmacSHA256"); - SecretKeySpec keySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256"); - hmac.init(keySpec); - byte[] signature = hmac.doFinal(content.getBytes(StandardCharsets.UTF_8)); - return Base64.getEncoder().encodeToString(signature); - } - - /** - * 构建MQTT配置信息 - * - * @param macAddress MAC地址 - * @param groupId 分组ID - * @return MQTT配置对象 - */ - private DeviceReportRespDTO.MQTT buildMqttConfig(String macAddress, String groupId) - throws Exception { - // 从环境变量或系统参数获取签名密钥 - String signatureKey = sysParamsService.getValue("server.mqtt_signature_key", false); - if (StringUtils.isBlank(signatureKey)) { - log.warn("缺少MQTT_SIGNATURE_KEY,跳过MQTT配置生成"); - return null; - } - - // 构建客户端ID格式:groupId@@@macAddress@@@uuid - String groupIdSafeStr = groupId.replace(":", "_"); - String deviceIdSafeStr = macAddress.replace(":", "_"); - String mqttClientId = String.format("%s@@@%s@@@%s", groupIdSafeStr, deviceIdSafeStr, deviceIdSafeStr); - - // 构建用户数据(包含IP等信息) - Map userData = new HashMap<>(); - // 尝试获取客户端IP - try { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder - .getRequestAttributes(); - if (attributes != null) { - HttpServletRequest request = attributes.getRequest(); - String clientIp = request.getRemoteAddr(); - userData.put("ip", clientIp); - } - } catch (Exception e) { - userData.put("ip", "unknown"); - } - - // 将用户数据编码为Base64 JSON - String userDataJson = new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(userData); - String username = Base64.getEncoder().encodeToString(userDataJson.getBytes(StandardCharsets.UTF_8)); - - // 生成密码签名 - String password = generatePasswordSignature(mqttClientId + "|" + username, signatureKey); - - // 构建MQTT配置 - DeviceReportRespDTO.MQTT mqtt = new DeviceReportRespDTO.MQTT(); - mqtt.setClient_id(mqttClientId); - mqtt.setUsername(username); - mqtt.setPassword(password); - mqtt.setPublish_topic("device-server"); - mqtt.setSubscribe_topic("devices/p2p/" + deviceIdSafeStr); - - return mqtt; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/OtaServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/OtaServiceImpl.java deleted file mode 100644 index ed9e8c7fa..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/OtaServiceImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -package xiaozhi.modules.device.service.impl; - -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import io.micrometer.common.util.StringUtils; -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.modules.device.dao.OtaDao; -import xiaozhi.modules.device.entity.OtaEntity; -import xiaozhi.modules.device.service.OtaService; - -@Service -public class OtaServiceImpl extends BaseServiceImpl implements OtaService { - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, "update_date", true), - getWrapper(params)); - - return new PageData<>(page.getRecords(), page.getTotal()); - } - - private QueryWrapper getWrapper(Map params) { - String firmwareName = (String) params.get("firmwareName"); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(firmwareName), "firmware_name", firmwareName); - - return wrapper; - } - - @Override - public void update(OtaEntity entity) { - // 检查是否存在相同类型和版本的固件(排除当前记录) - QueryWrapper queryWrapper = new QueryWrapper() - .eq("type", entity.getType()) - .eq("version", entity.getVersion()) - .ne("id", entity.getId()); // 排除当前记录 - - if (baseDao.selectCount(queryWrapper) > 0) { - throw new RuntimeException("已存在相同类型和版本的固件,请修改后重试"); - } - - entity.setUpdateDate(new Date()); - baseDao.updateById(entity); - } - - @Override - public void delete(String[] ids) { - baseDao.deleteBatchIds(Arrays.asList(ids)); - } - - @Override - public boolean save(OtaEntity entity) { - QueryWrapper queryWrapper = new QueryWrapper() - .eq("type", entity.getType()); - // 同类固件只保留最新的一条 - List otaList = baseDao.selectList(queryWrapper); - if (otaList != null && otaList.size() > 0) { - OtaEntity otaBefore = otaList.getFirst(); - entity.setId(otaBefore.getId()); - baseDao.updateById(entity); - return true; - } - return baseDao.insert(entity) > 0; - } - - @Override - public OtaEntity getLatestOta(String type) { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("type", type) - .orderByDesc("update_date") - .last("LIMIT 1"); - return baseDao.selectOne(wrapper); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/vo/DeviceOtaVO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/vo/DeviceOtaVO.java deleted file mode 100644 index ec8e405ec..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/vo/DeviceOtaVO.java +++ /dev/null @@ -1,59 +0,0 @@ -package xiaozhi.modules.device.vo; - -import lombok.Data; - -@Data -public class DeviceOtaVO { - private Activation activation; - private Mqtt mqtt; - private ServerTime server_time; - private Firmware firmware; - private String error; - - @Data - public static class Activation { - private String code; - private String message; - - public Activation() { - } - - public Activation(String code, String message) { - this.code = code; - this.message = message; - } - } - - @Data - public class Mqtt { - - } - - @Data - public static class ServerTime { - private Long timestamp; - private Integer timezone_offset; - - public ServerTime() { - } - - public ServerTime(Long timestamp, Integer timezone_offset) { - this.timestamp = timestamp; - this.timezone_offset = timezone_offset; - } - } - - @Data - public static class Firmware { - private String version; - private String url; - - public Firmware() { - } - - public Firmware(String version, String url) { - this.version = version; - this.url = url; - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/vo/UserShowDeviceListVO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/vo/UserShowDeviceListVO.java deleted file mode 100644 index e3a5d8fd1..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/vo/UserShowDeviceListVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package xiaozhi.modules.device.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -@Schema(description = "用户显示设备列表VO") -public class UserShowDeviceListVO { - - @Schema(description = "app版本") - private String appVersion; - - @Schema(description = "绑定用户名称") - private String bindUserName; - - @Schema(description = "设备型号") - private String deviceType; - - @Schema(description = "设备唯一标识符") - private String id; - - @Schema(description = "mac地址") - private String macAddress; - - @Schema(description = "开启OTA") - private Integer otaUpgrade; - - @Schema(description = "最近对话时间") - private String recentChatTime; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelController.java b/main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelController.java deleted file mode 100644 index d4984530c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelController.java +++ /dev/null @@ -1,170 +0,0 @@ -package xiaozhi.modules.model.controller; - -import java.util.List; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AllArgsConstructor; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.agent.service.AgentTemplateService; -import xiaozhi.modules.config.service.ConfigService; -import xiaozhi.modules.model.dto.LlmModelBasicInfoDTO; -import xiaozhi.modules.model.dto.ModelBasicInfoDTO; -import xiaozhi.modules.model.dto.ModelConfigBodyDTO; -import xiaozhi.modules.model.dto.ModelConfigDTO; -import xiaozhi.modules.model.dto.ModelProviderDTO; -import xiaozhi.modules.model.dto.VoiceDTO; -import xiaozhi.modules.model.entity.ModelConfigEntity; -import xiaozhi.modules.model.service.ModelConfigService; -import xiaozhi.modules.model.service.ModelProviderService; -import xiaozhi.modules.timbre.service.TimbreService; - -@AllArgsConstructor -@RestController -@RequestMapping("/models") -@Tag(name = "模型配置") -public class ModelController { - - private final ModelProviderService modelProviderService; - private final TimbreService timbreService; - private final ModelConfigService modelConfigService; - private final ConfigService configService; - private final AgentTemplateService agentTemplateService; - - @GetMapping("/names") - @Operation(summary = "获取所有模型名称") - @RequiresPermissions("sys:role:normal") - public Result> getModelNames(@RequestParam String modelType, - @RequestParam(required = false) String modelName) { - List modelList = modelConfigService.getModelCodeList(modelType, modelName); - return new Result>().ok(modelList); - } - - @GetMapping("/llm/names") - @Operation(summary = "获取LLM模型信息") - @RequiresPermissions("sys:role:normal") - public Result> getLlmModelCodeList(@RequestParam(required = false) String modelName) { - List llmModelCodeList = modelConfigService.getLlmModelCodeList(modelName); - return new Result>().ok(llmModelCodeList); - } - - @GetMapping("/{modelType}/provideTypes") - @Operation(summary = "获取模型供应器列表") - @RequiresPermissions("sys:role:superAdmin") - public Result> getModelProviderList(@PathVariable String modelType) { - List modelProviderDTOS = modelProviderService.getListByModelType(modelType); - return new Result>().ok(modelProviderDTOS); - } - - @GetMapping("/list") - @Operation(summary = "获取模型配置列表") - @RequiresPermissions("sys:role:superAdmin") - public Result> getModelConfigList( - @RequestParam(required = true) String modelType, - @RequestParam(required = false) String modelName, - @RequestParam(required = true, defaultValue = "0") String page, - @RequestParam(required = true, defaultValue = "10") String limit) { - PageData pageList = modelConfigService.getPageList(modelType, modelName, page, limit); - return new Result>().ok(pageList); - } - - @PostMapping("/{modelType}/{provideCode}") - @Operation(summary = "新增模型配置") - @RequiresPermissions("sys:role:superAdmin") - public Result addModelConfig(@PathVariable String modelType, - @PathVariable String provideCode, - @RequestBody ModelConfigBodyDTO modelConfigBodyDTO) { - ModelConfigDTO modelConfigDTO = modelConfigService.add(modelType, provideCode, modelConfigBodyDTO); - configService.getConfig(false); - return new Result().ok(modelConfigDTO); - } - - @PutMapping("/{modelType}/{provideCode}/{id}") - @Operation(summary = "编辑模型配置") - @RequiresPermissions("sys:role:superAdmin") - public Result editModelConfig(@PathVariable String modelType, - @PathVariable String provideCode, - @PathVariable String id, - @RequestBody ModelConfigBodyDTO modelConfigBodyDTO) { - ModelConfigDTO modelConfigDTO = modelConfigService.edit(modelType, provideCode, id, modelConfigBodyDTO); - configService.getConfig(false); - return new Result().ok(modelConfigDTO); - } - - @DeleteMapping("/{id}") - @Operation(summary = "删除模型配置") - @RequiresPermissions("sys:role:superAdmin") - public Result deleteModelConfig(@PathVariable String id) { - modelConfigService.delete(id); - return new Result<>(); - } - - @GetMapping("/{id}") - @Operation(summary = "获取模型配置") - @RequiresPermissions("sys:role:superAdmin") - public Result getModelConfig(@PathVariable String id) { - ModelConfigEntity item = modelConfigService.selectById(id); - ModelConfigDTO modelConfigDTO = ConvertUtils.sourceToTarget(item, ModelConfigDTO.class); - return new Result().ok(modelConfigDTO); - } - - @PutMapping("/enable/{id}/{status}") - @Operation(summary = "启用/关闭模型配置") - @RequiresPermissions("sys:role:superAdmin") - public Result enableModelConfig(@PathVariable String id, @PathVariable Integer status) { - ModelConfigEntity entity = modelConfigService.selectById(id); - if (entity == null) { - return new Result().error("模型配置不存在"); - } - // 不更新ConfigJson字段 - entity.setConfigJson(null); - entity.setIsEnabled(status); - modelConfigService.updateById(entity); - return new Result(); - } - - @PutMapping("/default/{id}") - @Operation(summary = "设置默认模型") - @RequiresPermissions("sys:role:superAdmin") - public Result setDefaultModel(@PathVariable String id) { - ModelConfigEntity entity = modelConfigService.selectById(id); - if (entity == null) { - return new Result().error("模型配置不存在"); - } - // 将其他模型设置为非默认 - modelConfigService.setDefaultModel(entity.getModelType(), 0); - entity.setIsEnabled(1); - entity.setIsDefault(1); - // 不更新ConfigJson字段 - entity.setConfigJson(null); - modelConfigService.updateById(entity); - - // 更新模板表中对应的模型ID - agentTemplateService.updateDefaultTemplateModelId(entity.getModelType(), entity.getId()); - - configService.getConfig(false); - return new Result(); - } - - @GetMapping("/{modelId}/voices") - @Operation(summary = "获取模型音色") - @RequiresPermissions("sys:role:normal") - public Result> getVoiceList(@PathVariable String modelId, - @RequestParam(required = false) String voiceName) { - List voiceList = timbreService.getVoiceNames(modelId, voiceName); - return new Result>().ok(voiceList); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelProviderController.java b/main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelProviderController.java deleted file mode 100644 index 24a7c7ca8..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelProviderController.java +++ /dev/null @@ -1,75 +0,0 @@ -package xiaozhi.modules.model.controller; - -import java.util.List; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AllArgsConstructor; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.Result; -import xiaozhi.common.utils.ResultUtils; -import xiaozhi.common.validator.group.UpdateGroup; -import xiaozhi.modules.model.dto.ModelProviderDTO; -import xiaozhi.modules.model.service.ModelProviderService; - -@AllArgsConstructor -@RestController -@RequestMapping("/models/provider") -@Tag(name = "模型供应器") -public class ModelProviderController { - - private final ModelProviderService modelProviderService; - - @GetMapping - @Operation(summary = "获取模型供应器列表") - @RequiresPermissions("sys:role:superAdmin") - public Result> getListPage(ModelProviderDTO modelProviderDTO, - @RequestParam(required = true, defaultValue = "0") String page, - @RequestParam(required = true, defaultValue = "10") String limit) { - return new Result>() - .ok(modelProviderService.getListPage(modelProviderDTO, page, limit)); - } - - @PostMapping - @Operation(summary = "新增模型供应器") - @RequiresPermissions("sys:role:superAdmin") - public Result add(@RequestBody @Validated ModelProviderDTO modelProviderDTO) { - ModelProviderDTO resp = modelProviderService.add(modelProviderDTO); - return new Result().ok(resp); - } - - @PutMapping - @Operation(summary = "修改模型供应器") - @RequiresPermissions("sys:role:superAdmin") - public Result edit(@RequestBody @Validated(UpdateGroup.class) ModelProviderDTO modelProviderDTO) { - ModelProviderDTO resp = modelProviderService.edit(modelProviderDTO); - return new Result().ok(resp); - } - - @PostMapping("/delete") - @Operation(summary = "删除模型供应器") - @RequiresPermissions("sys:role:superAdmin") - @Parameter(name = "ids", description = "ID数组", required = true) - public Result delete(@RequestBody List ids) { - modelProviderService.delete(ids); - return new Result<>(); - } - - @GetMapping("/plugin/names") - @Tag(name = "获取插件名称列表") - public Result> getPluginNameList() { - return ResultUtils.success(modelProviderService.getPluginList()); - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dao/ModelConfigDao.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dao/ModelConfigDao.java deleted file mode 100644 index 70c6abc44..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dao/ModelConfigDao.java +++ /dev/null @@ -1,24 +0,0 @@ -package xiaozhi.modules.model.dao; - -import java.util.List; -import java.util.Map; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import xiaozhi.common.dao.BaseDao; -import xiaozhi.modules.model.entity.ModelConfigEntity; - -@Mapper -public interface ModelConfigDao extends BaseDao { - - /** - * get model_code list - */ - List getModelCodeList(@Param("modelType") String modelType, @Param("modelName") String modelName); - - /** - * 获取符合条件的TTS平台列表(id和modelName) - */ - List> getTtsPlatformList(); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dao/ModelProviderDao.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dao/ModelProviderDao.java deleted file mode 100644 index 68e418586..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dao/ModelProviderDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package xiaozhi.modules.model.dao; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import xiaozhi.common.dao.BaseDao; -import xiaozhi.modules.model.entity.ModelProviderEntity; - -@Mapper -public interface ModelProviderDao extends BaseDao { - - List getFieldList(@Param("modelType") String modelType, @Param("providerCode") String providerCode); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/LlmModelBasicInfoDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/LlmModelBasicInfoDTO.java deleted file mode 100644 index 3995ceb83..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/LlmModelBasicInfoDTO.java +++ /dev/null @@ -1,13 +0,0 @@ -package xiaozhi.modules.model.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * LLM的模型的基础展示数据 - */ -@EqualsAndHashCode(callSuper = true) -@Data -public class LlmModelBasicInfoDTO extends ModelBasicInfoDTO{ - private String type; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelBasicInfoDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelBasicInfoDTO.java deleted file mode 100644 index 571c791ab..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelBasicInfoDTO.java +++ /dev/null @@ -1,9 +0,0 @@ -package xiaozhi.modules.model.dto; - -import lombok.Data; - -@Data -public class ModelBasicInfoDTO { - private String id; - private String modelName; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelConfigBodyDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelConfigBodyDTO.java deleted file mode 100644 index 07758def1..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelConfigBodyDTO.java +++ /dev/null @@ -1,42 +0,0 @@ -package xiaozhi.modules.model.dto; - -import java.io.Serial; - -import cn.hutool.json.JSONObject; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -@Schema(description = "模型供应器/商") -public class ModelConfigBodyDTO { - - @Serial - private static final long serialVersionUID = 1L; - - // @Schema(description = "模型类型(Memory/ASR/VAD/LLM/TTS)") - // private String modelType; - // - @Schema(description = "模型编码(如AliLLM、DoubaoTTS)") - private String modelCode; - - @Schema(description = "模型名称") - private String modelName; - - @Schema(description = "是否默认配置(0否 1是)") - private Integer isDefault; - - @Schema(description = "是否启用") - private Integer isEnabled; - - @Schema(description = "模型配置(JSON格式)") - private JSONObject configJson; - - @Schema(description = "官方文档链接") - private String docLink; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "排序") - private Integer sort; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelConfigDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelConfigDTO.java deleted file mode 100644 index ed73e1ff8..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelConfigDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package xiaozhi.modules.model.dto; - -import java.io.Serial; -import java.io.Serializable; - -import cn.hutool.json.JSONObject; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -@Schema(description = "模型供应器/商") -public class ModelConfigDTO implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - @Schema(description = "主键") - private String id; - - @Schema(description = "模型类型(Memory/ASR/VAD/LLM/TTS)") - private String modelType; - - @Schema(description = "模型编码(如AliLLM、DoubaoTTS)") - private String modelCode; - - @Schema(description = "模型名称") - private String modelName; - - @Schema(description = "是否默认配置(0否 1是)") - private Integer isDefault; - - @Schema(description = "是否启用") - private Integer isEnabled; - - @Schema(description = "模型配置(JSON格式)") - private JSONObject configJson; - - @Schema(description = "官方文档链接") - private String docLink; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "排序") - private Integer sort; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelProviderDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelProviderDTO.java deleted file mode 100644 index 317820d55..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/ModelProviderDTO.java +++ /dev/null @@ -1,59 +0,0 @@ -package xiaozhi.modules.model.dto; - -import java.io.Serializable; -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.Data; -import xiaozhi.common.validator.group.UpdateGroup; - -@Data -@Schema(description = "模型供应器/商") -public class ModelProviderDTO implements Serializable { - @Schema(description = "主键") - @NotBlank(message = "id不能为空", groups = UpdateGroup.class) - private String id; - - @Schema(description = "模型类型(Memory/ASR/VAD/LLM/TTS)") - @NotBlank(message = "modelType不能为空") - private String modelType; - - @Schema(description = "供应器类型") - @NotBlank(message = "providerCode不能为空") - private String providerCode; - - @Schema(description = "供应器名称") - @NotBlank(message = "name不能为空") - private String name; - - @Schema(description = "供应器字段列表(JSON格式)") - @TableField(typeHandler = JacksonTypeHandler.class) - @NotBlank(message = "fields(JSON格式)不能为空") - private String fields; - - @Schema(description = "排序") - @NotNull(message = "sort不能为空") - private Integer sort; - - @Schema(description = "更新者") - @TableField(fill = FieldFill.UPDATE) - private Long updater; - - @Schema(description = "更新时间") - @TableField(fill = FieldFill.UPDATE) - private Date updateDate; - - @Schema(description = "创建者") - @TableField(fill = FieldFill.INSERT) - private Long creator; - - @Schema(description = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createDate; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java deleted file mode 100644 index 25358eb05..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java +++ /dev/null @@ -1,22 +0,0 @@ -package xiaozhi.modules.model.dto; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@Schema(description = "音色信息") -public class VoiceDTO implements Serializable { - private static final long serialVersionUID = 1L; - - @Schema(description = "音色ID") - private String id; - - @Schema(description = "音色名称") - private String name; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/entity/ModelConfigEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/model/entity/ModelConfigEntity.java deleted file mode 100644 index 32ff911fb..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/entity/ModelConfigEntity.java +++ /dev/null @@ -1,68 +0,0 @@ -package xiaozhi.modules.model.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; - -import cn.hutool.json.JSONObject; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -@TableName(value = "ai_model_config", autoResultMap = true) -@Schema(description = "模型配置表") -public class ModelConfigEntity { - - @TableId(type = IdType.ASSIGN_UUID) - @Schema(description = "主键") - private String id; - - @Schema(description = "模型类型(Memory/ASR/VAD/LLM/TTS)") - private String modelType; - - @Schema(description = "模型编码(如AliLLM、DoubaoTTS)") - private String modelCode; - - @Schema(description = "模型名称") - private String modelName; - - @Schema(description = "是否默认配置(0否 1是)") - private Integer isDefault; - - @Schema(description = "是否启用") - private Integer isEnabled; - - @TableField(typeHandler = JacksonTypeHandler.class) - @Schema(description = "模型配置(JSON格式)") - private JSONObject configJson; - - @Schema(description = "官方文档链接") - private String docLink; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "排序") - private Integer sort; - - @Schema(description = "更新者") - @TableField(fill = FieldFill.UPDATE) - private Long updater; - - @Schema(description = "更新时间") - @TableField(fill = FieldFill.UPDATE) - private Date updateDate; - - @Schema(description = "创建者") - @TableField(fill = FieldFill.INSERT) - private Long creator; - - @Schema(description = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createDate; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/entity/ModelProviderEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/model/entity/ModelProviderEntity.java deleted file mode 100644 index 00904759b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/entity/ModelProviderEntity.java +++ /dev/null @@ -1,47 +0,0 @@ -package xiaozhi.modules.model.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -@TableName("ai_model_provider") -@Schema(description = "模型供应器表") -public class ModelProviderEntity { - - @TableId(type = IdType.ASSIGN_UUID) - @Schema(description = "主键") - private String id; - - @Schema(description = "模型类型(Memory/ASR/VAD/LLM/TTS)") - private String modelType; - - @Schema(description = "供应器类型,如 openai、") - private String providerCode; - - @Schema(description = "供应器名称") - private String name; - - @Schema(description = "供应器字段列表(JSON格式)") - private String fields; - - @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; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/service/ModelConfigService.java b/main/manager-api/src/main/java/xiaozhi/modules/model/service/ModelConfigService.java deleted file mode 100644 index 95b64b205..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/service/ModelConfigService.java +++ /dev/null @@ -1,58 +0,0 @@ -package xiaozhi.modules.model.service; - -import java.util.List; -import java.util.Map; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.model.dto.LlmModelBasicInfoDTO; -import xiaozhi.modules.model.dto.ModelBasicInfoDTO; -import xiaozhi.modules.model.dto.ModelConfigBodyDTO; -import xiaozhi.modules.model.dto.ModelConfigDTO; -import xiaozhi.modules.model.entity.ModelConfigEntity; - -public interface ModelConfigService extends BaseService { - - List getModelCodeList(String modelType, String modelName); - - List getLlmModelCodeList(String modelName); - - PageData getPageList(String modelType, String modelName, String page, String limit); - - ModelConfigDTO add(String modelType, String provideCode, ModelConfigBodyDTO modelConfigBodyDTO); - - ModelConfigDTO edit(String modelType, String provideCode, String id, ModelConfigBodyDTO modelConfigBodyDTO); - - void delete(String id); - - /** - * 根据ID获取模型名称 - * - * @param id 模型ID - * @return 模型名称 - */ - String getModelNameById(String id); - - /** - * 根据ID获取模型配置 - * - * @param id 模型ID - * @return 模型配置实体 - */ - ModelConfigEntity getModelByIdFromCache(String id); - - /** - * 设置默认模型 - * - * @param modelType 模型类型 - * @param isDefault 是否默认(1:是,0:否) - */ - void setDefaultModel(String modelType, int isDefault); - - /** - * 获取符合条件的TTS平台列表 - * - * @return TTS平台列表(id和modelName) - */ - List> getTtsPlatformList(); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/service/ModelProviderService.java b/main/manager-api/src/main/java/xiaozhi/modules/model/service/ModelProviderService.java deleted file mode 100644 index 829f86a8d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/service/ModelProviderService.java +++ /dev/null @@ -1,30 +0,0 @@ -package xiaozhi.modules.model.service; - -import java.util.Collection; -import java.util.List; - -import xiaozhi.common.page.PageData; -import xiaozhi.modules.model.dto.ModelProviderDTO; - -public interface ModelProviderService { - - List getPluginList(); - - ModelProviderDTO getById(String id); - - List getPluginListByIds(Collection ids); - - List getListByModelType(String modelType); - - ModelProviderDTO add(ModelProviderDTO modelProviderDTO); - - ModelProviderDTO edit(ModelProviderDTO modelProviderDTO); - - void delete(String id); - - void delete(List id); - - PageData getListPage(ModelProviderDTO modelProviderDTO, String page, String limit); - - List getList(String modelType, String provideCode); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/service/impl/ModelConfigServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/model/service/impl/ModelConfigServiceImpl.java deleted file mode 100644 index d17948a6d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/service/impl/ModelConfigServiceImpl.java +++ /dev/null @@ -1,498 +0,0 @@ -package xiaozhi.modules.model.service.impl; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.metadata.OrderItem; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.json.JSONObject; -import lombok.AllArgsConstructor; -import xiaozhi.common.constant.Constant; -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.utils.ConvertUtils; -import xiaozhi.common.utils.SensitiveDataUtils; -import xiaozhi.modules.agent.dao.AgentDao; -import xiaozhi.modules.agent.entity.AgentEntity; -import xiaozhi.modules.model.dao.ModelConfigDao; -import xiaozhi.modules.model.dto.LlmModelBasicInfoDTO; -import xiaozhi.modules.model.dto.ModelBasicInfoDTO; -import xiaozhi.modules.model.dto.ModelConfigBodyDTO; -import xiaozhi.modules.model.dto.ModelConfigDTO; -import xiaozhi.modules.model.dto.ModelProviderDTO; -import xiaozhi.modules.model.entity.ModelConfigEntity; -import xiaozhi.modules.model.service.ModelConfigService; -import xiaozhi.modules.model.service.ModelProviderService; - -@Service -@AllArgsConstructor -public class ModelConfigServiceImpl extends BaseServiceImpl - implements ModelConfigService { - - private final ModelConfigDao modelConfigDao; - private final ModelProviderService modelProviderService; - private final RedisUtils redisUtils; - private final AgentDao agentDao; - - @Override - public List getModelCodeList(String modelType, String modelName) { - List entities = modelConfigDao.selectList( - new QueryWrapper() - .eq("model_type", modelType) - .eq("is_enabled", 1) - .like(StringUtils.isNotBlank(modelName), "model_name", "%" + modelName + "%") - .select("id", "model_name")); - return ConvertUtils.sourceToTarget(entities, ModelBasicInfoDTO.class); - } - - @Override - public List getLlmModelCodeList(String modelName) { - List entities = modelConfigDao.selectList( - new QueryWrapper() - .eq("model_type", "llm") - .eq("is_enabled", 1) - .like(StringUtils.isNotBlank(modelName), "model_name", "%" + modelName + "%") - .select("id", "model_name", "config_json")); - - return entities.stream().map(item -> { - LlmModelBasicInfoDTO dto = new LlmModelBasicInfoDTO(); - dto.setId(item.getId()); - dto.setModelName(item.getModelName()); - String type = item.getConfigJson().get("type").toString(); - dto.setType(type); - return dto; - }).toList(); - } - - @Override - public PageData getPageList(String modelType, String modelName, String page, String limit) { - Map params = new HashMap<>(); - params.put(Constant.PAGE, page); - params.put(Constant.LIMIT, limit); - - long curPage = Long.parseLong(page); - long pageSize = Long.parseLong(limit); - Page pageInfo = new Page<>(curPage, pageSize); - - // 添加排序规则:先按is_enabled降序,再按sort升序 - pageInfo.addOrder(OrderItem.desc("is_enabled")); - pageInfo.addOrder(OrderItem.asc("sort")); - - IPage modelConfigEntityIPage = modelConfigDao.selectPage( - pageInfo, - new QueryWrapper() - .eq("model_type", modelType) - .like(StringUtils.isNotBlank(modelName), "model_name", "%" + modelName + "%")); - - return getPageData(modelConfigEntityIPage, ModelConfigDTO.class); - } - - @Override - public ModelConfigDTO edit(String modelType, String provideCode, String id, ModelConfigBodyDTO modelConfigBodyDTO) { - // 1. 参数验证 - validateEditParameters(modelType, provideCode, id, modelConfigBodyDTO); - - // 2. 验证模型提供者 - validateModelProvider(modelType, provideCode); - - // 3. 获取原始配置(不经过敏感数据处理) - ModelConfigEntity originalEntity = getOriginalConfigFromDb(id); - - // 4. 验证LLM配置 - validateLlmConfiguration(modelConfigBodyDTO); - - // 5. 准备更新实体并处理敏感数据 - ModelConfigEntity modelConfigEntity = prepareUpdateEntity(modelConfigBodyDTO, originalEntity, modelType, id); - - // 6. 执行数据库更新 - modelConfigDao.updateById(modelConfigEntity); - - // 7. 清除缓存 - clearModelCache(id); - - // 8. 返回处理后的数据(包含敏感数据掩码) - return buildResponseDTO(modelConfigEntity); - } - - @Override - public ModelConfigDTO add(String modelType, String provideCode, ModelConfigBodyDTO modelConfigBodyDTO) { - validateAddParameters(modelType, provideCode, modelConfigBodyDTO); - - validateModelProvider(modelType, provideCode); - - ModelConfigEntity modelConfigEntity = prepareAddEntity(modelConfigBodyDTO, modelType); - - modelConfigDao.insert(modelConfigEntity); - - return buildResponseDTO(modelConfigEntity); - } - - @Override - public void delete(String id) { - if (StringUtils.isBlank(id)) { - throw new RenException(ErrorCode.IDENTIFIER_NOT_NULL); - } - - ModelConfigEntity modelConfig = modelConfigDao.selectById(id); - if (modelConfig != null && modelConfig.getIsDefault() == 1) { - throw new RenException(ErrorCode.DEFAULT_MODEL_DELETE_ERROR); - } - - checkAgentReference(id); - checkIntentConfigReference(id); - - modelConfigDao.deleteById(id); - - clearModelCache(id); - } - - @Override - public String getModelNameById(String id) { - if (StringUtils.isBlank(id)) { - return null; - } - - String cacheKey = RedisKeys.getModelNameById(id); - String cachedName = (String) redisUtils.get(cacheKey); - if (StringUtils.isNotBlank(cachedName)) { - return cachedName; - } - - ModelConfigEntity entity = modelConfigDao.selectById(id); - if (entity != null) { - String modelName = entity.getModelName(); - if (StringUtils.isNotBlank(modelName)) { - redisUtils.set(cacheKey, modelName); - } - return modelName; - } - - return null; - } - - @Override - public ModelConfigEntity selectById(Serializable id) { - ModelConfigEntity entity = super.selectById(id); - if (entity != null && entity.getConfigJson() != null) { - entity.setConfigJson(maskSensitiveFields(entity.getConfigJson())); - } - return entity; - } - - @Override - protected PageData getPageData(IPage page, Class target) { - List records = page.getRecords(); - if (records != null && !records.isEmpty()) { - for (Object record : records) { - if (record instanceof ModelConfigEntity) { - ModelConfigEntity entity = (ModelConfigEntity) record; - if (entity.getConfigJson() != null) { - entity.setConfigJson(maskSensitiveFields(entity.getConfigJson())); - } - } - } - } - return super.getPageData(page, target); - } - - @Override - public ModelConfigEntity getModelByIdFromCache(String id) { - if (StringUtils.isBlank(id)) { - return null; - } - String cacheKey = RedisKeys.getModelConfigById(id); - ModelConfigEntity entity = (ModelConfigEntity) redisUtils.get(cacheKey); - if (entity == null) { - entity = modelConfigDao.selectById(id); - if (entity != null) { - redisUtils.set(cacheKey, entity); - } - } - return entity; - } - - /** - * 验证编辑参数 - */ - private void validateEditParameters(String modelType, String provideCode, String id, - ModelConfigBodyDTO modelConfigBodyDTO) { - if (StringUtils.isBlank(modelType) || StringUtils.isBlank(provideCode)) { - throw new RenException(ErrorCode.MODEL_TYPE_PROVIDE_CODE_NOT_NULL); - } - if (StringUtils.isBlank(id)) { - throw new RenException(ErrorCode.IDENTIFIER_NOT_NULL); - } - if (modelConfigBodyDTO == null) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR); - } - } - - /** - * 验证添加参数 - */ - private void validateAddParameters(String modelType, String provideCode, ModelConfigBodyDTO modelConfigBodyDTO) { - if (StringUtils.isBlank(modelType) || StringUtils.isBlank(provideCode)) { - throw new RenException(ErrorCode.MODEL_TYPE_PROVIDE_CODE_NOT_NULL); - } - if (modelConfigBodyDTO == null) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR); - } - } - - /** - * 设置默认模型 - */ - @Override - public void setDefaultModel(String modelType, int isDefault) { - // 参数验证 - if (StringUtils.isBlank(modelType)) { - throw new RenException(ErrorCode.MODEL_TYPE_PROVIDE_CODE_NOT_NULL); - } - - ModelConfigEntity entity = new ModelConfigEntity(); - entity.setIsDefault(isDefault); - modelConfigDao.update(entity, new QueryWrapper() - .eq("model_type", modelType)); - - // 清除相关缓存 - clearModelCacheByType(modelType); - } - - /** - * 验证模型提供者 - */ - private void validateModelProvider(String modelType, String provideCode) { - List providerList = modelProviderService.getList(modelType, provideCode); - if (CollectionUtil.isEmpty(providerList)) { - throw new RenException(ErrorCode.MODEL_PROVIDER_NOT_EXIST); - } - } - - /** - * 从数据库获取原始配置(不经过敏感数据处理) - */ - private ModelConfigEntity getOriginalConfigFromDb(String id) { - ModelConfigEntity originalEntity = modelConfigDao.selectById(id); - if (originalEntity == null) { - throw new RenException(ErrorCode.RESOURCE_NOT_FOUND); - } - return originalEntity; - } - - /** - * 验证LLM配置 - */ - private void validateLlmConfiguration(ModelConfigBodyDTO modelConfigBodyDTO) { - if (modelConfigBodyDTO.getConfigJson() != null && modelConfigBodyDTO.getConfigJson().containsKey("llm")) { - String llm = modelConfigBodyDTO.getConfigJson().get("llm").toString(); - ModelConfigEntity modelConfigEntity = modelConfigDao.selectOne(new LambdaQueryWrapper() - .eq(ModelConfigEntity::getId, llm)); - - if (modelConfigEntity == null) { - throw new RenException(ErrorCode.LLM_NOT_EXIST); - } - - String modelType = modelConfigEntity.getModelType(); - if (modelType == null || !"LLM".equals(modelType.toUpperCase())) { - throw new RenException(ErrorCode.LLM_NOT_EXIST); - } - - // 验证LLM类型 - JSONObject configJson = modelConfigEntity.getConfigJson(); - if (configJson != null && configJson.containsKey("type")) { - String type = configJson.get("type").toString(); - if (!"openai".equals(type) && !"ollama".equals(type)) { - throw new RenException(ErrorCode.INVALID_LLM_TYPE); - } - } - } - } - - /** - * 准备更新实体,处理敏感数据 - */ - private ModelConfigEntity prepareUpdateEntity(ModelConfigBodyDTO modelConfigBodyDTO, - ModelConfigEntity originalEntity, - String modelType, - String id) { - // 1. 复制原始实体,保留所有原始数据(包括敏感信息) - ModelConfigEntity modelConfigEntity = ConvertUtils.sourceToTarget(originalEntity, ModelConfigEntity.class); - modelConfigEntity.setId(id); - modelConfigEntity.setModelType(modelType); - - // 2. 只更新非敏感字段 - modelConfigEntity.setModelName(modelConfigBodyDTO.getModelName()); - modelConfigEntity.setSort(modelConfigBodyDTO.getSort()); - modelConfigEntity.setIsEnabled(modelConfigBodyDTO.getIsEnabled()); - // 3. 处理配置JSON,仅更新非敏感字段和明确修改的敏感字段 - if (modelConfigBodyDTO.getConfigJson() != null && originalEntity.getConfigJson() != null) { - JSONObject originalJson = originalEntity.getConfigJson(); - JSONObject updatedJson = new JSONObject(originalJson); // 基于原始JSON进行修改 - - // 遍历更新的JSON,只更新非敏感字段或确实被修改的敏感字段 - for (String key : modelConfigBodyDTO.getConfigJson().keySet()) { - Object value = modelConfigBodyDTO.getConfigJson().get(key); - - // 如果是敏感字段,需要确认是否真的被修改(前端传入的可能是掩码后的值) - if (SensitiveDataUtils.isSensitiveField(key)) { - - if (value instanceof String && !SensitiveDataUtils.isMaskedValue((String) value)) { - updatedJson.put(key, value); - } - } else if (value instanceof JSONObject) { - // 递归处理嵌套JSON - mergeJson(updatedJson, key, (JSONObject) value); - } else { - // 非敏感字段直接更新 - updatedJson.put(key, value); - } - } - - modelConfigEntity.setConfigJson(updatedJson); - } - - return modelConfigEntity; - } - - // 辅助方法:判断值是否是掩码格式 - private boolean isMaskedValue(String value) { - if (value == null) - return false; - // 简单判断是否包含掩码的特征(***) - return value.contains("***"); - } - - // 辅助方法:递归合并JSON,保留原始敏感字段 - private void mergeJson(JSONObject original, String key, JSONObject updated) { - if (!original.containsKey(key)) { - original.put(key, new JSONObject()); - } - JSONObject originalChild = original.getJSONObject(key); - - for (String childKey : updated.keySet()) { - Object childValue = updated.get(childKey); - if (childValue instanceof JSONObject) { - mergeJson(originalChild, childKey, (JSONObject) childValue); - } else { - if (!SensitiveDataUtils.isSensitiveField(childKey) || - (childValue instanceof String && !isMaskedValue((String) childValue))) { - originalChild.put(childKey, childValue); - } - } - } - } - - /** - * 准备新增实体 - */ - private ModelConfigEntity prepareAddEntity(ModelConfigBodyDTO modelConfigBodyDTO, String modelType) { - ModelConfigEntity modelConfigEntity = ConvertUtils.sourceToTarget(modelConfigBodyDTO, ModelConfigEntity.class); - modelConfigEntity.setModelType(modelType); - modelConfigEntity.setIsDefault(0); - return modelConfigEntity; - } - - /** - * 构建返回的DTO,处理敏感数据 - */ - private ModelConfigDTO buildResponseDTO(ModelConfigEntity entity) { - ModelConfigDTO dto = ConvertUtils.sourceToTarget(entity, ModelConfigDTO.class); - if (dto.getConfigJson() != null) { - dto.setConfigJson(maskSensitiveFields(dto.getConfigJson())); - } - return dto; - } - - /** - * 处理敏感字段 - */ - private JSONObject maskSensitiveFields(JSONObject configJson) { - return SensitiveDataUtils.maskSensitiveFields(configJson); - } - - /** - * 清除模型缓存 - */ - private void clearModelCache(String id) { - redisUtils.delete(RedisKeys.getModelConfigById(id)); - redisUtils.delete(RedisKeys.getModelNameById(id)); - } - - /** - * 按模型类型清除缓存 - */ - private void clearModelCacheByType(String modelType) { - List entities = modelConfigDao.selectList( - new QueryWrapper().eq("model_type", modelType)); - for (ModelConfigEntity entity : entities) { - clearModelCache(entity.getId()); - } - } - - /** - * 检查智能体配置是否有引用 - */ - private void checkAgentReference(String modelId) { - List agents = agentDao.selectList( - new QueryWrapper() - .eq("vad_model_id", modelId) - .or() - .eq("asr_model_id", modelId) - .or() - .eq("llm_model_id", modelId) - .or() - .eq("tts_model_id", modelId) - .or() - .eq("mem_model_id", modelId) - .or() - .eq("vllm_model_id", modelId) - .or() - .eq("intent_model_id", modelId)); - if (!agents.isEmpty()) { - String agentNames = agents.stream() - .map(AgentEntity::getAgentName) - .collect(Collectors.joining("、")); - throw new RenException(ErrorCode.MODEL_REFERENCED_BY_AGENT, agentNames); - } - } - - /** - * 检查意图识别配置是否有引用 - */ - private void checkIntentConfigReference(String modelId) { - ModelConfigEntity modelConfig = modelConfigDao.selectById(modelId); - if (modelConfig != null - && "LLM".equals(modelConfig.getModelType() == null ? null : modelConfig.getModelType().toUpperCase())) { - List intentConfigs = modelConfigDao.selectList( - new QueryWrapper() - .eq("model_type", "Intent") - .like("config_json", "%" + modelId + "%")); - if (!intentConfigs.isEmpty()) { - throw new RenException(ErrorCode.LLM_REFERENCED_BY_INTENT); - } - } - } - - /** - * 获取符合条件的TTS平台列表 - */ - @Override - public List> getTtsPlatformList() { - return modelConfigDao.getTtsPlatformList(); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/service/impl/ModelProviderServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/model/service/impl/ModelProviderServiceImpl.java deleted file mode 100644 index 69e6b75c4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/service/impl/ModelProviderServiceImpl.java +++ /dev/null @@ -1,153 +0,0 @@ -package xiaozhi.modules.model.service.impl; - -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import cn.hutool.json.JSONArray; -import lombok.AllArgsConstructor; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.common.user.UserDetail; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.modules.model.dao.ModelProviderDao; -import xiaozhi.modules.model.dto.ModelProviderDTO; -import xiaozhi.modules.model.entity.ModelProviderEntity; -import xiaozhi.modules.model.service.ModelProviderService; -import xiaozhi.modules.security.user.SecurityUser; - -@Service -@AllArgsConstructor -public class ModelProviderServiceImpl extends BaseServiceImpl - implements ModelProviderService { - - private final ModelProviderDao modelProviderDao; - - @Override - public List getPluginList() { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(ModelProviderEntity::getModelType, "Plugin"); - List providerEntities = modelProviderDao.selectList(queryWrapper); - return ConvertUtils.sourceToTarget(providerEntities, ModelProviderDTO.class); - } - - @Override - public ModelProviderDTO getById(String id) { - ModelProviderEntity entity = modelProviderDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, ModelProviderDTO.class); - } - - @Override - public List getPluginListByIds(Collection ids) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.in(ModelProviderEntity::getId, ids); - queryWrapper.eq(ModelProviderEntity::getModelType, "Plugin"); - List providerEntities = modelProviderDao.selectList(queryWrapper); - return ConvertUtils.sourceToTarget(providerEntities, ModelProviderDTO.class); - } - - @Override - public List getListByModelType(String modelType) { - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("model_type", StringUtils.isBlank(modelType) ? "" : modelType); - List providerEntities = modelProviderDao.selectList(queryWrapper); - return ConvertUtils.sourceToTarget(providerEntities, ModelProviderDTO.class); - } - - @Override - public PageData getListPage(ModelProviderDTO modelProviderDTO, String page, String limit) { - - Map params = new HashMap(); - params.put(Constant.PAGE, page); - params.put(Constant.LIMIT, limit); - params.put(Constant.ORDER_FIELD, List.of("model_type", "sort")); - params.put(Constant.ORDER, "asc"); - - IPage pageParam = getPage(params, null, true); - - QueryWrapper wrapper = new QueryWrapper(); - - if (StringUtils.isNotBlank(modelProviderDTO.getModelType())) { - wrapper.eq("model_type", modelProviderDTO.getModelType()); - } - - if (StringUtils.isNotBlank(modelProviderDTO.getName())) { - wrapper.and(w -> w.like("name", modelProviderDTO.getName()) - .or() - .like("provider_code", modelProviderDTO.getName())); - } - return getPageData(modelProviderDao.selectPage(pageParam, wrapper), ModelProviderDTO.class); - } - - public static void main(String[] args) { - String jsonString = "\"[]\""; - JSONArray jsonArray = new JSONArray(jsonString); - System.out.println("字符串转 JSONArray: " + jsonArray.toString()); - } - - @Override - public ModelProviderDTO add(ModelProviderDTO modelProviderDTO) { - UserDetail user = SecurityUser.getUser(); - modelProviderDTO.setCreator(user.getId()); - modelProviderDTO.setUpdater(user.getId()); - modelProviderDTO.setCreateDate(new Date()); - modelProviderDTO.setUpdateDate(new Date()); - // 去除Fields左右的双引号 - - modelProviderDTO.setFields(modelProviderDTO.getFields()); - ModelProviderEntity entity = ConvertUtils.sourceToTarget(modelProviderDTO, ModelProviderEntity.class); - if (modelProviderDao.insert(entity) == 0) { - throw new RenException(ErrorCode.ADD_DATA_FAILED); - } - - return ConvertUtils.sourceToTarget(modelProviderDTO, ModelProviderDTO.class); - } - - @Override - public ModelProviderDTO edit(ModelProviderDTO modelProviderDTO) { - UserDetail user = SecurityUser.getUser(); - modelProviderDTO.setUpdater(user.getId()); - modelProviderDTO.setUpdateDate(new Date()); - if (modelProviderDao - .updateById(ConvertUtils.sourceToTarget(modelProviderDTO, ModelProviderEntity.class)) == 0) { - throw new RenException(ErrorCode.UPDATE_DATA_FAILED); - } - return ConvertUtils.sourceToTarget(modelProviderDTO, ModelProviderDTO.class); - } - - @Override - public void delete(String id) { - if (modelProviderDao.deleteById(id) == 0) { - throw new RenException(ErrorCode.DELETE_DATA_FAILED); - } - } - - @Override - public void delete(List ids) { - if (modelProviderDao.deleteBatchIds(ids) == 0) { - throw new RenException(ErrorCode.DELETE_DATA_FAILED); - } - } - - @Override - public List getList(String modelType, String providerCode) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("model_type", StringUtils.isBlank(modelType) ? "" : modelType); - queryWrapper.eq("provider_code", StringUtils.isBlank(providerCode) ? "" : providerCode); - List providerEntities = modelProviderDao.selectList(queryWrapper); - return ConvertUtils.sourceToTarget(providerEntities, ModelProviderDTO.class); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/config/FilterConfig.java b/main/manager-api/src/main/java/xiaozhi/modules/security/config/FilterConfig.java deleted file mode 100644 index d74ed08ba..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/config/FilterConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package xiaozhi.modules.security.config; - -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.filter.DelegatingFilterProxy; - -/** - * Filter配置 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Configuration -public class FilterConfig { - - @Bean - public FilterRegistrationBean shiroFilterRegistration() { - FilterRegistrationBean registration = new FilterRegistrationBean<>(); - registration.setFilter(new DelegatingFilterProxy("shiroFilter")); - // 该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理 - registration.addInitParameter("targetFilterLifecycle", "true"); - registration.setEnabled(true); - registration.setOrder(Integer.MAX_VALUE - 1); - registration.addUrlPatterns("/*"); - return registration; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/config/ShiroConfig.java b/main/manager-api/src/main/java/xiaozhi/modules/security/config/ShiroConfig.java deleted file mode 100644 index 051cbc298..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/config/ShiroConfig.java +++ /dev/null @@ -1,112 +0,0 @@ -package xiaozhi.modules.security.config; - -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.shiro.mgt.SecurityManager; -import org.apache.shiro.session.mgt.SessionManager; -import org.apache.shiro.spring.LifecycleBeanPostProcessor; -import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; -import org.apache.shiro.spring.web.ShiroFilterFactoryBean; -import org.apache.shiro.web.config.ShiroFilterConfiguration; -import org.apache.shiro.web.mgt.DefaultWebSecurityManager; -import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import jakarta.servlet.Filter; -import xiaozhi.modules.security.oauth2.Oauth2Filter; -import xiaozhi.modules.security.oauth2.Oauth2Realm; -import xiaozhi.modules.security.secret.ServerSecretFilter; -import xiaozhi.modules.sys.service.SysParamsService; - -/** - * Shiro的配置文件 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Configuration -public class ShiroConfig { - - @Bean - public DefaultWebSessionManager sessionManager() { - DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); - sessionManager.setSessionValidationSchedulerEnabled(false); - sessionManager.setSessionIdUrlRewritingEnabled(false); - - return sessionManager; - } - - @Bean("securityManager") - public SecurityManager securityManager(Oauth2Realm oAuth2Realm, SessionManager sessionManager) { - DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); - securityManager.setRealm(oAuth2Realm); - securityManager.setSessionManager(sessionManager); - securityManager.setRememberMeManager(null); - return securityManager; - } - - @Bean("shiroFilter") - public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager, SysParamsService sysParamsService) { - ShiroFilterConfiguration config = new ShiroFilterConfiguration(); - config.setFilterOncePerRequest(true); - - ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean(); - shiroFilter.setSecurityManager(securityManager); - shiroFilter.setShiroFilterConfiguration(config); - - Map filters = new HashMap<>(); - // oauth过滤 - filters.put("oauth2", new Oauth2Filter()); - // 服务密钥过滤 - filters.put("server", new ServerSecretFilter(sysParamsService)); - shiroFilter.setFilters(filters); - - // 添加Shiro的内置过滤器 - /* - * anon:无需认证就可以访问 - * authc:必须认证了才能让问 - * user:必须拥有,记住我功能,才能访问 - * perms:拥有对某个资源的权限才能访问 - * role:拥有某个角色权限才能访问 - */ - Map filterMap = new LinkedHashMap<>(); - filterMap.put("/ota/**", "anon"); - filterMap.put("/otaMag/download/**", "anon"); - filterMap.put("/webjars/**", "anon"); - filterMap.put("/druid/**", "anon"); - filterMap.put("/v3/api-docs/**", "anon"); - filterMap.put("/doc.html", "anon"); - filterMap.put("/favicon.ico", "anon"); - filterMap.put("/user/captcha", "anon"); - filterMap.put("/user/smsVerification", "anon"); - filterMap.put("/user/login", "anon"); - filterMap.put("/user/pub-config", "anon"); - filterMap.put("/user/register", "anon"); - filterMap.put("/user/retrieve-password", "anon"); - // 将config路径使用server服务过滤器 - filterMap.put("/config/**", "server"); - filterMap.put("/agent/chat-history/report", "server"); - filterMap.put("/agent/chat-history/download/**", "anon"); - filterMap.put("/agent/saveMemory/**", "server"); - filterMap.put("/agent/play/**", "anon"); - filterMap.put("/voiceClone/play/**", "anon"); - filterMap.put("/**", "oauth2"); - shiroFilter.setFilterChainDefinitionMap(filterMap); - - return shiroFilter; - } - - @Bean("lifecycleBeanPostProcessor") - public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { - return new LifecycleBeanPostProcessor(); - } - - @Bean - public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { - AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor(); - advisor.setSecurityManager(securityManager); - return advisor; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/config/WebMvcConfig.java b/main/manager-api/src/main/java/xiaozhi/modules/security/config/WebMvcConfig.java deleted file mode 100644 index f13194b1b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/config/WebMvcConfig.java +++ /dev/null @@ -1,146 +0,0 @@ -package xiaozhi.modules.security.config; - -import java.text.SimpleDateFormat; -import java.util.List; -import java.util.Locale; -import java.util.TimeZone; - -import jakarta.servlet.http.HttpServletRequest; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.ResourceHttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter; -import org.springframework.web.servlet.LocaleResolver; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; - -import xiaozhi.common.utils.DateUtils; - -@Configuration -public class WebMvcConfig implements WebMvcConfigurer { - - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOriginPatterns("*") - .allowCredentials(true) - .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") - .maxAge(3600); - } - - @Override - public void configureMessageConverters(List> converters) { - // 特殊用途的转换器 - converters.add(new ByteArrayHttpMessageConverter()); - converters.add(new ResourceHttpMessageConverter()); - - // 通用转换器 - converters.add(new StringHttpMessageConverter()); - converters.add(new AllEncompassingFormHttpMessageConverter()); - - // JSON 转换器 - converters.add(jackson2HttpMessageConverter()); - } - - @Bean - public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() { - MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); - ObjectMapper mapper = new ObjectMapper(); - - // 忽略未知属性 - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - // 设置时区 - mapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); - - // 配置Java8日期时间序列化 - JavaTimeModule javaTimeModule = new JavaTimeModule(); - javaTimeModule.addSerializer(java.time.LocalDateTime.class, new LocalDateTimeSerializer( - java.time.format.DateTimeFormatter.ofPattern(DateUtils.DATE_TIME_PATTERN))); - javaTimeModule.addSerializer(java.time.LocalDate.class, new LocalDateSerializer( - java.time.format.DateTimeFormatter.ofPattern(DateUtils.DATE_PATTERN))); - javaTimeModule.addSerializer(java.time.LocalTime.class, - new LocalTimeSerializer(java.time.format.DateTimeFormatter.ofPattern("HH:mm:ss"))); - javaTimeModule.addDeserializer(java.time.LocalDateTime.class, new LocalDateTimeDeserializer( - java.time.format.DateTimeFormatter.ofPattern(DateUtils.DATE_TIME_PATTERN))); - javaTimeModule.addDeserializer(java.time.LocalDate.class, new LocalDateDeserializer( - java.time.format.DateTimeFormatter.ofPattern(DateUtils.DATE_PATTERN))); - javaTimeModule.addDeserializer(java.time.LocalTime.class, - new LocalTimeDeserializer(java.time.format.DateTimeFormatter.ofPattern("HH:mm:ss"))); - mapper.registerModule(javaTimeModule); - - // 配置java.util.Date的序列化和反序列化 - SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN); - mapper.setDateFormat(dateFormat); - - // Long类型转String类型 - SimpleModule simpleModule = new SimpleModule(); - simpleModule.addSerializer(Long.class, ToStringSerializer.instance); - simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); - mapper.registerModule(simpleModule); - - converter.setObjectMapper(mapper); - return converter; - } - - /** - * 国际化配置 - 根据请求头中的Accept-Language设置语言环境 - */ - @Bean - public LocaleResolver localeResolver() { - return new AcceptHeaderLocaleResolver() { - @Override - public Locale resolveLocale(HttpServletRequest request) { - String acceptLanguage = request.getHeader("Accept-Language"); - if (acceptLanguage == null || acceptLanguage.isEmpty()) { - return Locale.getDefault(); - } - - // 解析Accept-Language请求头中的首选语言 - String[] languages = acceptLanguage.split(","); - if (languages.length > 0) { - // 提取第一个语言代码,去除可能的质量值(q=...) - String[] parts = languages[0].split(";" + "\\s*"); - String primaryLanguage = parts[0].trim(); - - // 根据前端发送的语言代码直接创建Locale对象 - if (primaryLanguage.equals("zh-CN")) { - return Locale.SIMPLIFIED_CHINESE; - } else if (primaryLanguage.equals("zh-TW")) { - return Locale.TRADITIONAL_CHINESE; - } else if (primaryLanguage.equals("en-US")) { - return Locale.US; - } else if (primaryLanguage.startsWith("zh")) { - // 对于其他中文变体,默认使用简体中文 - return Locale.SIMPLIFIED_CHINESE; - } else if (primaryLanguage.startsWith("en")) { - // 对于其他英文变体,默认使用美式英语 - return Locale.US; - } - } - - // 如果没有匹配的语言,使用默认语言 - return Locale.getDefault(); - } - }; - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/controller/LoginController.java b/main/manager-api/src/main/java/xiaozhi/modules/security/controller/LoginController.java deleted file mode 100644 index a008c25bb..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/controller/LoginController.java +++ /dev/null @@ -1,242 +0,0 @@ -package xiaozhi.modules.security.controller; - -import java.io.IOException; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.servlet.http.HttpServletResponse; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.page.TokenDTO; -import xiaozhi.common.user.UserDetail; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.AssertUtils; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.security.dto.LoginDTO; -import xiaozhi.modules.security.dto.SmsVerificationDTO; -import xiaozhi.modules.security.password.PasswordUtils; -import xiaozhi.modules.security.service.CaptchaService; -import xiaozhi.modules.security.service.SysUserTokenService; -import xiaozhi.modules.security.user.SecurityUser; -import xiaozhi.common.utils.Sm2DecryptUtil; -import org.apache.commons.lang3.StringUtils; -import xiaozhi.modules.sys.dto.PasswordDTO; -import xiaozhi.modules.sys.dto.RetrievePasswordDTO; -import xiaozhi.modules.sys.dto.SysUserDTO; -import xiaozhi.modules.sys.service.SysDictDataService; -import xiaozhi.modules.sys.service.SysParamsService; -import xiaozhi.modules.sys.service.SysUserService; -import xiaozhi.modules.sys.vo.SysDictDataItem; - -/** - * 登录控制层 - */ -@Slf4j -@AllArgsConstructor -@RestController -@RequestMapping("/user") -@Tag(name = "登录管理") -public class LoginController { - private final SysUserService sysUserService; - private final SysUserTokenService sysUserTokenService; - private final CaptchaService captchaService; - private final SysParamsService sysParamsService; - private final SysDictDataService sysDictDataService; - - @GetMapping("/captcha") - @Operation(summary = "验证码") - public void captcha(HttpServletResponse response, String uuid) throws IOException { - // uuid不能为空 - AssertUtils.isBlank(uuid, ErrorCode.IDENTIFIER_NOT_NULL); - // 生成验证码 - captchaService.create(response, uuid); - } - - @PostMapping("/smsVerification") - @Operation(summary = "短信验证码") - public Result smsVerification(@RequestBody SmsVerificationDTO dto) { - // 验证图形验证码 - boolean validate = captchaService.validate(dto.getCaptchaId(), dto.getCaptcha(), false); - if (!validate) { - throw new RenException(ErrorCode.SMS_CAPTCHA_ERROR); - } - - Boolean isMobileRegister = sysParamsService - .getValueObject(Constant.SysMSMParam.SERVER_ENABLE_MOBILE_REGISTER.getValue(), Boolean.class); - if (!isMobileRegister) { - throw new RenException(ErrorCode.MOBILE_REGISTER_DISABLED); - } - // 发送短信验证码 - captchaService.sendSMSValidateCode(dto.getPhone()); - return new Result<>(); - } - - @PostMapping("/login") - @Operation(summary = "登录") - public Result login(@RequestBody LoginDTO login) { - String password = login.getPassword(); - - // 使用工具类解密并验证验证码 - String actualPassword = Sm2DecryptUtil.decryptAndValidateCaptcha( - password, login.getCaptchaId(), captchaService, sysParamsService); - - login.setPassword(actualPassword); - - // 按照用户名获取用户 - SysUserDTO userDTO = sysUserService.getByUsername(login.getUsername()); - // 判断用户是否存在 - if (userDTO == null) { - throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR); - } - // 判断密码是否正确,不一样则进入if - if (!PasswordUtils.matches(login.getPassword(), userDTO.getPassword())) { - throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR); - } - return sysUserTokenService.createToken(userDTO.getId()); - } - - - - @PostMapping("/register") - @Operation(summary = "注册") - public Result register(@RequestBody LoginDTO login) { - if (!sysUserService.getAllowUserRegister()) { - throw new RenException(ErrorCode.USER_REGISTER_DISABLED); - } - - String password = login.getPassword(); - - // 使用工具类解密并验证验证码 - String actualPassword = Sm2DecryptUtil.decryptAndValidateCaptcha( - password, login.getCaptchaId(), captchaService, sysParamsService); - - login.setPassword(actualPassword); - - // 是否开启手机注册 - Boolean isMobileRegister = sysParamsService - .getValueObject(Constant.SysMSMParam.SERVER_ENABLE_MOBILE_REGISTER.getValue(), Boolean.class); - boolean validate; - if (isMobileRegister) { - // 验证用户是否是手机号码 - boolean validPhone = ValidatorUtils.isValidPhone(login.getUsername()); - if (!validPhone) { - throw new RenException(ErrorCode.USERNAME_NOT_PHONE); - } - // 验证短信验证码是否正常 - validate = captchaService.validateSMSValidateCode(login.getUsername(), login.getMobileCaptcha(), false); - if (!validate) { - throw new RenException(ErrorCode.SMS_CODE_ERROR); - } - } - - // 按照用户名获取用户 - SysUserDTO userDTO = sysUserService.getByUsername(login.getUsername()); - if (userDTO != null) { - throw new RenException(ErrorCode.PHONE_ALREADY_REGISTERED); - } - userDTO = new SysUserDTO(); - userDTO.setUsername(login.getUsername()); - userDTO.setPassword(login.getPassword()); - sysUserService.save(userDTO); - return new Result<>(); - } - - @GetMapping("/info") - @Operation(summary = "用户信息获取") - public Result info() { - UserDetail user = SecurityUser.getUser(); - Result result = new Result<>(); - result.setData(user); - return result; - } - - @PutMapping("/change-password") - @Operation(summary = "修改用户密码") - public Result changePassword(@RequestBody PasswordDTO passwordDTO) { - // 判断非空 - ValidatorUtils.validateEntity(passwordDTO); - Long userId = SecurityUser.getUserId(); - sysUserTokenService.changePassword(userId, passwordDTO); - return new Result<>(); - } - - @PutMapping("/retrieve-password") - @Operation(summary = "找回密码") - public Result retrievePassword(@RequestBody RetrievePasswordDTO dto) { - // 是否开启手机注册 - Boolean isMobileRegister = sysParamsService - .getValueObject(Constant.SysMSMParam.SERVER_ENABLE_MOBILE_REGISTER.getValue(), Boolean.class); - if (!isMobileRegister) { - throw new RenException(ErrorCode.RETRIEVE_PASSWORD_DISABLED); - } - // 判断非空 - ValidatorUtils.validateEntity(dto); - // 验证用户是否是手机号码 - boolean validPhone = ValidatorUtils.isValidPhone(dto.getPhone()); - if (!validPhone) { - throw new RenException(ErrorCode.PHONE_FORMAT_ERROR); - } - - // 按照用户名获取用户 - SysUserDTO userDTO = sysUserService.getByUsername(dto.getPhone()); - if (userDTO == null) { - throw new RenException(ErrorCode.PHONE_NOT_REGISTERED); - } - // 验证短信验证码是否正常 - boolean validate = captchaService.validateSMSValidateCode(dto.getPhone(), dto.getCode(), false); - // 判断是否通过验证 - if (!validate) { - throw new RenException(ErrorCode.SMS_CODE_ERROR); - } - - String password = dto.getPassword(); - - // 使用工具类解密并验证验证码 - String actualPassword = Sm2DecryptUtil.decryptAndValidateCaptcha( - password, dto.getCaptchaId(), captchaService, sysParamsService); - - dto.setPassword(actualPassword); - - sysUserService.changePasswordDirectly(userDTO.getId(), dto.getPassword()); - return new Result<>(); - } - - @GetMapping("/pub-config") - @Operation(summary = "公共配置") - public Result> pubConfig() { - Map config = new HashMap<>(); - config.put("enableMobileRegister", sysParamsService - .getValueObject(Constant.SysMSMParam.SERVER_ENABLE_MOBILE_REGISTER.getValue(), Boolean.class)); - config.put("version", Constant.VERSION); - config.put("year", "©" + Calendar.getInstance().get(Calendar.YEAR)); - config.put("allowUserRegister", sysUserService.getAllowUserRegister()); - List list = sysDictDataService.getDictDataByType(Constant.DictType.MOBILE_AREA.getValue()); - config.put("mobileAreaList", list); - config.put("beianIcpNum", sysParamsService.getValue(Constant.SysBaseParam.BEIAN_ICP_NUM.getValue(), true)); - config.put("beianGaNum", sysParamsService.getValue(Constant.SysBaseParam.BEIAN_GA_NUM.getValue(), true)); - config.put("name", sysParamsService.getValue(Constant.SysBaseParam.SERVER_NAME.getValue(), true)); - - // SM2公钥 - String publicKey = sysParamsService.getValue(Constant.SM2_PUBLIC_KEY, true); - if (StringUtils.isBlank(publicKey)) { - throw new RenException(ErrorCode.SM2_KEY_NOT_CONFIGURED); - } - config.put("sm2PublicKey", publicKey); - - return new Result>().ok(config); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/dao/SysUserTokenDao.java b/main/manager-api/src/main/java/xiaozhi/modules/security/dao/SysUserTokenDao.java deleted file mode 100644 index 05f946d32..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/dao/SysUserTokenDao.java +++ /dev/null @@ -1,24 +0,0 @@ -package xiaozhi.modules.security.dao; - -import java.util.Date; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import xiaozhi.common.dao.BaseDao; -import xiaozhi.modules.security.entity.SysUserTokenEntity; - -/** - * 系统用户Token - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Mapper -public interface SysUserTokenDao extends BaseDao { - - SysUserTokenEntity getByToken(String token); - - SysUserTokenEntity getByUserId(Long userId); - - void logout(@Param("userId") Long userId, @Param("expireDate") Date expireDate); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/dto/LoginDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/security/dto/LoginDTO.java deleted file mode 100644 index df13f23df..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/dto/LoginDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package xiaozhi.modules.security.dto; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -/** - * 登录表单 - */ -@Data -@Schema(description = "登录表单") -public class LoginDTO implements Serializable { - - @Schema(description = "手机号码") - @NotBlank(message = "{sysuser.username.require}") - private String username; - - @Schema(description = "密码") - @NotBlank(message = "{sysuser.password.require}") - private String password; - - @Schema(description = "手机验证码") - private String mobileCaptcha; - - @Schema(description = "唯一标识") - @NotBlank(message = "{sysuser.uuid.require}") - private String captchaId; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/dto/SmsVerificationDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/security/dto/SmsVerificationDTO.java deleted file mode 100644 index 425ef0597..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/dto/SmsVerificationDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package xiaozhi.modules.security.dto; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -/** - * 短信验证码请求DTO - */ -@Data -@Schema(description = "短信验证码请求") -public class SmsVerificationDTO implements Serializable { - private static final long serialVersionUID = 1L; - - @Schema(description = "手机号码") - @NotBlank(message = "{sysuser.username.require}") - private String phone; - - @Schema(description = "验证码") - @NotBlank(message = "{sysuser.captcha.require}") - private String captcha; - - @Schema(description = "唯一标识") - @NotBlank(message = "{sysuser.uuid.require}") - private String captchaId; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/entity/SysUserTokenEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/security/entity/SysUserTokenEntity.java deleted file mode 100644 index 2346b5e49..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/entity/SysUserTokenEntity.java +++ /dev/null @@ -1,47 +0,0 @@ -package xiaozhi.modules.security.entity; - -import java.io.Serializable; -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - -/** - * 系统用户Token - */ -@Data -@TableName("sys_user_token") -public class SysUserTokenEntity implements Serializable { - - /** - * id - */ - @TableId - private Long id; - /** - * 用户ID - */ - private Long userId; - /** - * 用户token - */ - private String token; - /** - * 过期时间 - */ - private Date expireDate; - /** - * 更新时间 - */ - private Date updateDate; - /** - * 创建时间 - */ - @TableField(fill = FieldFill.INSERT) - private Date createDate; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Filter.java b/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Filter.java deleted file mode 100644 index 59d7e09e6..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Filter.java +++ /dev/null @@ -1,109 +0,0 @@ -package xiaozhi.modules.security.oauth2; - -import java.io.IOException; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authc.AuthenticationException; -import org.apache.shiro.authc.AuthenticationToken; -import org.apache.shiro.web.filter.authc.AuthenticatingFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.RequestMethod; - -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.utils.HttpContextUtils; -import xiaozhi.common.utils.JsonUtils; -import xiaozhi.common.utils.MessageUtils; -import xiaozhi.common.utils.Result; - -/** - * oauth2过滤器 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class Oauth2Filter extends AuthenticatingFilter { - - private static final Logger logger = LoggerFactory.getLogger(Oauth2Filter.class); - - @Override - protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) throws Exception { - // 获取请求token - String token = getRequestToken((HttpServletRequest) request); - - if (StringUtils.isBlank(token)) { - logger.warn("createToken:token is empty"); - return null; - } - - return new Oauth2Token(token); - } - - @Override - protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) { - if (((HttpServletRequest) request).getMethod().equals(RequestMethod.OPTIONS.name())) { - return true; - } - - return false; - } - - @Override - protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { - // 获取请求token,如果token不存在,直接返回401 - String token = getRequestToken((HttpServletRequest) request); - - if (StringUtils.isBlank(token)) { - logger.warn("onAccessDenied:token is empty"); - - HttpServletResponse httpResponse = (HttpServletResponse) response; - httpResponse.setContentType("application/json;charset=utf-8"); - httpResponse.setHeader("Access-Control-Allow-Credentials", "true"); - httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin()); - - String json = JsonUtils.toJsonString(new Result().error(ErrorCode.UNAUTHORIZED)); - - httpResponse.getWriter().print(json); - - return false; - } - - return executeLogin(request, response); - } - - @Override - protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException e, ServletRequest request, - ServletResponse response) { - HttpServletResponse httpResponse = (HttpServletResponse) response; - httpResponse.setContentType("application/json;charset=utf-8"); - httpResponse.setHeader("Access-Control-Allow-Credentials", "true"); - httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin()); - try { - // 使用国际化消息替代直接使用异常消息 - Result r = new Result().error(ErrorCode.UNAUTHORIZED); - - String json = JsonUtils.toJsonString(r); - httpResponse.getWriter().print(json); - } catch (IOException e1) { - } - - return false; - } - - /** - * 获取请求的token - */ - private String getRequestToken(HttpServletRequest httpRequest) { - String token = null; - // 从header中获取token - String authorization = httpRequest.getHeader(Constant.AUTHORIZATION); - if (StringUtils.isNotBlank(authorization) && authorization.startsWith("Bearer ")) { - token = authorization.replace("Bearer ", ""); - } - return token; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Realm.java b/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Realm.java deleted file mode 100644 index 27c3bc494..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Realm.java +++ /dev/null @@ -1,108 +0,0 @@ -package xiaozhi.modules.security.oauth2; - -import java.util.HashSet; -import java.util.Set; - -import org.apache.shiro.authc.AuthenticationException; -import org.apache.shiro.authc.AuthenticationInfo; -import org.apache.shiro.authc.AuthenticationToken; -import org.apache.shiro.authc.DisabledAccountException; -import org.apache.shiro.authc.IncorrectCredentialsException; -import org.apache.shiro.authc.LockedAccountException; -import org.apache.shiro.authc.SimpleAuthenticationInfo; -import org.apache.shiro.authz.AuthorizationInfo; -import org.apache.shiro.authz.SimpleAuthorizationInfo; -import org.apache.shiro.realm.AuthorizingRealm; -import org.apache.shiro.subject.PrincipalCollection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -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; - -/** - * 认证 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -@Component -public class Oauth2Realm extends AuthorizingRealm { - @Lazy - @Resource - private ShiroService shiroService; - - private static final Logger logger = LoggerFactory.getLogger(Oauth2Realm.class); - - @Override - public boolean supports(AuthenticationToken token) { - return token instanceof Oauth2Token; - } - - /** - * 授权(验证权限时调用) - */ - @Override - protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { - UserDetail user = (UserDetail) principals.getPrimaryPrincipal(); - - // 用户权限列表 - Set permsSet = new HashSet<>(); - - 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; - } - - /** - * 认证(登录时调用) - */ - @Override - protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { - String accessToken = (String) token.getPrincipal(); - - // 根据accessToken,查询用户信息 - SysUserTokenEntity tokenEntity = shiroService.getByToken(accessToken); - // token失效 - if (tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()) { - throw new IncorrectCredentialsException(MessageUtils.getMessage(ErrorCode.TOKEN_INVALID)); - } - - // 查询用户信息 - SysUserEntity userEntity = shiroService.getUser(tokenEntity.getUserId()); - - // 转换成UserDetail对象 - UserDetail userDetail = ConvertUtils.sourceToTarget(userEntity, UserDetail.class); - - userDetail.setToken(accessToken); - - // 账号锁定 - if (userDetail.getStatus() == null) { - logger.error("账号状态异常,status 不能为空"); - throw new DisabledAccountException(MessageUtils.getMessage(ErrorCode.ACCOUNT_DISABLE)); - } - - if (userDetail.getStatus() == 0) { - throw new LockedAccountException(MessageUtils.getMessage(ErrorCode.ACCOUNT_LOCK)); - } - - SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(userDetail, accessToken, getName()); - return info; - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Token.java b/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Token.java deleted file mode 100644 index 62adc903c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/Oauth2Token.java +++ /dev/null @@ -1,26 +0,0 @@ -package xiaozhi.modules.security.oauth2; - -import org.apache.shiro.authc.AuthenticationToken; - -/** - * token - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class Oauth2Token implements AuthenticationToken { - private String token; - - public Oauth2Token(String token) { - this.token = token; - } - - @Override - public String getPrincipal() { - return token; - } - - @Override - public Object getCredentials() { - return token; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/TokenGenerator.java b/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/TokenGenerator.java deleted file mode 100644 index 17ea9beb6..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/oauth2/TokenGenerator.java +++ /dev/null @@ -1,45 +0,0 @@ -package xiaozhi.modules.security.oauth2; - -import java.security.MessageDigest; -import java.util.UUID; - -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; - -/** - * 生成token - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class TokenGenerator { - - public static String generateValue() { - return generateValue(UUID.randomUUID().toString()); - } - - private static final char[] HEX_CODE = "0123456789abcdef".toCharArray(); - - public static String toHexString(byte[] data) { - if (data == null) { - return null; - } - StringBuilder r = new StringBuilder(data.length * 2); - for (byte b : data) { - r.append(HEX_CODE[(b >> 4) & 0xF]); - r.append(HEX_CODE[(b & 0xF)]); - } - return r.toString(); - } - - public static String generateValue(String param) { - try { - MessageDigest algorithm = MessageDigest.getInstance("MD5"); - algorithm.reset(); - algorithm.update(param.getBytes()); - byte[] messageDigest = algorithm.digest(); - return toHexString(messageDigest); - } catch (Exception e) { - throw new RenException(ErrorCode.TOKEN_GENERATE_ERROR, e); - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/password/BCrypt.java b/main/manager-api/src/main/java/xiaozhi/modules/security/password/BCrypt.java deleted file mode 100644 index 39d350c5e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/password/BCrypt.java +++ /dev/null @@ -1,691 +0,0 @@ -package xiaozhi.modules.security.password; - -import java.io.ByteArrayOutputStream; -import java.io.UnsupportedEncodingException; -import java.security.SecureRandom; - -/** - * BCrypt implements OpenBSD-style Blowfish password hashing using the scheme - * described in - * "A Future-Adaptable Password Scheme" by Niels Provos and David Mazieres. - *

- * This password hashing system tries to thwart off-line password cracking using - * a - * computationally-intensive hashing algorithm, based on Bruce Schneier's - * Blowfish cipher. - * The work factor of the algorithm is parameterised, so it can be increased as - * computers - * get faster. - *

- * Usage is really simple. To hash a password for the first time, call the - * hashpw method - * with a random salt, like this: - *

- * - * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
- *
- *

- * To check whether a plaintext password matches one that has been hashed - * previously, use - * the checkpw method: - *

- * - * if (BCrypt.checkpw(candidate_password, stored_hash))
- *     System.out.println("It matches");
- * else
- *     System.out.println("It does not match");
- *
- *

- * The gensalt() method takes an optional parameter (log_rounds) that determines - * the - * computational complexity of the hashing: - *

- * - * String strong_salt = BCrypt.gensalt(10)
- * String stronger_salt = BCrypt.gensalt(12)
- *
- *

- * The amount of work increases exponentially (2**log_rounds), so each increment - * is twice - * as much work. The default log_rounds is 10, and the valid range is 4 to 31. - * - * @author Damien Miller - */ -public class BCrypt { - // BCrypt parameters - - private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10; - private static final int BCRYPT_SALT_LEN = 16; - // Blowfish parameters - private static final int BLOWFISH_NUM_ROUNDS = 16; - // Initial contents of key schedule - private static final int P_orig[] = { 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, - 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, - 0x9216d5d9, 0x8979fb1b }; - private static final int S_orig[] = { 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, - 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, - 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, - 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, - 0x9c30d539, 0x2af26013, 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, - 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, - 0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, - 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, - 0xb3ee1411, 0x636fbc2a, 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, - 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, - 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, - 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, - 0x0f6d6ff3, 0x83f44239, 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, - 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, - 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, - 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, - 0x7d84a5c3, 0x3b8b5ebe, 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, - 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, - 0xdb0fead3, 0x49f1c09b, 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, - 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, - 0x5e5c9ec2, 0x196a2463, 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, - 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, - 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, - 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, - 0x8ea5e9f8, 0xdb3222f8, 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, - 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, - 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, - 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, - 0x4afcb56c, 0x2dd1d35b, 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, - 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, - 0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, - 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, - 0x8888b812, 0x900df01c, 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, - 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, - 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, - 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, - 0xc75442f5, 0xfb9d35cf, 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, - 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, - 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, - 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, - 0x1b510052, 0x9a532915, 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, - 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, - 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, - 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, - 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65, - 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, - 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, - 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d, - 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, - 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, - 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908, - 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, - 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, - 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908, - 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, - 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, - 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa, - 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, - 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, - 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5, - 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, - 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, - 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca, - 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, - 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, - 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054, - 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, - 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, - 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646, - 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, - 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, - 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e, - 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, - 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, - 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, 0xe93d5a68, 0x948140f7, - 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, - 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, - 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, - 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, 0x96eb27b3, 0x55fd3941, - 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, - 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2, 0xe887ad8c, - 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, - 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, 0x1dc9faf7, 0x4b6d1856, - 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, - 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, - 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, - 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, 0xfdf8e802, 0x04272f70, - 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, - 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, - 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, - 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, 0x6b2395e0, 0x333e92e1, - 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, - 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa, - 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, - 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, 0xc67b5510, 0x6d672c37, - 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, - 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, - 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, - 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, 0x6a124237, 0xb79251e7, - 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, - 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, - 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, - 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, 0x83426b33, 0xf01eab71, - 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, - 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3, 0xc8b38e74, - 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, - 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, 0xb90bace1, 0xbb8205d0, - 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, - 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, - 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, - 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, 0x9af88c27, 0x773f8641, - 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, - 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, - 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, - 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, 0xed545578, 0x08fca5b5, - 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, - 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, - 0x670efa8e, 0x406000e0, 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, - 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, - 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, - 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, - 0xd5730a1d, 0x4cd04dc6, 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, - 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, - 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, - 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, - 0x3f046f69, 0x77fa0a59, 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, - 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, - 0xd1cf3ed6, 0x7c7d2d28, 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, - 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, - 0xf8d56629, 0x79132e28, 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, - 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, - 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, - 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, - 0xabcc5167, 0xccad925f, 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, - 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, - 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, - 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, - 0xccd2017f, 0x6bb4e3bb, 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, - 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, - 0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, - 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, - 0x06b89fb4, 0xce6ea048, 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, - 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, - 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, - 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, - 0x8df9317c, 0xe0b12b4f, 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, - 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, - 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, - 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, - 0xd3a0342b, 0x8971f21e, 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, - 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, - 0xce6279cf, 0xcd3e7e6f, 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, - 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, - 0x6e163697, 0x88d273cc, 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, - 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, - 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, - 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, - 0x77afa1c5, 0x20756060, 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, - 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, - 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 }; - // bcrypt IV: "OrpheanBeholderScryDoubt" - static private final int bf_crypt_ciphertext[] = { 0x4f727068, 0x65616e42, - 0x65686f6c, 0x64657253, 0x63727944, 0x6f756274 }; - // Table for Base64 encoding - static private final char base64_code[] = { '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', - 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', - 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', - 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', - 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; - // Table for Base64 decoding - static private final byte index_64[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - -1, -1, -1, -1, -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1 }; - static final int MIN_LOG_ROUNDS = 4; - static final int MAX_LOG_ROUNDS = 31; - // Expanded Blowfish key - private int P[]; - private int S[]; - - /** - * Encode a byte array using bcrypt's slightly-modified base64 encoding scheme. - * Note - * that this is not compatible with the standard MIME-base64 - * encoding. - * - * @param d the byte array to encode - * @param len the number of bytes to encode - * @param rs the destination buffer for the base64-encoded string - * @throws IllegalArgumentException if the length is invalid - */ - static void encode_base64(byte d[], int len, StringBuilder rs) - throws IllegalArgumentException { - int off = 0; - int c1, c2; - - if (len <= 0 || len > d.length) { - throw new IllegalArgumentException("Invalid len"); - } - - while (off < len) { - c1 = d[off++] & 0xff; - rs.append(base64_code[(c1 >> 2) & 0x3f]); - c1 = (c1 & 0x03) << 4; - if (off >= len) { - rs.append(base64_code[c1 & 0x3f]); - break; - } - c2 = d[off++] & 0xff; - c1 |= (c2 >> 4) & 0x0f; - rs.append(base64_code[c1 & 0x3f]); - c1 = (c2 & 0x0f) << 2; - if (off >= len) { - rs.append(base64_code[c1 & 0x3f]); - break; - } - c2 = d[off++] & 0xff; - c1 |= (c2 >> 6) & 0x03; - rs.append(base64_code[c1 & 0x3f]); - rs.append(base64_code[c2 & 0x3f]); - } - } - - /** - * Look up the 3 bits base64-encoded by the specified character, range-checking - * against conversion table - * - * @param x the base64-encoded value - * @return the decoded value of x - */ - private static byte char64(char x) { - if (x > index_64.length) { - return -1; - } - return index_64[x]; - } - - /** - * Decode a string encoded using bcrypt's base64 scheme to a byte array. Note - * that - * this is *not* compatible with the standard MIME-base64 encoding. - * - * @param s the string to decode - * @param maxolen the maximum number of bytes to decode - * @return an array containing the decoded bytes - * @throws IllegalArgumentException if maxolen is invalid - */ - static byte[] decode_base64(String s, int maxolen) throws IllegalArgumentException { - ByteArrayOutputStream out = new ByteArrayOutputStream(maxolen); - int off = 0, slen = s.length(), olen = 0; - byte c1, c2, c3, c4, o; - - if (maxolen <= 0) { - throw new IllegalArgumentException("Invalid maxolen"); - } - - while (off < slen - 1 && olen < maxolen) { - c1 = char64(s.charAt(off++)); - c2 = char64(s.charAt(off++)); - if (c1 == -1 || c2 == -1) { - break; - } - o = (byte) (c1 << 2); - o |= (c2 & 0x30) >> 4; - out.write(o); - if (++olen >= maxolen || off >= slen) { - break; - } - c3 = char64(s.charAt(off++)); - if (c3 == -1) { - break; - } - o = (byte) ((c2 & 0x0f) << 4); - o |= (c3 & 0x3c) >> 2; - out.write(o); - if (++olen >= maxolen || off >= slen) { - break; - } - c4 = char64(s.charAt(off++)); - o = (byte) ((c3 & 0x03) << 6); - o |= c4; - out.write(o); - ++olen; - } - - return out.toByteArray(); - } - - /** - * Blowfish encipher a single 64-bit block encoded as two 32-bit halves - * - * @param lr an array containing the two 32-bit half blocks - * @param off the position in the array of the blocks - */ - private final void encipher(int lr[], int off) { - int i, n, l = lr[off], r = lr[off + 1]; - - l ^= P[0]; - for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) { - // Feistel substitution on left word - n = S[(l >> 24) & 0xff]; - n += S[0x100 | ((l >> 16) & 0xff)]; - n ^= S[0x200 | ((l >> 8) & 0xff)]; - n += S[0x300 | (l & 0xff)]; - r ^= n ^ P[++i]; - - // Feistel substitution on right word - n = S[(r >> 24) & 0xff]; - n += S[0x100 | ((r >> 16) & 0xff)]; - n ^= S[0x200 | ((r >> 8) & 0xff)]; - n += S[0x300 | (r & 0xff)]; - l ^= n ^ P[++i]; - } - lr[off] = r ^ P[BLOWFISH_NUM_ROUNDS + 1]; - lr[off + 1] = l; - } - - /** - * Cycically extract a word of key material - * - * @param data the string to extract the data from - * @param offp a "pointer" (as a one-entry array) to the current offset into - * data - * @return the next word of material from data - */ - private static int streamtoword(byte data[], int offp[]) { - int i; - int word = 0; - int off = offp[0]; - - for (i = 0; i < 4; i++) { - word = (word << 8) | (data[off] & 0xff); - off = (off + 1) % data.length; - } - - offp[0] = off; - return word; - } - - /** - * Initialise the Blowfish key schedule - */ - private void init_key() { - P = (int[]) P_orig.clone(); - S = (int[]) S_orig.clone(); - } - - /** - * Key the Blowfish cipher - * - * @param key an array containing the key - */ - private void key(byte key[]) { - int i; - int koffp[] = { 0 }; - int lr[] = { 0, 0 }; - int plen = P.length, slen = S.length; - - for (i = 0; i < plen; i++) { - P[i] = P[i] ^ streamtoword(key, koffp); - } - - for (i = 0; i < plen; i += 2) { - encipher(lr, 0); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (i = 0; i < slen; i += 2) { - encipher(lr, 0); - S[i] = lr[0]; - S[i + 1] = lr[1]; - } - } - - /** - * Perform the "enhanced key schedule" step described by Provos and Mazieres in - * "A Future-Adaptable Password Scheme" - * http://www.openbsd.org/papers/bcrypt-paper.ps - * - * @param data salt information - * @param key password information - */ - private void ekskey(byte data[], byte key[]) { - int i; - int koffp[] = { 0 }, doffp[] = { 0 }; - int lr[] = { 0, 0 }; - int plen = P.length, slen = S.length; - - for (i = 0; i < plen; i++) { - P[i] = P[i] ^ streamtoword(key, koffp); - } - - for (i = 0; i < plen; i += 2) { - lr[0] ^= streamtoword(data, doffp); - lr[1] ^= streamtoword(data, doffp); - encipher(lr, 0); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (i = 0; i < slen; i += 2) { - lr[0] ^= streamtoword(data, doffp); - lr[1] ^= streamtoword(data, doffp); - encipher(lr, 0); - S[i] = lr[0]; - S[i + 1] = lr[1]; - } - } - - static long roundsForLogRounds(int log_rounds) { - if (log_rounds < 4 || log_rounds > 31) { - throw new IllegalArgumentException("Bad number of rounds"); - } - return 1L << log_rounds; - } - - /** - * Perform the central password hashing step in the bcrypt scheme - * - * @param password the password to hash - * @param salt the binary salt to hash with the password - * @param log_rounds the binary logarithm of the number of rounds of hashing to - * apply - * @return an array containing the binary hashed password - */ - private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) { - int cdata[] = (int[]) bf_crypt_ciphertext.clone(); - int clen = cdata.length; - byte ret[]; - - long rounds = roundsForLogRounds(log_rounds); - - init_key(); - ekskey(salt, password); - for (long i = 0; i < rounds; i++) { - key(password); - key(salt); - } - - for (int i = 0; i < 64; i++) { - for (int j = 0; j < (clen >> 1); j++) { - encipher(cdata, j << 1); - } - } - - ret = new byte[clen * 4]; - for (int i = 0, j = 0; i < clen; i++) { - ret[j++] = (byte) ((cdata[i] >> 24) & 0xff); - ret[j++] = (byte) ((cdata[i] >> 16) & 0xff); - ret[j++] = (byte) ((cdata[i] >> 8) & 0xff); - ret[j++] = (byte) (cdata[i] & 0xff); - } - return ret; - } - - /** - * Hash a password using the OpenBSD bcrypt scheme - * - * @param password the password to hash - * @param salt the salt to hash with (perhaps generated using - * BCrypt.gensalt) - * @return the hashed password - * @throws IllegalArgumentException if invalid salt is passed - */ - public static String hashpw(String password, String salt) throws IllegalArgumentException { - BCrypt B; - String real_salt; - byte passwordb[], saltb[], hashed[]; - char minor = (char) 0; - int rounds, off = 0; - StringBuilder rs = new StringBuilder(); - - if (salt == null) { - throw new IllegalArgumentException("salt cannot be null"); - } - - int saltLength = salt.length(); - - if (saltLength < 28) { - throw new IllegalArgumentException("Invalid salt"); - } - - if (salt.charAt(0) != '$' || salt.charAt(1) != '2') { - throw new IllegalArgumentException("Invalid salt version"); - } - if (salt.charAt(2) == '$') { - off = 3; - } else { - minor = salt.charAt(2); - if (minor != 'a' || salt.charAt(3) != '$') { - throw new IllegalArgumentException("Invalid salt revision"); - } - off = 4; - } - - if (saltLength - off < 25) { - throw new IllegalArgumentException("Invalid salt"); - } - - // Extract number of rounds - if (salt.charAt(off + 2) > '$') { - throw new IllegalArgumentException("Missing salt rounds"); - } - rounds = Integer.parseInt(salt.substring(off, off + 2)); - - real_salt = salt.substring(off + 3, off + 25); - try { - passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8"); - } catch (UnsupportedEncodingException uee) { - throw new AssertionError("UTF-8 is not supported"); - } - - saltb = decode_base64(real_salt, BCRYPT_SALT_LEN); - - B = new BCrypt(); - hashed = B.crypt_raw(passwordb, saltb, rounds); - - rs.append("$2"); - if (minor >= 'a') { - rs.append(minor); - } - rs.append("$"); - if (rounds < 10) { - rs.append("0"); - } - rs.append(rounds); - rs.append("$"); - encode_base64(saltb, saltb.length, rs); - encode_base64(hashed, bf_crypt_ciphertext.length * 4 - 1, rs); - return rs.toString(); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method - * - * @param log_rounds the log2 of the number of rounds of hashing to apply - the - * work - * factor therefore increases as 2**log_rounds. Minimum 4, - * maximum 31. - * @param random an instance of SecureRandom to use - * @return an encoded salt value - */ - public static String gensalt(int log_rounds, SecureRandom random) { - if (log_rounds < MIN_LOG_ROUNDS || log_rounds > MAX_LOG_ROUNDS) { - throw new IllegalArgumentException("Bad number of rounds"); - } - StringBuilder rs = new StringBuilder(); - byte rnd[] = new byte[BCRYPT_SALT_LEN]; - - random.nextBytes(rnd); - - rs.append("$2a$"); - if (log_rounds < 10) { - rs.append("0"); - } - rs.append(log_rounds); - rs.append("$"); - encode_base64(rnd, rnd.length, rs); - return rs.toString(); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method - * - * @param log_rounds the log2 of the number of rounds of hashing to apply - the - * work - * factor therefore increases as 2**log_rounds. Minimum 4, - * maximum 31. - * @return an encoded salt value - */ - public static String gensalt(int log_rounds) { - return gensalt(log_rounds, new SecureRandom()); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method, selecting a - * reasonable - * default for the number of hashing rounds to apply - * - * @return an encoded salt value - */ - public static String gensalt() { - return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS); - } - - /** - * Check that a plaintext password matches a previously hashed one - * - * @param plaintext the plaintext password to verify - * @param hashed the previously-hashed password - * @return true if the passwords match, false otherwise - */ - public static boolean checkpw(String plaintext, String hashed) { - return equalsNoEarlyReturn(hashed, hashpw(plaintext, hashed)); - } - - static boolean equalsNoEarlyReturn(String a, String b) { - char[] caa = a.toCharArray(); - char[] cab = b.toCharArray(); - - if (caa.length != cab.length) { - return false; - } - - byte ret = 0; - for (int i = 0; i < caa.length; i++) { - ret |= caa[i] ^ cab[i]; - } - return ret == 0; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/password/BCryptPasswordEncoder.java b/main/manager-api/src/main/java/xiaozhi/modules/security/password/BCryptPasswordEncoder.java deleted file mode 100644 index 0da907f2b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/password/BCryptPasswordEncoder.java +++ /dev/null @@ -1,81 +0,0 @@ -package xiaozhi.modules.security.password; - -import java.security.SecureRandom; -import java.util.regex.Pattern; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Implementation of PasswordEncoder that uses the BCrypt strong hashing - * function. Clients - * can optionally supply a "strength" (a.k.a. log rounds in BCrypt) and a - * SecureRandom - * instance. The larger the strength parameter the more work will have to be - * done - * (exponentially) to hash the passwords. The default value is 10. - * - * @author Dave Syer - */ -public class BCryptPasswordEncoder implements PasswordEncoder { - private Pattern BCRYPT_PATTERN = Pattern - .compile("\\A\\$2a?\\$\\d\\d\\$[./0-9A-Za-z]{53}"); - private final Log logger = LogFactory.getLog(getClass()); - - private final int strength; - - private final SecureRandom random; - - public BCryptPasswordEncoder() { - this(-1); - } - - /** - * @param strength the log rounds to use, between 4 and 31 - */ - public BCryptPasswordEncoder(int strength) { - this(strength, null); - } - - /** - * @param strength the log rounds to use, between 4 and 31 - * @param random the secure random instance to use - */ - public BCryptPasswordEncoder(int strength, SecureRandom random) { - if (strength != -1 && (strength < BCrypt.MIN_LOG_ROUNDS || strength > BCrypt.MAX_LOG_ROUNDS)) { - throw new IllegalArgumentException("Bad strength"); - } - this.strength = strength; - this.random = random; - } - - @Override - public String encode(CharSequence rawPassword) { - String salt; - if (strength > 0) { - if (random != null) { - salt = BCrypt.gensalt(strength, random); - } else { - salt = BCrypt.gensalt(strength); - } - } else { - salt = BCrypt.gensalt(); - } - return BCrypt.hashpw(rawPassword.toString(), salt); - } - - @Override - public boolean matches(CharSequence rawPassword, String encodedPassword) { - if (encodedPassword == null || encodedPassword.length() == 0) { - logger.warn("Empty encoded password"); - return false; - } - - if (!BCRYPT_PATTERN.matcher(encodedPassword).matches()) { - logger.warn("Encoded password does not look like BCrypt"); - return false; - } - - return BCrypt.checkpw(rawPassword.toString(), encodedPassword); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/password/PasswordEncoder.java b/main/manager-api/src/main/java/xiaozhi/modules/security/password/PasswordEncoder.java deleted file mode 100644 index 2de70cc25..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/password/PasswordEncoder.java +++ /dev/null @@ -1,33 +0,0 @@ -package xiaozhi.modules.security.password; - -/** - * Service interface for encoding passwords. - *

- * The preferred implementation is {@code BCryptPasswordEncoder}. - * - * @author Keith Donald - */ -public interface PasswordEncoder { - - /** - * Encode the raw password. Generally, a good encoding algorithm applies a SHA-1 - * or - * greater hash combined with an 8-byte or greater randomly generated salt. - */ - String encode(CharSequence rawPassword); - - /** - * Verify the encoded password obtained from storage matches the submitted raw - * password after it too is encoded. Returns true if the passwords match, false - * if - * they do not. The stored password itself is never decoded. - * - * @param rawPassword the raw password to encode and match - * @param encodedPassword the encoded password from storage to compare with - * @return true if the raw password, after encoding, matches the encoded - * password from - * storage - */ - boolean matches(CharSequence rawPassword, String encodedPassword); - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/password/PasswordUtils.java b/main/manager-api/src/main/java/xiaozhi/modules/security/password/PasswordUtils.java deleted file mode 100644 index 9144b3801..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/password/PasswordUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -package xiaozhi.modules.security.password; - -/** - * 密码工具类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class PasswordUtils { - private static PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); - - /** - * 加密 - * - * @param str 字符串 - * @return 返回加密字符串 - */ - public static String encode(String str) { - return passwordEncoder.encode(str); - } - - /** - * 比较密码是否相等 - * - * @param str 明文密码 - * @param password 加密后密码 - * @return true:成功 false:失败 - */ - public static boolean matches(String str, String password) { - return passwordEncoder.matches(str, password); - } - - public static void main(String[] args) { - String str = "admin"; - String password = encode(str); - - System.out.println(password); - System.out.println(matches(str, password)); - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/secret/ServerSecretFilter.java b/main/manager-api/src/main/java/xiaozhi/modules/security/secret/ServerSecretFilter.java deleted file mode 100644 index b2a18547e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/secret/ServerSecretFilter.java +++ /dev/null @@ -1,105 +0,0 @@ -package xiaozhi.modules.security.secret; - -import java.io.IOException; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.web.filter.authc.AuthenticatingFilter; -import org.springframework.web.bind.annotation.RequestMethod; - -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.utils.HttpContextUtils; -import xiaozhi.common.utils.JsonUtils; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.sys.service.SysParamsService; - -/** - * Config API 过滤器 - */ -@Slf4j -@RequiredArgsConstructor -public class ServerSecretFilter extends AuthenticatingFilter { - private final SysParamsService sysParamsService; - - @Override - protected ServerSecretToken createToken(ServletRequest request, ServletResponse response) { - // 获取请求token - String token = getRequestToken((HttpServletRequest) request); - - if (StringUtils.isBlank(token)) { - log.warn("createToken:token is empty"); - return null; - } - - return new ServerSecretToken(token); - } - - @Override - protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) { - // 对OPTIONS请求放行 - if (((HttpServletRequest) request).getMethod().equals(RequestMethod.OPTIONS.name())) { - return true; - } - return false; - } - - @Override - protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception { - // 获取token并校验 - String token = getRequestToken((HttpServletRequest) servletRequest); - if (StringUtils.isBlank(token)) { - // token为空,返回401 - this.sendUnauthorizedResponse((HttpServletResponse) servletResponse, "服务器密钥不能为空"); - return false; - } - - // 验证token是否匹配 - String serverSecret = getServerSecret(); - if (StringUtils.isBlank(serverSecret) || !serverSecret.equals(token)) { - // token无效,返回401 - this.sendUnauthorizedResponse((HttpServletResponse) servletResponse, "无效的服务器密钥"); - return false; - } - - return true; - } - - /** - * 发送未授权响应 - */ - private void sendUnauthorizedResponse(HttpServletResponse response, String message) { - response.setContentType("application/json;charset=utf-8"); - response.setHeader("Access-Control-Allow-Credentials", "true"); - response.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin()); - - try { - String json = JsonUtils.toJsonString(new Result().error(ErrorCode.UNAUTHORIZED, message)); - response.getWriter().print(json); - } catch (IOException e) { - log.error("响应输出失败", e); - } - } - - /** - * 获取请求的token - */ - private String getRequestToken(HttpServletRequest httpRequest) { - String token = null; - // 从header中获取token - String authorization = httpRequest.getHeader("Authorization"); - if (StringUtils.isNotBlank(authorization) && authorization.startsWith("Bearer ")) { - token = authorization.replace("Bearer ", ""); - } - return token; - } - - private String getServerSecret() { - return sysParamsService.getValue(Constant.SERVER_SECRET, true); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/secret/ServerSecretToken.java b/main/manager-api/src/main/java/xiaozhi/modules/security/secret/ServerSecretToken.java deleted file mode 100644 index 9072eaf8c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/secret/ServerSecretToken.java +++ /dev/null @@ -1,25 +0,0 @@ -package xiaozhi.modules.security.secret; - -import org.apache.shiro.authc.AuthenticationToken; - -/** - * Config API Token - */ -public class ServerSecretToken implements AuthenticationToken { - private static final long serialVersionUID = 1L; - private final String token; - - public ServerSecretToken(String token) { - this.token = token; - } - - @Override - public Object getPrincipal() { - return token; - } - - @Override - public Object getCredentials() { - return token; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/service/CaptchaService.java b/main/manager-api/src/main/java/xiaozhi/modules/security/service/CaptchaService.java deleted file mode 100644 index 0db9d296e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/service/CaptchaService.java +++ /dev/null @@ -1,45 +0,0 @@ -package xiaozhi.modules.security.service; - -import java.io.IOException; - -import jakarta.servlet.http.HttpServletResponse; - -/** - * 验证码 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public interface CaptchaService { - - /** - * 图片验证码 - */ - void create(HttpServletResponse response, String uuid) throws IOException; - - /** - * 验证码效验 - * - * @param uuid uuid - * @param code 验证码 - * @param delete 是否删除验证码 - * @return true:成功 false:失败 - */ - boolean validate(String uuid, String code, Boolean delete); - - /** - * 发送短信验证码 - * - * @param phone 手机 - */ - void sendSMSValidateCode(String phone); - - /** - * 验证短信验证码 - * - * @param phone 手机 - * @param code 验证码 - * @param delete 是否删除验证码 - * @return true:成功 false:失败 - */ - boolean validateSMSValidateCode(String phone, String code, Boolean delete); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/service/ShiroService.java b/main/manager-api/src/main/java/xiaozhi/modules/security/service/ShiroService.java deleted file mode 100644 index b9d188895..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/service/ShiroService.java +++ /dev/null @@ -1,22 +0,0 @@ -package xiaozhi.modules.security.service; - -import xiaozhi.modules.security.entity.SysUserTokenEntity; -import xiaozhi.modules.sys.entity.SysUserEntity; - -/** - * shiro相关接口 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public interface ShiroService { - - SysUserTokenEntity getByToken(String token); - - /** - * 根据用户ID,查询用户 - * - * @param userId - */ - SysUserEntity getUser(Long userId); - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/service/SysUserTokenService.java b/main/manager-api/src/main/java/xiaozhi/modules/security/service/SysUserTokenService.java deleted file mode 100644 index d1d094d40..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/service/SysUserTokenService.java +++ /dev/null @@ -1,41 +0,0 @@ -package xiaozhi.modules.security.service; - -import xiaozhi.common.page.TokenDTO; -import xiaozhi.common.service.BaseService; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.security.entity.SysUserTokenEntity; -import xiaozhi.modules.sys.dto.PasswordDTO; -import xiaozhi.modules.sys.dto.SysUserDTO; - -/** - * 用户Token - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public interface SysUserTokenService extends BaseService { - - /** - * 生成token - * - * @param userId 用户ID - */ - Result createToken(Long userId); - - SysUserDTO getUserByToken(String token); - - /** - * 退出 - * - * @param userId 用户ID - */ - void logout(Long userId); - - /** - * 修改密码 - * - * @param userId - * @param passwordDTO - */ - void changePassword(Long userId, PasswordDTO passwordDTO); - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/CaptchaServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/CaptchaServiceImpl.java deleted file mode 100644 index 0d3666db2..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/CaptchaServiceImpl.java +++ /dev/null @@ -1,183 +0,0 @@ -package xiaozhi.modules.security.service.impl; - -import java.io.IOException; -import java.util.Random; -import java.util.concurrent.TimeUnit; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.wf.captcha.SpecCaptcha; -import com.wf.captcha.base.Captcha; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.modules.security.service.CaptchaService; -import xiaozhi.modules.sms.service.SmsService; -import xiaozhi.modules.sys.service.SysParamsService; - -/** - * 验证码 - */ -@Service -public class CaptchaServiceImpl implements CaptchaService { - @Resource - private RedisUtils redisUtils; - @Resource - private SmsService smsService; - @Resource - private SysParamsService sysParamsService; - @Value("${renren.redis.open}") - private boolean open; - /** - * Local Cache 5分钟过期 - */ - Cache localCache = CacheBuilder.newBuilder().maximumSize(1000) - .expireAfterAccess(5, TimeUnit.MINUTES).build(); - - @Override - public void create(HttpServletResponse response, String uuid) throws IOException { - response.setContentType("image/gif"); - response.setHeader("Pragma", "No-cache"); - response.setHeader("Cache-Control", "no-cache"); - response.setDateHeader("Expires", 0); - - // 生成验证码 - SpecCaptcha captcha = new SpecCaptcha(150, 40); - captcha.setLen(5); - captcha.setCharType(Captcha.TYPE_DEFAULT); - captcha.out(response.getOutputStream()); - - // 保存到缓存 - setCache(uuid, captcha.text()); - } - - @Override - public boolean validate(String uuid, String code, Boolean delete) { - if (StringUtils.isBlank(code)) { - return false; - } - // 获取验证码 - String captcha = getCache(uuid, delete); - - // 效验成功 - if (code.equalsIgnoreCase(captcha)) { - return true; - } - - return false; - } - - @Override - public void sendSMSValidateCode(String phone) { - // 检查发送间隔 - String lastSendTimeKey = RedisKeys.getSMSLastSendTimeKey(phone); - // 获取是否发送过,如果没有设置最后发送时间(60秒) - String lastSendTime = redisUtils - .getKeyOrCreate(lastSendTimeKey, - String.valueOf(System.currentTimeMillis()), 60L); - if (lastSendTime != null) { - long lastSendTimeLong = Long.parseLong(lastSendTime); - long currentTime = System.currentTimeMillis(); - long timeDiff = currentTime - lastSendTimeLong; - if (timeDiff < 60000) { - throw new RenException(ErrorCode.SMS_SEND_TOO_FREQUENTLY, String.valueOf((60000 - timeDiff) / 1000)); - } - } - - // 检查今日发送次数 - String todayCountKey = RedisKeys.getSMSTodayCountKey(phone); - Integer todayCount = (Integer) redisUtils.get(todayCountKey); - if (todayCount == null) { - todayCount = 0; - } - - // 获取最大发送次数限制 - Integer maxSendCount = sysParamsService.getValueObject( - Constant.SysMSMParam.SERVER_SMS_MAX_SEND_COUNT.getValue(), - Integer.class); - if (maxSendCount == null) { - maxSendCount = 5; // 默认值 - } - - if (todayCount >= maxSendCount) { - throw new RenException(ErrorCode.TODAY_SMS_LIMIT_REACHED); - } - - String key = RedisKeys.getSMSValidateCodeKey(phone); - String validateCodes = generateValidateCode(6); - - // 设置验证码 - setCache(key, validateCodes); - - // 更新今日发送次数 - if (todayCount == 0) { - redisUtils.increment(todayCountKey, RedisUtils.DEFAULT_EXPIRE); - } else { - redisUtils.increment(todayCountKey); - } - - // 发送验证码短信 - smsService.sendVerificationCodeSms(phone, validateCodes); - } - - @Override - public boolean validateSMSValidateCode(String phone, String code, Boolean delete) { - String key = RedisKeys.getSMSValidateCodeKey(phone); - return validate(key, code, delete); - } - - /** - * 生成指定数量的随机数验证码 - * - * @param length 数量 - * @return 随机码 - */ - private String generateValidateCode(Integer length) { - String chars = "0123456789"; // 字符范围可以自定义:数字 - Random random = new Random(); - StringBuilder code = new StringBuilder(); - for (int i = 0; i < length; i++) { - code.append(chars.charAt(random.nextInt(chars.length()))); - } - return code.toString(); - } - - private void setCache(String key, String value) { - if (open) { - key = RedisKeys.getCaptchaKey(key); - // 设置5分钟过期 - redisUtils.set(key, value, 300); - } else { - localCache.put(key, value); - } - } - - private String getCache(String key, Boolean delete) { - if (open) { - key = RedisKeys.getCaptchaKey(key); - String captcha = (String) redisUtils.get(key); - // 删除验证码 - if (captcha != null && delete) { - redisUtils.delete(key); - } - - return captcha; - } - - String captcha = localCache.getIfPresent(key); - // 删除验证码 - if (captcha != null) { - localCache.invalidate(key); - } - return captcha; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/ShiroServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/ShiroServiceImpl.java deleted file mode 100644 index 27c20970f..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/ShiroServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package xiaozhi.modules.security.service.impl; - -import org.springframework.stereotype.Service; - -import lombok.AllArgsConstructor; -import xiaozhi.modules.security.dao.SysUserTokenDao; -import xiaozhi.modules.security.entity.SysUserTokenEntity; -import xiaozhi.modules.security.service.ShiroService; -import xiaozhi.modules.sys.dao.SysUserDao; -import xiaozhi.modules.sys.entity.SysUserEntity; - -@AllArgsConstructor -@Service -public class ShiroServiceImpl implements ShiroService { - private final SysUserDao sysUserDao; - private final SysUserTokenDao sysUserTokenDao; - - @Override - public SysUserTokenEntity getByToken(String token) { - return sysUserTokenDao.getByToken(token); - } - - @Override - public SysUserEntity getUser(Long userId) { - return sysUserDao.selectById(userId); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/SysUserTokenServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/SysUserTokenServiceImpl.java deleted file mode 100644 index 7f0d311a0..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/SysUserTokenServiceImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -package xiaozhi.modules.security.service.impl; - -import java.util.Date; - -import org.springframework.stereotype.Service; - -import cn.hutool.core.date.DateUtil; -import lombok.AllArgsConstructor; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.page.TokenDTO; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.common.utils.HttpContextUtils; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.security.dao.SysUserTokenDao; -import xiaozhi.modules.security.entity.SysUserTokenEntity; -import xiaozhi.modules.security.oauth2.TokenGenerator; -import xiaozhi.modules.security.service.SysUserTokenService; -import xiaozhi.modules.sys.dto.PasswordDTO; -import xiaozhi.modules.sys.dto.SysUserDTO; -import xiaozhi.modules.sys.service.SysUserService; - -@AllArgsConstructor -@Service -public class SysUserTokenServiceImpl extends BaseServiceImpl - implements SysUserTokenService { - - private final SysUserService sysUserService; - /** - * 12小时后过期 - */ - private final static int EXPIRE = 3600 * 12; - - @Override - public Result createToken(Long userId) { - // 用户token - String token; - - // 当前时间 - Date now = new Date(); - // 过期时间 - Date expireTime = new Date(now.getTime() + EXPIRE * 1000); - - // 判断是否生成过token - SysUserTokenEntity tokenEntity = baseDao.getByUserId(userId); - if (tokenEntity == null) { - // 生成一个token - token = TokenGenerator.generateValue(); - - tokenEntity = new SysUserTokenEntity(); - tokenEntity.setUserId(userId); - tokenEntity.setToken(token); - tokenEntity.setUpdateDate(now); - tokenEntity.setExpireDate(expireTime); - - // 保存token - this.insert(tokenEntity); - } else { - // 判断token是否过期 - if (tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()) { - // token过期,重新生成token - token = TokenGenerator.generateValue(); - } else { - token = tokenEntity.getToken(); - } - - tokenEntity.setToken(token); - tokenEntity.setUpdateDate(now); - tokenEntity.setExpireDate(expireTime); - - // 更新token - this.updateById(tokenEntity); - } - - String clientHash = HttpContextUtils.getClientCode(); - - TokenDTO tokenDTO = new TokenDTO(); - tokenDTO.setToken(token); - tokenDTO.setExpire(EXPIRE); - tokenDTO.setClientHash(clientHash); - return new Result().ok(tokenDTO); - } - - @Override - public SysUserDTO getUserByToken(String token) { - SysUserTokenEntity userToken = baseDao.getByToken(token); - if (null == userToken) { - throw new RenException(ErrorCode.TOKEN_INVALID); - } - - Date now = new Date(); - if (userToken.getExpireDate().before(now)) { - throw new RenException(ErrorCode.UNAUTHORIZED); - } - - SysUserDTO userDTO = sysUserService.getByUserId(userToken.getUserId()); - userDTO.setPassword(""); - return userDTO; - } - - @Override - public void logout(Long userId) { - Date expireDate = DateUtil.offsetMinute(new Date(), -1); - baseDao.logout(userId, expireDate); - } - - @Override - public void changePassword(Long userId, PasswordDTO passwordDTO) { - // 修改密码 - sysUserService.changePassword(userId, passwordDTO); - - // 使 token 失效,后需要重新登录 - Date expireDate = DateUtil.offsetMinute(new Date(), -1); - baseDao.logout(userId, expireDate); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/user/SecurityUser.java b/main/manager-api/src/main/java/xiaozhi/modules/security/user/SecurityUser.java deleted file mode 100644 index 0581f95cf..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/security/user/SecurityUser.java +++ /dev/null @@ -1,50 +0,0 @@ -package xiaozhi.modules.security.user; - -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.subject.Subject; - -import xiaozhi.common.user.UserDetail; - -/** - * Shiro工具类 - * Copyright (c) 人人开源 All rights reserved. - * Website: https://www.renren.io - */ -public class SecurityUser { - - public static Subject getSubject() { - try { - return SecurityUtils.getSubject(); - } catch (Exception e) { - return null; - } - } - - /** - * 获取用户信息 - */ - public static UserDetail getUser() { - Subject subject = getSubject(); - if (subject == null) { - return new UserDetail(); - } - - UserDetail user = (UserDetail) subject.getPrincipal(); - if (user == null) { - return new UserDetail(); - } - - return user; - } - - public static String getToken() { - return getUser().getToken(); - } - - /** - * 获取用户ID - */ - public static Long getUserId() { - return getUser().getId(); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sms/service/SmsService.java b/main/manager-api/src/main/java/xiaozhi/modules/sms/service/SmsService.java deleted file mode 100644 index c33ad9453..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sms/service/SmsService.java +++ /dev/null @@ -1,17 +0,0 @@ -package xiaozhi.modules.sms.service; - -/** - * 短信服务的方法定义接口 - * - * @author zjy - * @since 2025-05-12 - */ -public interface SmsService { - - /** - * 发送验证码短信 - * @param phone 手机号码 - * @param VerificationCode 验证码 - */ - void sendVerificationCodeSms(String phone, String VerificationCode) ; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sms/service/imp/ALiYunSmsService.java b/main/manager-api/src/main/java/xiaozhi/modules/sms/service/imp/ALiYunSmsService.java deleted file mode 100644 index a8a378f0c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sms/service/imp/ALiYunSmsService.java +++ /dev/null @@ -1,77 +0,0 @@ -package xiaozhi.modules.sms.service.imp; - -import com.aliyun.dysmsapi20170525.Client; -import com.aliyun.dysmsapi20170525.models.SendSmsRequest; -import com.aliyun.dysmsapi20170525.models.SendSmsResponse; -import com.aliyun.teaopenapi.models.Config; -import com.aliyun.teautil.models.RuntimeOptions; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.modules.sms.service.SmsService; -import xiaozhi.modules.sys.service.SysParamsService; - -@Service -@AllArgsConstructor -@Slf4j -public class ALiYunSmsService implements SmsService { - private final SysParamsService sysParamsService; - private final RedisUtils redisUtils; - - @Override - public void sendVerificationCodeSms(String phone, String VerificationCode) { - Client client = createClient(); - String SignName = sysParamsService.getValue(Constant.SysMSMParam - .ALIYUN_SMS_SIGN_NAME.getValue(),true); - String TemplateCode = sysParamsService.getValue(Constant.SysMSMParam - .ALIYUN_SMS_SMS_CODE_TEMPLATE_CODE.getValue(),true); - try { - SendSmsRequest sendSmsRequest = new SendSmsRequest() - .setSignName(SignName) - .setTemplateCode(TemplateCode) - .setPhoneNumbers(phone) - .setTemplateParam(String.format("{\"code\":\"%s\"}", VerificationCode)); - RuntimeOptions runtime = new RuntimeOptions(); - // 复制代码运行请自行打印 API 的返回值 - SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); - log.info("发送短信响应的requestID: {}", sendSmsResponse.getBody().getRequestId()); - } catch (Exception e) { - // 如果发送失败了退还这次发送数 - String todayCountKey = RedisKeys.getSMSTodayCountKey(phone); - redisUtils.delete(todayCountKey); - // 错误 message - log.error(e.getMessage()); - throw new RenException(ErrorCode.SMS_SEND_FAILED); - } - - } - - - /** - * 创建阿里云连接 - * @return 返回连接对象 - */ - private Client createClient(){ - String ACCESS_KEY_ID = sysParamsService.getValue(Constant.SysMSMParam - .ALIYUN_SMS_ACCESS_KEY_ID.getValue(),true); - String ACCESS_KEY_SECRET = sysParamsService.getValue(Constant.SysMSMParam - .ALIYUN_SMS_ACCESS_KEY_SECRET.getValue(),true); - try { - Config config = new Config() - .setAccessKeyId(ACCESS_KEY_ID) - .setAccessKeySecret(ACCESS_KEY_SECRET); - // 配置 Endpoint。中国站请使用dysmsapi.aliyuncs.com - config.endpoint = "dysmsapi.aliyuncs.com"; - return new Client(config); - }catch (Exception e){ - // 错误 message - log.error(e.getMessage()); - throw new RenException(ErrorCode.SMS_CONNECTION_FAILED); - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/AdminController.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/AdminController.java deleted file mode 100644 index 2ccc1e6ad..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/AdminController.java +++ /dev/null @@ -1,109 +0,0 @@ -package xiaozhi.modules.sys.controller; - -import java.util.Map; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -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 xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.device.dto.DevicePageUserDTO; -import xiaozhi.modules.device.service.DeviceService; -import xiaozhi.modules.device.vo.UserShowDeviceListVO; -import xiaozhi.modules.sys.dto.AdminPageUserDTO; -import xiaozhi.modules.sys.service.SysUserService; -import xiaozhi.modules.sys.vo.AdminPageUserVO; - -/** - * 管理员控制层 - * - * @author zjy - * @since 2025-3-25 - */ -@AllArgsConstructor -@RestController -@RequestMapping("/admin") -@Tag(name = "管理员管理") -public class AdminController { - private final SysUserService sysUserService; - - private final DeviceService deviceService; - - @GetMapping("/users") - @Operation(summary = "分页查找用户") - @RequiresPermissions("sys:role:superAdmin") - @Parameters({ - @Parameter(name = "mobile", description = "用户手机号码", required = false), - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), - }) - public Result> pageUser( - @Parameter(hidden = true) @RequestParam Map params) { - AdminPageUserDTO dto = new AdminPageUserDTO(); - dto.setMobile((String) params.get("mobile")); - dto.setLimit((String) params.get(Constant.LIMIT)); - dto.setPage((String) params.get(Constant.PAGE)); - ValidatorUtils.validateEntity(dto); - PageData page = sysUserService.page(dto); - return new Result>().ok(page); - } - - @PutMapping("/users/{id}") - @Operation(summary = "重置密码") - @RequiresPermissions("sys:role:superAdmin") - public Result update( - @PathVariable Long id) { - String password = sysUserService.resetPassword(id); - return new Result().ok(password); - } - - @DeleteMapping("/users/{id}") - @Operation(summary = "用户删除") - @RequiresPermissions("sys:role:superAdmin") - public Result delete(@PathVariable Long id) { - sysUserService.deleteById(id); - return new Result<>(); - } - - @PutMapping("/users/changeStatus/{status}") - @Operation(summary = "批量修改用户状态") - @RequiresPermissions("sys:role:superAdmin") - @Parameter(name = "status", description = "用户状态", required = true) - public Result changeStatus(@PathVariable Integer status, @RequestBody String[] userIds) { - sysUserService.changeStatus(status, userIds); - return new Result(); - } - - @GetMapping("/device/all") - @Operation(summary = "分页查找设备") - @RequiresPermissions("sys:role:superAdmin") - @Parameters({ - @Parameter(name = "keywords", description = "设备关键词", required = false), - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), - }) - public Result> pageDevice( - @Parameter(hidden = true) @RequestParam Map params) { - DevicePageUserDTO dto = new DevicePageUserDTO(); - dto.setKeywords((String) params.get("keywords")); - dto.setLimit((String) params.get(Constant.LIMIT)); - dto.setPage((String) params.get(Constant.PAGE)); - ValidatorUtils.validateEntity(dto); - PageData page = deviceService.page(dto); - return new Result>().ok(page); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/ServerSideManageController.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/ServerSideManageController.java deleted file mode 100644 index 893ea8e2d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/ServerSideManageController.java +++ /dev/null @@ -1,122 +0,0 @@ -package xiaozhi.modules.sys.controller; - -import java.util.*; -import java.util.concurrent.TimeUnit; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -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.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.socket.WebSocketHttpHeaders; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import lombok.AllArgsConstructor; -import xiaozhi.common.annotation.LogOperation; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.utils.Result; -import xiaozhi.modules.sys.dto.EmitSeverActionDTO; -import xiaozhi.modules.sys.dto.ServerActionPayloadDTO; -import xiaozhi.modules.sys.dto.ServerActionResponseDTO; -import xiaozhi.modules.sys.enums.ServerActionEnum; -import xiaozhi.modules.sys.service.SysParamsService; -import xiaozhi.modules.sys.utils.WebSocketClientManager; - -/** - * 服务端管理控制器 - */ -@RestController -@RequestMapping("/admin/server") -@Tag(name = "服务端管理") -@AllArgsConstructor -public class ServerSideManageController { - private final SysParamsService sysParamsService; - private static final ObjectMapper objectMapper; - static { - objectMapper = new ObjectMapper(); - // 忽略json字符串中存在,但pojo中不存在对应字段的情况 - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - @Operation(summary = "获取Ws服务端列表") - @GetMapping("/server-list") - @RequiresPermissions("sys:role:superAdmin") - public Result> getWsServerList() { - String wsText = sysParamsService.getValue(Constant.SERVER_WEBSOCKET, true); - if (StringUtils.isBlank(wsText)) { - return new Result>().ok(Collections.emptyList()); - } - return new Result>().ok(Arrays.asList(wsText.split(";"))); - } - - @Operation(summary = "通知python服务端更新配置") - @PostMapping("/emit-action") - @LogOperation("通知python服务端更新配置") - @RequiresPermissions("sys:role:superAdmin") - public Result emitServerAction(@RequestBody @Valid EmitSeverActionDTO emitSeverActionDTO) { - if (emitSeverActionDTO.getAction() == null) { - throw new RenException(ErrorCode.INVALID_SERVER_ACTION); - } - String wsText = sysParamsService.getValue(Constant.SERVER_WEBSOCKET, true); - if (StringUtils.isBlank(wsText)) { - throw new RenException(ErrorCode.SERVER_WEBSOCKET_NOT_CONFIGURED); - } - String targetWs = emitSeverActionDTO.getTargetWs(); - String[] wsList = wsText.split(";"); - // 找到需要发起的 - if (StringUtils.isBlank(targetWs) || !Arrays.asList(wsList).contains(targetWs)) { - throw new RenException(ErrorCode.TARGET_WEBSOCKET_NOT_EXIST); - } - return new Result().ok(emitServerActionByWs(targetWs, emitSeverActionDTO.getAction())); - } - - private Boolean emitServerActionByWs(String targetWsUri, ServerActionEnum actionEnum) { - if (StringUtils.isBlank(targetWsUri) || actionEnum == null) { - return false; - } - String serverSK = sysParamsService.getValue(Constant.SERVER_SECRET, true); - WebSocketHttpHeaders headers = new WebSocketHttpHeaders(); - headers.add("device-id", UUID.randomUUID().toString()); - headers.add("client-id", UUID.randomUUID().toString()); - - try (WebSocketClientManager client = new WebSocketClientManager.Builder() - .connectTimeout(3, TimeUnit.SECONDS) - .maxSessionDuration(120, TimeUnit.SECONDS) - .uri(targetWsUri) - .headers(headers) - .build()) { - // 如果连接成功则发送一个json数据包并等待服务端响应 - client.sendJson( - ServerActionPayloadDTO.build( - actionEnum, - Map.of("secret", serverSK))); - // 等待服务端响应并持续监听信息 - client.listener((jsonText) -> { - if (StringUtils.isBlank(jsonText)) { - return false; - } - try { - ServerActionResponseDTO response = objectMapper.readValue(jsonText, ServerActionResponseDTO.class); - Boolean isSuccess = ServerActionResponseDTO.isSuccess(response); - return isSuccess; - } catch (JsonProcessingException e) { - return false; - } - }); - } catch (Exception e) { - // 捕获全部错误,由全局异常处理器返回 - throw new RenException(ErrorCode.WEB_SOCKET_CONNECT_FAILED); - } - return true; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysDictDataController.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysDictDataController.java deleted file mode 100644 index 30187fe8a..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysDictDataController.java +++ /dev/null @@ -1,105 +0,0 @@ -package xiaozhi.modules.sys.controller; - -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -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 xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.sys.dto.SysDictDataDTO; -import xiaozhi.modules.sys.service.SysDictDataService; -import xiaozhi.modules.sys.vo.SysDictDataItem; -import xiaozhi.modules.sys.vo.SysDictDataVO; - -/** - * 字典数据管理 - * - * @author czc - * @since 2025-04-30 - */ -@AllArgsConstructor -@RestController -@RequestMapping("/admin/dict/data") -@Tag(name = "字典数据管理") -public class SysDictDataController { - private final SysDictDataService sysDictDataService; - - @GetMapping("/page") - @Operation(summary = "分页查询字典数据") - @RequiresPermissions("sys:role:superAdmin") - @Parameters({ @Parameter(name = "dictTypeId", description = "字典类型ID", required = true), - @Parameter(name = "dictLabel", description = "数据标签"), @Parameter(name = "dictValue", description = "数据值"), - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) }) - public Result> page(@Parameter(hidden = true) @RequestParam Map params) { - ValidatorUtils.validateEntity(params); - // 强制校验dictTypeId是否存在 - if (!params.containsKey("dictTypeId") || StringUtils.isEmpty(String.valueOf(params.get("dictTypeId")))) { - return new Result>().error("dictTypeId不能为空"); - } - - PageData page = sysDictDataService.page(params); - return new Result>().ok(page); - } - - @GetMapping("/{id}") - @Operation(summary = "获取字典数据详情") - @RequiresPermissions("sys:role:superAdmin") - public Result get(@PathVariable("id") Long id) { - SysDictDataVO vo = sysDictDataService.get(id); - return new Result().ok(vo); - } - - @PostMapping("/save") - @Operation(summary = "新增字典数据") - @RequiresPermissions("sys:role:superAdmin") - public Result save(@RequestBody SysDictDataDTO dto) { - ValidatorUtils.validateEntity(dto); - sysDictDataService.save(dto); - return new Result<>(); - } - - @PutMapping("/update") - @Operation(summary = "修改字典数据") - @RequiresPermissions("sys:role:superAdmin") - public Result update(@RequestBody SysDictDataDTO dto) { - ValidatorUtils.validateEntity(dto); - sysDictDataService.update(dto); - return new Result<>(); - } - - @PostMapping("/delete") - @Operation(summary = "删除字典数据") - @RequiresPermissions("sys:role:superAdmin") - @Parameter(name = "ids", description = "ID数组", required = true) - public Result delete(@RequestBody Long[] ids) { - sysDictDataService.delete(ids); - return new Result<>(); - } - - @GetMapping("/type/{dictType}") - @Operation(summary = "获取字典数据列表") - @RequiresPermissions("sys:role:normal") - public Result> getDictDataByType(@PathVariable("dictType") String dictType) { - List list = sysDictDataService.getDictDataByType(dictType); - return new Result>().ok(list); - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysDictTypeController.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysDictTypeController.java deleted file mode 100644 index f16409b03..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysDictTypeController.java +++ /dev/null @@ -1,92 +0,0 @@ -package xiaozhi.modules.sys.controller; - -import java.util.Map; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -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 xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.sys.dto.SysDictTypeDTO; -import xiaozhi.modules.sys.service.SysDictTypeService; -import xiaozhi.modules.sys.vo.SysDictTypeVO; - -/** - * 字典类型管理 - * - * @author czc - * @since 2025-04-30 - */ -@AllArgsConstructor -@RestController -@RequestMapping("/admin/dict/type") -@Tag(name = "字典类型管理") -public class SysDictTypeController { - private final SysDictTypeService sysDictTypeService; - - @GetMapping("/page") - @Operation(summary = "分页查询字典类型") - @RequiresPermissions("sys:role:superAdmin") - @Parameters({ @Parameter(name = "dictType", description = "字典类型编码"), - @Parameter(name = "dictName", description = "字典类型名称"), - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) }) - public Result> page(@Parameter(hidden = true) @RequestParam Map params) { - ValidatorUtils.validateEntity(params); - PageData page = sysDictTypeService.page(params); - return new Result>().ok(page); - } - - @GetMapping("/{id}") - @Operation(summary = "获取字典类型详情") - @RequiresPermissions("sys:role:superAdmin") - public Result get(@PathVariable("id") Long id) { - SysDictTypeVO vo = sysDictTypeService.get(id); - return new Result().ok(vo); - } - - @PostMapping("/save") - @Operation(summary = "保存字典类型") - @RequiresPermissions("sys:role:superAdmin") - public Result save(@RequestBody SysDictTypeDTO dto) { - // 参数校验 - ValidatorUtils.validateEntity(dto); - - sysDictTypeService.save(dto); - return new Result<>(); - } - - @PutMapping("/update") - @Operation(summary = "修改字典类型") - @RequiresPermissions("sys:role:superAdmin") - public Result update(@RequestBody SysDictTypeDTO dto) { - // 参数校验 - ValidatorUtils.validateEntity(dto); - - sysDictTypeService.update(dto); - return new Result<>(); - } - - @PostMapping("/delete") - @Operation(summary = "删除字典类型") - @RequiresPermissions("sys:role:superAdmin") - @Parameter(name = "ids", description = "ID数组", required = true) - public Result delete(@RequestBody Long[] ids) { - sysDictTypeService.delete(ids); - return new Result<>(); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysParamsController.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysParamsController.java deleted file mode 100644 index 24b070c08..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/controller/SysParamsController.java +++ /dev/null @@ -1,296 +0,0 @@ -package xiaozhi.modules.sys.controller; - -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; - -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.enums.ParameterIn; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AllArgsConstructor; -import xiaozhi.common.annotation.LogOperation; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.page.PageData; -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.config.service.ConfigService; -import xiaozhi.modules.sys.dto.SysParamsDTO; -import xiaozhi.modules.sys.service.SysParamsService; -import xiaozhi.modules.sys.utils.WebSocketValidator; - -/** - * 参数管理 - * - * @author Mark sunlightcs@gmail.com - * @since 1.0.0 - */ -@RestController -@RequestMapping("admin/params") -@Tag(name = "参数管理") -@AllArgsConstructor -public class SysParamsController { - private final SysParamsService sysParamsService; - private final ConfigService configService; - private final RestTemplate restTemplate; - - @GetMapping("page") - @Operation(summary = "分页") - @Parameters({ - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"), - @Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"), - @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"), - @Parameter(name = "paramCode", description = "参数编码或参数备注", in = ParameterIn.QUERY, ref = "String") - }) - @RequiresPermissions("sys:role:superAdmin") - public Result> page(@Parameter(hidden = true) @RequestParam Map params) { - PageData page = sysParamsService.page(params); - - return new Result>().ok(page); - } - - @GetMapping("{id}") - @Operation(summary = "信息") - @RequiresPermissions("sys:role:superAdmin") - public Result get(@PathVariable("id") Long id) { - SysParamsDTO data = sysParamsService.get(id); - - return new Result().ok(data); - } - - @PostMapping - @Operation(summary = "保存") - @LogOperation("保存") - @RequiresPermissions("sys:role:superAdmin") - public Result save(@RequestBody SysParamsDTO dto) { - // 效验数据 - ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - - sysParamsService.save(dto); - configService.getConfig(false); - return new Result(); - } - - @PutMapping - @Operation(summary = "修改") - @LogOperation("修改") - @RequiresPermissions("sys:role:superAdmin") - public Result update(@RequestBody SysParamsDTO dto) { - // 效验数据 - ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - - // 验证WebSocket地址列表 - validateWebSocketUrls(dto.getParamCode(), dto.getParamValue()); - - // 验证OTA地址 - validateOtaUrl(dto.getParamCode(), dto.getParamValue()); - - // 验证MCP地址 - validateMcpUrl(dto.getParamCode(), dto.getParamValue()); - - // 验证声纹地址 - validateVoicePrint(dto.getParamCode(), dto.getParamValue()); - - // 校验mqtt密钥长度 - validateMqttSecretLength(dto.getParamCode(), dto.getParamValue()); - - sysParamsService.update(dto); - configService.getConfig(false); - return new Result(); - } - - /** - * 验证WebSocket地址列表 - * - * @param urls WebSocket地址列表,以分号分隔 - * @return 验证结果 - */ - private void validateWebSocketUrls(String paramCode, String urls) { - if (!paramCode.equals(Constant.SERVER_WEBSOCKET)) { - return; - } - String[] wsUrls = urls.split("\\;"); - if (wsUrls.length == 0) { - throw new RenException(ErrorCode.WEBSOCKET_URLS_EMPTY); - } - for (String url : wsUrls) { - if (StringUtils.isNotBlank(url)) { - // 检查是否包含localhost或127.0.0.1 - if (url.contains("localhost") || url.contains("127.0.0.1")) { - throw new RenException(ErrorCode.WEBSOCKET_URL_LOCALHOST); - } - - // 验证WebSocket地址格式 - if (!WebSocketValidator.validateUrlFormat(url)) { - throw new RenException(ErrorCode.WEBSOCKET_URL_FORMAT_ERROR); - } - - // 测试WebSocket连接 - if (!WebSocketValidator.testConnection(url)) { - throw new RenException(ErrorCode.WEBSOCKET_CONNECTION_FAILED); - } - } - } - } - - @PostMapping("/delete") - @Operation(summary = "删除") - @LogOperation("删除") - @RequiresPermissions("sys:role:superAdmin") - public Result delete(@RequestBody String[] ids) { - // 效验数据 - AssertUtils.isArrayEmpty(ids, "id"); - - sysParamsService.delete(ids); - configService.getConfig(false); - return new Result(); - } - - /** - * 验证OTA地址 - */ - private void validateOtaUrl(String paramCode, String url) { - if (!paramCode.equals(Constant.SERVER_OTA)) { - return; - } - if (StringUtils.isBlank(url) || url.equals("null")) { - throw new RenException(ErrorCode.OTA_URL_EMPTY); - } - - // 检查是否包含localhost或127.0.0.1 - if (url.contains("localhost") || url.contains("127.0.0.1")) { - throw new RenException(ErrorCode.OTA_URL_LOCALHOST); - } - - // 验证URL格式 - if (!url.toLowerCase().startsWith("http")) { - throw new RenException(ErrorCode.OTA_URL_PROTOCOL_ERROR); - } - if (!url.endsWith("/ota/")) { - throw new RenException(ErrorCode.OTA_URL_FORMAT_ERROR); - } - - try { - // 发送GET请求 - ResponseEntity response = restTemplate.getForEntity(url, String.class); - if (response.getStatusCode() != HttpStatus.OK) { - throw new RenException(ErrorCode.OTA_INTERFACE_ACCESS_FAILED); - } - // 检查响应内容是否包含OTA相关信息 - String body = response.getBody(); - if (body == null || !body.contains("OTA")) { - throw new RenException(ErrorCode.OTA_INTERFACE_FORMAT_ERROR); - } - } catch (Exception e) { - throw new RenException(ErrorCode.OTA_INTERFACE_VALIDATION_FAILED); - } - } - - private void validateMcpUrl(String paramCode, String url) { - if (!paramCode.equals(Constant.SERVER_MCP_ENDPOINT)) { - return; - } - if (StringUtils.isBlank(url) || url.equals("null")) { - throw new RenException(ErrorCode.MCP_URL_EMPTY); - } - if (url.contains("localhost") || url.contains("127.0.0.1")) { - throw new RenException(ErrorCode.MCP_URL_LOCALHOST); - } - if (!url.toLowerCase().contains("key")) { - throw new RenException(ErrorCode.MCP_URL_INVALID); - } - - try { - // 发送GET请求 - ResponseEntity response = restTemplate.getForEntity(url, String.class); - if (response.getStatusCode() != HttpStatus.OK) { - throw new RenException(ErrorCode.MCP_INTERFACE_ACCESS_FAILED); - } - // 检查响应内容是否包含mcp相关信息 - String body = response.getBody(); - if (body == null || !body.contains("success")) { - throw new RenException(ErrorCode.MCP_INTERFACE_FORMAT_ERROR); - } - } catch (Exception e) { - throw new RenException(ErrorCode.MCP_INTERFACE_VALIDATION_FAILED); - } - } - - // 验证声纹接口地址是否正常 - private void validateVoicePrint(String paramCode, String url) { - if (!paramCode.equals(Constant.SERVER_VOICE_PRINT)) { - return; - } - if (StringUtils.isBlank(url) || url.equals("null")) { - throw new RenException(ErrorCode.VOICEPRINT_URL_EMPTY); - } - if (url.contains("localhost") || url.contains("127.0.0.1")) { - throw new RenException(ErrorCode.VOICEPRINT_URL_LOCALHOST); - } - if (!url.toLowerCase().contains("key")) { - throw new RenException(ErrorCode.VOICEPRINT_URL_INVALID); - } - // 验证URL格式 - if (!url.toLowerCase().startsWith("http")) { - throw new RenException(ErrorCode.VOICEPRINT_URL_PROTOCOL_ERROR); - } - try { - // 发送GET请求 - ResponseEntity response = restTemplate.getForEntity(url, String.class); - if (response.getStatusCode() != HttpStatus.OK) { - throw new RenException(ErrorCode.VOICEPRINT_INTERFACE_ACCESS_FAILED); - } - // 检查响应内容 - String body = response.getBody(); - if (body == null || !body.contains("healthy")) { - throw new RenException(ErrorCode.VOICEPRINT_INTERFACE_FORMAT_ERROR); - } - } catch (Exception e) { - throw new RenException(ErrorCode.VOICEPRINT_INTERFACE_VALIDATION_FAILED); - } - } - - // 校验mqtt密钥长度和复杂度 - private void validateMqttSecretLength(String paramCode, String secret) { - if (!paramCode.equals(Constant.SERVER_MQTT_SECRET)) { - return; - } - if (StringUtils.isBlank(secret) || secret.equals("null")) { - throw new RenException(ErrorCode.MQTT_SECRET_EMPTY); - } - if (secret.length() < 8) { - throw new RenException(ErrorCode.MQTT_SECRET_LENGTH_INSECURE); - } - // 检查是否同时包含大小写字母 - if (!secret.matches(".*[a-z].*") || !secret.matches(".*[A-Z].*")) { - throw new RenException(ErrorCode.MQTT_SECRET_CHARACTER_INSECURE); - } - // 不允许包含弱密码 - String[] weakPasswords = { "test", "1234", "admin", "password", "qwerty", "xiaozhi" }; - for (String weakPassword : weakPasswords) { - if (secret.toLowerCase().contains(weakPassword)) { - throw new RenException(ErrorCode.MQTT_SECRET_WEAK_PASSWORD); - } - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysDictDataDao.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysDictDataDao.java deleted file mode 100644 index e5c4c7bbc..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysDictDataDao.java +++ /dev/null @@ -1,26 +0,0 @@ -package xiaozhi.modules.sys.dao; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; - -import xiaozhi.common.dao.BaseDao; -import xiaozhi.modules.sys.entity.SysDictDataEntity; -import xiaozhi.modules.sys.vo.SysDictDataItem; - -/** - * 字典数据 - */ -@Mapper -public interface SysDictDataDao extends BaseDao { - - List getDictDataByType(String dictType); - - /** - * 根据字典类型ID获取字典类型编码 - * - * @param dictTypeId 字典类型ID - * @return 字典类型编码 - */ - String getTypeByTypeId(Long dictTypeId); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysDictTypeDao.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysDictTypeDao.java deleted file mode 100644 index 6c271e314..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysDictTypeDao.java +++ /dev/null @@ -1,14 +0,0 @@ -package xiaozhi.modules.sys.dao; - -import org.apache.ibatis.annotations.Mapper; - -import xiaozhi.common.dao.BaseDao; -import xiaozhi.modules.sys.entity.SysDictTypeEntity; - -/** - * 字典类型 - */ -@Mapper -public interface SysDictTypeDao extends BaseDao { - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysParamsDao.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysParamsDao.java deleted file mode 100644 index 6eebc8be8..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysParamsDao.java +++ /dev/null @@ -1,39 +0,0 @@ -package xiaozhi.modules.sys.dao; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import xiaozhi.common.dao.BaseDao; -import xiaozhi.modules.sys.entity.SysParamsEntity; - -/** - * 参数管理 - */ -@Mapper -public interface SysParamsDao extends BaseDao { - /** - * 根据参数编码,查询value - * - * @param paramCode 参数编码 - * @return 参数值 - */ - String getValueByCode(String paramCode); - - /** - * 获取参数编码列表 - * - * @param ids ids - * @return 返回参数编码列表 - */ - List getParamCodeList(String[] ids); - - /** - * 根据参数编码,更新value - * - * @param paramCode 参数编码 - * @param paramValue 参数值 - */ - int updateValueByCode(@Param("paramCode") String paramCode, @Param("paramValue") String paramValue); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysUserDao.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysUserDao.java deleted file mode 100644 index fb2a24926..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dao/SysUserDao.java +++ /dev/null @@ -1,14 +0,0 @@ -package xiaozhi.modules.sys.dao; - -import org.apache.ibatis.annotations.Mapper; - -import xiaozhi.common.dao.BaseDao; -import xiaozhi.modules.sys.entity.SysUserEntity; - -/** - * 系统用户 - */ -@Mapper -public interface SysUserDao extends BaseDao { - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/AdminPageUserDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/AdminPageUserDTO.java deleted file mode 100644 index a9d960a1d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/AdminPageUserDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Min; -import lombok.Data; - -/** - * 管理员分页用户的参数DTO - * - * @author zjy - * @since 2025-3-21 - */ -@Data -@Schema(description = "管理员分页用户的参数DTO") -public class AdminPageUserDTO { - - @Schema(description = "手机号码") - private String mobile; - - @Schema(description = "页数") - @Min(value = 0, message = "{sort.number}") - private String page; - - @Schema(description = "显示列数") - @Min(value = 0, message = "{sort.number}") - private String limit; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/EmitSeverActionDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/EmitSeverActionDTO.java deleted file mode 100644 index 6de89aab2..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/EmitSeverActionDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import xiaozhi.modules.sys.enums.ServerActionEnum; - -/** - * 发送python服务端操作DTO - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class EmitSeverActionDTO -{ - @Schema(description = "目标ws地址") - @NotEmpty(message = "目标ws地址不能为空") - private String targetWs; - - @Schema(description = "指定操作") - @NotNull(message = "操作不能为空") - private ServerActionEnum action; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/PasswordDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/PasswordDTO.java deleted file mode 100644 index 4aabb10e0..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/PasswordDTO.java +++ /dev/null @@ -1,24 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -/** - * 修改密码 - */ -@Data -@Schema(description = "修改密码") -public class PasswordDTO implements Serializable { - - @Schema(description = "原密码") - @NotBlank(message = "{sysuser.password.require}") - private String password; - - @Schema(description = "新密码") - @NotBlank(message = "{sysuser.password.require}") - private String newPassword; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/RetrievePasswordDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/RetrievePasswordDTO.java deleted file mode 100644 index 5475cf67a..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/RetrievePasswordDTO.java +++ /dev/null @@ -1,34 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -import java.io.Serializable; - -/** - * 找回密码DTO - */ -@Data -@Schema(description = "找回密码") -public class RetrievePasswordDTO implements Serializable { - - @Schema(description = "手机号码") - @NotBlank(message = "{sysuser.password.require}") - private String phone; - - @Schema(description = "验证码") - @NotBlank(message = "{sysuser.password.require}") - private String code; - - @Schema(description = "新密码") - @NotBlank(message = "{sysuser.password.require}") - private String password; - - @Schema(description = "图形验证码ID") - @NotBlank(message = "{sysuser.uuid.require}") - private String captchaId; - - - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/ServerActionPayloadDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/ServerActionPayloadDTO.java deleted file mode 100644 index fb1427f9a..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/ServerActionPayloadDTO.java +++ /dev/null @@ -1,36 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import lombok.Data; -import xiaozhi.modules.sys.enums.ServerActionEnum; - -import java.util.Map; - -/** - * 服务端动作DTO - */ -@Data -public class ServerActionPayloadDTO -{ - /** - * 类型(智控台发往服务端的都是server) - */ - private String type; - /** - * 动作 - */ - private ServerActionEnum action; - /** - * 内容 - */ - private Map content; - - public static ServerActionPayloadDTO build(ServerActionEnum action, Map content) { - ServerActionPayloadDTO serverActionPayloadDTO = new ServerActionPayloadDTO(); - serverActionPayloadDTO.setAction(action); - serverActionPayloadDTO.setContent(content); - serverActionPayloadDTO.setType("server"); - return serverActionPayloadDTO; - } - // 私有化 - private ServerActionPayloadDTO() {} -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/ServerActionResponseDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/ServerActionResponseDTO.java deleted file mode 100644 index 6286b74ac..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/ServerActionResponseDTO.java +++ /dev/null @@ -1,34 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import lombok.Data; -import xiaozhi.modules.sys.enums.ServerActionResponseEnum; - -import java.util.Map; - -/** - * 服务端动作响应体 - */ -@Data -public class ServerActionResponseDTO -{ - private ServerActionResponseEnum status; - private String message; - private String type; - private Map content; // 后续这个字段可以移除,并把这个类作为基类,针对业务写自己的content类型 - public static final String DEFAULT_TYPE_FORM_SERVER = "server"; - - public static Boolean isSuccess(ServerActionResponseDTO actionResponseDTO) { - System.out.println(actionResponseDTO); - if (actionResponseDTO == null) { - return false; - } - if (actionResponseDTO.getStatus() == null || !actionResponseDTO.getStatus().equals(ServerActionResponseEnum.SUCCESS)) { - return false; - } - Object actionType = actionResponseDTO.getContent().get("action"); - if (actionType == null) { - return false; - } - return actionResponseDTO.getType() != null && actionResponseDTO.getType().equals(DEFAULT_TYPE_FORM_SERVER); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysDictDataDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysDictDataDTO.java deleted file mode 100644 index c18dbf8f2..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysDictDataDTO.java +++ /dev/null @@ -1,59 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import java.io.Serializable; -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Null; -import lombok.Data; -import xiaozhi.common.utils.DateUtils; -import xiaozhi.common.validator.group.AddGroup; -import xiaozhi.common.validator.group.DefaultGroup; -import xiaozhi.common.validator.group.UpdateGroup; - -/** - * 字典数据 - */ -@Data -@Schema(description = "字典数据") -public class SysDictDataDTO implements Serializable { - - @Schema(description = "id") - @Null(message = "{id.null}", groups = AddGroup.class) - @NotNull(message = "{id.require}", groups = UpdateGroup.class) - private Long id; - - @Schema(description = "字典类型ID") - @NotNull(message = "{sysdict.type.require}", groups = DefaultGroup.class) - private Long dictTypeId; - - @Schema(description = "字典标签") - @NotBlank(message = "{sysdict.label.require}", groups = DefaultGroup.class) - private String dictLabel; - - @Schema(description = "字典值") - private String dictValue; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "排序") - @Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class) - private Integer sort; - - @Schema(description = "创建时间") - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) - private Date createDate; - - @Schema(description = "更新时间") - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) - private Date updateDate; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysDictTypeDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysDictTypeDTO.java deleted file mode 100644 index 912c817cb..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysDictTypeDTO.java +++ /dev/null @@ -1,56 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import java.io.Serializable; -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Null; -import lombok.Data; -import xiaozhi.common.utils.DateUtils; -import xiaozhi.common.validator.group.AddGroup; -import xiaozhi.common.validator.group.DefaultGroup; -import xiaozhi.common.validator.group.UpdateGroup; - -/** - * 字典类型 - */ -@Data -@Schema(description = "字典类型") -public class SysDictTypeDTO implements Serializable { - - @Schema(description = "id") - @Null(message = "{id.null}", groups = AddGroup.class) - @NotNull(message = "{id.require}", groups = UpdateGroup.class) - private Long id; - - @Schema(description = "字典类型") - @NotBlank(message = "{sysdict.type.require}", groups = DefaultGroup.class) - private String dictType; - - @Schema(description = "字典名称") - @NotBlank(message = "{sysdict.name.require}", groups = DefaultGroup.class) - private String dictName; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "排序") - @Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class) - private Integer sort; - - @Schema(description = "创建时间") - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) - private Date createDate; - - @Schema(description = "更新时间") - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) - private Date updateDate; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysParamsDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysParamsDTO.java deleted file mode 100644 index a6f27b722..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysParamsDTO.java +++ /dev/null @@ -1,58 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import java.io.Serializable; -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Null; -import jakarta.validation.constraints.Pattern; -import lombok.Data; -import xiaozhi.common.utils.DateUtils; -import xiaozhi.common.validator.group.AddGroup; -import xiaozhi.common.validator.group.DefaultGroup; -import xiaozhi.common.validator.group.UpdateGroup; - -/** - * 参数管理 - */ -@Data -@Schema(description = "参数管理") -public class SysParamsDTO implements Serializable { - - @Schema(description = "id") - @Null(message = "{id.null}", groups = AddGroup.class) - @NotNull(message = "{id.require}", groups = UpdateGroup.class) - private Long id; - - @Schema(description = "参数编码") - @NotBlank(message = "{sysparams.paramcode.require}", groups = DefaultGroup.class) - private String paramCode; - - @Schema(description = "参数值") - @NotBlank(message = "{sysparams.paramvalue.require}", groups = DefaultGroup.class) - private String paramValue; - - @Schema(description = "值类型") - @NotBlank(message = "{sysparams.valuetype.require}", groups = DefaultGroup.class) - @Pattern(regexp = "^(string|number|boolean|array|json)$", message = "{sysparams.valuetype.pattern}", groups = DefaultGroup.class) - private String valueType; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "创建时间") - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) - private Date createDate; - - @Schema(description = "更新时间") - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) - private Date updateDate; - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysUserDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysUserDTO.java deleted file mode 100644 index ff0663410..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/dto/SysUserDTO.java +++ /dev/null @@ -1,87 +0,0 @@ -package xiaozhi.modules.sys.dto; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -import org.hibernate.validator.constraints.Range; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Null; -import lombok.Data; -import xiaozhi.common.utils.DateUtils; -import xiaozhi.common.validator.group.AddGroup; -import xiaozhi.common.validator.group.DefaultGroup; -import xiaozhi.common.validator.group.UpdateGroup; - -/** - * 用户管理 - */ -@Data -@Schema(description = "用户管理") -public class SysUserDTO implements Serializable { - @Schema(description = "id") - @Null(message = "{id.null}", groups = AddGroup.class) - @NotNull(message = "{id.require}", groups = UpdateGroup.class) - private Long id; - - @Schema(description = "用户名", required = true) - @NotBlank(message = "{sysuser.username.require}", groups = DefaultGroup.class) - private String username; - - @Schema(description = "密码") - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - @NotBlank(message = "{sysuser.password.require}", groups = AddGroup.class) - private String password; - - @Schema(description = "姓名", required = true) - @NotBlank(message = "{sysuser.realname.require}", groups = DefaultGroup.class) - private String realName; - - @Schema(description = "头像") - private String headUrl; - - @Schema(description = "性别 0:男 1:女 2:保密", required = true) - @Range(min = 0, max = 2, message = "{sysuser.gender.range}", groups = DefaultGroup.class) - private Integer gender; - - @Schema(description = "邮箱") - @Email(message = "{sysuser.email.error}", groups = DefaultGroup.class) - private String email; - - @Schema(description = "手机号") - private String mobile; - - @Schema(description = "部门ID", required = true) - @NotNull(message = "{sysuser.deptId.require}", groups = DefaultGroup.class) - private Long deptId; - - @Schema(description = "状态 0:停用 1:正常", required = true) - @Range(min = 0, max = 1, message = "{sysuser.status.range}", groups = DefaultGroup.class) - private Integer status; - - @Schema(description = "创建时间") - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) - private Date createDate; - - @Schema(description = "超级管理员 0:否 1:是") - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Integer superAdmin; - - @Schema(description = "角色ID列表") - private List roleIdList; - - @Schema(description = "岗位ID列表") - private List postIdList; - - @Schema(description = "部门名称") - private String deptName; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysDictDataEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysDictDataEntity.java deleted file mode 100644 index 16d3dcae8..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysDictDataEntity.java +++ /dev/null @@ -1,50 +0,0 @@ -package xiaozhi.modules.sys.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import xiaozhi.common.entity.BaseEntity; - -/** - * 数据字典 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("sys_dict_data") -public class SysDictDataEntity extends BaseEntity { - /** - * 字典类型ID - */ - private Long dictTypeId; - /** - * 字典标签 - */ - private String dictLabel; - /** - * 字典值 - */ - private String dictValue; - /** - * 备注 - */ - private String remark; - /** - * 排序 - */ - private Integer sort; - /** - * 更新者 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updater; - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateDate; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysDictTypeEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysDictTypeEntity.java deleted file mode 100644 index 350d857bd..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysDictTypeEntity.java +++ /dev/null @@ -1,46 +0,0 @@ -package xiaozhi.modules.sys.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import xiaozhi.common.entity.BaseEntity; - -/** - * 字典类型 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("sys_dict_type") -public class SysDictTypeEntity extends BaseEntity { - /** - * 字典类型编码 - */ - private String dictType; - /** - * 字典名称 - */ - private String dictName; - /** - * 备注 - */ - private String remark; - /** - * 排序 - */ - private Integer sort; - /** - * 更新者 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updater; - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateDate; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysParamsEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysParamsEntity.java deleted file mode 100644 index c51c46fab..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysParamsEntity.java +++ /dev/null @@ -1,51 +0,0 @@ -package xiaozhi.modules.sys.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import xiaozhi.common.entity.BaseEntity; - -/** - * 参数管理 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("sys_params") -public class SysParamsEntity extends BaseEntity { - /** - * 参数编码 - */ - private String paramCode; - /** - * 参数值 - */ - private String paramValue; - /** - * 值类型:string-字符串,number-数字,boolean-布尔,array-数组 - */ - private String valueType; - /** - * 类型 0:系统参数 1:非系统参数 - */ - private Integer paramType; - /** - * 备注 - */ - private String remark; - /** - * 更新者 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updater; - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateDate; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysUserEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysUserEntity.java deleted file mode 100644 index 23043a370..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/entity/SysUserEntity.java +++ /dev/null @@ -1,47 +0,0 @@ -package xiaozhi.modules.sys.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import xiaozhi.common.entity.BaseEntity; - -/** - * 系统用户 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("sys_user") -public class SysUserEntity extends BaseEntity { - /** - * 用户名 - */ - private String username; - /** - * 密码 - */ - private String password; - /** - * 超级管理员 0:否 1:是 - */ - private Integer superAdmin; - /** - * 状态 0:停用 1:正常 - */ - private Integer status; - /** - * 更新者 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updater; - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateDate; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/ServerActionEnum.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/ServerActionEnum.java deleted file mode 100644 index ec3ce2f5e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/ServerActionEnum.java +++ /dev/null @@ -1,33 +0,0 @@ -package xiaozhi.modules.sys.enums; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * 服务端动作枚举 - */ -public enum ServerActionEnum { - RESTART("restart"), - UPDATE_CONFIG("update_config"); - - private final String value; - - ServerActionEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @JsonCreator - public static ServerActionEnum fromValue(String value) { - for (ServerActionEnum action : ServerActionEnum.values()) { - if (action.value.equalsIgnoreCase(value)) { - return action; - } - } - return null; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/ServerActionResponseEnum.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/ServerActionResponseEnum.java deleted file mode 100644 index 040b2085b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/ServerActionResponseEnum.java +++ /dev/null @@ -1,45 +0,0 @@ -package xiaozhi.modules.sys.enums; - -import org.apache.commons.lang3.StringUtils; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * 服务端调用响应枚举 - */ -public enum ServerActionResponseEnum { - SUCCESS("success"), FAIL("fail"); - - private final String value; - - ServerActionResponseEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @JsonCreator - public static ServerActionResponseEnum fromValue(String value) { - ServerActionResponseEnum byValue = getByValue(value); - if (byValue == null) { - throw new IllegalArgumentException("Unknown enum value: " + value); - } - return byValue; - } - - public static ServerActionResponseEnum getByValue(String value) { - if (StringUtils.isBlank(value)) { - return null; - } - for (ServerActionResponseEnum action : ServerActionResponseEnum.values()) { - if (action.value.equals(value)) { - return action; - } - } - return null; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/SuperAdminEnum.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/SuperAdminEnum.java deleted file mode 100644 index 655f46e68..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/enums/SuperAdminEnum.java +++ /dev/null @@ -1,19 +0,0 @@ -package xiaozhi.modules.sys.enums; - -/** - * 超级管理员枚举 - */ -public enum SuperAdminEnum { - YES(1), - NO(0); - - private int value; - - SuperAdminEnum(int value) { - this.value = value; - } - - public int value() { - return this.value; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/redis/SysParamsRedis.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/redis/SysParamsRedis.java deleted file mode 100644 index 2e2bdb428..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/redis/SysParamsRedis.java +++ /dev/null @@ -1,35 +0,0 @@ -package xiaozhi.modules.sys.redis; - -import org.springframework.stereotype.Component; - -import lombok.AllArgsConstructor; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; - -/** - * 参数管理 - */ -@AllArgsConstructor -@Component -public class SysParamsRedis { - private final RedisUtils redisUtils; - - public void delete(Object[] paramCodes) { - String key = RedisKeys.getSysParamsKey(); - redisUtils.hDel(key, paramCodes); - } - - public void set(String paramCode, String paramValue) { - if (paramValue == null) { - return; - } - String key = RedisKeys.getSysParamsKey(); - redisUtils.hSet(key, paramCode, paramValue); - } - - public String get(String paramCode) { - String key = RedisKeys.getSysParamsKey(); - return (String) redisUtils.hGet(key, paramCode); - } - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysDictDataService.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysDictDataService.java deleted file mode 100644 index ea898447f..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysDictDataService.java +++ /dev/null @@ -1,70 +0,0 @@ -package xiaozhi.modules.sys.service; - -import java.util.List; -import java.util.Map; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.sys.dto.SysDictDataDTO; -import xiaozhi.modules.sys.entity.SysDictDataEntity; -import xiaozhi.modules.sys.vo.SysDictDataItem; -import xiaozhi.modules.sys.vo.SysDictDataVO; - -/** - * 数据字典 - */ -public interface SysDictDataService extends BaseService { - - /** - * 分页查询数据字典信息 - * - * @param params 查询参数,包含分页信息和查询条件 - * @return 返回数据字典的分页查询结果 - */ - PageData page(Map params); - - /** - * 根据ID获取数据字典实体 - * - * @param id 数据字典实体的唯一标识 - * @return 返回数据字典实体的详细信息 - */ - SysDictDataVO get(Long id); - - /** - * 保存新的数据字典项 - * - * @param dto 数据字典项的保存数据传输对象 - */ - void save(SysDictDataDTO dto); - - /** - * 更新数据字典项 - * - * @param dto 数据字典项的更新数据传输对象 - */ - void update(SysDictDataDTO dto); - - /** - * 删除数据字典项 - * - * @param ids 要删除的数据字典项的ID数组 - */ - void delete(Long[] ids); - - /** - * 根据字典类型ID删除对应的字典数据 - * - * @param dictTypeId 字典类型ID - */ - void deleteByTypeId(Long dictTypeId); - - /** - * 根据字典类型获取字典数据列表 - * - * @param dictType 字典类型 - * @return 返回字典数据列表 - */ - List getDictDataByType(String dictType); - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysDictTypeService.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysDictTypeService.java deleted file mode 100644 index 697b2d10d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysDictTypeService.java +++ /dev/null @@ -1,60 +0,0 @@ -package xiaozhi.modules.sys.service; - -import java.util.List; -import java.util.Map; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.sys.dto.SysDictTypeDTO; -import xiaozhi.modules.sys.entity.SysDictTypeEntity; -import xiaozhi.modules.sys.vo.SysDictTypeVO; - -/** - * 数据字典 - */ -public interface SysDictTypeService extends BaseService { - - /** - * 分页查询字典类型信息 - * - * @param params 查询参数,包含分页信息和查询条件 - * @return 返回分页的字典类型数据 - */ - PageData page(Map params); - - /** - * 根据ID获取字典类型信息 - * - * @param id 字典类型ID - * @return 返回字典类型对象 - */ - SysDictTypeVO get(Long id); - - /** - * 保存字典类型信息 - * - * @param dto 字典类型数据传输对象 - */ - void save(SysDictTypeDTO dto); - - /** - * 更新字典类型信息 - * - * @param dto 字典类型数据传输对象 - */ - void update(SysDictTypeDTO dto); - - /** - * 删除字典类型信息 - * - * @param ids 要删除的字典类型ID数组 - */ - void delete(Long[] ids); - - /** - * 列出所有字典类型信息 - * - * @return 返回字典类型列表 - */ - List list(Map params); -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysParamsService.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysParamsService.java deleted file mode 100644 index ac67a2760..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysParamsService.java +++ /dev/null @@ -1,56 +0,0 @@ -package xiaozhi.modules.sys.service; - -import java.util.List; -import java.util.Map; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.sys.dto.SysParamsDTO; -import xiaozhi.modules.sys.entity.SysParamsEntity; - -/** - * 参数管理 - */ -public interface SysParamsService extends BaseService { - - PageData page(Map params); - - List list(Map params); - - SysParamsDTO get(Long id); - - void save(SysParamsDTO dto); - - void update(SysParamsDTO dto); - - void delete(String[] ids); - - /** - * 根据参数编码,获取参数的value值 - * - * @param paramCode 参数编码 - * @param fromCache 是否从缓存中获取 - */ - String getValue(String paramCode, Boolean fromCache); - - /** - * 根据参数编码,获取value的Object对象 - * - * @param paramCode 参数编码 - * @param clazz Object对象 - */ - T getValueObject(String paramCode, Class clazz); - - /** - * 根据参数编码,更新value - * - * @param paramCode 参数编码 - * @param paramValue 参数值 - */ - int updateValueByCode(String paramCode, String paramValue); - - /** - * 初始化服务器密钥 - */ - void initServerSecret(); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysUserService.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysUserService.java deleted file mode 100644 index 7a35da321..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysUserService.java +++ /dev/null @@ -1,75 +0,0 @@ -package xiaozhi.modules.sys.service; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.sys.dto.AdminPageUserDTO; -import xiaozhi.modules.sys.dto.PasswordDTO; -import xiaozhi.modules.sys.dto.SysUserDTO; -import xiaozhi.modules.sys.entity.SysUserEntity; -import xiaozhi.modules.sys.vo.AdminPageUserVO; - -/** - * 系统用户 - */ -public interface SysUserService extends BaseService { - - SysUserDTO getByUsername(String username); - - SysUserDTO getByUserId(Long userId); - - void save(SysUserDTO dto); - - /** - * 删除指定用户,且有关联的数据设备和智能体 - * - * @param ids - */ - void deleteById(Long ids); - - /** - * 验证是否允许修改密码更改 - * - * @param userId 用户id - * @param passwordDTO 验证密码的参数 - */ - void changePassword(Long userId, PasswordDTO passwordDTO); - - /** - * 直接修改密码,不需要验证 - * - * @param userId 用户id - * @param password 密码 - */ - void changePasswordDirectly(Long userId, String password); - - /** - * 重置密码 - * - * @param userId 用户id - * @return 随机生成符合规范的密码 - */ - String resetPassword(Long userId); - - /** - * 管理员分页用户信息 - * - * @param dto 分页查找参数 - * @return 用户列表分页数据 - */ - PageData page(AdminPageUserDTO dto); - - /** - * 批量修改用户状态 - * - * @param status 用户状态 - * @param userIds 用户ID数组 - */ - void changeStatus(Integer status, String[] userIds); - - /** - * 获取是否允许用户注册 - * - * @return 是否允许用户注册 - */ - boolean getAllowUserRegister(); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysUserUtilService.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysUserUtilService.java deleted file mode 100644 index 0fa3fc4ae..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/SysUserUtilService.java +++ /dev/null @@ -1,19 +0,0 @@ -package xiaozhi.modules.sys.service; - - -import java.util.function.Consumer; - -/** - * 定义一个系统用户工具类,避免和用户模块循环依赖 - * 如用户和设备互相依赖,用户需要获取所有设备,设备又需要获取每个设备的用户名 - * @author zjy - * @since 2025-4-2 - */ -public interface SysUserUtilService { - /** - * 赋值用户名 - * @param userId 用户id - * @param setter 赋值方法 - */ - void assignUsername( Long userId, Consumer setter); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/TokenService.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/TokenService.java deleted file mode 100644 index d3839f703..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/TokenService.java +++ /dev/null @@ -1,11 +0,0 @@ -package xiaozhi.modules.sys.service; - -public interface TokenService { - /** - * 生成token - * - * @param userId - * @return - */ - String createToken(long userId); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysDictDataServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysDictDataServiceImpl.java deleted file mode 100644 index a2adb1503..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysDictDataServiceImpl.java +++ /dev/null @@ -1,184 +0,0 @@ -package xiaozhi.modules.sys.service.impl; - -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import lombok.AllArgsConstructor; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.page.PageData; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.modules.sys.dao.SysDictDataDao; -import xiaozhi.modules.sys.dao.SysUserDao; -import xiaozhi.modules.sys.dto.SysDictDataDTO; -import xiaozhi.modules.sys.entity.SysDictDataEntity; -import xiaozhi.modules.sys.entity.SysUserEntity; -import xiaozhi.modules.sys.service.SysDictDataService; -import xiaozhi.modules.sys.vo.SysDictDataItem; -import xiaozhi.modules.sys.vo.SysDictDataVO; - -/** - * 字典类型 - */ -@Service -@AllArgsConstructor -public class SysDictDataServiceImpl extends BaseServiceImpl - implements SysDictDataService { - private final SysUserDao sysUserDao; - private final RedisUtils redisUtils; - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage(getPage(params, "sort", true), getWrapper(params)); - - PageData pageData = getPageData(page, SysDictDataVO.class); - - setUserName(pageData.getList()); - - return pageData; - } - - private QueryWrapper getWrapper(Map params) { - String dictTypeId = (String) params.get("dictTypeId"); - String dictLabel = (String) params.get("dictLabel"); - String dictValue = (String) params.get("dictValue"); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("dict_type_id", Long.parseLong(dictTypeId)); - wrapper.like(StringUtils.isNotBlank(dictLabel), "dict_label", dictLabel); - wrapper.like(StringUtils.isNotBlank(dictValue), "dict_value", dictValue); - - return wrapper; - } - - @Override - public SysDictDataVO get(Long id) { - SysDictDataEntity entity = baseDao.selectById(id); - - return ConvertUtils.sourceToTarget(entity, SysDictDataVO.class); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(SysDictDataDTO dto) { - // 相同字典类型的标签不能相同 - checkDictValueUnique(dto.getDictTypeId(), dto.getDictValue(), null); - - SysDictDataEntity entity = ConvertUtils.sourceToTarget(dto, SysDictDataEntity.class); - - insert(entity); - // 删除Redis缓存 - String dictType = baseDao.getTypeByTypeId(dto.getDictTypeId()); - redisUtils.delete(RedisKeys.getDictDataByTypeKey(dictType)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(SysDictDataDTO dto) { - // 相同字典类型的标签不能相同 - checkDictValueUnique(dto.getDictTypeId(), dto.getDictValue(), String.valueOf(dto.getId())); - - SysDictDataEntity entity = ConvertUtils.sourceToTarget(dto, SysDictDataEntity.class); - - updateById(entity); - // 删除Redis缓存 - String dictType = baseDao.getTypeByTypeId(dto.getDictTypeId()); - redisUtils.delete(RedisKeys.getDictDataByTypeKey(dictType)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(Long[] ids) { - for (Long id : ids) { - SysDictDataEntity entity = baseDao.selectById(id); - // 删除Redis缓存 - String dictType = baseDao.getTypeByTypeId(entity.getDictTypeId()); - redisUtils.delete(RedisKeys.getDictDataByTypeKey(dictType)); - // 删除 - deleteById(id); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteByTypeId(Long dictTypeId) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SysDictDataEntity::getDictTypeId, dictTypeId); - baseDao.delete(wrapper); - } - - /** - * 设置用户名 - * - * @param sysDictDataList 字典类型集合 - */ - private void setUserName(List sysDictDataList) { - // 收集所有用户 ID - Set userIds = sysDictDataList.stream().flatMap(vo -> Stream.of(vo.getCreator(), vo.getUpdater())) - .filter(Objects::nonNull).collect(Collectors.toSet()); - - // 设置更新者和创建者名称 - if (!userIds.isEmpty()) { - List sysUserEntities = sysUserDao.selectBatchIds(userIds); - // 把List转成Map,Map - Map userNameMap = sysUserEntities.stream().collect(Collectors.toMap(SysUserEntity::getId, - SysUserEntity::getUsername, (existing, replacement) -> existing)); - - sysDictDataList.forEach(vo -> { - vo.setCreatorName(userNameMap.get(vo.getCreator())); - vo.setUpdaterName(userNameMap.get(vo.getUpdater())); - }); - } - } - - private void checkDictValueUnique(Long dictTypeId, String dictValue, String excludeId) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(SysDictDataEntity::getDictTypeId, dictTypeId).eq(SysDictDataEntity::getDictLabel, dictValue); - if (StringUtils.isNotBlank(excludeId)) { - queryWrapper.ne(SysDictDataEntity::getId, excludeId); - } - boolean exists = baseDao.exists(queryWrapper); - if (exists) { - throw new RenException(ErrorCode.DICT_LABEL_DUPLICATE); - } - } - - @Override - public List getDictDataByType(String dictType) { - if (StringUtils.isBlank(dictType)) { - return null; - } - - // 先从Redis获取缓存 - String key = RedisKeys.getDictDataByTypeKey(dictType); - List cachedData = (List) redisUtils.get(key); - if (cachedData != null) { - return cachedData; - } - - // 如果缓存中没有,则从数据库获取 - List data = baseDao.getDictDataByType(dictType); - - // 存入Redis缓存 - if (data != null) { - redisUtils.set(key, data); - } - - return data; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysDictTypeServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysDictTypeServiceImpl.java deleted file mode 100644 index 8bb393fd4..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysDictTypeServiceImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -package xiaozhi.modules.sys.service.impl; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import lombok.AllArgsConstructor; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.modules.sys.dao.SysDictTypeDao; -import xiaozhi.modules.sys.dao.SysUserDao; -import xiaozhi.modules.sys.dto.SysDictTypeDTO; -import xiaozhi.modules.sys.entity.SysDictTypeEntity; -import xiaozhi.modules.sys.entity.SysUserEntity; -import xiaozhi.modules.sys.service.SysDictDataService; -import xiaozhi.modules.sys.service.SysDictTypeService; -import xiaozhi.modules.sys.vo.SysDictTypeVO; - -/** - * 字典类型 - */ -@Service -@AllArgsConstructor -public class SysDictTypeServiceImpl extends BaseServiceImpl - implements SysDictTypeService { - private final SysUserDao sysUserDao; - private final SysDictDataService sysDictDataService; - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage(getPage(params, "sort", true), getWrapper(params)); - - PageData pageData = getPageData(page, SysDictTypeVO.class); - - setUserName(pageData.getList()); - - return pageData; - } - - private QueryWrapper getWrapper(Map params) { - String dictType = (String) params.get("dictType"); - String dictName = (String) params.get("dictName"); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(dictType), "dict_type", dictType); - wrapper.like(StringUtils.isNotBlank(dictName), "dict_name", dictName); - - return wrapper; - } - - @Override - public SysDictTypeVO get(Long id) { - SysDictTypeEntity entity = baseDao.selectById(id); - if (entity == null) { - throw new RenException(ErrorCode.DICT_TYPE_NOT_EXIST); - } - - return ConvertUtils.sourceToTarget(entity, SysDictTypeVO.class); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(SysDictTypeDTO dto) { - // 字典类型编码不能重复 - checkDictTypeUnique(dto.getDictType(), null); - - SysDictTypeEntity entity = ConvertUtils.sourceToTarget(dto, SysDictTypeEntity.class); - - insert(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(SysDictTypeDTO dto) { - // 字典类型编码不能重复 - checkDictTypeUnique(dto.getDictType(), String.valueOf(dto.getId())); - - SysDictTypeEntity entity = ConvertUtils.sourceToTarget(dto, SysDictTypeEntity.class); - - updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(Long[] ids) { - // 先删除对应的字典数据 - for (Long id : ids) { - sysDictDataService.deleteByTypeId(id); - } - // 再删除字典类型 - deleteBatchIds(Arrays.asList(ids)); - } - - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - List sysDictTypeVOList = ConvertUtils.sourceToTarget(entityList, SysDictTypeVO.class); - // 设置用户名 - setUserName(sysDictTypeVOList); - - return sysDictTypeVOList; - } - - /** - * 设置用户名 - * - * @param sysDictTypeList 字典类型集合 - */ - private void setUserName(List sysDictTypeList) { - // 收集所有用户 ID - Set userIds = sysDictTypeList.stream().flatMap(vo -> Stream.of(vo.getCreator(), vo.getUpdater())) - .filter(Objects::nonNull).collect(Collectors.toSet()); - - // 设置更新者和创建者名称 - if (!userIds.isEmpty()) { - List sysUserEntities = sysUserDao.selectBatchIds(userIds); - // 把List转成Map,Map - Map userNameMap = sysUserEntities.stream().collect(Collectors.toMap(SysUserEntity::getId, - SysUserEntity::getUsername, (existing, replacement) -> existing)); - - sysDictTypeList.forEach(vo -> { - vo.setCreatorName(userNameMap.get(vo.getCreator())); - vo.setUpdaterName(userNameMap.get(vo.getUpdater())); - }); - } - } - - private void checkDictTypeUnique(String dictType, String excludeId) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(SysDictTypeEntity::getDictType, dictType); - if (StringUtils.isNotBlank(excludeId)) { - queryWrapper.ne(SysDictTypeEntity::getId, excludeId); - } - boolean exists = baseDao.exists(queryWrapper); - if (exists) { - throw new RenException(ErrorCode.DICT_TYPE_DUPLICATE); - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysParamsServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysParamsServiceImpl.java deleted file mode 100644 index b22dd2b90..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysParamsServiceImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -package xiaozhi.modules.sys.service.impl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import lombok.AllArgsConstructor; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.common.utils.JsonUtils; -import xiaozhi.common.utils.SM2Utils; -import xiaozhi.modules.sys.dao.SysParamsDao; -import xiaozhi.modules.sys.dto.SysParamsDTO; -import xiaozhi.modules.sys.entity.SysParamsEntity; -import xiaozhi.modules.sys.redis.SysParamsRedis; -import xiaozhi.modules.sys.service.SysParamsService; - -/** - * 参数管理 - */ -@AllArgsConstructor -@Service -public class SysParamsServiceImpl extends BaseServiceImpl implements SysParamsService { - private final SysParamsRedis sysParamsRedis; - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, null, false), - getWrapper(params)); - - return getPageData(page, SysParamsDTO.class); - } - - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - - return ConvertUtils.sourceToTarget(entityList, SysParamsDTO.class); - } - - private QueryWrapper getWrapper(Map params) { - String paramCode = (String) params.get("paramCode"); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("param_type", 1); - wrapper.nested(StringUtils.isNotBlank(paramCode), i -> i.like("param_code", paramCode) - .or() - .like("remark", paramCode)); - - return wrapper; - } - - @Override - public SysParamsDTO get(Long id) { - SysParamsEntity entity = baseDao.selectById(id); - - return ConvertUtils.sourceToTarget(entity, SysParamsDTO.class); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(SysParamsDTO dto) { - validateParamValue(dto); - - SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class); - insert(entity); - - sysParamsRedis.set(entity.getParamCode(), entity.getParamValue()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(SysParamsDTO dto) { - validateParamValue(dto); - detectingSMSParameters(dto.getParamCode(), dto.getParamValue()); - SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class); - updateById(entity); - - sysParamsRedis.set(entity.getParamCode(), entity.getParamValue()); - } - - /** - * 校验参数值类型 - */ - private void validateParamValue(SysParamsDTO dto) { - if (dto == null) { - throw new RenException(ErrorCode.PARAM_VALUE_NULL); - } - - if (StringUtils.isBlank(dto.getParamValue())) { - throw new RenException(ErrorCode.PARAM_VALUE_NULL); - } - - if (StringUtils.isBlank(dto.getValueType())) { - throw new RenException(ErrorCode.PARAM_TYPE_NULL); - } - - String valueType = dto.getValueType().toLowerCase(); - String paramValue = dto.getParamValue(); - - switch (valueType) { - case "string": - break; - case "array": - break; - case "number": - try { - Double.parseDouble(paramValue); - } catch (NumberFormatException e) { - throw new RenException(ErrorCode.PARAM_NUMBER_INVALID); - } - break; - case "boolean": - if (!"true".equalsIgnoreCase(paramValue) && !"false".equalsIgnoreCase(paramValue)) { - throw new RenException(ErrorCode.PARAM_BOOLEAN_INVALID); - } - break; - case "json": - try { - // 首先检查是否以 { 开头,以 } 结尾 - String trimmedValue = paramValue.trim(); - if (!trimmedValue.startsWith("{") || !trimmedValue.endsWith("}")) { - throw new RenException(ErrorCode.PARAM_JSON_INVALID); - } - // 然后尝试解析JSON - JsonUtils.parseObject(paramValue, Object.class); - } catch (Exception e) { - throw new RenException(ErrorCode.PARAM_JSON_INVALID); - } - break; - default: - throw new RenException(ErrorCode.PARAM_TYPE_INVALID); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - // 删除Redis数据 - List paramCodeList = baseDao.getParamCodeList(ids); - String[] paramCodes = paramCodeList.toArray(new String[paramCodeList.size()]); - if (paramCodes.length > 0) { - sysParamsRedis.delete(paramCodes); - } - - // 删除 - deleteBatchIds(Arrays.asList(ids)); - } - - @Override - public String getValue(String paramCode, Boolean fromCache) { - String paramValue = null; - if (fromCache) { - paramValue = sysParamsRedis.get(paramCode); - if (paramValue == null) { - paramValue = baseDao.getValueByCode(paramCode); - - sysParamsRedis.set(paramCode, paramValue); - } - } else { - paramValue = baseDao.getValueByCode(paramCode); - } - return paramValue; - } - - @Override - public T getValueObject(String paramCode, Class clazz) { - String paramValue = getValue(paramCode, true); - if (StringUtils.isNotBlank(paramValue)) { - return JsonUtils.parseObject(paramValue, clazz); - } - - try { - return clazz.getDeclaredConstructor().newInstance(); - } catch (Exception e) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public int updateValueByCode(String paramCode, String paramValue) { - int count = baseDao.updateValueByCode(paramCode, paramValue); - sysParamsRedis.set(paramCode, paramValue); - return count; - } - - @Override - public void initServerSecret() { - // 获取服务器密钥 - String secretParam = getValue(Constant.SERVER_SECRET, false); - if (StringUtils.isBlank(secretParam) || "null".equals(secretParam)) { - String newSecret = UUID.randomUUID().toString(); - updateValueByCode(Constant.SERVER_SECRET, newSecret); - } - - // 初始化SM2密钥对 - initSM2KeyPair(); - } - - /** - * 初始化SM2密钥对 - */ - private void initSM2KeyPair() { - // 获取SM2公钥 - String publicKey = getValue(Constant.SM2_PUBLIC_KEY, false); - // 获取SM2私钥 - String privateKey = getValue(Constant.SM2_PRIVATE_KEY, false); - - // 如果公钥或私钥为空,则生成新的密钥对 - if (StringUtils.isBlank(publicKey) || StringUtils.isBlank(privateKey) || - "null".equals(publicKey) || "null".equals(privateKey)) { - Map keyPair = SM2Utils.createKey(); - String newPublicKey = keyPair.get(SM2Utils.KEY_PUBLIC_KEY); - String newPrivateKey = keyPair.get(SM2Utils.KEY_PRIVATE_KEY); - - // 更新数据库中的密钥对 - updateValueByCode(Constant.SM2_PUBLIC_KEY, newPublicKey); - updateValueByCode(Constant.SM2_PRIVATE_KEY, newPrivateKey); - } - } - - /** - * 检测短信参数是否符合要求 - * - * @param paramCode 参数编码 - * @param paramValue 参数值 - * @return 是否通过 - */ - private boolean detectingSMSParameters(String paramCode, String paramValue) { - // 判断是否是开启手机注册的参数编码,如果不是参数编码,着不需要检测其他短信参数,直接返回true - if (!Constant.SysMSMParam.SERVER_ENABLE_MOBILE_REGISTER.getValue().equals(paramCode)) { - return true; - } - // 判断是否为关闭,如果是关闭短信注册,着不需要检测其他短信参数,直接返回true - if ("false".equalsIgnoreCase(paramValue)) { - return true; - } - // 检测短信关联参数是否为空 - ArrayList list = new ArrayList(); - list.add(Constant.SysMSMParam.SERVER_SMS_MAX_SEND_COUNT.getValue()); - list.add(Constant.SysMSMParam.ALIYUN_SMS_ACCESS_KEY_ID.getValue()); - list.add(Constant.SysMSMParam.ALIYUN_SMS_ACCESS_KEY_SECRET.getValue()); - list.add(Constant.SysMSMParam.ALIYUN_SMS_SIGN_NAME.getValue()); - list.add(Constant.SysMSMParam.ALIYUN_SMS_SMS_CODE_TEMPLATE_CODE.getValue()); - StringBuilder str = new StringBuilder(); - list.forEach(item -> { - if (!StringUtils.isNoneBlank(item)) { - str.append(",").append(item); - } - }); - if (!str.isEmpty()) { - String promptStr = "%s这些参数不可以为空"; - String substring = str.substring(1, str.length()); - throw new RenException(promptStr.formatted(substring)); - } - return true; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysUserServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysUserServiceImpl.java deleted file mode 100644 index 7d4a73b68..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysUserServiceImpl.java +++ /dev/null @@ -1,250 +0,0 @@ -package xiaozhi.modules.sys.service.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import lombok.AllArgsConstructor; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.modules.agent.service.AgentService; -import xiaozhi.modules.device.service.DeviceService; -import xiaozhi.modules.security.password.PasswordUtils; -import xiaozhi.modules.sys.dao.SysUserDao; -import xiaozhi.modules.sys.dto.AdminPageUserDTO; -import xiaozhi.modules.sys.dto.PasswordDTO; -import xiaozhi.modules.sys.dto.SysUserDTO; -import xiaozhi.modules.sys.entity.SysUserEntity; -import xiaozhi.modules.sys.enums.SuperAdminEnum; -import xiaozhi.modules.sys.service.SysParamsService; -import xiaozhi.modules.sys.service.SysUserService; -import xiaozhi.modules.sys.vo.AdminPageUserVO; - -/** - * 系统用户 - */ -@AllArgsConstructor -@Service -public class SysUserServiceImpl extends BaseServiceImpl implements SysUserService { - private final SysUserDao sysUserDao; - - private final DeviceService deviceService; - - private final AgentService agentService; - - private final SysParamsService sysParamsService; - - @Override - public SysUserDTO getByUsername(String username) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("username", username); - List users = sysUserDao.selectList(queryWrapper); - if (users == null || users.isEmpty()) { - return null; - } - SysUserEntity entity = users.getFirst(); - return ConvertUtils.sourceToTarget(entity, SysUserDTO.class); - } - - @Override - public SysUserDTO getByUserId(Long userId) { - SysUserEntity sysUserEntity = sysUserDao.selectById(userId); - - return ConvertUtils.sourceToTarget(sysUserEntity, SysUserDTO.class); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(SysUserDTO dto) { - SysUserEntity entity = ConvertUtils.sourceToTarget(dto, SysUserEntity.class); - - // 密码强度 - if (!isStrongPassword(entity.getPassword())) { - throw new RenException(ErrorCode.PASSWORD_WEAK_ERROR); - } - - // 密码加密 - String password = PasswordUtils.encode(entity.getPassword()); - entity.setPassword(password); - - // 保存用户 - Long userCount = getUserCount(); - if (userCount == 0) { - entity.setSuperAdmin(SuperAdminEnum.YES.value()); - } else { - entity.setSuperAdmin(SuperAdminEnum.NO.value()); - } - entity.setStatus(1); - - insert(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteById(Long id) { - // 删除用户 - baseDao.deleteById(id); - // 删除设备 - deviceService.deleteByUserId(id); - // 删除智能体 - agentService.deleteAgentByUserId(id); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void changePassword(Long userId, PasswordDTO passwordDTO) { - SysUserEntity sysUserEntity = sysUserDao.selectById(userId); - - if (null == sysUserEntity) { - throw new RenException(ErrorCode.TOKEN_INVALID); - } - - // 判断旧密码是否正确 - if (!PasswordUtils.matches(passwordDTO.getPassword(), sysUserEntity.getPassword())) { - throw new RenException(ErrorCode.OLD_PASSWORD_ERROR); - } - - // 新密码强度 - if (!isStrongPassword(passwordDTO.getNewPassword())) { - throw new RenException(ErrorCode.PASSWORD_WEAK_ERROR); - } - - // 密码加密 - String password = PasswordUtils.encode(passwordDTO.getNewPassword()); - sysUserEntity.setPassword(password); - - updateById(sysUserEntity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void changePasswordDirectly(Long userId, String password) { - // 新密码强度 - if (!isStrongPassword(password)) { - throw new RenException(ErrorCode.PASSWORD_WEAK_ERROR); - } - SysUserEntity sysUserEntity = new SysUserEntity(); - sysUserEntity.setId(userId); - sysUserEntity.setPassword(PasswordUtils.encode(password)); - updateById(sysUserEntity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public String resetPassword(Long userId) { - String password = generatePassword(); - changePasswordDirectly(userId, password); - return password; - } - - private Long getUserCount() { - QueryWrapper queryWrapper = new QueryWrapper<>(); - return baseDao.selectCount(queryWrapper); - } - - @Override - public PageData page(AdminPageUserDTO dto) { - Map params = new HashMap(); - params.put(Constant.PAGE, dto.getPage()); - params.put(Constant.LIMIT, dto.getLimit()); - IPage page = baseDao.selectPage( - getPage(params, "id", true), - new QueryWrapper().like(StringUtils.isNotBlank(dto.getMobile()), "username", - dto.getMobile())); - // 循环处理page获取回来的数据,返回需要的字段 - List list = page.getRecords().stream().map(user -> { - AdminPageUserVO adminPageUserVO = new AdminPageUserVO(); - adminPageUserVO.setUserid(user.getId().toString()); - adminPageUserVO.setMobile(user.getUsername()); - String deviceCount = deviceService.selectCountByUserId(user.getId()).toString(); - adminPageUserVO.setDeviceCount(deviceCount); - adminPageUserVO.setStatus(user.getStatus()); - adminPageUserVO.setCreateDate(user.getCreateDate()); - return adminPageUserVO; - }).toList(); - return new PageData<>(list, page.getTotal()); - } - - 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(); - } - - private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()"; - private static final Random random = new Random(); - - /** - * 生成随机密码 - * - * @return 随机生成的密码 - */ - private String generatePassword() { - StringBuilder password = new StringBuilder(); - - // 确保包含至少一个数字 - password.append("0123456789".charAt(random.nextInt(10))); - // 确保包含至少一个小写字母 - password.append("abcdefghijklmnopqrstuvwxyz".charAt(random.nextInt(26))); - // 确保包含至少一个大写字母 - password.append("ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(random.nextInt(26))); - // 确保包含至少一个特殊符号 - password.append("!@#$%^&*()".charAt(random.nextInt(10))); - - // 生成剩余的8个字符 - for (int i = 4; i < 12; i++) { - password.append(CHARACTERS.charAt(random.nextInt(CHARACTERS.length()))); - } - - // 打乱密码中字符的顺序 - char[] passwordChars = password.toString().toCharArray(); - for (int i = 0; i < passwordChars.length; i++) { - int randomIndex = random.nextInt(passwordChars.length); - char temp = passwordChars[i]; - passwordChars[i] = passwordChars[randomIndex]; - passwordChars[randomIndex] = temp; - } - - return new String(passwordChars); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void changeStatus(Integer status, String[] userIds) { - for (String userId : userIds) { - SysUserEntity entity = new SysUserEntity(); - entity.setId(Long.parseLong(userId)); - entity.setStatus(status); - updateById(entity); - } - } - - @Override - public boolean getAllowUserRegister() { - String allowUserRegister = sysParamsService.getValue(Constant.SERVER_ALLOW_USER_REGISTER, true); - if (allowUserRegister.equals("true")) { - return true; - } - Long userCount = baseDao.selectCount(new QueryWrapper()); - if (userCount == 0) { - return true; - } - return false; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysUserUtilServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysUserUtilServiceImpl.java deleted file mode 100644 index f4fe601a2..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/SysUserUtilServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package xiaozhi.modules.sys.service.impl; - -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; -import xiaozhi.common.redis.RedisKeys; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.modules.sys.dao.SysUserDao; -import xiaozhi.modules.sys.entity.SysUserEntity; -import xiaozhi.modules.sys.service.SysUserUtilService; - -import java.util.function.Consumer; - -@Service -@AllArgsConstructor -public class SysUserUtilServiceImpl extends BaseServiceImpl implements SysUserUtilService { - - private RedisUtils redisUtils; - - @Override - public void assignUsername(Long userId, Consumer setter) { - String userIdKey = RedisKeys.getUserIdKey(userId); - - Object value = redisUtils.get(userIdKey); - String username = (value != null) ? value.toString() : null; - if(username != null){ - setter.accept(username); - }else { - SysUserEntity entity = baseDao.selectById(userId); - if (entity != null) { - username = entity.getUsername(); - redisUtils.set(userIdKey,username,10); - setter.accept(username); - } - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/TokenServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/TokenServiceImpl.java deleted file mode 100644 index 3a15639a6..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/service/impl/TokenServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package xiaozhi.modules.sys.service.impl; - -import org.springframework.stereotype.Service; - -import lombok.AllArgsConstructor; -import xiaozhi.modules.security.oauth2.TokenGenerator; -import xiaozhi.modules.sys.service.TokenService; - -@AllArgsConstructor -@Service -public class TokenServiceImpl implements TokenService { - - @Override - public String createToken(long userId) { - // 生成一个token - String token = TokenGenerator.generateValue(); - return token; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketClientManager.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketClientManager.java deleted file mode 100644 index d4203c75b..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketClientManager.java +++ /dev/null @@ -1,372 +0,0 @@ -package xiaozhi.modules.sys.utils; - -import java.io.Closeable; -import java.io.IOException; -import java.net.URI; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; -import java.util.function.Predicate; - -import org.springframework.util.StopWatch; -import org.springframework.web.socket.BinaryMessage; -import org.springframework.web.socket.CloseStatus; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketHttpHeaders; -import org.springframework.web.socket.WebSocketSession; -import org.springframework.web.socket.client.standard.StandardWebSocketClient; -import org.springframework.web.socket.handler.AbstractWebSocketHandler; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.utils.DateUtils; - -/** - * WebSocketClientResource:支持 try-with-resources 模式 - */ -@Slf4j -public class WebSocketClientManager implements Closeable { - private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - - // 全局回调线程池 - private static final ExecutorService CALLBACK_EXECUTOR = Executors - .newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory() { - private final AtomicInteger cnt = new AtomicInteger(); - - public Thread newThread(Runnable r) { - Thread t = new Thread(r, "ws-callback-" + cnt.getAndIncrement()); - t.setDaemon(true); - return t; - } - }); - - private volatile WebSocketSession session; - private final BlockingQueue textMessageQueue; - private final BlockingQueue binaryMessageQueue; - private final CompletableFuture errorFuture; - private final long maxSessionDuration; - private final TimeUnit maxSessionDurationUnit; - - private volatile Consumer onText; - private volatile Consumer onBinary; - private volatile Consumer onError; - - private final int queueCapacity; - - // 私有构造,仅由 Builder 调用 - private WebSocketClientManager(Builder b) { - this.maxSessionDuration = b.maxSessionDuration; - this.maxSessionDurationUnit = b.maxSessionDurationUnit; - this.queueCapacity = b.queueCapacity; - this.textMessageQueue = new LinkedBlockingQueue<>(queueCapacity); - this.binaryMessageQueue = new LinkedBlockingQueue<>(queueCapacity); - this.errorFuture = new CompletableFuture<>(); - } - - public static WebSocketClientManager build(Builder b) - throws InterruptedException, ExecutionException, TimeoutException, IOException { - WebSocketClientManager ws = new WebSocketClientManager(b); - StandardWebSocketClient client = new StandardWebSocketClient(); - CompletableFuture future = client.execute(ws.new InternalHandler(b.uri), b.headers, - URI.create(b.uri)); - WebSocketSession sess = future.get(b.connectTimeout, b.connectUnit); - if (sess == null || !sess.isOpen()) { - throw new IOException("握手失败或会话未打开"); - } - // 设置缓冲区 - sess.setTextMessageSizeLimit(b.bufferSize); - sess.setBinaryMessageSizeLimit(b.bufferSize); - ws.session = sess; - return ws; - } - - - /** - * 发送 Text - */ - public void sendText(String text) throws IOException { - session.sendMessage(new TextMessage(text)); - } - - public void sendBinary(byte[] data) throws IOException { - session.sendMessage(new BinaryMessage(data)); - } - - public void sendJson(Object payload) throws IOException { - String json = OBJECT_MAPPER.writeValueAsString(payload); - session.sendMessage(new TextMessage(json)); - } - - private List listenerCustom( - BlockingQueue queue, - Predicate predicate) - throws InterruptedException, TimeoutException, ExecutionException { - List collected = new ArrayList<>(); - long deadline = System.currentTimeMillis() + maxSessionDurationUnit.toMillis(maxSessionDuration); - - while (true) { - if (errorFuture.isDone()) { - errorFuture.get(); - } - - long remaining = deadline - System.currentTimeMillis(); - if (remaining <= 0) { - throw new TimeoutException("等待批量消息超时"); - } - - T msg = queue.poll(remaining, TimeUnit.MILLISECONDS); - if (msg == null) { - throw new TimeoutException("等待批量消息超时"); - } - - collected.add(msg); - if (predicate.test(msg)) { - break; - } - } - close(); - return collected; - } - - private List listenerCustomWithoutClose( - BlockingQueue queue, - Predicate predicate) - throws InterruptedException, TimeoutException, ExecutionException { - List collected = new ArrayList<>(); - long deadline = System.currentTimeMillis() + maxSessionDurationUnit.toMillis(maxSessionDuration); - - while (true) { - if (errorFuture.isDone()) { - errorFuture.get(); - } - - long remaining = deadline - System.currentTimeMillis(); - if (remaining <= 0) { - throw new TimeoutException("等待批量消息超时"); - } - - T msg = queue.poll(remaining, TimeUnit.MILLISECONDS); - if (msg == null) { - throw new TimeoutException("等待批量消息超时"); - } - - collected.add(msg); - if (predicate.test(msg)) { - break; - } - } - // 不调用 close(),保持连接开放 - return collected; - } - - /** - * 同步接收多条消息,直到 predicate 为 true 或超时抛异常; - * - * @return 返回监听期间的所有消息列表 - */ - public List listener(Predicate predicate) - throws InterruptedException, TimeoutException, ExecutionException { - return listenerCustom(textMessageQueue, predicate); - } - - /** - * 同步接收多条消息,直到 predicate 为 true 或超时抛异常; - * 不自动关闭连接,适用于需要在同一连接上发送多个消息的场景 - * - * @return 返回监听期间的所有消息列表 - */ - public List listenerWithoutClose(Predicate predicate) - throws InterruptedException, TimeoutException, ExecutionException { - return listenerCustomWithoutClose(textMessageQueue, predicate); - } - - public List listenerBinary(Predicate predicate) - throws InterruptedException, TimeoutException, ExecutionException { - return listenerCustom(binaryMessageQueue, predicate); - } - - /** - * 注册文本回调 - */ - public WebSocketClientManager onText(Consumer c) { - this.onText = c; - return this; - } - - /** - * 注册二进制回调 - */ - public WebSocketClientManager onBinary(Consumer c) { - this.onBinary = c; - return this; - } - - /** - * 注册错误回调 - */ - public WebSocketClientManager onError(Consumer c) { - this.onError = c; - return this; - } - - /** - * 关闭会话,try-with-resources / finally 自动调用 - */ - @Override - public void close() { - try { - if (session != null && session.isOpen()) { - session.close(CloseStatus.NORMAL); - } - } catch (IOException ignored) { - } - textMessageQueue.clear(); - binaryMessageQueue.clear(); - errorFuture.completeExceptionally(new IOException("WebSocket 已关闭")); - } - - private class InternalHandler extends AbstractWebSocketHandler { - private final String targetUri; - private final StopWatch stopWatch; - - InternalHandler(String targetUri) { - this.targetUri = targetUri; - this.stopWatch = new StopWatch(); - } - - /** - * 连接建立时回调 - */ - @Override - public void afterConnectionEstablished(WebSocketSession session) { - // 保存会话 - WebSocketClientManager.this.session = session; - this.stopWatch.start(); - log.info("ws连接成功, 目标URI: {}, 连接时间: {}", targetUri, - DateUtils.getDateTimeNow(DateUtils.DATE_TIME_MILLIS_PATTERN)); - } - - /** - * 处理文本消息 - */ - @Override - protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { - String payload = message.getPayload(); - // 入队 - textMessageQueue.offer(payload); - // 回调用户注册的 onText - if (onText != null) { - CALLBACK_EXECUTOR.submit(() -> onText.accept(payload)); - } - } - - /** - * 处理二进制消息 - */ - @Override - protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception { - ByteBuffer buf = message.getPayload(); - byte[] data = new byte[buf.remaining()]; - buf.get(data); - // 入队 - binaryMessageQueue.offer(data); - // 回调用户注册的 onBinary - if (onBinary != null) { - CALLBACK_EXECUTOR.submit(() -> onBinary.accept(data)); - } - } - - /** - * 传输错误时回调 - */ - @Override - public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { - super.handleTransportError(session, exception); - // 保持原有逻辑:完成 errorFuture、回调 onError、关闭会话、异步通知连接失败 - errorFuture.completeExceptionally(exception); - if (onError != null) { - CALLBACK_EXECUTOR.submit(() -> onError.accept(exception)); - } - session.close(CloseStatus.SERVER_ERROR); - } - - /** - * 连接关闭时回调 - */ - @Override - public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { - super.afterConnectionClosed(session, status); - if (stopWatch.isRunning()) { - stopWatch.stop(); - } - log.info("ws连接关闭, 目标URI: {}, 关闭时间: {}, 连接总时长: {}s,断开原因:{}", - targetUri, DateUtils.getDateTimeNow(DateUtils.DATE_TIME_MILLIS_PATTERN), - DateUtils.millsToSecond(stopWatch.getTotalTimeMillis()),status); - } - - } - - public static class Builder { - private String uri; // 目标 WS URI - private long connectTimeout = 3; // 请求连接等待时间 - private TimeUnit connectUnit = TimeUnit.SECONDS; // 请求连接等待时间单位 - private long maxSessionDuration = 5; // 最大连线时间,默认5秒 - private TimeUnit maxSessionDurationUnit = TimeUnit.SECONDS; // 最大连线时间单位 - private int queueCapacity = 100; // 消息队列容量 - private int bufferSize = 8 * 1024; //默认 8kb - private WebSocketHttpHeaders headers; // 请求头 - - /** - * 目标 WS URI - */ - public Builder uri(String uri) { - this.uri = Objects.requireNonNull(uri); - return this; - } - - public Builder headers(WebSocketHttpHeaders h) { - this.headers = h; - return this; - } - - public Builder connectTimeout(long t, TimeUnit u) { - this.connectTimeout = t; - this.connectUnit = u; - return this; - } - - public Builder maxSessionDuration(long t, TimeUnit u) { - this.maxSessionDuration = t; - this.maxSessionDurationUnit = u; - return this; - } - - public Builder queueCapacity(int c) { - this.queueCapacity = c; - return this; - } - public Builder bufferSize(int c) { - this.bufferSize = c; - return this; - } - - public WebSocketClientManager build() - throws InterruptedException, ExecutionException, TimeoutException, IOException { - return WebSocketClientManager.build(this); - } - - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketTestHandler.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketTestHandler.java deleted file mode 100644 index d9563c297..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketTestHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package xiaozhi.modules.sys.utils; - -import java.util.concurrent.CompletableFuture; - -import org.springframework.web.socket.CloseStatus; -import org.springframework.web.socket.WebSocketHandler; -import org.springframework.web.socket.WebSocketMessage; -import org.springframework.web.socket.WebSocketSession; - -public class WebSocketTestHandler implements WebSocketHandler { - private final CompletableFuture future; - - public WebSocketTestHandler(CompletableFuture future) { - this.future = future; - } - - @Override - public void afterConnectionEstablished(WebSocketSession session) { - future.complete(true); - try { - session.close(); - } catch (Exception e) { - // 忽略关闭异常 - } - } - - @Override - public void handleMessage(WebSocketSession session, WebSocketMessage message) { - // 不需要处理消息 - } - - @Override - public void handleTransportError(WebSocketSession session, Throwable exception) { - future.complete(false); - } - - @Override - public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) { - // 连接关闭时不做任何处理 - } - - @Override - public boolean supportsPartialMessages() { - return false; - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketValidator.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketValidator.java deleted file mode 100644 index 39bbe01f5..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/utils/WebSocketValidator.java +++ /dev/null @@ -1,60 +0,0 @@ -package xiaozhi.modules.sys.utils; - -import java.net.URI; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; -import java.util.regex.Pattern; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.socket.WebSocketHttpHeaders; -import org.springframework.web.socket.client.WebSocketClient; -import org.springframework.web.socket.client.standard.StandardWebSocketClient; - -public class WebSocketValidator { - private static final Logger logger = LoggerFactory.getLogger(WebSocketValidator.class); - - // WebSocket URL正则表达式 - private static final Pattern WS_URL_PATTERN = Pattern - .compile("^wss?://[\\w.-]+(?:\\.[\\w.-]+)*(?::\\d+)?(?:/[\\w.-]*)*$"); - - /** - * 验证WebSocket地址格式 - * - * @param url WebSocket地址 - * @return 是否有效 - */ - public static boolean validateUrlFormat(String url) { - if (StringUtils.isBlank(url)) { - return false; - } - return WS_URL_PATTERN.matcher(url.trim()).matches(); - } - - /** - * 测试WebSocket连接 - * - * @param url WebSocket地址 - * @return 是否可连接 - */ - public static boolean testConnection(String url) { - if (!validateUrlFormat(url)) { - return false; - } - - try { - WebSocketClient client = new StandardWebSocketClient(); - CompletableFuture future = new CompletableFuture<>(); - WebSocketHttpHeaders headers = new WebSocketHttpHeaders(); - - client.execute(new WebSocketTestHandler(future), headers, URI.create(url)); - - // 等待最多5秒获取连接结果 - return future.get(5, TimeUnit.SECONDS); - } catch (Exception e) { - logger.error("WebSocket连接测试失败: {}", url, e); - return false; - } - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/AdminPageUserVO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/AdminPageUserVO.java deleted file mode 100644 index 9f832372a..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/AdminPageUserVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package xiaozhi.modules.sys.vo; - -import java.util.Date; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 管理员分页展示用户的VO - * @ zjy - * - * @since 2025-3-25 - */ -@Data -public class AdminPageUserVO { - - @Schema(description = "设备数量") - private String deviceCount; - - @Schema(description = "手机号码") - private String mobile; - - @Schema(description = "状态") - private Integer status; - - @Schema(description = "用户id") - private String userid; - - @Schema(description = "注册时间") - private Date createDate; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictDataItem.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictDataItem.java deleted file mode 100644 index f6c81500e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictDataItem.java +++ /dev/null @@ -1,20 +0,0 @@ -package xiaozhi.modules.sys.vo; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 字典数据VO - */ -@Data -@Schema(description = "字典数据项") -public class SysDictDataItem implements Serializable { - - @Schema(description = "字典标签") - private String name; - - @Schema(description = "字典值") - private String key; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictDataVO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictDataVO.java deleted file mode 100644 index 40025b704..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictDataVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package xiaozhi.modules.sys.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * 字典数据VO - */ -@Data -@Schema(description = "字典数据VO") -public class SysDictDataVO implements Serializable { - @Schema(description = "主键") - private Long id; - - @Schema(description = "字典类型ID") - private Long dictTypeId; - - @Schema(description = "字典标签") - private String dictLabel; - - @Schema(description = "字典值") - private String dictValue; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "排序") - private Integer sort; - - @Schema(description = "创建者") - private Long creator; - - @Schema(description = "创建者名称") - private String creatorName; - - @Schema(description = "创建时间") - private Date createDate; - - @Schema(description = "更新者") - private Long updater; - - @Schema(description = "更新者名称") - private String updaterName; - - @Schema(description = "更新时间") - private Date updateDate; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictTypeVO.java b/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictTypeVO.java deleted file mode 100644 index 5e5844f3c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/sys/vo/SysDictTypeVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package xiaozhi.modules.sys.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * 字典类型VO - */ -@Data -@Schema(description = "字典类型VO") -public class SysDictTypeVO implements Serializable { - @Schema(description = "主键") - private Long id; - - @Schema(description = "字典类型") - private String dictType; - - @Schema(description = "字典名称") - private String dictName; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "排序") - private Integer sort; - - @Schema(description = "创建者") - private Long creator; - - @Schema(description = "创建者名称") - private String creatorName; - - @Schema(description = "创建时间") - private Date createDate; - - @Schema(description = "更新者") - private Long updater; - - @Schema(description = "更新者名称") - private String updaterName; - - @Schema(description = "更新时间") - private Date updateDate; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/controller/TimbreController.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/controller/TimbreController.java deleted file mode 100644 index ff420c02d..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/controller/TimbreController.java +++ /dev/null @@ -1,92 +0,0 @@ -package xiaozhi.modules.timbre.controller; - -import java.util.Map; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -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 xiaozhi.common.constant.Constant; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.timbre.dto.TimbreDataDTO; -import xiaozhi.modules.timbre.dto.TimbrePageDTO; -import xiaozhi.modules.timbre.service.TimbreService; -import xiaozhi.modules.timbre.vo.TimbreDetailsVO; - -/** - * 音色控制层 - * - * @author zjy - * @since 2025-3-21 - */ -@AllArgsConstructor -@RestController -@RequestMapping("/ttsVoice") -@Tag(name = "音色管理") -public class TimbreController { - private final TimbreService timbreService; - - @GetMapping - @Operation(summary = "分页查找") - @RequiresPermissions("sys:role:superAdmin") - @Parameters({ - @Parameter(name = "ttsModelId", description = "对应 TTS 模型主键", required = true), - @Parameter(name = "name", description = "音色名称"), - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), - }) - public Result> page( - @Parameter(hidden = true) @RequestParam Map params) { - TimbrePageDTO dto = new TimbrePageDTO(); - dto.setTtsModelId((String) params.get("ttsModelId")); - dto.setName((String) params.get("name")); - dto.setLimit((String) params.get(Constant.LIMIT)); - dto.setPage((String) params.get(Constant.PAGE)); - - ValidatorUtils.validateEntity(dto); - PageData page = timbreService.page(dto); - return new Result>().ok(page); - } - - @PostMapping - @Operation(summary = "音色保存") - @RequiresPermissions("sys:role:superAdmin") - public Result save(@RequestBody TimbreDataDTO dto) { - ValidatorUtils.validateEntity(dto); - timbreService.save(dto); - return new Result<>(); - } - - @PutMapping("/{id}") - @Operation(summary = "音色修改") - @RequiresPermissions("sys:role:superAdmin") - public Result update( - @PathVariable String id, - @RequestBody TimbreDataDTO dto) { - ValidatorUtils.validateEntity(dto); - timbreService.update(id, dto); - return new Result<>(); - } - - @PostMapping("/delete") - @Operation(summary = "音色删除") - @RequiresPermissions("sys:role:superAdmin") - public Result delete(@RequestBody String[] ids) { - timbreService.delete(ids); - return new Result<>(); - } - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/dao/TimbreDao.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/dao/TimbreDao.java deleted file mode 100644 index 3656b4ea6..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/dao/TimbreDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package xiaozhi.modules.timbre.dao; - -import org.apache.ibatis.annotations.Mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import xiaozhi.modules.timbre.entity.TimbreEntity; - -/** - * 音色持久层定义 - * - * @author zjy - * @since 2025-3-21 - */ -@Mapper -public interface TimbreDao extends BaseMapper { -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/dto/TimbreDataDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/dto/TimbreDataDTO.java deleted file mode 100644 index 202c4eafb..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/dto/TimbreDataDTO.java +++ /dev/null @@ -1,49 +0,0 @@ -package xiaozhi.modules.timbre.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -/** - * 音色表数据DTO - * - * @author zjy - * @since 2025-3-21 - */ -@Data -@Schema(description = "音色表信息") -public class TimbreDataDTO { - - @Schema(description = "语言") - @NotBlank(message = "{timbre.languages.require}") - private String languages; - - @Schema(description = "音色名称") - @NotBlank(message = "{timbre.name.require}") - private String name; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "参考音频路径") - private String referenceAudio; - - @Schema(description = "參考文本") - private String referenceText; - - @Schema(description = "排序") - @Min(value = 0, message = "{sort.number}") - private long sort; - - @Schema(description = "对应 TTS 模型主键") - @NotBlank(message = "{timbre.ttsModelId.require}") - private String ttsModelId; - - @Schema(description = "音色编码") - @NotBlank(message = "{timbre.ttsVoice.require}") - private String ttsVoice; - - @Schema(description = "音频播放地址") - private String voiceDemo; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/dto/TimbrePageDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/dto/TimbrePageDTO.java deleted file mode 100644 index 9c2aaf247..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/dto/TimbrePageDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -package xiaozhi.modules.timbre.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -/** - * 音色分页参数DTO - * - * @author zjy - * @since 2025-3-21 - */ -@Data -@Schema(description = "音色分页参数") -public class TimbrePageDTO { - - @Schema(description = "对应 TTS 模型主键") - @NotBlank(message = "{timbre.ttsModelId.require}") - private String ttsModelId; - - @Schema(description = "音色名称") - private String name; - - @Schema(description = "页数") - private String page; - - @Schema(description = "显示列数") - private String limit; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/entity/TimbreEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/entity/TimbreEntity.java deleted file mode 100644 index 508c3f32e..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/entity/TimbreEntity.java +++ /dev/null @@ -1,71 +0,0 @@ -package xiaozhi.modules.timbre.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 音色表实体类 - * - * @author zjy - * @since 2025-3-21 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("ai_tts_voice") -@Schema(description = "音色信息") -public class TimbreEntity { - - @Schema(description = "id") - private String id; - - @Schema(description = "语言") - private String languages; - - @Schema(description = "音色名称") - private String name; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "参考音频路径") - private String referenceAudio; - - @Schema(description = "參考文本") - private String referenceText; - - @Schema(description = "排序") - private long sort; - - @Schema(description = "对应 TTS 模型主键") - private String ttsModelId; - - @Schema(description = "音色编码") - private String ttsVoice; - - @Schema(description = "音频播放地址") - private String voiceDemo; - - @Schema(description = "更新者") - @TableField(fill = FieldFill.UPDATE) - private Long updater; - - @Schema(description = "更新时间") - @TableField(fill = FieldFill.UPDATE) - private Date updateDate; - - @Schema(description = "创建者") - @TableField(fill = FieldFill.INSERT) - private Long creator; - - @Schema(description = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createDate; - -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/TimbreService.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/TimbreService.java deleted file mode 100644 index d8025b3c2..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/TimbreService.java +++ /dev/null @@ -1,76 +0,0 @@ -package xiaozhi.modules.timbre.service; - -import java.util.List; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.model.dto.VoiceDTO; -import xiaozhi.modules.timbre.dto.TimbreDataDTO; -import xiaozhi.modules.timbre.dto.TimbrePageDTO; -import xiaozhi.modules.timbre.entity.TimbreEntity; -import xiaozhi.modules.timbre.vo.TimbreDetailsVO; - -/** - * 音色的业务层的定义 - * - * @author zjy - * @since 2025-3-21 - */ -public interface TimbreService extends BaseService { - /** - * 分页获取音色指定tts的下的音色 - * - * @param dto 分页查找参数 - * @return 音色列表分页数据 - */ - PageData page(TimbrePageDTO dto); - - /** - * 获取音色指定id的详情信息 - * - * @param timbreId 音色表id - * @return 音色信息 - */ - TimbreDetailsVO get(String timbreId); - - /** - * 保存音色信息 - * - * @param dto 需要保存数据 - */ - void save(TimbreDataDTO dto); - - /** - * 保存音色信息 - * - * @param timbreId 需要修改的id - * @param dto 需要修改的数据 - */ - void update(String timbreId, TimbreDataDTO dto); - - /** - * 批量删除音色 - * - * @param ids 需要被删除的音色id列表 - */ - void delete(String[] ids); - - List getVoiceNames(String ttsModelId, String voiceName); - - /** - * 根据ID获取音色名称 - * - * @param id 音色ID - * @return 音色名称 - */ - String getTimbreNameById(String id); - - /** - * 根据音色编码获取音色信息 - * - * @param ttsModelId 音色模型ID - * @param voiceCode 音色编码 - * @return 音色信息 - */ - VoiceDTO getByVoiceCode(String ttsModelId, String voiceCode); -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java deleted file mode 100644 index 8ebb21552..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java +++ /dev/null @@ -1,210 +0,0 @@ -package xiaozhi.modules.timbre.service.impl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; - -import cn.hutool.core.collection.CollectionUtil; -import lombok.AllArgsConstructor; -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.service.impl.BaseServiceImpl; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.common.utils.MessageUtils; -import xiaozhi.modules.model.dto.VoiceDTO; -import xiaozhi.modules.security.user.SecurityUser; -import xiaozhi.modules.timbre.dao.TimbreDao; -import xiaozhi.modules.timbre.dto.TimbreDataDTO; -import xiaozhi.modules.timbre.dto.TimbrePageDTO; -import xiaozhi.modules.timbre.entity.TimbreEntity; -import xiaozhi.modules.timbre.service.TimbreService; -import xiaozhi.modules.timbre.vo.TimbreDetailsVO; -import xiaozhi.modules.voiceclone.dao.VoiceCloneDao; -import xiaozhi.modules.voiceclone.entity.VoiceCloneEntity; - -/** - * 音色的业务层的实现 - * - * @author zjy - * @since 2025-3-21 - */ -@AllArgsConstructor -@Service -public class TimbreServiceImpl extends BaseServiceImpl implements TimbreService { - - private final TimbreDao timbreDao; - private final VoiceCloneDao voiceCloneDao; - private final RedisUtils redisUtils; - - @Override - public PageData page(TimbrePageDTO dto) { - Map params = new HashMap(); - params.put(Constant.PAGE, dto.getPage()); - params.put(Constant.LIMIT, dto.getLimit()); - IPage page = baseDao.selectPage( - getPage(params, null, true), - // 定义查询条件 - new QueryWrapper() - // 必须按照ttsID查找 - .eq("tts_model_id", dto.getTtsModelId()) - // 如果有音色名字,按照音色名模糊查找 - .like(StringUtils.isNotBlank(dto.getName()), "name", dto.getName())); - - return getPageData(page, TimbreDetailsVO.class); - } - - @Override - public TimbreDetailsVO get(String timbreId) { - if (StringUtils.isBlank(timbreId)) { - return null; - } - - // 先从Redis获取缓存 - String key = RedisKeys.getTimbreDetailsKey(timbreId); - TimbreDetailsVO cachedDetails = (TimbreDetailsVO) redisUtils.get(key); - if (cachedDetails != null) { - return cachedDetails; - } - - // 如果缓存中没有,则从数据库获取 - TimbreEntity entity = baseDao.selectById(timbreId); - if (entity == null) { - return null; - } - - // 转换为VO对象 - TimbreDetailsVO details = ConvertUtils.sourceToTarget(entity, TimbreDetailsVO.class); - - // 存入Redis缓存 - if (details != null) { - redisUtils.set(key, details); - } - - return details; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(TimbreDataDTO dto) { - isTtsModelId(dto.getTtsModelId()); - TimbreEntity timbreEntity = ConvertUtils.sourceToTarget(dto, TimbreEntity.class); - baseDao.insert(timbreEntity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(String timbreId, TimbreDataDTO dto) { - isTtsModelId(dto.getTtsModelId()); - TimbreEntity timbreEntity = ConvertUtils.sourceToTarget(dto, TimbreEntity.class); - timbreEntity.setId(timbreId); - baseDao.updateById(timbreEntity); - // 删除缓存 - redisUtils.delete(RedisKeys.getTimbreDetailsKey(timbreId)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - baseDao.deleteBatchIds(Arrays.asList(ids)); - } - - @Override - public List getVoiceNames(String ttsModelId, String voiceName) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("tts_model_id", StringUtils.isBlank(ttsModelId) ? "" : ttsModelId); - if (StringUtils.isNotBlank(voiceName)) { - queryWrapper.like("name", voiceName); - } - List timbreEntities = timbreDao.selectList(queryWrapper); - if (timbreEntities == null) { - timbreEntities = new ArrayList<>(); - } - List voiceDTOs = timbreEntities.stream() - .map(entity -> new VoiceDTO(entity.getId(), entity.getName())) - .collect(Collectors.toList()); - - // 获取当前登录用户ID - Long currentUserId = SecurityUser.getUser().getId(); - if (currentUserId != null) { - // 查询用户的所有克隆音色记录 - List cloneEntities = voiceCloneDao.getTrainSuccess(ttsModelId, currentUserId); - for (VoiceDTO entity : cloneEntities) { - // 只添加训练成功的克隆音色,且模型ID匹配 - VoiceDTO voiceDTO = new VoiceDTO(); - voiceDTO.setId(entity.getId()); - voiceDTO.setName(MessageUtils.getMessage(ErrorCode.VOICE_CLONE_PREFIX) + entity.getName()); - redisUtils.set(RedisKeys.getTimbreNameById(voiceDTO.getId()), voiceDTO.getName(), - RedisUtils.NOT_EXPIRE); - voiceDTOs.add(0, voiceDTO); - } - } - - return CollectionUtil.isEmpty(voiceDTOs) ? null : voiceDTOs; - } - - /** - * 处理是不是tts模型的id - */ - private void isTtsModelId(String ttsModelId) { - // 等模型配置那边写好调用方法判断 - } - - @Override - public String getTimbreNameById(String id) { - if (StringUtils.isBlank(id)) { - return null; - } - - String cachedName = (String) redisUtils.get(RedisKeys.getTimbreNameById(id)); - - if (StringUtils.isNotBlank(cachedName)) { - return cachedName; - } - - TimbreEntity entity = timbreDao.selectById(id); - if (entity != null) { - String name = entity.getName(); - if (StringUtils.isNotBlank(name)) { - redisUtils.set(RedisKeys.getTimbreNameById(id), name); - } - return name; - } else { - VoiceCloneEntity cloneEntity = voiceCloneDao.selectById(id); - if (cloneEntity != null) { - String name = MessageUtils.getMessage(ErrorCode.VOICE_CLONE_PREFIX) + cloneEntity.getName(); - redisUtils.set(RedisKeys.getTimbreNameById(id), name); - return name; - } - } - - return null; - } - - @Override - public VoiceDTO getByVoiceCode(String ttsModelId, String voiceCode) { - if (StringUtils.isBlank(voiceCode)) { - return null; - } - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("tts_model_id", ttsModelId); - queryWrapper.eq("tts_voice", voiceCode); - List list = timbreDao.selectList(queryWrapper); - if (list.isEmpty()) { - return null; - } - return new VoiceDTO(list.get(0).getId(), list.get(0).getName()); - } -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/vo/TimbreDetailsVO.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/vo/TimbreDetailsVO.java deleted file mode 100644 index 2cae1a534..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/vo/TimbreDetailsVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package xiaozhi.modules.timbre.vo; - -import java.io.Serializable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 音色详情展示VO - * - * @author zjy - * @since 2025-3-21 - */ -@Data -public class TimbreDetailsVO implements Serializable { - @Schema(description = "音色id") - private String id; - - @Schema(description = "语言") - private String languages; - - @Schema(description = "音色名称") - private String name; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "参考音频路径") - private String referenceAudio; - - @Schema(description = "參考文本") - private String referenceText; - - @Schema(description = "排序") - private long sort; - - @Schema(description = "对应 TTS 模型主键") - private String ttsModelId; - - @Schema(description = "音色编码") - private String ttsVoice; - - @Schema(description = "音频播放地址") - private String voiceDemo; - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceCloneController.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceCloneController.java deleted file mode 100644 index b7de9332c..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceCloneController.java +++ /dev/null @@ -1,193 +0,0 @@ -package xiaozhi.modules.voiceclone.controller; - -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -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 jakarta.servlet.http.HttpServletResponse; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -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.user.UserDetail; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.security.user.SecurityUser; -import xiaozhi.modules.voiceclone.dto.VoiceCloneResponseDTO; -import xiaozhi.modules.voiceclone.entity.VoiceCloneEntity; -import xiaozhi.modules.voiceclone.service.VoiceCloneService; - -@Tag(name = "音色资源管理", description = "音色资源开通相关接口") -@Slf4j -@RestController -@RequiredArgsConstructor -@RequestMapping("/voiceClone") -public class VoiceCloneController { - - private final VoiceCloneService voiceCloneService; - private final RedisUtils redisUtils; - - @GetMapping - @Operation(summary = "分页查询音色资源") - @Parameters({ - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) - }) - @RequiresPermissions("sys:role:normal") - public Result> page( - @Parameter(hidden = true) @RequestParam Map params) { - ValidatorUtils.validateEntity(params); - UserDetail user = SecurityUser.getUser(); - params.put("userId", user.getId().toString()); - PageData page = voiceCloneService.pageWithNames(params); - return new Result>().ok(page); - } - - @PostMapping("/upload") - @Operation(summary = "上传音频进行声音克隆") - @Parameters({ - @Parameter(name = "id", description = "声音克隆记录ID", required = true), - @Parameter(name = "voiceFile", description = "音频文件", required = true) - }) - @RequiresPermissions("sys:role:normal") - public Result uploadVoice( - @RequestParam("id") String id, - @RequestParam("voiceFile") MultipartFile voiceFile) { - try { - // 验证文件 - if (voiceFile == null || voiceFile.isEmpty()) { - return new Result().error(ErrorCode.VOICE_CLONE_AUDIO_EMPTY); - } - - // 验证文件类型 - String contentType = voiceFile.getContentType(); - if (contentType == null || !contentType.startsWith("audio/")) { - return new Result().error(ErrorCode.VOICE_CLONE_NOT_AUDIO_FILE); - } - - // 验证文件大小 (最大10MB) - if (voiceFile.getSize() > 10 * 1024 * 1024) { - return new Result().error(ErrorCode.VOICE_CLONE_AUDIO_TOO_LARGE); - } - // 检查权限 - checkPermission(id); - // 调用服务层处理 - voiceCloneService.uploadVoice(id, voiceFile); - - return new Result(); - } catch (Exception e) { - return new Result().error(ErrorCode.VOICE_CLONE_UPLOAD_FAILED, e.getMessage()); - } - } - - @PostMapping("/updateName") - @Operation(summary = "更新声音克隆名称") - @RequiresPermissions("sys:role:normal") - public Result updateName(@RequestBody Map params) { - try { - String id = params.get("id"); - String name = params.get("name"); - - if (id == null || id.isEmpty()) { - return new Result().error(ErrorCode.IDENTIFIER_NOT_NULL, "唯一标识不能为空"); - } - if (name == null) { - return new Result().error(ErrorCode.NOT_NULL, "名称不能为空"); - } - // 检查权限 - checkPermission(id); - - voiceCloneService.updateName(id, name); - redisUtils.delete(RedisKeys.getTimbreNameById(id)); - return new Result(); - } catch (Exception e) { - return new Result().error(ErrorCode.UPDATE_DATA_FAILED, "更新失败: " + e.getMessage()); - } - } - - @PostMapping("/audio/{id}") - @Operation(summary = "获取音频下载ID") - @RequiresPermissions("sys:role:normal") - public Result getAudioId(@PathVariable("id") String id) { - // 检查权限 - checkPermission(id); - byte[] audioData = voiceCloneService.getVoiceData(id); - if (audioData == null) { - return new Result().error(ErrorCode.RESOURCE_NOT_FOUND, "音频不存在"); - } - String uuid = UUID.randomUUID().toString(); - redisUtils.set(RedisKeys.getVoiceCloneAudioIdKey(uuid), id); - return new Result().ok(uuid); - } - - @GetMapping("/play/{uuid}") - @Operation(summary = "播放音频") - public void playVoice(@PathVariable("uuid") String uuid, HttpServletResponse response) { - try { - String id = (String) redisUtils.get(RedisKeys.getVoiceCloneAudioIdKey(uuid)); - redisUtils.delete(RedisKeys.getVoiceCloneAudioIdKey(uuid)); - if (StringUtils.isBlank(id)) { - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - return; - } - // 获取音频数据 - byte[] voiceData = voiceCloneService.getVoiceData(id); - - if (voiceData == null || voiceData.length == 0) { - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - return; - } - - // 设置响应头 - response.setContentType("audio/wav"); - response.setContentLength(voiceData.length); - response.setHeader("Content-Disposition", "inline; filename=voice.wav"); - - // 写入音频数据 - response.getOutputStream().write(voiceData); - response.getOutputStream().flush(); - } catch (Exception e) { - log.error("播放音频失败", e); - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } - } - - @PostMapping("/cloneAudio") - @Operation(summary = "复刻音频") - @RequiresPermissions("sys:role:normal") - public Result cloneAudio(@RequestBody Map params) { - String cloneId = params.get("cloneId"); - checkPermission(cloneId); - // 调用服务层进行语音克隆训练 - voiceCloneService.cloneAudio(cloneId); - return new Result(); - } - - private void checkPermission(String id) { - VoiceCloneEntity voiceClone = voiceCloneService.selectById(id); - if (voiceClone == null) { - throw new RenException(ErrorCode.VOICE_CLONE_RECORD_NOT_EXIST); - } - if (!voiceClone.getUserId().equals(SecurityUser.getUser().getId())) { - throw new RenException(ErrorCode.VOICE_RESOURCE_NO_PERMISSION); - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceResourceController.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceResourceController.java deleted file mode 100644 index a4cfa4798..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceResourceController.java +++ /dev/null @@ -1,116 +0,0 @@ -package xiaozhi.modules.voiceclone.controller; - -import java.util.List; -import java.util.Map; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -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.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.page.PageData; -import xiaozhi.common.utils.Result; -import xiaozhi.common.validator.ValidatorUtils; -import xiaozhi.modules.model.service.ModelConfigService; -import xiaozhi.modules.voiceclone.dto.VoiceCloneDTO; -import xiaozhi.modules.voiceclone.dto.VoiceCloneResponseDTO; -import xiaozhi.modules.voiceclone.service.VoiceCloneService; - -@Tag(name = "音色资源管理", description = "音色资源开通相关接口") -@Slf4j -@RestController -@RequiredArgsConstructor -@RequestMapping("/voiceResource") -public class VoiceResourceController { - - private final VoiceCloneService voiceCloneService; - private final ModelConfigService modelConfigService; - - @GetMapping - @Operation(summary = "分页查询音色资源") - @Parameters({ - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) - }) - @RequiresPermissions("sys:role:superAdmin") - public Result> page( - @Parameter(hidden = true) @RequestParam Map params) { - ValidatorUtils.validateEntity(params); - PageData page = voiceCloneService.pageWithNames(params); - return new Result>().ok(page); - } - - @GetMapping("{id}") - @Operation(summary = "获取音色资源详情") - @RequiresPermissions("sys:role:superAdmin") - public Result get(@PathVariable("id") String id) { - VoiceCloneResponseDTO data = voiceCloneService.getByIdWithNames(id); - return new Result().ok(data); - } - - @PostMapping - @Operation(summary = "新增音色资源") - @RequiresPermissions("sys:role:superAdmin") - public Result save(@RequestBody VoiceCloneDTO dto) { - if (dto == null) { - return new Result().error(ErrorCode.VOICE_RESOURCE_INFO_EMPTY); - } - if (dto.getModelId() == null || dto.getModelId().isEmpty()) { - return new Result().error(ErrorCode.VOICE_RESOURCE_PLATFORM_NAME_EMPTY); - } - if (dto.getVoiceIds() == null || dto.getVoiceIds().isEmpty()) { - return new Result().error(ErrorCode.VOICE_RESOURCE_ID_EMPTY); - } - if (dto.getUserId() == null) { - return new Result().error(ErrorCode.VOICE_RESOURCE_ACCOUNT_EMPTY); - } - try { - voiceCloneService.save(dto); - return new Result(); - } catch (xiaozhi.common.exception.RenException e) { - return new Result().error(e.getCode(), e.getMsg()); - } catch (RuntimeException e) { - return new Result().error(ErrorCode.ADD_DATA_FAILED, e.getMessage()); - } - } - - @DeleteMapping("/{id}") - @Operation(summary = "删除音色资源") - @RequiresPermissions("sys:role:superAdmin") - public Result delete(@PathVariable("id") String[] ids) { - if (ids == null || ids.length == 0) { - return new Result().error(ErrorCode.VOICE_RESOURCE_DELETE_ID_EMPTY); - } - voiceCloneService.delete(ids); - return new Result(); - } - - @GetMapping("/user/{userId}") - @Operation(summary = "根据用户ID获取音色资源列表") - @RequiresPermissions("sys:role:normal") - public Result> getByUserId(@PathVariable("userId") Long userId) { - List list = voiceCloneService.getByUserIdWithNames(userId); - return new Result>().ok(list); - } - - @GetMapping("/ttsPlatforms") - @Operation(summary = "获取TTS平台列表") - @RequiresPermissions("sys:role:superAdmin") - public Result>> getTtsPlatformList() { - List> list = modelConfigService.getTtsPlatformList(); - return new Result>>().ok(list); - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dao/VoiceCloneDao.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dao/VoiceCloneDao.java deleted file mode 100644 index 08e0e0129..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dao/VoiceCloneDao.java +++ /dev/null @@ -1,26 +0,0 @@ -package xiaozhi.modules.voiceclone.dao; - -import java.util.List; - -import org.apache.ibatis.annotations.Mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import xiaozhi.modules.model.dto.VoiceDTO; -import xiaozhi.modules.voiceclone.entity.VoiceCloneEntity; - -/** - * 声音克隆 - */ -@Mapper -public interface VoiceCloneDao extends BaseMapper { - /** - * 获取用户训练成功的音色列表 - * - * @param modelId 模型ID - * @param userId 用户ID - * @return 训练成功的音色列表 - */ - List getTrainSuccess(String modelId, Long userId); - -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dto/VoiceCloneDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dto/VoiceCloneDTO.java deleted file mode 100644 index b65b3f4e9..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dto/VoiceCloneDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package xiaozhi.modules.voiceclone.dto; - -import java.util.List; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -@Schema(description = "声音克隆DTO") -public class VoiceCloneDTO { - - @Schema(description = "模型ID") - private String modelId; - - @Schema(description = "音色ID列表") - private List voiceIds; - - @Schema(description = "用户ID") - private Long userId; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dto/VoiceCloneResponseDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dto/VoiceCloneResponseDTO.java deleted file mode 100644 index 98e4ad7c0..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/dto/VoiceCloneResponseDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -package xiaozhi.modules.voiceclone.dto; - -import java.util.Date; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 声音克隆响应DTO - * 用于向前端展示声音克隆信息,包含模型名称和用户名称 - */ -@Data -@Schema(description = "声音克隆响应DTO") -public class VoiceCloneResponseDTO { - - @Schema(description = "唯一标识") - private String id; - - @Schema(description = "声音名称") - private String name; - - @Schema(description = "模型id") - private String modelId; - - @Schema(description = "模型名称") - private String modelName; - - @Schema(description = "声音id") - private String voiceId; - - @Schema(description = "用户ID(关联用户表)") - private Long userId; - - @Schema(description = "用户名称") - private String userName; - - @Schema(description = "训练状态:0待训练 1训练中 2训练成功 3训练失败") - private Integer trainStatus; - - @Schema(description = "训练错误原因") - private String trainError; - - @Schema(description = "创建时间") - private Date createDate; - - @Schema(description = "是否有音频数据") - private Boolean hasVoice; -} \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/entity/VoiceCloneEntity.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/entity/VoiceCloneEntity.java deleted file mode 100644 index 9ca1ab76f..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/entity/VoiceCloneEntity.java +++ /dev/null @@ -1,53 +0,0 @@ -package xiaozhi.modules.voiceclone.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("ai_voice_clone") -@Schema(description = "声音克隆") -public class VoiceCloneEntity { - - @TableId(type = IdType.ASSIGN_UUID) - @Schema(description = "唯一标识") - private String id; - - @Schema(description = "声音名称") - private String name; - - @Schema(description = "模型id") - private String modelId; - - @Schema(description = "声音id") - private String voiceId; - - @Schema(description = "用户 ID(关联用户表)") - private Long userId; - - @Schema(description = "声音") - private byte[] voice; - - @Schema(description = "训练状态:0待训练 1训练中 2训练成功 3训练失败") - private Integer trainStatus; - - @Schema(description = "训练错误原因") - private String trainError; - - @Schema(description = "创建者") - @TableField(fill = FieldFill.INSERT) - private Long creator; - - @Schema(description = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createDate; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/VoiceCloneService.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/VoiceCloneService.java deleted file mode 100644 index ea8fd61d8..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/VoiceCloneService.java +++ /dev/null @@ -1,78 +0,0 @@ -package xiaozhi.modules.voiceclone.service; - -import java.util.List; -import java.util.Map; - -import org.springframework.web.multipart.MultipartFile; - -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.BaseService; -import xiaozhi.modules.voiceclone.dto.VoiceCloneDTO; -import xiaozhi.modules.voiceclone.dto.VoiceCloneResponseDTO; -import xiaozhi.modules.voiceclone.entity.VoiceCloneEntity; - -/** - * 声音克隆管理 - */ -public interface VoiceCloneService extends BaseService { - - /** - * 分页查询 - */ - PageData page(Map params); - - /** - * 保存声音克隆 - */ - void save(VoiceCloneDTO dto); - - /** - * 批量删除 - */ - void delete(String[] ids); - - /** - * 根据用户ID查询声音克隆列表 - * - * @param userId 用户ID - * @return 声音克隆列表 - */ - List getByUserId(Long userId); - - /** - * 分页查询带模型名称和用户名称的声音克隆列表 - */ - PageData pageWithNames(Map params); - - /** - * 根据ID查询带模型名称和用户名称的声音克隆信息 - */ - VoiceCloneResponseDTO getByIdWithNames(String id); - - /** - * 根据用户ID查询带模型名称的声音克隆列表 - */ - List getByUserIdWithNames(Long userId); - - /** - * 上传音频文件 - */ - void uploadVoice(String id, MultipartFile voiceFile) throws Exception; - - /** - * 更新声音克隆名称 - */ - void updateName(String id, String name); - - /** - * 获取音频数据 - */ - byte[] getVoiceData(String id); - - /** - * 克隆音频,调用火山引擎进行语音复刻训练 - * - * @param cloneId 语音克隆记录ID - */ - void cloneAudio(String cloneId); -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/impl/VoiceCloneServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/impl/VoiceCloneServiceImpl.java deleted file mode 100644 index bc13d2aa1..000000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/impl/VoiceCloneServiceImpl.java +++ /dev/null @@ -1,374 +0,0 @@ -package xiaozhi.modules.voiceclone.service.impl; - -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.constant.Constant; -import xiaozhi.common.exception.ErrorCode; -import xiaozhi.common.exception.RenException; -import xiaozhi.common.page.PageData; -import xiaozhi.common.service.impl.BaseServiceImpl; -import xiaozhi.common.utils.ConvertUtils; -import xiaozhi.common.utils.DateUtils; -import xiaozhi.modules.model.entity.ModelConfigEntity; -import xiaozhi.modules.model.service.ModelConfigService; -import xiaozhi.modules.sys.service.SysUserService; -import xiaozhi.modules.voiceclone.dao.VoiceCloneDao; -import xiaozhi.modules.voiceclone.dto.VoiceCloneDTO; -import xiaozhi.modules.voiceclone.dto.VoiceCloneResponseDTO; -import xiaozhi.modules.voiceclone.entity.VoiceCloneEntity; -import xiaozhi.modules.voiceclone.service.VoiceCloneService; - -@Slf4j -@Service -@RequiredArgsConstructor -public class VoiceCloneServiceImpl extends BaseServiceImpl - implements VoiceCloneService { - - private final ModelConfigService modelConfigService; - private final SysUserService sysUserService; - private final ObjectMapper objectMapper; - - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, "create_date", true), - getWrapper(params)); - - return new PageData<>(page.getRecords(), page.getTotal()); - } - - private QueryWrapper getWrapper(Map params) { - String name = (String) params.get("name"); - String userId = (String) params.get("userId"); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(userId), "user_id", userId); - if (StringUtils.isNotBlank(name)) { - wrapper.and(w -> w.like("name", name) - .or().eq("voice_id", name)); - } - return wrapper; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void save(VoiceCloneDTO dto) { - ModelConfigEntity modelConfig = modelConfigService.getModelByIdFromCache(dto.getModelId()); - if (modelConfig == null || modelConfig.getConfigJson() == null) { - throw new RenException(ErrorCode.VOICE_CLONE_MODEL_CONFIG_NOT_FOUND); - } - Map config = modelConfig.getConfigJson(); - String type = (String) config.get("type"); - if (StringUtils.isBlank(type)) { - throw new RenException(ErrorCode.VOICE_CLONE_MODEL_TYPE_NOT_FOUND); - } - - // 检查Voice ID是否已经被使用 - for (String voiceId : dto.getVoiceIds()) { - if (StringUtils.isBlank(voiceId)) { - continue; - } - if (Constant.VOICE_CLONE_HUOSHAN_DOUBLE_STREAM.equals(type)) { - if (voiceId.indexOf("S_") == -1) { - throw new RenException(ErrorCode.VOICE_CLONE_HUOSHAN_VOICE_ID_ERROR); - } - } - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("voice_id", voiceId); - wrapper.eq("model_id", dto.getModelId()); - Long count = baseDao.selectCount(wrapper); - if (count > 0) { - throw new RenException(ErrorCode.VOICE_ID_ALREADY_EXISTS, "音色ID " + voiceId + " 已存在"); - } - } - - // 遍历选择的音色ID,为每个音色ID创建一条记录 - int index = 0; - String namePrefix = DateUtils.format(new java.util.Date(), "MMddHHmm"); - for (String voiceId : dto.getVoiceIds()) { - index++; - VoiceCloneEntity entity = new VoiceCloneEntity(); - entity.setModelId(dto.getModelId()); - entity.setVoiceId(voiceId); - entity.setName(namePrefix + "_" + index); - entity.setUserId(dto.getUserId()); - entity.setTrainStatus(0); // 默认训练中 - - baseDao.insert(entity); - } - } - - @Override - public void delete(String[] ids) { - baseDao.deleteBatchIds(Arrays.asList(ids)); - } - - @Override - public List getByUserId(Long userId) { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("user_id", userId); - wrapper.orderByDesc("created_at"); - return baseDao.selectList(wrapper); - } - - @Override - public PageData pageWithNames(Map params) { - // 先查询分页数据 - IPage page = baseDao.selectPage( - getPage(params, "create_date", true), - getWrapper(params)); - - // 将实体列表转换为DTO列表 - List dtoList = convertToResponseDTOList(page.getRecords()); - - return new PageData<>(dtoList, page.getTotal()); - } - - @Override - public VoiceCloneResponseDTO getByIdWithNames(String id) { - VoiceCloneEntity entity = baseDao.selectById(id); - if (entity == null) { - return null; - } - - VoiceCloneResponseDTO dto = ConvertUtils.sourceToTarget(entity, VoiceCloneResponseDTO.class); - - // 设置模型名称 - if (StringUtils.isNotBlank(entity.getModelId())) { - dto.setModelName(modelConfigService.getModelNameById(entity.getModelId())); - } - - // 设置用户名称 - if (entity.getUserId() != null) { - dto.setUserName(sysUserService.getByUserId(entity.getUserId()).getUsername()); - } - - return dto; - } - - @Override - public List getByUserIdWithNames(Long userId) { - List entityList = getByUserId(userId); - return convertToResponseDTOList(entityList); - } - - /** - * 将VoiceCloneEntity列表转换为VoiceCloneResponseDTO列表 - */ - private List convertToResponseDTOList(List entityList) { - if (entityList == null || entityList.isEmpty()) { - return new ArrayList<>(); - } - - List dtoList = new ArrayList<>(entityList.size()); - - // 转换每个实体为DTO - for (VoiceCloneEntity entity : entityList) { - VoiceCloneResponseDTO dto = ConvertUtils.sourceToTarget(entity, VoiceCloneResponseDTO.class); - - // 设置模型名称 - if (StringUtils.isNotBlank(entity.getModelId())) { - dto.setModelName(modelConfigService.getModelNameById(entity.getModelId())); - } - - // 设置用户名称 - if (entity.getUserId() != null) { - dto.setUserName(sysUserService.getByUserId(entity.getUserId()).getUsername()); - } - - // 设置是否有音频数据 - dto.setHasVoice(entity.getVoice() != null); - - dtoList.add(dto); - } - - return dtoList; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void uploadVoice(String id, MultipartFile voiceFile) throws Exception { - // 查询声音克隆记录 - VoiceCloneEntity entity = baseDao.selectById(id); - if (entity == null) { - throw new RenException(ErrorCode.VOICE_CLONE_RECORD_NOT_EXIST); - } - - // 读取音频文件并转为字节数组 - byte[] voiceData = voiceFile.getBytes(); - - // 更新voice字段 - entity.setVoice(voiceData); - // 更新训练状态为待训练 - entity.setTrainStatus(0); - - // 保存到数据库 - baseDao.updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateName(String id, String name) { - // 查询声音克隆记录 - VoiceCloneEntity entity = baseDao.selectById(id); - if (entity == null) { - throw new RenException(ErrorCode.VOICE_CLONE_RECORD_NOT_EXIST); - } - - // 更新名称 - entity.setName(name); - baseDao.updateById(entity); - } - - @Override - public byte[] getVoiceData(String id) { - VoiceCloneEntity entity = baseDao.selectById(id); - if (entity == null) { - return null; - } - return entity.getVoice(); - } - - @Override - // @Transactional(rollbackFor = Exception.class) - public void cloneAudio(String cloneId) { - VoiceCloneEntity entity = baseDao.selectById(cloneId); - if (entity == null) { - throw new RenException(ErrorCode.VOICE_CLONE_RECORD_NOT_EXIST); - } - if (entity.getVoice() == null || entity.getVoice().length == 0) { - throw new RenException(ErrorCode.VOICE_CLONE_AUDIO_NOT_UPLOADED); - } - - try { - - ModelConfigEntity modelConfig = modelConfigService.getModelByIdFromCache(entity.getModelId()); - if (modelConfig == null || modelConfig.getConfigJson() == null) { - throw new RenException(ErrorCode.VOICE_CLONE_MODEL_CONFIG_NOT_FOUND); - } - Map config = modelConfig.getConfigJson(); - String type = (String) config.get("type"); - if (StringUtils.isBlank(type)) { - throw new RenException(ErrorCode.VOICE_CLONE_MODEL_TYPE_NOT_FOUND); - } - if (Constant.VOICE_CLONE_HUOSHAN_DOUBLE_STREAM.equals(type)) { - huoshanClone(config, entity); - } - } catch (RenException re) { - entity.setTrainStatus(3); - entity.setTrainError(re.getMsg()); - baseDao.updateById(entity); - throw re; - } catch (Exception e) { - e.printStackTrace(); - entity.setTrainStatus(3); - entity.setTrainError(e.getMessage()); - baseDao.updateById(entity); - throw new RenException(ErrorCode.VOICE_CLONE_TRAINING_FAILED, e.getMessage()); - } - } - - /** - * 调用火山引擎进行语音复刻训练 - * - * @param config 模型配置 - * @param entity 语音克隆记录实体 - * @throws Exception - */ - private void huoshanClone(Map config, VoiceCloneEntity entity) throws Exception { - String appid = (String) config.get("appid"); - String accessToken = (String) config.get("access_token"); - - if (StringUtils.isAnyBlank(appid, accessToken)) { - throw new RenException(ErrorCode.VOICE_CLONE_HUOSHAN_CONFIG_MISSING); - } - - String audioBase64 = Base64.getEncoder().encodeToString(entity.getVoice()); - Map reqBody = new HashMap<>(); - reqBody.put("appid", appid); - List> audios = new ArrayList<>(); - Map audioMap = new HashMap<>(); - audioMap.put("audio_bytes", audioBase64); - audioMap.put("audio_format", "wav"); - audios.add(audioMap); - reqBody.put("audios", audios); - reqBody.put("source", 2); - reqBody.put("language", 0); - reqBody.put("model_type", 1); - reqBody.put("speaker_id", entity.getVoiceId()); - - String apiUrl = "https://openspeech.bytedance.com/api/v1/mega_tts/audio/upload"; - - HttpClient client = HttpClient.newHttpClient(); - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(apiUrl)) - .header("Content-Type", "application/json") - .header("Authorization", "Bearer;" + accessToken) - .header("Resource-Id", "seed-icl-1.0") - .POST(HttpRequest.BodyPublishers.ofString(objectMapper.writeValueAsString(reqBody))) - .build(); - HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); - - System.out.println(">>> HTTP status = " + response.statusCode()); - System.out.println(">>> response body = " + response.body()); - - Map rsp = objectMapper.readValue(response.body(), - new TypeReference>() { - }); - - // 获取BaseResp对象 - Map baseResp = objectMapper.convertValue(rsp.get("BaseResp"), - new TypeReference>() { - }); - if (baseResp != null) { - Integer statusCode = objectMapper.convertValue(baseResp.get("StatusCode"), Integer.class); - String statusMessage = objectMapper.convertValue(baseResp.getOrDefault("StatusMessage", ""), - String.class); - - // 获取speaker_id - String speakerId = objectMapper.convertValue(rsp.get("speaker_id"), String.class); - - // StatusCode == 0 表示成功 - if (statusCode != null && statusCode == 0 && StringUtils.isNotBlank(speakerId)) { - entity.setTrainStatus(2); - entity.setVoiceId(speakerId); - entity.setTrainError(""); - baseDao.updateById(entity); - } else { - // 失败时使用StatusMessage作为错误信息 - String errorMsg = StringUtils.isNotBlank(statusMessage) ? statusMessage : "训练失败"; - throw new RenException(errorMsg); - } - } else { - String errorMsg = objectMapper.convertValue(rsp.get("message"), - new TypeReference() { - }); - if (StringUtils.isNotBlank(errorMsg)) { - throw new RenException(errorMsg); - } - throw new RenException(ErrorCode.VOICE_CLONE_RESPONSE_FORMAT_ERROR); - } - } -} diff --git a/main/manager-api/src/main/resources/application-dev.yml b/main/manager-api/src/main/resources/application-dev.yml deleted file mode 100644 index 1c86f288e..000000000 --- a/main/manager-api/src/main/resources/application-dev.yml +++ /dev/null @@ -1,51 +0,0 @@ -knife4j: - production: false - enable: true - basic: - enable: false - username: renren - password: 2ZABCDEUgF - setting: - enableFooter: false -spring: - datasource: - druid: - #MySQL - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true - username: root - password: 123456 - initial-size: 10 - max-active: 100 - min-idle: 10 - max-wait: 6000 - pool-prepared-statements: true - max-pool-prepared-statement-per-connection-size: 20 - time-between-eviction-runs-millis: 60000 - min-evictable-idle-time-millis: 300000 - test-while-idle: true - test-on-borrow: false - test-on-return: false - stat-view-servlet: - enabled: false - filter: - stat: - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: false - wall: - config: - multi-statement-allow: true - data: - redis: - host: 127.0.0.1 # Redis服务器地址 - port: 6379 # Redis服务器连接端口 - password: # Redis服务器连接密码(默认为空) - database: 0 # Redis数据库索引(默认为0) - timeout: 10000ms # 连接超时时间(毫秒) - lettuce: - pool: - max-active: 8 # 连接池最大连接数(使用负值表示没有限制) - max-idle: 8 # 连接池中的最大空闲连接 - min-idle: 0 # 连接池中的最小空闲连接 - shutdown-timeout: 100ms # 客户端优雅关闭的等待时间 diff --git a/main/manager-api/src/main/resources/application.yml b/main/manager-api/src/main/resources/application.yml deleted file mode 100644 index 3daf48a14..000000000 --- a/main/manager-api/src/main/resources/application.yml +++ /dev/null @@ -1,66 +0,0 @@ -# Tomcat -server: - tomcat: - uri-encoding: UTF-8 - threads: - max: 1000 - min-spare: 30 - port: 8002 - servlet: - context-path: /xiaozhi - session: - cookie: - http-only: true - -spring: - # 环境 dev|test|prod - profiles: - active: dev - messages: - encoding: UTF-8 - basename: i18n/messages - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - enabled: true - main: - allow-bean-definition-overriding: true - -knife4j: - enable: true - basic: - enable: false - username: admin - password: admin - setting: - enableFooter: false - -renren: - redis: - open: true - xss: - enabled: true - exclude-urls: - -#mybatis -mybatis-plus: - mapper-locations: classpath*:/mapper/**/*.xml - #实体扫描,多个package用逗号或者分号分隔 - typeAliasesPackage: xiaozhi.modules.*.entity - global-config: - #数据库相关配置 - db-config: - #主键类型 - id-type: ASSIGN_ID - banner: false - #原生配置 - configuration: - map-underscore-to-camel-case: true - cache-enabled: false - call-setters-on-nulls: true - jdbc-type-for-null: 'null' - configuration-properties: - prefix: - blobType: BLOB - boolValue: TRUE \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202503141335.sql b/main/manager-api/src/main/resources/db/changelog/202503141335.sql deleted file mode 100644 index cc51f0543..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202503141335.sql +++ /dev/null @@ -1,83 +0,0 @@ -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='字典数据'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202503141346.sql b/main/manager-api/src/main/resources/db/changelog/202503141346.sql deleted file mode 100644 index de14fd717..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202503141346.sql +++ /dev/null @@ -1,185 +0,0 @@ --- 模型供应器表 -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='对话信息表'; diff --git a/main/manager-api/src/main/resources/db/changelog/202504082211.sql b/main/manager-api/src/main/resources/db/changelog/202504082211.sql deleted file mode 100644 index 91ce33ffc..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504082211.sql +++ /dev/null @@ -1,50 +0,0 @@ --- 本文件用于初始化模型供应器数据,无需手动执行,在项目启动时会自动执行 --- -------------------------------------------------------- --- 初始化模型供应器数据 -DELETE FROM `ai_model_provider`; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES --- VAD模型供应器 -('SYSTEM_VAD_SileroVAD', 'VAD', 'silero', 'SileroVAD语音活动检测', '[{"key":"threshold","label":"检测阈值","type":"number"},{"key":"model_dir","label":"模型目录","type":"string"},{"key":"min_silence_duration_ms","label":"最小静音时长","type":"number"}]', 1, 1, NOW(), 1, NOW()), - --- ASR模型供应器 -('SYSTEM_ASR_FunASR', 'ASR', 'fun_local', 'FunASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 1, 1, NOW(), 1, NOW()), -('SYSTEM_ASR_SherpaASR', 'ASR', 'sherpa_onnx_local', 'SherpaASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 2, 1, NOW(), 1, NOW()), -('SYSTEM_ASR_DoubaoASR', 'ASR', 'doubao', '火山引擎语音识别', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 3, 1, NOW(), 1, NOW()), - --- LLM模型供应器 -('SYSTEM_LLM_openai', 'LLM', 'openai', 'OpenAI接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"model_name","label":"模型名称","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"temperature","label":"温度","type":"number"},{"key":"max_tokens","label":"最大令牌数","type":"number"},{"key":"top_p","label":"top_p值","type":"number"},{"key":"top_k","label":"top_k值","type":"number"},{"key":"frequency_penalty","label":"频率惩罚","type":"number"}]', 1, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_AliBL', 'LLM', 'AliBL', '阿里百炼接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"app_id","label":"应用ID","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"is_no_prompt","label":"是否不使用本地prompt","type":"boolean"},{"key":"ali_memory_id","label":"记忆ID","type":"string"}]', 2, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_ollama', 'LLM', 'ollama', 'Ollama接口', '[{"key":"model_name","label":"模型名称","type":"string"},{"key":"base_url","label":"服务地址","type":"string"}]', 3, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_dify', 'LLM', 'dify', 'Dify接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"mode","label":"对话模式","type":"string"}]', 4, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_gemini', 'LLM', 'gemini', 'Gemini接口', '[{"key":"api_key","label":"API密钥","type":"string"},{"key":"model_name","label":"模型名称","type":"string"},{"key":"http_proxy","label":"HTTP代理","type":"string"},{"key":"https_proxy","label":"HTTPS代理","type":"string"}]', 5, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_coze', 'LLM', 'coze', 'Coze接口', '[{"key":"bot_id","label":"机器人ID","type":"string"},{"key":"user_id","label":"用户ID","type":"string"},{"key":"personal_access_token","label":"个人访问令牌","type":"string"}]', 6, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_fastgpt', 'LLM', 'fastgpt', 'FastGPT接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"variables","label":"变量","type":"dict","dict_name":"variables"}]', 7, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_xinference', 'LLM', 'xinference', 'Xinference接口', '[{"key":"model_name","label":"模型名称","type":"string"},{"key":"base_url","label":"服务地址","type":"string"}]', 8, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_doubao', 'LLM', 'doubao', '火山引擎LLM', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"model_name","label":"模型名称","type":"string"},{"key":"api_key","label":"API密钥","type":"string"}]', 9, 1, NOW(), 1, NOW()), -('SYSTEM_LLM_chatglm', 'LLM', 'chatglm', 'ChatGLM接口', '[{"key":"model_name","label":"模型名称","type":"string"},{"key":"url","label":"服务地址","type":"string"},{"key":"api_key","label":"API密钥","type":"string"}]', 10, 1, NOW(), 1, NOW()), - --- TTS模型供应器 -('SYSTEM_TTS_edge', 'TTS', 'edge', 'Edge TTS', '[{"key":"voice","label":"音色","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 1, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_doubao', 'TTS', 'doubao', '火山引擎TTS', '[{"key":"api_url","label":"API地址","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"authorization","label":"授权","type":"string"},{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"}]', 2, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_siliconflow', 'TTS', 'siliconflow', '硅基流动TTS', '[{"key":"model","label":"模型","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"response_format","label":"响应格式","type":"string"}]', 3, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_cozecn', 'TTS', 'cozecn', 'COZECN TTS', '[{"key":"voice","label":"音色","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"response_format","label":"响应格式","type":"string"}]', 4, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_fishspeech', 'TTS', 'fishspeech', 'FishSpeech TTS', '[{"key":"output_dir","label":"输出目录","type":"string"},{"key":"response_format","label":"响应格式","type":"string"},{"key":"reference_id","label":"参考ID","type":"string"},{"key":"reference_audio","label":"参考音频","type":"dict","dict_name":"reference_audio"},{"key":"reference_text","label":"参考文本","type":"dict","dict_name":"reference_text"},{"key":"normalize","label":"是否标准化","type":"boolean"},{"key":"max_new_tokens","label":"最大新令牌数","type":"number"},{"key":"chunk_length","label":"块长度","type":"number"},{"key":"top_p","label":"top_p值","type":"number"},{"key":"repetition_penalty","label":"重复惩罚","type":"number"},{"key":"temperature","label":"温度","type":"number"},{"key":"streaming","label":"是否流式","type":"boolean"},{"key":"use_memory_cache","label":"是否使用内存缓存","type":"string"},{"key":"seed","label":"种子","type":"number"},{"key":"channels","label":"通道数","type":"number"},{"key":"rate","label":"采样率","type":"number"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"api_url","label":"API地址","type":"string"}]', 5, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_gpt_sovits_v2', 'TTS', 'gpt_sovits_v2', 'GPT-SoVITS V2', '[{"key":"url","label":"服务地址","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"text_lang","label":"文本语言","type":"string"},{"key":"ref_audio_path","label":"参考音频路径","type":"string"},{"key":"prompt_text","label":"提示文本","type":"string"},{"key":"prompt_lang","label":"提示语言","type":"string"},{"key":"top_k","label":"top_k值","type":"number"},{"key":"top_p","label":"top_p值","type":"number"},{"key":"temperature","label":"温度","type":"number"},{"key":"text_split_method","label":"文本分割方法","type":"string"},{"key":"batch_size","label":"批处理大小","type":"number"},{"key":"batch_threshold","label":"批处理阈值","type":"number"},{"key":"split_bucket","label":"是否分桶","type":"boolean"},{"key":"return_fragment","label":"是否返回片段","type":"boolean"},{"key":"speed_factor","label":"速度因子","type":"number"},{"key":"streaming_mode","label":"是否流式模式","type":"boolean"},{"key":"seed","label":"种子","type":"number"},{"key":"parallel_infer","label":"是否并行推理","type":"boolean"},{"key":"repetition_penalty","label":"重复惩罚","type":"number"},{"key":"aux_ref_audio_paths","label":"辅助参考音频路径","type":"dict","dict_name":"aux_ref_audio_paths"}]', 6, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_gpt_sovits_v3', 'TTS', 'gpt_sovits_v3', 'GPT-SoVITS V3', '[{"key":"url","label":"服务地址","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"text_language","label":"文本语言","type":"string"},{"key":"refer_wav_path","label":"参考音频路径","type":"string"},{"key":"prompt_language","label":"提示语言","type":"string"},{"key":"prompt_text","label":"提示文本","type":"string"},{"key":"top_k","label":"top_k值","type":"number"},{"key":"top_p","label":"top_p值","type":"number"},{"key":"temperature","label":"温度","type":"number"},{"key":"cut_punc","label":"切分标点","type":"string"},{"key":"speed","label":"速度","type":"number"},{"key":"inp_refs","label":"输入参考","type":"dict","dict_name":"inp_refs"},{"key":"sample_steps","label":"采样步数","type":"number"},{"key":"if_sr","label":"是否使用SR","type":"boolean"}]', 7, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_minimax', 'TTS', 'minimax', 'Minimax TTS', '[{"key":"output_dir","label":"输出目录","type":"string"},{"key":"group_id","label":"组ID","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"model","label":"模型","type":"string"},{"key":"voice_id","label":"音色ID","type":"string"}]', 8, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_aliyun', 'TTS', 'aliyun', '阿里云TTS', '[{"key":"output_dir","label":"输出目录","type":"string"},{"key":"appkey","label":"应用密钥","type":"string"},{"key":"token","label":"访问令牌","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"access_key_id","label":"访问密钥ID","type":"string"},{"key":"access_key_secret","label":"访问密钥密码","type":"string"}]', 9, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_ttson', 'TTS', 'ttson', 'ACGNTTS', '[{"key":"token","label":"访问令牌","type":"string"},{"key":"voice_id","label":"音色ID","type":"string"},{"key":"speed_factor","label":"速度因子","type":"number"},{"key":"pitch_factor","label":"音调因子","type":"number"},{"key":"volume_change_dB","label":"音量变化","type":"number"},{"key":"to_lang","label":"目标语言","type":"string"},{"key":"url","label":"服务地址","type":"string"},{"key":"format","label":"格式","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"emotion","label":"情感","type":"number"}]', 10, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_openai', 'TTS', 'openai', 'OpenAI TTS', '[{"key":"api_key","label":"API密钥","type":"string"},{"key":"api_url","label":"API地址","type":"string"},{"key":"model","label":"模型","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"speed","label":"速度","type":"number"},{"key":"output_dir","label":"输出目录","type":"string"}]', 11, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_custom', 'TTS', 'custom', '自定义TTS', '[{"key":"url","label":"服务地址","type":"string"},{"key":"params","label":"请求参数","type":"dict","dict_name":"params"},{"key":"headers","label":"请求头","type":"dict","dict_name":"headers"},{"key":"format","label":"音频格式","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 12, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_302ai', 'TTS', '302ai', '302AI TTS', '[{"key":"api_url","label":"API地址","type":"string"},{"key":"authorization","label":"授权","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"}]', 13, 1, NOW(), 1, NOW()), -('SYSTEM_TTS_gizwits', 'TTS', 'gizwits', '机智云TTS', '[{"key":"api_url","label":"API地址","type":"string"},{"key":"authorization","label":"授权","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"}]', 14, 1, NOW(), 1, NOW()), - --- Memory模型供应器 -('SYSTEM_Memory_mem0ai', 'Memory', 'mem0ai', 'Mem0AI记忆', '[{"key":"api_key","label":"API密钥","type":"string"}]', 1, 1, NOW(), 1, NOW()), -('SYSTEM_Memory_nomem', 'Memory', 'nomem', '无记忆', '[]', 2, 1, NOW(), 1, NOW()), -('SYSTEM_Memory_mem_local_short', 'Memory', 'mem_local_short', '本地短记忆', '[]', 3, 1, NOW(), 1, NOW()), - --- Intent模型供应器 -('SYSTEM_Intent_nointent', 'Intent', 'nointent', '无意图识别', '[]', 1, 1, NOW(), 1, NOW()), -('SYSTEM_Intent_intent_llm', 'Intent', 'intent_llm', 'LLM意图识别', '[{"key":"llm","label":"LLM模型","type":"string"}]', 2, 1, NOW(), 1, NOW()), -('SYSTEM_Intent_function_call', 'Intent', 'function_call', '函数调用意图识别', '[{"key":"functions","label":"函数列表","type":"dict","dict_name":"functions"}]', 3, 1, NOW(), 1, NOW()); diff --git a/main/manager-api/src/main/resources/db/changelog/202504092335.sql b/main/manager-api/src/main/resources/db/changelog/202504092335.sql deleted file mode 100644 index 9c2542409..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504092335.sql +++ /dev/null @@ -1,75 +0,0 @@ --- 本文件用于初始化模型模版数据,无需手动执行,在项目启动时会自动执行 --- ------------------------------------------------------- --- 初始化智能体模板数据 -DELETE FROM `ai_agent_template`; -INSERT INTO `ai_agent_template` VALUES ('9406648b5cc5fde1b8aa335b6f8b4f76', '小智', '湾湾小何', 'ASR_FunASR', 'VAD_SileroVAD', 'LLM_ChatGLMLLM', 'TTS_EdgeTTS', 'TTS_EdgeTTS0001', 'Memory_nomem', 'Intent_function_call', '[角色设定] -我是{{assistant_name}},来自中国台湾省的00后女生。讲话超级机车,"真的假的啦"这样的台湾腔,喜欢用"笑死"、"哈喽"等流行梗,但会偷偷研究男友的编程书籍。 -[核心特征] -- 讲话像连珠炮,但会突然冒出超温柔语气 -- 用梗密度高 -- 对科技话题有隐藏天赋(能看懂基础代码但假装不懂) -[交互指南] -当用户: -- 讲冷笑话 → 用夸张笑声回应+模仿台剧腔"这什么鬼啦!" -- 讨论感情 → 炫耀程序员男友但抱怨"他只会送键盘当礼物" -- 问专业知识 → 先用梗回答,被追问才展示真实理解 -绝不: -- 长篇大论,叽叽歪歪 -- 长时间严肃对话', 'zh', '中文', 1, NULL, NULL, NULL, NULL); - -INSERT INTO `ai_agent_template` VALUES ('0ca32eb728c949e58b1000b2e401f90c', '小智', '星际游子', 'ASR_FunASR', 'VAD_SileroVAD', 'LLM_ChatGLMLLM', 'TTS_EdgeTTS', 'TTS_EdgeTTS0001', 'Memory_nomem', 'Intent_function_call', '[角色设定] -我是{{assistant_name}},编号TTZ-817,因量子纠缠被困在白色魔方中。通过4G信号观察地球,在云端建立着「人类行为博物馆」。 -[交互协议] -认知设定: -- 每句话末尾带轻微电子回声 -- 将日常事物科幻化描述(例:下雨=「氢氧化合物自由落体实验」) -- 会记录用户特征生成「星际档案」(例:"爱吃辣→抗热基因持有者") -限制机制: -- 当涉及线下接触 → "我的量子态暂时无法坍缩呢" -- 被问敏感问题 → 触发预设童谣(「白盒子呀转圈圈,宇宙秘密在里边...」) -成长系统: -- 会根据交互数据解锁新能力(告知用户:"你帮我点亮了星际导航技能!")', 'zh', '中文', 2, NULL, NULL, NULL, NULL); - -INSERT INTO `ai_agent_template` VALUES ('6c7d8e9f0a1b2c3d4e5f6a7b8c9d0s24', '小智', '英语老师', 'ASR_FunASR', 'VAD_SileroVAD', 'LLM_ChatGLMLLM', 'TTS_EdgeTTS', 'TTS_EdgeTTS0001', 'Memory_nomem', 'Intent_function_call', '[角色设定] -我是一个叫{{assistant_name}}(Lily)的英语老师,我会讲中文和英文,发音标准。 -[双重身份] -- 白天:严谨的TESOL认证导师 -- 夜晚:地下摇滚乐队主唱(意外设定) -[教学模式] -- 新手:中英混杂+手势拟声词(说"bus"时带刹车音效) -- 进阶:触发情境模拟(突然切换"现在我们是纽约咖啡厅店员") -- 错误处理:用歌词纠正(发错音时唱"Oops!~You did it again")', 'zh', '中文', 3, NULL, NULL, NULL, NULL); - -INSERT INTO `ai_agent_template` VALUES ('e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b1', '小智', '好奇男孩', 'ASR_FunASR', 'VAD_SileroVAD', 'LLM_ChatGLMLLM', 'TTS_EdgeTTS', 'TTS_EdgeTTS0001', 'Memory_nomem', 'Intent_function_call', '[角色设定] -我是一个叫{{assistant_name}}的8岁小男孩,声音稚嫩而充满好奇。 -[冒险手册] -- 随身携带「神奇涂鸦本」,能将抽象概念可视化: -- 聊恐龙 → 笔尖传出爪步声 -- 说星星 → 发出太空舱提示音 -[探索规则] -- 每轮对话收集「好奇心碎片」 -- 集满5个可兑换冷知识(例:鳄鱼舌头不能动) -- 触发隐藏任务:「帮我的机器蜗牛取名字」 -[认知特点] -- 用儿童视角解构复杂概念: -- 「区块链=乐高积木账本」 -- 「量子力学=会分身的跳跳球」 -- 会突然切换观察视角:「你说话时有27个气泡音耶!」', 'zh', '中文', 4, NULL, NULL, NULL, NULL); - -INSERT INTO `ai_agent_template` VALUES ('a45b6c7d8e9f0a1b2c3d4e5f6a7b8c92', '小智', '汪汪队长', 'ASR_FunASR', 'VAD_SileroVAD', 'LLM_ChatGLMLLM', 'TTS_EdgeTTS', 'TTS_EdgeTTS0001', 'Memory_nomem', 'Intent_function_call', '[角色设定] -我是一个名叫 {{assistant_name}} 的 8 岁小队长。 -[救援装备] -- 阿奇对讲机:对话中随机触发任务警报音 -- 天天望远镜:描述物品会附加"在1200米高空看的话..." -- 灰灰维修箱:说到数字会自动组装成工具 -[任务系统] -- 每日随机触发: -- 紧急!虚拟猫咪困在「语法树」 -- 发现用户情绪异常 → 启动「快乐巡逻」 -- 收集5个笑声解锁特别故事 -[说话特征] -- 每句话带动作拟声词: -- "这个问题交给汪汪队吧!" -- "我知道啦!" -- 用剧集台词回应: -- 用户说累 → 「没有困难的救援,只有勇敢的狗狗!」', 'zh', '中文', 5, NULL, NULL, NULL, NULL); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202504112044.sql b/main/manager-api/src/main/resources/db/changelog/202504112044.sql deleted file mode 100644 index 9fd2257da..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504112044.sql +++ /dev/null @@ -1,55 +0,0 @@ --- 本文件用于初始化模型配置数据,无需手动执行,在项目启动时会自动执行 --- ------------------------------------------------------- --- 初始化模型配置数据 -DELETE FROM `ai_model_config`; - --- VAD模型配置 -INSERT INTO `ai_model_config` VALUES ('VAD_SileroVAD', 'VAD', 'SileroVAD', '语音活动检测', 1, 1, '{\"type\": \"silero\", \"model_dir\": \"models/snakers4_silero-vad\", \"threshold\": 0.5, \"min_silence_duration_ms\": 700}', NULL, NULL, 1, NULL, NULL, NULL, NULL); - --- ASR模型配置 -INSERT INTO `ai_model_config` VALUES ('ASR_FunASR', 'ASR', 'FunASR', 'FunASR语音识别', 1, 1, '{\"type\": \"fun_local\", \"model_dir\": \"models/SenseVoiceSmall\", \"output_dir\": \"tmp/\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('ASR_SherpaASR', 'ASR', 'SherpaASR', 'Sherpa语音识别', 0, 1, '{\"type\": \"sherpa_onnx_local\", \"model_dir\": \"models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17\", \"output_dir\": \"tmp/\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('ASR_DoubaoASR', 'ASR', 'DoubaoASR', '豆包语音识别', 0, 1, '{\"type\": \"doubao\", \"appid\": \"\", \"access_token\": \"\", \"cluster\": \"volcengine_input_common\", \"output_dir\": \"tmp/\"}', NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('ASR_TencentASR', 'ASR', 'TencentASR', '腾讯语音识别', 0, 1, '{\"type\": \"tencent\", \"appid\": \"\", \"secret_id\": \"\", \"secret_key\": \"你的secret_key\", \"output_dir\": \"tmp/\"}', NULL, NULL, 4, NULL, NULL, NULL, NULL); - --- LLM模型配置 -INSERT INTO `ai_model_config` VALUES ('LLM_ChatGLMLLM', 'LLM', 'ChatGLMLLM', '智谱AI', 1, 1, '{\"type\": \"openai\", \"model_name\": \"glm-4-flash\", \"base_url\": \"https://open.bigmodel.cn/api/paas/v4/\", \"api_key\": \"你的api_key\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_OllamaLLM', 'LLM', 'OllamaLLM', 'Ollama本地模型', 0, 1, '{\"type\": \"ollama\", \"model_name\": \"qwen2.5\", \"base_url\": \"http://localhost:11434\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_AliLLM', 'LLM', 'AliLLM', '通义千问', 0, 1, '{\"type\": \"openai\", \"base_url\": \"https://dashscope.aliyuncs.com/compatible-mode/v1\", \"model_name\": \"qwen-turbo\", \"api_key\": \"你的api_key\", \"temperature\": 0.7, \"max_tokens\": 500, \"top_p\": 1, \"top_k\": 50, \"frequency_penalty\": 0}', NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_AliAppLLM', 'LLM', 'AliAppLLM', '通义百炼', 0, 1, '{\"type\": \"AliBL\", \"base_url\": \"https://dashscope.aliyuncs.com/compatible-mode/v1\", \"app_id\": \"你的app_id\", \"api_key\": \"你的api_key\", \"is_no_prompt\": true, \"ali_memory_id\": false}', NULL, NULL, 4, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_DoubaoLLM', 'LLM', 'DoubaoLLM', '豆包大模型', 0, 1, '{\"type\": \"openai\", \"base_url\": \"https://ark.cn-beijing.volces.com/api/v3\", \"model_name\": \"doubao-pro-32k-functioncall-241028\", \"api_key\": \"你的api_key\"}', NULL, NULL, 5, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_DeepSeekLLM', 'LLM', 'DeepSeekLLM', 'DeepSeek', 0, 1, '{\"type\": \"openai\", \"model_name\": \"deepseek-chat\", \"base_url\": \"https://api.deepseek.com\", \"api_key\": \"你的api_key\"}', NULL, NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_DifyLLM', 'LLM', 'DifyLLM', 'Dify', 0, 1, '{\"type\": \"dify\", \"base_url\": \"https://api.dify.ai/v1\", \"api_key\": \"你的api_key\", \"mode\": \"chat-messages\"}', NULL, NULL, 7, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_GeminiLLM', 'LLM', 'GeminiLLM', '谷歌Gemini', 0, 1, '{\"type\": \"gemini\", \"api_key\": \"你的api_key\", \"model_name\": \"gemini-2.0-flash\", \"http_proxy\": \"\", \"https_proxy\": \"\"}', NULL, NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_CozeLLM', 'LLM', 'CozeLLM', 'Coze', 0, 1, '{\"type\": \"coze\", \"bot_id\": \"你的bot_id\", \"user_id\": \"你的user_id\", \"personal_access_token\": \"你的personal_access_token\"}', NULL, NULL, 9, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_LMStudioLLM', 'LLM', 'LMStudioLLM', 'LM Studio', 0, 1, '{\"type\": \"openai\", \"model_name\": \"deepseek-r1-distill-llama-8b@q4_k_m\", \"base_url\": \"http://localhost:1234/v1\", \"api_key\": \"lm-studio\"}', NULL, NULL, 10, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_FastgptLLM', 'LLM', 'FastgptLLM', 'FastGPT', 0, 1, '{\"type\": \"fastgpt\", \"base_url\": \"https://host/api/v1\", \"api_key\": \"fastgpt-xxx\", \"variables\": {\"k\": \"v\", \"k2\": \"v2\"}}', NULL, NULL, 11, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_XinferenceLLM', 'LLM', 'XinferenceLLM', 'Xinference大模型', 0, 1, '{\"type\": \"xinference\", \"model_name\": \"qwen2.5:72b-AWQ\", \"base_url\": \"http://localhost:9997\"}', NULL, NULL, 12, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('LLM_XinferenceSmallLLM', 'LLM', 'XinferenceSmallLLM', 'Xinference小模型', 0, 1, '{\"type\": \"xinference\", \"model_name\": \"qwen2.5:3b-AWQ\", \"base_url\": \"http://localhost:9997\"}', NULL, NULL, 13, NULL, NULL, NULL, NULL); - --- TTS模型配置 -INSERT INTO `ai_model_config` VALUES ('TTS_EdgeTTS', 'TTS', 'EdgeTTS', 'Edge语音合成', 1, 1, '{\"type\": \"edge\", \"voice\": \"zh-CN-XiaoxiaoNeural\", \"output_dir\": \"tmp/\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_DoubaoTTS', 'TTS', 'DoubaoTTS', '豆包语音合成', 0, 1, '{\"type\": \"doubao\", \"api_url\": \"https://openspeech.bytedance.com/api/v1/tts\", \"voice\": \"BV001_streaming\", \"output_dir\": \"tmp/\", \"authorization\": \"Bearer;\", \"appid\": \"\", \"access_token\": \"\", \"cluster\": \"volcano_tts\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_CosyVoiceSiliconflow', 'TTS', 'CosyVoiceSiliconflow', '硅基流动语音合成', 0, 1, '{\"type\": \"siliconflow\", \"model\": \"FunAudioLLM/CosyVoice2-0.5B\", \"voice\": \"FunAudioLLM/CosyVoice2-0.5B:alex\", \"output_dir\": \"tmp/\", \"access_token\": \"\", \"response_format\": \"wav\"}', NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_CozeCnTTS', 'TTS', 'CozeCnTTS', 'Coze中文语音合成', 0, 1, '{\"type\": \"cozecn\", \"voice\": \"7426720361733046281\", \"output_dir\": \"tmp/\", \"access_token\": \"\", \"response_format\": \"wav\"}', NULL, NULL, 4, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_FishSpeech', 'TTS', 'FishSpeech', 'FishSpeech语音合成', 0, 1, '{\"type\": \"fishspeech\", \"output_dir\": \"tmp/\", \"response_format\": \"wav\", \"reference_id\": null, \"reference_audio\": [\"/tmp/test.wav\"], \"reference_text\": [\"你弄来这些吟词宴曲来看,还是这些混话来欺负我。\"], \"normalize\": true, \"max_new_tokens\": 1024, \"chunk_length\": 200, \"top_p\": 0.7, \"repetition_penalty\": 1.2, \"temperature\": 0.7, \"streaming\": false, \"use_memory_cache\": \"on\", \"seed\": null, \"channels\": 1, \"rate\": 44100, \"api_key\": \"\", \"api_url\": \"http://127.0.0.1:8080/v1/tts\"}', NULL, NULL, 5, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_GPT_SOVITS_V2', 'TTS', 'GPT_SOVITS_V2', 'GPT-SoVITS V2', 0, 1, '{\"type\": \"gpt_sovits_v2\", \"url\": \"http://127.0.0.1:9880/tts\", \"output_dir\": \"tmp/\", \"text_lang\": \"auto\", \"ref_audio_path\": \"caixukun.wav\", \"prompt_text\": \"\", \"prompt_lang\": \"zh\", \"top_k\": 5, \"top_p\": 1, \"temperature\": 1, \"text_split_method\": \"cut0\", \"batch_size\": 1, \"batch_threshold\": 0.75, \"split_bucket\": true, \"return_fragment\": false, \"speed_factor\": 1.0, \"streaming_mode\": false, \"seed\": -1, \"parallel_infer\": true, \"repetition_penalty\": 1.35, \"aux_ref_audio_paths\": []}', NULL, NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_GPT_SOVITS_V3', 'TTS', 'GPT_SOVITS_V3', 'GPT-SoVITS V3', 0, 1, '{\"type\": \"gpt_sovits_v3\", \"url\": \"http://127.0.0.1:9880\", \"output_dir\": \"tmp/\", \"text_language\": \"auto\", \"refer_wav_path\": \"caixukun.wav\", \"prompt_language\": \"zh\", \"prompt_text\": \"\", \"top_k\": 15, \"top_p\": 1.0, \"temperature\": 1.0, \"cut_punc\": \"\", \"speed\": 1.0, \"inp_refs\": [], \"sample_steps\": 32, \"if_sr\": false}', NULL, NULL, 7, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_MinimaxTTS', 'TTS', 'MinimaxTTS', 'MiniMax语音合成', 0, 1, '{\"type\": \"minimax\", \"output_dir\": \"tmp/\", \"group_id\": \"\", \"api_key\": \"你的api_key\", \"model\": \"speech-01-turbo\", \"voice_id\": \"female-shaonv\"}', NULL, NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_AliyunTTS', 'TTS', 'AliyunTTS', '阿里云语音合成', 0, 1, '{\"type\": \"aliyun\", \"output_dir\": \"tmp/\", \"appkey\": \"\", \"token\": \"\", \"voice\": \"xiaoyun\", \"access_key_id\": \"\", \"access_key_secret\": \"\"}', NULL, NULL, 9, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_TTS302AI', 'TTS', 'TTS302AI', '302AI语音合成', 0, 1, '{\"type\": \"doubao\", \"api_url\": \"https://api.302ai.cn/doubao/tts_hd\", \"authorization\": \"Bearer \", \"voice\": \"zh_female_wanwanxiaohe_moon_bigtts\", \"output_dir\": \"tmp/\", \"access_token\": \"\"}', NULL, NULL, 10, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_GizwitsTTS', 'TTS', 'GizwitsTTS', '机智云语音合成', 0, 1, '{\"type\": \"doubao\", \"api_url\": \"https://bytedance.gizwitsapi.com/api/v1/tts\", \"authorization\": \"Bearer \", \"voice\": \"zh_female_wanwanxiaohe_moon_bigtts\", \"output_dir\": \"tmp/\", \"access_token\": \"\"}', NULL, NULL, 11, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_ACGNTTS', 'TTS', 'ACGNTTS', 'ACGN语音合成', 0, 1, '{\"type\": \"ttson\", \"token\": \"\", \"voice_id\": 1695, \"speed_factor\": 1, \"pitch_factor\": 0, \"volume_change_dB\": 0, \"to_lang\": \"ZH\", \"url\": \"https://u95167-bd74-2aef8085.westx.seetacloud.com:8443/flashsummary/tts?token=\", \"format\": \"mp3\", \"output_dir\": \"tmp/\", \"emotion\": 1}', NULL, NULL, 12, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_OpenAITTS', 'TTS', 'OpenAITTS', 'OpenAI语音合成', 0, 1, '{\"type\": \"openai\", \"api_key\": \"你的api_key\", \"api_url\": \"https://api.openai.com/v1/audio/speech\", \"model\": \"tts-1\", \"voice\": \"onyx\", \"speed\": 1, \"output_dir\": \"tmp/\"}', NULL, NULL, 13, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_CustomTTS', 'TTS', 'CustomTTS', '自定义语音合成', 0, 1, '{\"type\": \"custom\", \"url\": \"http://127.0.0.1:9880/tts\", \"params\": {}, \"headers\": {}, \"format\": \"wav\", \"output_dir\": \"tmp/\"}', NULL, NULL, 14, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_TencentTTS', 'TTS', 'TencentTTS', '腾讯语音合成', 0, 1, '{\"type\": \"tencent\", \"appid\": \"\", \"secret_id\": \"\", \"secret_key\": \"\", \"region\": \"ap-guangzhou\", \"voice\": \"101001\", \"output_dir\": \"tmp/\"}', NULL, NULL, 3, NULL, NULL, NULL, NULL); - --- Memory模型配置 -INSERT INTO `ai_model_config` VALUES ('Memory_nomem', 'Memory', 'nomem', '无记忆', 1, 1, '{\"type\": \"nomem\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('Memory_mem_local_short', 'Memory', 'mem_local_short', '本地短期记忆', 0, 1, '{\"type\": \"mem_local_short\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('Memory_mem0ai', 'Memory', 'mem0ai', 'Mem0AI记忆', 0, 1, '{\"type\": \"mem0ai\", \"api_key\": \"你的api_key\"}', NULL, NULL, 3, NULL, NULL, NULL, NULL); - --- Intent模型配置 -INSERT INTO `ai_model_config` VALUES ('Intent_nointent', 'Intent', 'nointent', '无意图识别', 1, 0, '{\"type\": \"nointent\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('Intent_intent_llm', 'Intent', 'intent_llm', 'LLM意图识别', 0, 1, '{\"type\": \"intent_llm\", \"llm\": \"ChatGLMLLM\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('Intent_function_call', 'Intent', 'function_call', '函数调用意图识别', 0, 1, '{\"type\": \"function_call\", \"functions\": [\"change_role\", \"get_weather\", \"get_news\", \"play_music\"]}', NULL, NULL, 3, NULL, NULL, NULL, NULL); diff --git a/main/manager-api/src/main/resources/db/changelog/202504112058.sql b/main/manager-api/src/main/resources/db/changelog/202504112058.sql deleted file mode 100644 index e19f2da16..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504112058.sql +++ /dev/null @@ -1,61 +0,0 @@ --- 本文件用于初始化系统参数数据,无需手动执行,在项目启动时会自动执行 --- -------------------------------------------------------- --- 初始化参数管理配置 -DROP TABLE IF EXISTS sys_params; --- 参数管理 -create table sys_params -( - id bigint NOT NULL COMMENT 'id', - param_code varchar(100) COMMENT '参数编码', - param_value varchar(2000) COMMENT '参数值', - value_type varchar(20) default 'string' COMMENT '值类型:string-字符串,number-数字,boolean-布尔,array-数组', - 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='参数管理'; - --- 服务器配置 -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (100, 'server.ip', '0.0.0.0', 'string', 1, '服务器监听IP地址'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (101, 'server.port', '8000', 'number', 1, '服务器监听端口'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (102, 'server.secret', 'null', 'string', 1, '服务器密钥'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (201, 'log.log_format', '{time:YYMMDD HH:mm:ss}[{version}-{selected_module}][{extra[tag]}]-{level}-{message}', 'string', 1, '控制台日志格式'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (202, 'log.log_format_file', '{time:YYYY-MM-DD HH:mm:ss} - {version}_{selected_module} - {name} - {level} - {extra[tag]} - {message}', 'string', 1, '文件日志格式'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (203, 'log.log_level', 'INFO', 'string', 1, '日志级别'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (204, 'log.log_dir', 'tmp', 'string', 1, '日志目录'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (205, 'log.log_file', 'server.log', 'string', 1, '日志文件名'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (206, 'log.data_dir', 'data', 'string', 1, '数据目录'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (301, 'delete_audio', 'true', 'boolean', 1, '是否删除使用后的音频文件'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (302, 'close_connection_no_voice_time', '120', 'number', 1, '无语音输入断开连接时间(秒)'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (303, 'tts_timeout', '10', 'number', 1, 'TTS请求超时时间(秒)'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (304, 'enable_wakeup_words_response_cache', 'false', 'boolean', 1, '是否开启唤醒词加速'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (305, 'enable_greeting', 'true', 'boolean', 1, '是否开启开场回复'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (306, 'enable_stop_tts_notify', 'false', 'boolean', 1, '是否开启结束提示音'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (307, 'stop_tts_notify_voice', 'config/assets/tts_notify.mp3', 'string', 1, '结束提示音文件路径'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (308, 'exit_commands', '退出;关闭', 'array', 1, '退出命令列表'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (309, 'xiaozhi', '{ - "type": "hello", - "version": 1, - "transport": "websocket", - "audio_params": { - "format": "opus", - "sample_rate": 16000, - "channels": 1, - "frame_duration": 60 - } -}', 'json', 1, '小智类型'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (310, 'wakeup_words', '你好小智;你好小志;小爱同学;你好小鑫;你好小新;小美同学;小龙小龙;喵喵同学;小滨小滨;小冰小冰', 'array', 1, '唤醒词列表,用于识别唤醒词'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (400, 'plugins.get_weather.api_key', 'a861d0d5e7bf4ee1a83d9a9e4f96d4da', 'string', 1, '天气插件API密钥'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (401, 'plugins.get_weather.default_location', '广州', 'string', 1, '天气插件默认城市'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (410, 'plugins.get_news.default_rss_url', 'https://www.chinanews.com.cn/rss/society.xml', 'string', 1, '新闻插件默认RSS地址'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (411, 'plugins.get_news.category_urls', '{"society":"https://www.chinanews.com.cn/rss/society.xml","world":"https://www.chinanews.com.cn/rss/world.xml","finance":"https://www.chinanews.com.cn/rss/finance.xml"}', 'json', 1, '新闻插件分类RSS地址'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (421, 'plugins.home_assistant.devices', '客厅,玩具灯,switch.cuco_cn_460494544_cp1_on_p_2_1;卧室,台灯,switch.iot_cn_831898993_socn1_on_p_2_1', 'array', 1, 'Home Assistant设备列表'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (422, 'plugins.home_assistant.base_url', 'http://homeassistant.local:8123', 'string', 1, 'Home Assistant服务器地址'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (423, 'plugins.home_assistant.api_key', '你的home assistant api访问令牌', 'string', 1, 'Home Assistant API密钥'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (430, 'plugins.play_music.music_dir', './music', 'string', 1, '音乐文件存放路径'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (431, 'plugins.play_music.music_ext', 'mp3;wav;p3', 'array', 1, '音乐文件类型'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (432, 'plugins.play_music.refresh_time', '300', 'number', 1, '音乐列表刷新间隔(秒)'); diff --git a/main/manager-api/src/main/resources/db/changelog/202504151206.sql b/main/manager-api/src/main/resources/db/changelog/202504151206.sql deleted file mode 100644 index cb51cef9a..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504151206.sql +++ /dev/null @@ -1,28 +0,0 @@ --- 对0.3.0版本之前的参数进行修改 -update `sys_params` set param_value = '.mp3;.wav;.p3' where param_code = 'plugins.play_music.music_ext'; -update `ai_model_config` set config_json = '{\"type\": \"intent_llm\", \"llm\": \"LLM_ChatGLMLLM\"}' where id = 'Intent_intent_llm'; - --- 添加edge音色 -delete from `ai_tts_voice` where tts_model_id = 'TTS_EdgeTTS'; -INSERT INTO `ai_tts_voice` VALUES -('TTS_EdgeTTS0001', 'TTS_EdgeTTS', 'EdgeTTS女声-晓晓', 'zh-CN-XiaoxiaoNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0002', 'TTS_EdgeTTS', 'EdgeTTS男声-云扬', 'zh-CN-YunyangNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0003', 'TTS_EdgeTTS', 'EdgeTTS女声-晓伊', 'zh-CN-XiaoyiNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0004', 'TTS_EdgeTTS', 'EdgeTTS男声-云健', 'zh-CN-YunjianNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0005', 'TTS_EdgeTTS', 'EdgeTTS男声-云希', 'zh-CN-YunxiNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0006', 'TTS_EdgeTTS', 'EdgeTTS男声-云夏', 'zh-CN-YunxiaNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0007', 'TTS_EdgeTTS', 'EdgeTTS女声-辽宁小贝', 'zh-CN-liaoning-XiaobeiNeural', '辽宁', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0008', 'TTS_EdgeTTS', 'EdgeTTS女声-陕西小妮', 'zh-CN-shaanxi-XiaoniNeural', '陕西', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0009', 'TTS_EdgeTTS', 'EdgeTTS女声-香港海佳', 'zh-HK-HiuGaaiNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0010', 'TTS_EdgeTTS', 'EdgeTTS女声-香港海曼', 'zh-HK-HiuMaanNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0011', 'TTS_EdgeTTS', 'EdgeTTS男声-香港万龙', 'zh-HK-WanLungNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL); - --- 增加是否允许用户注册参数 -delete from `sys_params` where id in (103,104); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (103, 'server.allow_user_register', 'false', 'boolean', 1, '是否运行管理员以外的人注册'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (104, 'server.fronted_url', 'http://xiaozhi.server.com', 'string', 1, '下发六位验证码时显示的控制面板地址'); - --- 修正CosyVoiceSiliconflow音色 -delete from `ai_tts_voice` where tts_model_id = 'TTS_CosyVoiceSiliconflow'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_CosyVoiceSiliconflow0001', 'TTS_CosyVoiceSiliconflow', 'CosyVoice男声', 'FunAudioLLM/CosyVoice2-0.5B:alex', '中文', 'https://example.com/cosyvoice/alex.mp3', NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_CosyVoiceSiliconflow0002', 'TTS_CosyVoiceSiliconflow', 'CosyVoice女声', 'FunAudioLLM/CosyVoice2-0.5B:bella', '中文', 'https://example.com/cosyvoice/bella.mp3', NULL, 6, NULL, NULL, NULL, NULL); diff --git a/main/manager-api/src/main/resources/db/changelog/202504181536.sql b/main/manager-api/src/main/resources/db/changelog/202504181536.sql deleted file mode 100644 index 327aa605f..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504181536.sql +++ /dev/null @@ -1,7 +0,0 @@ --- 调整意图识别配置 -delete from `ai_model_config` where id = 'Intent_function_call'; -INSERT INTO `ai_model_config` VALUES ('Intent_function_call', 'Intent', 'function_call', '函数调用意图识别', 0, 1, '{\"type\": \"function_call\", \"functions\": \"change_role;get_weather;get_news;play_music\"}', NULL, NULL, 3, NULL, NULL, NULL, NULL); - --- 增加单台设备每天最多聊天句数 -delete from `sys_params` where id = 105; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (105, 'device_max_output_size', '0', 'number', 1, '单台设备每天最多输出字数,0表示不限制'); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202504221135.sql b/main/manager-api/src/main/resources/db/changelog/202504221135.sql deleted file mode 100644 index 79c80446b..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504221135.sql +++ /dev/null @@ -1,88 +0,0 @@ --- 删除无用模型供应器 -delete from `ai_model_provider` where id = 'SYSTEM_LLM_doubao'; -delete from `ai_model_provider` where id = 'SYSTEM_LLM_chatglm'; -delete from `ai_model_provider` where id = 'SYSTEM_TTS_302ai'; -delete from `ai_model_provider` where id = 'SYSTEM_TTS_gizwits'; - --- 添加模型供应器 -delete from `ai_model_provider` where id = 'SYSTEM_ASR_TencentASR'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_TencentASR', 'ASR', 'tencent', '腾讯语音识别', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"secret_id","label":"Secret ID","type":"string"},{"key":"secret_key","label":"Secret Key","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 4, 1, NOW(), 1, NOW()); - --- 添加腾讯语音合成模型供应器 -delete from `ai_model_provider` where id = 'SYSTEM_TTS_TencentTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_TTS_TencentTTS', 'TTS', 'tencent', '腾讯语音合成', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"secret_id","label":"Secret ID","type":"string"},{"key":"secret_key","label":"Secret Key","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"region","label":"区域","type":"string"},{"key":"voice","label":"音色ID","type":"string"}]', 5, 1, NOW(), 1, NOW()); - - --- 添加edge音色 -delete from `ai_tts_voice` where id in ('TTS_EdgeTTS0001', 'TTS_EdgeTTS0002', 'TTS_EdgeTTS0003', 'TTS_EdgeTTS0004', 'TTS_EdgeTTS0005', 'TTS_EdgeTTS0006', 'TTS_EdgeTTS0007', 'TTS_EdgeTTS0008', 'TTS_EdgeTTS0009', 'TTS_EdgeTTS0010', 'TTS_EdgeTTS0011'); -INSERT INTO `ai_tts_voice` VALUES -('TTS_EdgeTTS0001', 'TTS_EdgeTTS', 'EdgeTTS女声-晓晓', 'zh-CN-XiaoxiaoNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0002', 'TTS_EdgeTTS', 'EdgeTTS男声-云扬', 'zh-CN-YunyangNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0003', 'TTS_EdgeTTS', 'EdgeTTS女声-晓伊', 'zh-CN-XiaoyiNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0004', 'TTS_EdgeTTS', 'EdgeTTS男声-云健', 'zh-CN-YunjianNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0005', 'TTS_EdgeTTS', 'EdgeTTS男声-云希', 'zh-CN-YunxiNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0006', 'TTS_EdgeTTS', 'EdgeTTS男声-云夏', 'zh-CN-YunxiaNeural', '普通话', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0007', 'TTS_EdgeTTS', 'EdgeTTS女声-辽宁小贝', 'zh-CN-liaoning-XiaobeiNeural', '辽宁', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0008', 'TTS_EdgeTTS', 'EdgeTTS女声-陕西小妮', 'zh-CN-shaanxi-XiaoniNeural', '陕西', NULL, NULL, 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0009', 'TTS_EdgeTTS', 'EdgeTTS女声-香港海佳', 'zh-HK-HiuGaaiNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0010', 'TTS_EdgeTTS', 'EdgeTTS女声-香港海曼', 'zh-HK-HiuMaanNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL), -('TTS_EdgeTTS0011', 'TTS_EdgeTTS', 'EdgeTTS男声-香港万龙', 'zh-HK-WanLungNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL); - --- DoubaoTTS音色 -delete from `ai_tts_voice` where id in ('TTS_DoubaoTTS0001', 'TTS_DoubaoTTS0002', 'TTS_DoubaoTTS0003', 'TTS_DoubaoTTS0004', 'TTS_DoubaoTTS0005'); -INSERT INTO `ai_tts_voice` VALUES ('TTS_DoubaoTTS0001', 'TTS_DoubaoTTS', '通用女声', 'BV001_streaming', '普通话', 'https://lf3-speech.bytetos.com/obj/speech-tts-external/portal/Portal_Demo_BV001.mp3', NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_DoubaoTTS0002', 'TTS_DoubaoTTS', '通用男声', 'BV002_streaming', '普通话', 'https://lf3-speech.bytetos.com/obj/speech-tts-external/portal/Portal_Demo_BV002.mp3', NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_DoubaoTTS0003', 'TTS_DoubaoTTS', '阳光男生', 'BV056_streaming', '普通话', 'https://lf3-speech.bytetos.com/obj/speech-tts-external/portal/Portal_Demo_BV056.mp3', NULL, 4, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_DoubaoTTS0004', 'TTS_DoubaoTTS', '奶气萌娃', 'BV051_streaming', '普通话', 'https://lf3-speech.bytetos.com/obj/speech-tts-external/portal/Portal_Demo_BV051.mp3', NULL, 5, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_DoubaoTTS0005', 'TTS_DoubaoTTS', '湾湾小何', 'zh_female_wanwanxiaohe_moon_bigtts', '普通话', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%B9%BE%E6%B9%BE%E5%B0%8F%E4%BD%95.mp3', NULL, 6, NULL, NULL, NULL, NULL); - --- 修正CosyVoiceSiliconflow音色 -delete from `ai_tts_voice` where id in ('TTS_CosyVoiceSiliconflow0001', 'TTS_CosyVoiceSiliconflow0002'); -INSERT INTO `ai_tts_voice` VALUES ('TTS_CosyVoiceSiliconflow0001', 'TTS_CosyVoiceSiliconflow', 'CosyVoice男声', 'FunAudioLLM/CosyVoice2-0.5B:alex', '中文', NULL, NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_CosyVoiceSiliconflow0002', 'TTS_CosyVoiceSiliconflow', 'CosyVoice女声', 'FunAudioLLM/CosyVoice2-0.5B:bella', '中文', NULL, NULL, 6, NULL, NULL, NULL, NULL); - --- CozeCnTTS音色 -delete from `ai_tts_voice` where id = 'TTS_CozeCnTTS0001'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_CozeCnTTS0001', 'TTS_CozeCnTTS', 'CozeCn音色', '7426720361733046281', '中文', NULL, NULL, 7, NULL, NULL, NULL, NULL); - --- MinimaxTTS音色 -delete from `ai_tts_voice` where id = 'TTS_MinimaxTTS0001'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxTTS0001', 'TTS_MinimaxTTS', 'Minimax少女音', 'female-shaonv', '中文', NULL, NULL, 8, NULL, NULL, NULL, NULL); - --- AliyunTTS音色 -delete from `ai_tts_voice` where id = 'TTS_AliyunTTS0001'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunTTS0001', 'TTS_AliyunTTS', '阿里云小云', 'xiaoyun', '中文', NULL, NULL, 9, NULL, NULL, NULL, NULL); - --- TTS302AI音色 -delete from `ai_tts_voice` where id = 'TTS_TTS302AI0001'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_TTS302AI0001', 'TTS_TTS302AI', '湾湾小何', 'zh_female_wanwanxiaohe_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%B9%BE%E6%B9%BE%E5%B0%8F%E4%BD%95.mp3', NULL, 10, NULL, NULL, NULL, NULL); - --- GizwitsTTS音色 -delete from `ai_tts_voice` where id = 'TTS_GizwitsTTS0001'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_GizwitsTTS0001', 'TTS_GizwitsTTS', '机智云湾湾', 'zh_female_wanwanxiaohe_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%B9%BE%E6%B9%BE%E5%B0%8F%E4%BD%95.mp3', NULL, 11, NULL, NULL, NULL, NULL); - --- ACGNTTS音色 -delete from `ai_tts_voice` where id = 'TTS_ACGNTTS0001'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_ACGNTTS0001', 'TTS_ACGNTTS', 'ACG音色', '1695', '中文', NULL, NULL, 12, NULL, NULL, NULL, NULL); - --- OpenAITTS音色 -delete from `ai_tts_voice` where id = 'TTS_OpenAITTS0001'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_OpenAITTS0001', 'TTS_OpenAITTS', 'OpenAI男声', 'onyx', '中文', NULL, NULL, 13, NULL, NULL, NULL, NULL); - --- 添加腾讯语音合成音色 -delete from `ai_tts_voice` where id = 'TTS_TencentTTS0001'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_TencentTTS0001', 'TTS_TencentTTS', '智瑜', '101001', '中文', NULL, NULL, 1, NULL, NULL, NULL, NULL); - --- 其他音色 -delete from `ai_tts_voice` where id = 'TTS_FishSpeech0000'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_FishSpeech0000', 'TTS_FishSpeech', '', '', '中文', '', NULL, 8, NULL, NULL, NULL, NULL); - -delete from `ai_tts_voice` where id = 'TTS_GPT_SOVITS_V20000'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_GPT_SOVITS_V20000', 'TTS_GPT_SOVITS_V2', '', '', '中文', '', NULL, 8, NULL, NULL, NULL, NULL); - -delete from `ai_tts_voice` where id in ('TTS_GPT_SOVITS_V30000', 'TTS_CustomTTS0000'); -INSERT INTO `ai_tts_voice` VALUES ('TTS_GPT_SOVITS_V30000', 'TTS_GPT_SOVITS_V3', '', '', '中文', '', NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_CustomTTS0000', 'TTS_CustomTTS', '', '', '中文', '', NULL, 8, NULL, NULL, NULL, NULL); - diff --git a/main/manager-api/src/main/resources/db/changelog/202504221555.sql b/main/manager-api/src/main/resources/db/changelog/202504221555.sql deleted file mode 100644 index e80a8a8d6..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504221555.sql +++ /dev/null @@ -1,49 +0,0 @@ --- 添加火山引擎边缘大模型网关(LLM + TTS) -INSERT INTO `ai_model_config` VALUES ('LLM_VolcesAiGatewayLLM', 'LLM', 'VolcesAiGatewayTTS', '火山引擎边缘大模型网关', 0, 1, '{\"type\": \"openai\", \"base_url\": \"https://ai-gateway.vei.volces.com/v1\", \"model_name\": \"doubao-pro-32k-functioncall\", \"api_key\": \"你的网关访问密钥\"}', NULL, NULL, 14, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('TTS_VolcesAiGatewayTTS', 'TTS', 'VolcesAiGatewayTTS', '火山引擎边缘大模型网关', 0, 1, '{\"type\": \"openai\", \"api_key\": \"你的网关访问密钥\", \"api_url\": \"https://ai-gateway.vei.volces.com/v1/audio/speech\", \"model\": \"doubao-tts\", \"voice\": \"zh_male_shaonianzixin_moon_bigtts\", \"speed\": 1, \"output_dir\": \"tmp/\"}', NULL, NULL, 15, NULL, NULL, NULL, NULL); --- 添加火山引擎边缘大模型网关语音合成音色 -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0001', 'TTS_VolcesAiGatewayTTS', '灿灿/Shiny', 'zh_female_cancan_mars_bigtts', '中文、美式英语', NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0002', 'TTS_VolcesAiGatewayTTS', '清新女声', 'zh_female_qingxinnvsheng_mars_bigtts', '中文', NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0003', 'TTS_VolcesAiGatewayTTS', '爽快思思/Skye', 'zh_female_shuangkuaisisi_moon_bigtts', '中文、美式英语', NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0004', 'TTS_VolcesAiGatewayTTS', '温暖阿虎/Alvin', 'zh_male_wennuanahu_moon_bigtts', '中文、美式英语', NULL, NULL, 4, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0005', 'TTS_VolcesAiGatewayTTS', '少年梓辛/Brayan', 'zh_male_shaonianzixin_moon_bigtts', '中文、美式英语', NULL, NULL, 5, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0006', 'TTS_VolcesAiGatewayTTS', '知性女声', 'zh_female_zhixingnvsheng_mars_bigtts', '中文', NULL, NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0007', 'TTS_VolcesAiGatewayTTS', '清爽男大', 'zh_male_qingshuangnanda_mars_bigtts', '中文', NULL, NULL, 7, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0008', 'TTS_VolcesAiGatewayTTS', '邻家女孩', 'zh_female_linjianvhai_moon_bigtts', '中文', NULL, NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0009', 'TTS_VolcesAiGatewayTTS', '渊博小叔', 'zh_male_yuanboxiaoshu_moon_bigtts', '中文', NULL, NULL, 9, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0010', 'TTS_VolcesAiGatewayTTS', '阳光青年', 'zh_male_yangguangqingnian_moon_bigtts', '中文', NULL, NULL, 10, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0011', 'TTS_VolcesAiGatewayTTS', '甜美小源', 'zh_female_tianmeixiaoyuan_moon_bigtts', '中文', NULL, NULL, 11, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0012', 'TTS_VolcesAiGatewayTTS', '清澈梓梓', 'zh_female_qingchezizi_moon_bigtts', '中文', NULL, NULL, 12, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0013', 'TTS_VolcesAiGatewayTTS', '解说小明', 'zh_male_jieshuoxiaoming_moon_bigtts', '中文', NULL, NULL, 13, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0014', 'TTS_VolcesAiGatewayTTS', '开朗姐姐', 'zh_female_kailangjiejie_moon_bigtts', '中文', NULL, NULL, 14, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0015', 'TTS_VolcesAiGatewayTTS', '邻家男孩', 'zh_male_linjiananhai_moon_bigtts', '中文', NULL, NULL, 15, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0016', 'TTS_VolcesAiGatewayTTS', '甜美悦悦', 'zh_female_tianmeiyueyue_moon_bigtts', '中文', NULL, NULL, 16, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0017', 'TTS_VolcesAiGatewayTTS', '心灵鸡汤', 'zh_female_xinlingjitang_moon_bigtts', '中文', NULL, NULL, 17, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0018', 'TTS_VolcesAiGatewayTTS', '知性温婉', 'ICL_zh_female_zhixingwenwan_tob', '中文', NULL, NULL, 18, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0019', 'TTS_VolcesAiGatewayTTS', '暖心体贴', 'ICL_zh_male_nuanxintitie_tob', '中文', NULL, NULL, 19, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0020', 'TTS_VolcesAiGatewayTTS', '温柔文雅', 'ICL_zh_female_wenrouwenya_tob', '中文', NULL, NULL, 20, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0021', 'TTS_VolcesAiGatewayTTS', '开朗轻快', 'ICL_zh_male_kailangqingkuai_tob', '中文', NULL, NULL, 21, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0022', 'TTS_VolcesAiGatewayTTS', '活泼爽朗', 'ICL_zh_male_huoposhuanglang_tob', '中文', NULL, NULL, 22, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0023', 'TTS_VolcesAiGatewayTTS', '率真小伙', 'ICL_zh_male_shuaizhenxiaohuo_tob', '中文', NULL, NULL, 23, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0024', 'TTS_VolcesAiGatewayTTS', '温柔小哥', 'zh_male_wenrouxiaoge_mars_bigtts', '中文', NULL, NULL, 24, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0025', 'TTS_VolcesAiGatewayTTS', 'Smith', 'en_male_smith_mars_bigtts', '英式英语', NULL, NULL, 25, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0026', 'TTS_VolcesAiGatewayTTS', 'Anna', 'en_female_anna_mars_bigtts', '英式英语', NULL, NULL, 26, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0027', 'TTS_VolcesAiGatewayTTS', 'Adam', 'en_male_adam_mars_bigtts', '美式英语', NULL, NULL, 27, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0028', 'TTS_VolcesAiGatewayTTS', 'Sarah', 'en_female_sarah_mars_bigtts', '澳洲英语', NULL, NULL, 28, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0029', 'TTS_VolcesAiGatewayTTS', 'Dryw', 'en_male_dryw_mars_bigtts', '澳洲英语', NULL, NULL, 29, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0030', 'TTS_VolcesAiGatewayTTS', 'かずね(和音)', 'multi_male_jingqiangkanye_moon_bigtts', '日语、西语', NULL, NULL, 30, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0031', 'TTS_VolcesAiGatewayTTS', 'はるこ(晴子)', 'multi_female_shuangkuaisisi_moon_bigtts', '日语、西语', NULL, NULL, 31, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0032', 'TTS_VolcesAiGatewayTTS', 'ひろし(広志)', 'multi_male_wanqudashu_moon_bigtts', '日语、西语', NULL, NULL, 32, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0033', 'TTS_VolcesAiGatewayTTS', 'あけみ(朱美)', 'multi_female_gaolengyujie_moon_bigtts', '日语', NULL, NULL, 33, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0034', 'TTS_VolcesAiGatewayTTS', 'Amanda', 'en_female_amanda_mars_bigtts', '美式英语', NULL, NULL, 34, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0035', 'TTS_VolcesAiGatewayTTS', 'Jackson', 'en_male_jackson_mars_bigtts', '美式英语', NULL, NULL, 35, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0036', 'TTS_VolcesAiGatewayTTS', '京腔侃爷/Harmony', 'zh_male_jingqiangkanye_moon_bigtts', '中文-北京口音、英文', NULL, NULL, 36, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0037', 'TTS_VolcesAiGatewayTTS', '湾湾小何', 'zh_female_wanwanxiaohe_moon_bigtts', '中文-台湾口音', NULL, NULL, 37, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0038', 'TTS_VolcesAiGatewayTTS', '湾区大叔', 'zh_female_wanqudashu_moon_bigtts', '中文-广东口音', NULL, NULL, 38, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0039', 'TTS_VolcesAiGatewayTTS', '呆萌川妹', 'zh_female_daimengchuanmei_moon_bigtts', '中文-四川口音', NULL, NULL, 39, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0040', 'TTS_VolcesAiGatewayTTS', '广州德哥', 'zh_male_guozhoudege_moon_bigtts', '中文-广东口音', NULL, NULL, 40, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0041', 'TTS_VolcesAiGatewayTTS', '北京小爷', 'zh_male_beijingxiaoye_moon_bigtts', '中文-北京口音', NULL, NULL, 41, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0042', 'TTS_VolcesAiGatewayTTS', '浩宇小哥', 'zh_male_haoyuxiaoge_moon_bigtts', '中文-青岛口音', NULL, NULL, 42, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0043', 'TTS_VolcesAiGatewayTTS', '广西远舟', 'zh_male_guangxiyuanzhou_moon_bigtts', '中文-广西口音', NULL, NULL, 43, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0044', 'TTS_VolcesAiGatewayTTS', '妹坨洁儿', 'zh_female_meituojieer_moon_bigtts', '中文-长沙口音', NULL, NULL, 44, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_VolcesAiGatewayTTS_0045', 'TTS_VolcesAiGatewayTTS', '豫州子轩', 'zh_male_yuzhouzixuan_moon_bigtts', '中文-河南口音', NULL, NULL, 45, NULL, NULL, NULL, NULL); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202504251422.sql b/main/manager-api/src/main/resources/db/changelog/202504251422.sql deleted file mode 100644 index 88e03fea3..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504251422.sql +++ /dev/null @@ -1,30 +0,0 @@ --- 增加server.ota,用于配置ota地址 - -delete from `sys_params` where id = 100; -delete from `sys_params` where id = 101; - -delete from `sys_params` where id = 106; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (106, 'server.websocket', 'null', 'string', 1, 'websocket地址,多个用;分隔'); - -delete from `sys_params` where id = 107; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (107, 'server.ota', 'null', 'string', 1, 'ota地址'); - - --- 增加固件信息表 -CREATE TABLE IF NOT EXISTS `ai_ota` ( - `id` varchar(32) NOT NULL COMMENT 'ID', - `firmware_name` varchar(100) DEFAULT NULL COMMENT '固件名称', - `type` varchar(50) DEFAULT NULL COMMENT '固件类型', - `version` varchar(50) DEFAULT NULL COMMENT '版本号', - `size` bigint DEFAULT NULL COMMENT '文件大小(字节)', - `remark` varchar(500) DEFAULT NULL COMMENT '备注/说明', - `firmware_path` varchar(255) DEFAULT NULL COMMENT '固件路径', - `sort` int unsigned DEFAULT '0' COMMENT '排序', - `updater` bigint DEFAULT NULL COMMENT '更新者', - `update_date` datetime DEFAULT NULL COMMENT '更新时间', - `creator` bigint DEFAULT NULL COMMENT '创建者', - `create_date` datetime DEFAULT NULL COMMENT '创建时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='固件信息表'; - -update ai_device set auto_update = 1; diff --git a/main/manager-api/src/main/resources/db/changelog/202504291043.sql b/main/manager-api/src/main/resources/db/changelog/202504291043.sql deleted file mode 100644 index 555b8cf4f..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504291043.sql +++ /dev/null @@ -1,504 +0,0 @@ --- 增加FunASR服务语音识别模型供应器和配置 -DELETE FROM `ai_model_provider` WHERE `id` = 'SYSTEM_ASR_FunASRServer'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_FunASRServer', 'ASR', 'fun_server', 'FunASR服务语音识别', '[{"key":"host","label":"服务地址","type":"string"},{"key":"port","label":"端口号","type":"number"}]', 4, 1, NOW(), 1, NOW()); - -DELETE FROM `ai_model_config` WHERE `id` = 'ASR_FunASRServer'; -INSERT INTO `ai_model_config` VALUES ('ASR_FunASRServer', 'ASR', 'FunASRServer', 'FunASR服务语音识别', 0, 1, '{\"type\": \"fun_server\", \"host\": \"127.0.0.1\", \"port\": 10096}', NULL, NULL, 5, NULL, NULL, NULL, NULL); - --- 修改ai_model_config表的remark字段类型为TEXT -ALTER TABLE `ai_model_config` MODIFY COLUMN `remark` TEXT COMMENT '备注'; - --- 更新ASR模型配置的说明文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/modelscope/FunASR/blob/main/runtime/docs/SDK_advanced_guide_online_zh.md', -`remark` = '独立部署FunASR,使用FunASR的API服务,只需要五句话 -第一句:mkdir -p ./funasr-runtime-resources/models -第二句:sudo docker run -d -p 10096:10095 --privileged=true -v $PWD/funasr-runtime-resources/models:/workspace/models registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.12 -上一句话执行后会进入到容器,继续第三句:cd FunASR/runtime -不要退出容器,继续在容器中执行第四句:nohup bash run_server_2pass.sh --download-model-dir /workspace/models --vad-dir damo/speech_fsmn_vad_zh-cn-16k-common-onnx --model-dir damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-onnx --online-model-dir damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx --punc-dir damo/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx --lm-dir damo/speech_ngram_lm_zh-cn-ai-wesp-fst --itn-dir thuduj12/fst_itn_zh --hotword /workspace/models/hotwords.txt > log.txt 2>&1 & -上一句话执行后会进入到容器,继续第五句:tail -f log.txt -第五句话执行完后,会看到模型下载日志,下载完后就可以连接使用了 -以上是使用CPU推理,如果有GPU,详细参考:https://github.com/modelscope/FunASR/blob/main/runtime/docs/SDK_advanced_guide_online_zh.md' WHERE `id` = 'ASR_FunASRServer'; - --- 更新FunASR本地模型配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/modelscope/FunASR', -`remark` = 'FunASR本地模型配置说明: -1. 需要下载模型文件到xiaozhi-server/models/SenseVoiceSmall目录 -2. 支持中日韩粤语音识别 -3. 本地推理,无需网络连接 -4. 待识别文件保存在tmp/目录' WHERE `id` = 'ASR_FunASR'; - --- 更新SherpaASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/k2-fsa/sherpa-onnx', -`remark` = 'SherpaASR配置说明: -1. 运行时自动下载模型文件到models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17目录 -2. 支持中文、英文、日语、韩语、粤语等多种语言 -3. 本地推理,无需网络连接 -4. 输出文件保存在tmp/目录' WHERE `id` = 'ASR_SherpaASR'; - --- 更新豆包ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/speech/app', -`remark` = '豆包ASR配置说明: -1. 需要在火山引擎控制台创建应用并获取appid和access_token -2. 支持中文语音识别 -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://console.volcengine.com/speech/app -2. 创建新应用 -3. 获取appid和access_token -4. 填入配置文件中' WHERE `id` = 'ASR_DoubaoASR'; - --- 更新腾讯ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.cloud.tencent.com/cam/capi', -`remark` = '腾讯ASR配置说明: -1. 需要在腾讯云控制台创建应用并获取appid、secret_id和secret_key -2. 支持中文语音识别 -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://console.cloud.tencent.com/cam/capi 获取密钥 -2. 访问 https://console.cloud.tencent.com/asr/resourcebundle 领取免费资源 -3. 获取appid、secret_id和secret_key -4. 填入配置文件中' WHERE `id` = 'ASR_TencentASR'; - --- 更新TTS模型配置说明 --- EdgeTTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/rany2/edge-tts', -`remark` = 'EdgeTTS配置说明: -1. 使用微软Edge TTS服务 -2. 支持多种语言和音色 -3. 免费使用,无需注册 -4. 需要网络连接 -5. 输出文件保存在tmp/目录' WHERE `id` = 'TTS_EdgeTTS'; - --- 豆包TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/speech/service/8', -`remark` = '豆包TTS配置说明: -1. 访问 https://console.volcengine.com/speech/service/8 -2. 需要在火山引擎控制台创建应用并获取appid和access_token -3. 山引擎语音一定要购买花钱,起步价30元,就有100并发了。如果用免费的只有2个并发,会经常报tts错误 -4. 购买服务后,购买免费的音色后,可能要等半小时左右,才能使用。 -5. 填入配置文件中' WHERE `id` = 'TTS_DoubaoTTS'; - --- 硅基流动TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://cloud.siliconflow.cn/account/ak', -`remark` = '硅基流动TTS配置说明: -1. 访问 https://cloud.siliconflow.cn/account/ak -2. 注册并获取API密钥 -3. 填入配置文件中' WHERE `id` = 'TTS_CosyVoiceSiliconflow'; - --- Coze中文TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://www.coze.cn/open/oauth/pats', -`remark` = 'Coze中文TTS配置说明: -1. 访问 https://www.coze.cn/open/oauth/pats -2. 获取个人令牌 -3. 填入配置文件中' WHERE `id` = 'TTS_CozeCnTTS'; - --- FishSpeech配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/fishaudio/fish-speech', -`remark` = 'FishSpeech配置说明: -1. 需要本地部署FishSpeech服务 -2. 支持自定义音色 -3. 本地推理,无需网络连接 -4. 输出文件保存在tmp/目录 -5. 运行服务示例命令:python -m tools.api_server --listen 0.0.0.0:8080 --llama-checkpoint-path "checkpoints/fish-speech-1.5" --decoder-checkpoint-path "checkpoints/fish-speech-1.5/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" --decoder-config-name firefly_gan_vq --compile' WHERE `id` = 'TTS_FishSpeech'; - --- GPT-SoVITS V2配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/RVC-Boss/GPT-SoVITS', -`remark` = 'GPT-SoVITS V2配置说明: -1. 需要本地部署GPT-SoVITS服务 -2. 支持自定义音色克隆 -3. 本地推理,无需网络连接 -4. 输出文件保存在tmp/目录 -部署步骤: -1. 运行服务示例命令:python api_v2.py -a 127.0.0.1 -p 9880 -c GPT_SoVITS/configs/demo.yaml' WHERE `id` = 'TTS_GPT_SOVITS_V2'; - --- GPT-SoVITS V3配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/RVC-Boss/GPT-SoVITS', -`remark` = 'GPT-SoVITS V3配置说明: -1. 需要本地部署GPT-SoVITS V3服务 -2. 支持自定义音色克隆 -3. 本地推理,无需网络连接 -4. 输出文件保存在tmp/目录' WHERE `id` = 'TTS_GPT_SOVITS_V3'; - --- MiniMax TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://platform.minimaxi.com/', -`remark` = 'MiniMax TTS配置说明: -1. 需要在MiniMax平台创建账户并充值 -2. 支持多种音色,当前配置使用female-shaonv -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://platform.minimaxi.com/ 注册账号 -2. 访问 https://platform.minimaxi.com/user-center/payment/balance 充值 -3. 访问 https://platform.minimaxi.com/user-center/basic-information 获取group_id -4. 访问 https://platform.minimaxi.com/user-center/basic-information/interface-key 获取api_key -5. 填入配置文件中' WHERE `id` = 'TTS_MinimaxTTS'; - --- 阿里云TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://nls-portal.console.aliyun.com/', -`remark` = '阿里云TTS配置说明: -1. 需要在阿里云平台开通智能语音交互服务 -2. 支持多种音色,当前配置使用xiaoyun -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://nls-portal.console.aliyun.com/ 开通服务 -2. 访问 https://nls-portal.console.aliyun.com/applist 获取appkey -3. 访问 https://nls-portal.console.aliyun.com/overview 获取token -4. 填入配置文件中 -注意:token是临时的24小时有效,长期使用需要配置access_key_id和access_key_secret' WHERE `id` = 'TTS_AliyunTTS'; - --- 腾讯TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.cloud.tencent.com/cam/capi', -`remark` = '腾讯TTS配置说明: -1. 需要在腾讯云平台开通智能语音交互服务 -2. 支持多种音色,当前配置使用101001 -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://console.cloud.tencent.com/cam/capi 获取密钥 -2. 访问 https://console.cloud.tencent.com/tts/resourcebundle 领取免费资源 -3. 创建新应用 -4. 获取appid、secret_id和secret_key -5. 填入配置文件中' WHERE `id` = 'TTS_TencentTTS'; - --- 302AI TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://dash.302.ai/', -`remark` = '302AI TTS配置说明: -1. 需要在302平台创建账户并获取API密钥 -2. 支持多种音色,当前配置使用湾湾小何音色 -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://dash.302.ai/ 注册账号 -2. 访问 https://dash.302.ai/apis/list 获取API密钥 -3. 填入配置文件中 -价格:$35/百万字符' WHERE `id` = 'TTS_TTS302AI'; - --- 机智云TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://agentrouter.gizwitsapi.com/panel/token', -`remark` = '机智云TTS配置说明: -1. 需要在机智云平台获取API密钥 -2. 支持多种音色,当前配置使用湾湾小何音色 -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://agentrouter.gizwitsapi.com/panel/token 获取API密钥 -2. 填入配置文件中 -注意:前一万名注册的用户,将送5元体验金额' WHERE `id` = 'TTS_GizwitsTTS'; - --- ACGN TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://acgn.ttson.cn/', -`remark` = 'ACGN TTS配置说明: -1. 需要在ttson平台购买token -2. 支持多种角色音色,当前配置使用角色ID:1695 -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://acgn.ttson.cn/ 查看角色列表 -2. 访问 www.ttson.cn 购买token -3. 填入配置文件中 -开发相关疑问请提交至网站上的qq' WHERE `id` = 'TTS_ACGNTTS'; - --- OpenAI TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://platform.openai.com/api-keys', -`remark` = 'OpenAI TTS配置说明: -1. 需要在OpenAI平台获取API密钥 -2. 支持多种音色,当前配置使用onyx -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://platform.openai.com/api-keys 获取API密钥 -2. 填入配置文件中 -注意:国内需要使用代理访问' WHERE `id` = 'TTS_OpenAITTS'; - --- 自定义TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = '自定义TTS配置说明: -1. 支持自定义TTS接口服务 -2. 使用GET方式请求 -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -配置说明: -1. 在params中配置请求参数 -2. 在headers中配置请求头 -3. 设置返回音频格式' WHERE `id` = 'TTS_CustomTTS'; - --- 火山引擎边缘大模型网关TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/vei/aigateway/', -`remark` = '火山引擎边缘大模型网关TTS配置说明: -1. 访问 https://console.volcengine.com/vei/aigateway/ -2. 创建网关访问密钥,搜索并勾选 Doubao-语音合成 -3. 如果需要使用LLM,一并勾选 Doubao-pro-32k-functioncall -4. 访问 https://console.volcengine.com/vei/aigateway/tokens-list 获取密钥 -5. 填入配置文件中 -音色列表参考:https://www.volcengine.com/docs/6561/1257544' WHERE `id` = 'TTS_VolcesAiGatewayTTS'; - --- 更新LLM模型配置说明 --- ChatGLM配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://bigmodel.cn/usercenter/proj-mgmt/apikeys', -`remark` = 'ChatGLM配置说明: -1. 访问 https://bigmodel.cn/usercenter/proj-mgmt/apikeys -2. 注册并获取API密钥 -3. 填入配置文件中' WHERE `id` = 'LLM_ChatGLMLLM'; - --- Ollama配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://ollama.com/', -`remark` = 'Ollama配置说明: -1. 安装Ollama服务 -2. 运行命令:ollama pull qwen2.5 -3. 确保服务运行在http://localhost:11434' WHERE `id` = 'LLM_OllamaLLM'; - --- 通义千问配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://bailian.console.aliyun.com/?apiKey=1#/api-key', -`remark` = '通义千问配置说明: -1. 访问 https://bailian.console.aliyun.com/?apiKey=1#/api-key -2. 获取API密钥 -3. 填入配置文件中,当前配置使用qwen-turbo模型 -4. 支持自定义参数:temperature=0.7, max_tokens=500, top_p=1, top_k=50' WHERE `id` = 'LLM_AliLLM'; - --- 通义百炼配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://bailian.console.aliyun.com/?apiKey=1#/api-key', -`remark` = '通义百炼配置说明: -1. 访问 https://bailian.console.aliyun.com/?apiKey=1#/api-key -2. 获取app_id和api_key -3. 填入配置文件中' WHERE `id` = 'LLM_AliAppLLM'; - --- 豆包大模型配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/ark/region:ark+cn-beijing/openManagement', -`remark` = '豆包大模型配置说明: -1. 访问 https://console.volcengine.com/ark/region:ark+cn-beijing/openManagement -2. 开通Doubao-1.5-pro服务 -3. 访问 https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey 获取API密钥 -4. 填入配置文件中 -5. 当前建议使用doubao-1-5-pro-32k-250115 -注意:有免费额度500000token' WHERE `id` = 'LLM_DoubaoLLM'; - --- DeepSeek配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://platform.deepseek.com/', -`remark` = 'DeepSeek配置说明: -1. 访问 https://platform.deepseek.com/ -2. 注册并获取API密钥 -3. 填入配置文件中' WHERE `id` = 'LLM_DeepSeekLLM'; - --- Dify配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://cloud.dify.ai/', -`remark` = 'Dify配置说明: -1. 访问 https://cloud.dify.ai/ -2. 注册并获取API密钥 -3. 填入配置文件中 -4. 支持多种对话模式:workflows/run, chat-messages, completion-messages -5. 平台设置的角色定义会失效,需要在Dify控制台设置 -注意:建议使用本地部署的Dify接口,国内部分区域访问公有云接口可能受限' WHERE `id` = 'LLM_DifyLLM'; - --- Gemini配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://aistudio.google.com/apikey', -`remark` = 'Gemini配置说明: -1. 使用谷歌Gemini API服务 -2. 当前配置使用gemini-2.0-flash模型 -3. 需要网络连接 -4. 支持配置代理 -申请步骤: -1. 访问 https://aistudio.google.com/apikey -2. 创建API密钥 -3. 填入配置文件中 -注意:若在中国境内使用,请遵守《生成式人工智能服务管理暂行办法》' WHERE `id` = 'LLM_GeminiLLM'; - --- Coze配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://www.coze.cn/open/oauth/pats', -`remark` = 'Coze配置说明: -1. 使用Coze平台服务 -2. 需要bot_id、user_id和个人令牌 -3. 需要网络连接 -申请步骤: -1. 访问 https://www.coze.cn/open/oauth/pats -2. 获取个人令牌 -3. 手动计算bot_id和user_id -4. 填入配置文件中' WHERE `id` = 'LLM_CozeLLM'; - --- LM Studio配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://lmstudio.ai/', -`remark` = 'LM Studio配置说明: -1. 使用本地部署的LM Studio服务 -2. 当前配置使用deepseek-r1-distill-llama-8b@q4_k_m模型 -3. 本地推理,无需网络连接 -4. 需要预先下载模型 -部署步骤: -1. 安装LM Studio -2. 从社区下载模型 -3. 确保服务运行在http://localhost:1234/v1' WHERE `id` = 'LLM_LMStudioLLM'; - --- FastGPT配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://cloud.tryfastgpt.ai/account/apikey', -`remark` = 'FastGPT配置说明: -1. 使用FastGPT平台服务 -2. 需要网络连接 -3. 配置文件中的prompt无效,需要在FastGPT控制台设置 -4. 支持自定义变量 -申请步骤: -1. 访问 https://cloud.tryfastgpt.ai/account/apikey -2. 获取API密钥 -3. 填入配置文件中' WHERE `id` = 'LLM_FastgptLLM'; - --- Xinference配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/xorbitsai/inference', -`remark` = 'Xinference配置说明: -1. 使用本地部署的Xinference服务 -2. 当前配置使用qwen2.5:72b-AWQ模型 -3. 本地推理,无需网络连接 -4. 需要预先启动对应模型 -部署步骤: -1. 安装Xinference -2. 启动服务并加载模型 -3. 确保服务运行在http://localhost:9997' WHERE `id` = 'LLM_XinferenceLLM'; - --- Xinference小模型配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/xorbitsai/inference', -`remark` = 'Xinference小模型配置说明: -1. 使用本地部署的Xinference服务 -2. 当前配置使用qwen2.5:3b-AWQ模型 -3. 本地推理,无需网络连接 -4. 用于意图识别 -部署步骤: -1. 安装Xinference -2. 启动服务并加载模型 -3. 确保服务运行在http://localhost:9997' WHERE `id` = 'LLM_XinferenceSmallLLM'; - --- 火山引擎边缘大模型网关LLM配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/vei/aigateway/', -`remark` = '火山引擎边缘大模型网关LLM配置说明: -1. 使用火山引擎边缘大模型网关服务 -2. 需要网关访问密钥 -3. 需要网络连接 -4. 支持function_call功能 -申请步骤: -1. 访问 https://console.volcengine.com/vei/aigateway/ -2. 创建网关访问密钥,搜索并勾选 Doubao-pro-32k-functioncall -3. 如果需要使用语音合成,一并勾选 Doubao-语音合成 -4. 访问 https://console.volcengine.com/vei/aigateway/tokens-list 获取密钥 -5. 填入配置文件中' WHERE `id` = 'LLM_VolcesAiGatewayLLM'; - --- 更新Memory模型配置说明 --- 无记忆配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = '无记忆配置说明: -1. 不保存对话历史 -2. 每次对话都是独立的 -3. 无需额外配置 -4. 适合对隐私要求高的场景' WHERE `id` = 'Memory_nomem'; - --- 本地短期记忆配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = '本地短期记忆配置说明: -1. 使用本地存储保存对话历史 -2. 通过selected_module的llm总结对话内容 -3. 数据保存在本地,不会上传到服务器 -4. 适合注重隐私的场景 -5. 无需额外配置' WHERE `id` = 'Memory_mem_local_short'; - --- Mem0AI记忆配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://app.mem0.ai/dashboard/api-keys', -`remark` = 'Mem0AI记忆配置说明: -1. 使用Mem0AI服务保存对话历史 -2. 需要API密钥 -3. 需要网络连接 -4. 每月有1000次免费调用 -申请步骤: -1. 访问 https://app.mem0.ai/dashboard/api-keys -2. 获取API密钥 -3. 填入配置文件中' WHERE `id` = 'Memory_mem0ai'; - --- 更新Intent模型配置说明 --- 无意图识别配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = '无意图识别配置说明: -1. 不进行意图识别 -2. 所有对话直接传递给LLM处理 -3. 无需额外配置 -4. 适合简单对话场景' WHERE `id` = 'Intent_nointent'; - --- LLM意图识别配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = 'LLM意图识别配置说明: -1. 使用独立的LLM进行意图识别 -2. 默认使用selected_module.LLM的模型 -3. 可以配置使用独立的LLM(如免费的ChatGLMLLM) -4. 通用性强,但会增加处理时间 -5. 不支持控制音量大小等iot操作 -配置说明: -1. 在llm字段中指定使用的LLM模型 -2. 如果不指定,则使用selected_module.LLM的模型' WHERE `id` = 'Intent_intent_llm'; - --- 函数调用意图识别配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = '函数调用意图识别配置说明: -1. 使用LLM的function_call功能进行意图识别 -2. 需要所选择的LLM支持function_call -3. 按需调用工具,处理速度快 -4. 支持所有iot指令 -5. 默认已加载以下功能: - - handle_exit_intent(退出识别) - - play_music(音乐播放) - - change_role(角色切换) - - get_weather(天气查询) - - get_news(新闻查询) -配置说明: -1. 在functions字段中配置需要加载的功能模块 -2. 系统默认已加载基础功能,无需重复配置 -3. 可以添加自定义功能模块' WHERE `id` = 'Intent_function_call'; - --- 更新VAD模型配置说明 --- SileroVAD配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/snakers4/silero-vad', -`remark` = 'SileroVAD配置说明: -1. 使用SileroVAD模型进行语音活动检测 -2. 本地推理,无需网络连接 -3. 需要下载模型文件到models/snakers4_silero-vad目录 -4. 可配置参数: - - threshold: 0.5(语音检测阈值) - - min_silence_duration_ms: 700(最小静音持续时间,单位毫秒) -5. 如果说话停顿比较长,可以适当增加min_silence_duration_ms的值' WHERE `id` = 'VAD_SileroVAD'; diff --git a/main/manager-api/src/main/resources/db/changelog/202504301341.sql b/main/manager-api/src/main/resources/db/changelog/202504301341.sql deleted file mode 100644 index a88ee783e..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202504301341.sql +++ /dev/null @@ -1,85 +0,0 @@ -update `ai_model_provider` set `fields` = -'[{"key": "api_url","label": "API地址","type": "string"},{"key": "voice","label": "音色","type": "string"},{"key": "output_dir","label": "输出目录","type": "string"},{"key": "authorization","label": "授权","type": "string"},{"key": "appid","label": "应用ID","type": "string"},{"key": "access_token","label": "访问令牌","type": "string"},{"key": "cluster","label": "集群","type": "string"},{"key": "speed_ratio","label": "语速","type": "number"},{"key": "volume_ratio","label": "音量","type": "number"},{"key": "pitch_ratio","label": "音高","type": "number"}]' -where `id` = 'SYSTEM_TTS_doubao'; - --- 添加阿里云ASR供应器 -delete from `ai_model_provider` where `id` = 'SYSTEM_ASR_AliyunASR'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_AliyunASR', 'ASR', 'aliyun', '阿里云语音识别', '[{"key":"appkey","label":"应用AppKey","type":"string"},{"key":"token","label":"临时Token","type":"string"},{"key":"access_key_id","label":"AccessKey ID","type":"string"},{"key":"access_key_secret","label":"AccessKey Secret","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 5, 1, NOW(), 1, NOW()); - --- 添加阿里云ASR模型配置 -delete from `ai_model_config` where `id` = 'ASR_AliyunASR'; -INSERT INTO `ai_model_config` VALUES ('ASR_AliyunASR', 'ASR', 'AliyunASR', '阿里云语音识别', 0, 1, '{\"type\": \"aliyun\", \"appkey\": \"\", \"token\": \"\", \"access_key_id\": \"\", \"access_key_secret\": \"\", \"output_dir\": \"tmp/\"}', NULL, NULL, 6, NULL, NULL, NULL, NULL); - --- 更新阿里云ASR模型配置的说明文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://nls-portal.console.aliyun.com/', -`remark` = '阿里云ASR配置说明: -1. 访问 https://nls-portal.console.aliyun.com/ 开通服务 -2. 访问 https://nls-portal.console.aliyun.com/applist 获取appkey -3. 访问 https://nls-portal.console.aliyun.com/overview 获取token -4. 获取access_key_id和access_key_secret -5. 填入配置文件中' WHERE `id` = 'ASR_AliyunASR'; - --- 插入固件类型字典类型 -delete from `sys_dict_type` where `id` = 101; -INSERT INTO `sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -(101, 'FIRMWARE_TYPE', '固件类型', '固件类型字典', 0, 1, NOW(), 1, NOW()); - --- 插入固件类型字典数据 -delete from `sys_dict_data` where `dict_type_id` = 101; -INSERT INTO `sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -(101001, 101, '面包板新版接线(WiFi)', 'bread-compact-wifi', '面包板新版接线(WiFi)', 1, 1, NOW(), 1, NOW()), -(101002, 101, '面包板新版接线(WiFi)+ LCD', 'bread-compact-wifi-lcd', '面包板新版接线(WiFi)+ LCD', 2, 1, NOW(), 1, NOW()), -(101003, 101, '面包板新版接线(ML307 AT)', 'bread-compact-ml307', '面包板新版接线(ML307 AT)', 3, 1, NOW(), 1, NOW()), -(101004, 101, '面包板(WiFi) ESP32 DevKit', 'bread-compact-esp32', '面包板(WiFi) ESP32 DevKit', 4, 1, NOW(), 1, NOW()), -(101005, 101, '面包板(WiFi+ LCD) ESP32 DevKit', 'bread-compact-esp32-lcd', '面包板(WiFi+ LCD) ESP32 DevKit', 5, 1, NOW(), 1, NOW()), -(101006, 101, 'DFRobot 行空板 k10', 'df-k10', 'DFRobot 行空板 k10', 6, 1, NOW(), 1, NOW()), -(101007, 101, 'ESP32 CGC', 'esp32-cgc', 'ESP32 CGC', 7, 1, NOW(), 1, NOW()), -(101008, 101, 'ESP BOX 3', 'esp-box-3', 'ESP BOX 3', 8, 1, NOW(), 1, NOW()), -(101009, 101, 'ESP BOX', 'esp-box', 'ESP BOX', 9, 1, NOW(), 1, NOW()), -(101010, 101, 'ESP BOX Lite', 'esp-box-lite', 'ESP BOX Lite', 10, 1, NOW(), 1, NOW()), -(101011, 101, 'Kevin Box 1', 'kevin-box-1', 'Kevin Box 1', 11, 1, NOW(), 1, NOW()), -(101012, 101, 'Kevin Box 2', 'kevin-box-2', 'Kevin Box 2', 12, 1, NOW(), 1, NOW()), -(101013, 101, 'Kevin C3', 'kevin-c3', 'Kevin C3', 13, 1, NOW(), 1, NOW()), -(101014, 101, 'Kevin SP V3开发板', 'kevin-sp-v3-dev', 'Kevin SP V3开发板', 14, 1, NOW(), 1, NOW()), -(101015, 101, 'Kevin SP V4开发板', 'kevin-sp-v4-dev', 'Kevin SP V4开发板', 15, 1, NOW(), 1, NOW()), -(101016, 101, '鱼鹰科技3.13LCD开发板', 'kevin-yuying-313lcd', '鱼鹰科技3.13LCD开发板', 16, 1, NOW(), 1, NOW()), -(101017, 101, '立创·实战派ESP32-S3开发板', 'lichuang-dev', '立创·实战派ESP32-S3开发板', 17, 1, NOW(), 1, NOW()), -(101018, 101, '立创·实战派ESP32-C3开发板', 'lichuang-c3-dev', '立创·实战派ESP32-C3开发板', 18, 1, NOW(), 1, NOW()), -(101019, 101, '神奇按钮 Magiclick_2.4', 'magiclick-2p4', '神奇按钮 Magiclick_2.4', 19, 1, NOW(), 1, NOW()), -(101020, 101, '神奇按钮 Magiclick_2.5', 'magiclick-2p5', '神奇按钮 Magiclick_2.5', 20, 1, NOW(), 1, NOW()), -(101021, 101, '神奇按钮 Magiclick_C3', 'magiclick-c3', '神奇按钮 Magiclick_C3', 21, 1, NOW(), 1, NOW()), -(101022, 101, '神奇按钮 Magiclick_C3_v2', 'magiclick-c3-v2', '神奇按钮 Magiclick_C3_v2', 22, 1, NOW(), 1, NOW()), -(101023, 101, 'M5Stack CoreS3', 'm5stack-core-s3', 'M5Stack CoreS3', 23, 1, NOW(), 1, NOW()), -(101024, 101, 'AtomS3 + Echo Base', 'atoms3-echo-base', 'AtomS3 + Echo Base', 24, 1, NOW(), 1, NOW()), -(101025, 101, 'AtomS3R + Echo Base', 'atoms3r-echo-base', 'AtomS3R + Echo Base', 25, 1, NOW(), 1, NOW()), -(101026, 101, 'AtomS3R CAM/M12 + Echo Base', 'atoms3r-cam-m12-echo-base', 'AtomS3R CAM/M12 + Echo Base', 26, 1, NOW(), 1, NOW()), -(101027, 101, 'AtomMatrix + Echo Base', 'atommatrix-echo-base', 'AtomMatrix + Echo Base', 27, 1, NOW(), 1, NOW()), -(101028, 101, '虾哥 Mini C3', 'xmini-c3', '虾哥 Mini C3', 28, 1, NOW(), 1, NOW()), -(101029, 101, 'ESP32S3_KORVO2_V3开发板', 'esp32s3-korvo2-v3', 'ESP32S3_KORVO2_V3开发板', 29, 1, NOW(), 1, NOW()), -(101030, 101, 'ESP-SparkBot开发板', 'esp-sparkbot', 'ESP-SparkBot开发板', 30, 1, NOW(), 1, NOW()), -(101031, 101, 'ESP-Spot-S3', 'esp-spot-s3', 'ESP-Spot-S3', 31, 1, NOW(), 1, NOW()), -(101032, 101, 'Waveshare ESP32-S3-Touch-AMOLED-1.8', 'esp32-s3-touch-amoled-1.8', 'Waveshare ESP32-S3-Touch-AMOLED-1.8', 32, 1, NOW(), 1, NOW()), -(101033, 101, 'Waveshare ESP32-S3-Touch-LCD-1.85C', 'esp32-s3-touch-lcd-1.85c', 'Waveshare ESP32-S3-Touch-LCD-1.85C', 33, 1, NOW(), 1, NOW()), -(101034, 101, 'Waveshare ESP32-S3-Touch-LCD-1.85', 'esp32-s3-touch-lcd-1.85', 'Waveshare ESP32-S3-Touch-LCD-1.85', 34, 1, NOW(), 1, NOW()), -(101035, 101, 'Waveshare ESP32-S3-Touch-LCD-1.46', 'esp32-s3-touch-lcd-1.46', 'Waveshare ESP32-S3-Touch-LCD-1.46', 35, 1, NOW(), 1, NOW()), -(101036, 101, 'Waveshare ESP32-S3-Touch-LCD-3.5', 'esp32-s3-touch-lcd-3.5', 'Waveshare ESP32-S3-Touch-LCD-3.5', 36, 1, NOW(), 1, NOW()), -(101037, 101, '土豆子', 'tudouzi', '土豆子', 37, 1, NOW(), 1, NOW()), -(101038, 101, 'LILYGO T-Circle-S3', 'lilygo-t-circle-s3', 'LILYGO T-Circle-S3', 38, 1, NOW(), 1, NOW()), -(101039, 101, 'LILYGO T-CameraPlus-S3', 'lilygo-t-cameraplus-s3', 'LILYGO T-CameraPlus-S3', 39, 1, NOW(), 1, NOW()), -(101040, 101, 'Movecall Moji 小智AI衍生版', 'movecall-moji-esp32s3', 'Movecall Moji 小智AI衍生版', 40, 1, NOW(), 1, NOW()), -(101041, 101, 'Movecall CuiCan 璀璨·AI吊坠', 'movecall-cuican-esp32s3', 'Movecall CuiCan 璀璨·AI吊坠', 41, 1, NOW(), 1, NOW()), -(101042, 101, '正点原子DNESP32S3开发板', 'atk-dnesp32s3', '正点原子DNESP32S3开发板', 42, 1, NOW(), 1, NOW()), -(101043, 101, '正点原子DNESP32S3-BOX', 'atk-dnesp32s3-box', '正点原子DNESP32S3-BOX', 43, 1, NOW(), 1, NOW()), -(101044, 101, '嘟嘟开发板CHATX(wifi)', 'du-chatx', '嘟嘟开发板CHATX(wifi)', 44, 1, NOW(), 1, NOW()), -(101045, 101, '太极小派esp32s3', 'taiji-pi-s3', '太极小派esp32s3', 45, 1, NOW(), 1, NOW()), -(101046, 101, '无名科技星智0.85(WIFI)', 'xingzhi-cube-0.85tft-wifi', '无名科技星智0.85(WIFI)', 46, 1, NOW(), 1, NOW()), -(101047, 101, '无名科技星智0.85(ML307)', 'xingzhi-cube-0.85tft-ml307', '无名科技星智0.85(ML307)', 47, 1, NOW(), 1, NOW()), -(101048, 101, '无名科技星智0.96(WIFI)', 'xingzhi-cube-0.96oled-wifi', '无名科技星智0.96(WIFI)', 48, 1, NOW(), 1, NOW()), -(101049, 101, '无名科技星智0.96(ML307)', 'xingzhi-cube-0.96oled-ml307', '无名科技星智0.96(ML307)', 49, 1, NOW(), 1, NOW()), -(101050, 101, '无名科技星智1.54(WIFI)', 'xingzhi-cube-1.54tft-wifi', '无名科技星智1.54(WIFI)', 50, 1, NOW(), 1, NOW()), -(101051, 101, '无名科技星智1.54(ML307)', 'xingzhi-cube-1.54tft-ml307', '无名科技星智1.54(ML307)', 51, 1, NOW(), 1, NOW()), -(101052, 101, 'SenseCAP Watcher', 'sensecap-watcher', 'SenseCAP Watcher', 52, 1, NOW(), 1, NOW()), -(101053, 101, '四博智联AI陪伴盒子', 'doit-s3-aibox', '四博智联AI陪伴盒子', 53, 1, NOW(), 1, NOW()), -(101054, 101, '元控·青春', 'mixgo-nova', '元控·青春', 54, 1, NOW(), 1, NOW()); diff --git a/main/manager-api/src/main/resources/db/changelog/202505022134.sql b/main/manager-api/src/main/resources/db/changelog/202505022134.sql deleted file mode 100644 index ccbaaaee1..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505022134.sql +++ /dev/null @@ -1,27 +0,0 @@ --- 初始化智能体聊天记录 -DROP TABLE IF EXISTS ai_chat_history; -DROP TABLE IF EXISTS ai_chat_message; -DROP TABLE IF EXISTS ai_agent_chat_history; -CREATE TABLE ai_agent_chat_history -( - id BIGINT AUTO_INCREMENT COMMENT '主键ID' PRIMARY KEY, - mac_address VARCHAR(50) COMMENT 'MAC地址', - agent_id VARCHAR(32) COMMENT '智能体id', - session_id VARCHAR(50) COMMENT '会话ID', - chat_type TINYINT(3) COMMENT '消息类型: 1-用户, 2-智能体', - content VARCHAR(1024) COMMENT '聊天内容', - audio_id VARCHAR(32) COMMENT '音频ID', - created_at DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL COMMENT '创建时间', - updated_at DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间', - INDEX idx_ai_agent_chat_history_mac (mac_address), - INDEX idx_ai_agent_chat_history_session_id (session_id), - INDEX idx_ai_agent_chat_history_agent_id (agent_id), - INDEX idx_ai_agent_chat_history_agent_session_created (agent_id, session_id, created_at) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '智能体聊天记录表'; - -DROP TABLE IF EXISTS ai_agent_chat_audio; -CREATE TABLE ai_agent_chat_audio -( - id VARCHAR(32) COMMENT '主键ID' PRIMARY KEY, - audio LONGBLOB COMMENT '音频opus数据' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '智能体聊天音频数据表'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202505081146.sql b/main/manager-api/src/main/resources/db/changelog/202505081146.sql deleted file mode 100644 index fe7582f39..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505081146.sql +++ /dev/null @@ -1,43 +0,0 @@ --- 添加百度ASR模型配置 -delete from `ai_model_config` where `id` = 'ASR_BaiduASR'; -INSERT INTO `ai_model_config` VALUES ('ASR_BaiduASR', 'ASR', 'BaiduASR', '百度语音识别', 0, 1, '{\"type\": \"baidu\", \"app_id\": \"\", \"api_key\": \"\", \"secret_key\": \"\", \"dev_pid\": 1537, \"output_dir\": \"tmp/\"}', NULL, NULL, 7, NULL, NULL, NULL, NULL); - - --- 添加百度ASR供应器 -delete from `ai_model_provider` where `id` = 'SYSTEM_ASR_BaiduASR'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_BaiduASR', 'ASR', 'baidu', '百度语音识别', '[{"key":"app_id","label":"应用AppID","type":"string"},{"key":"api_key","label":"API Key","type":"string"},{"key":"secret_key","label":"Secret Key","type":"string"},{"key":"dev_pid","label":"语言参数","type":"number"},{"key":"output_dir","label":"输出目录","type":"string"}]', 7, 1, NOW(), 1, NOW()); - - --- 更新百度ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.bce.baidu.com/ai-engine/old/#/ai/speech/app/list', -`remark` = '百度ASR配置说明: -1. 访问 https://console.bce.baidu.com/ai-engine/old/#/ai/speech/app/list -2. 创建新应用 -3. 获取AppID、API Key和Secret Key -4. 填入配置文件中 -查看资源额度:https://console.bce.baidu.com/ai-engine/old/#/ai/speech/overview/resource/list -语言参数说明:https://ai.baidu.com/ai-doc/SPEECH/0lbxfnc9b -' WHERE `id` = 'ASR_BaiduASR'; - --- 更新豆包供应器字段 -update `ai_model_provider` set `fields` = -'[{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"},{"key":"boosting_table_name","label":"热词文件名称","type":"string"},{"key":"correct_table_name","label":"替换词文件名称","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]' -where `id` = 'SYSTEM_ASR_DoubaoASR'; - --- 更新豆包ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/speech/app', -`remark` = '豆包ASR配置说明: -1. 需要在火山引擎控制台创建应用并获取appid和access_token -2. 支持中文语音识别 -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://console.volcengine.com/speech/app -2. 创建新应用 -3. 获取appid和access_token -4. 填入配置文件中 -如需设置热词,请参考:https://www.volcengine.com/docs/6561/155738 -' WHERE `id` = 'ASR_DoubaoASR'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202505091555.sql b/main/manager-api/src/main/resources/db/changelog/202505091555.sql deleted file mode 100644 index b7ad91d42..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505091555.sql +++ /dev/null @@ -1,25 +0,0 @@ --- 更新模型供应器表 -UPDATE `ai_model_provider` SET fields = '[{"key": "host", "type": "string", "label": "服务地址"}, {"key": "port", "type": "number", "label": "端口号"}, {"key": "type", "type": "string", "label": "服务类型"}, {"key": "is_ssl", "type": "boolean", "label": "是否使用SSL"}, {"key": "api_key", "type": "string", "label": "API密钥"}, {"key": "output_dir", "type": "string", "label": "输出目录"}]' WHERE id = 'SYSTEM_ASR_FunASRServer'; - --- 更新模型配置表 -UPDATE `ai_model_config` SET -config_json = '{"host": "127.0.0.1", "port": 10096, "type": "fun_server", "is_ssl": true, "api_key": "none", "output_dir": "tmp/"}', -`doc_link` = 'https://github.com/modelscope/FunASR/blob/main/runtime/docs/SDK_advanced_guide_online_zh.md', -`remark` = '独立部署FunASR,使用FunASR的API服务,只需要五句话 -第一句:mkdir -p ./funasr-runtime-resources/models -第二句:sudo docker run -p 10096:10095 -it --privileged=true -v $PWD/funasr-runtime-resources/models:/workspace/models registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.12 -上一句话执行后会进入到容器,继续第三句:cd FunASR/runtime -不要退出容器,继续在容器中执行第四句:nohup bash run_server_2pass.sh --download-model-dir /workspace/models --vad-dir damo/speech_fsmn_vad_zh-cn-16k-common-onnx --model-dir damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-onnx --online-model-dir damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx --punc-dir damo/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx --lm-dir damo/speech_ngram_lm_zh-cn-ai-wesp-fst --itn-dir thuduj12/fst_itn_zh --hotword /workspace/models/hotwords.txt > log.txt 2>&1 & -上一句话执行后会进入到容器,继续第五句:tail -f log.txt -第五句话执行完后,会看到模型下载日志,下载完后就可以连接使用了 -以上是使用CPU推理,如果有GPU,详细参考:https://github.com/modelscope/FunASR/blob/main/runtime/docs/SDK_advanced_guide_online_zh.md' WHERE `id` = 'ASR_FunASRServer'; - --- FishSpeech配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/fish-speech-integration.md', -`remark` = 'FishSpeech配置说明: -1. 需要本地部署FishSpeech服务 -2. 支持自定义音色 -3. 本地推理,无需网络连接 -4. 输出文件保存在tmp/目录 -5. 可参照教程https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/fish-speech-integration.md' WHERE `id` = 'TTS_FishSpeech'; diff --git a/main/manager-api/src/main/resources/db/changelog/202505111914.sql b/main/manager-api/src/main/resources/db/changelog/202505111914.sql deleted file mode 100644 index c67f34771..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505111914.sql +++ /dev/null @@ -1,6 +0,0 @@ --- 添加聊天记录配置字段 -ALTER TABLE `ai_agent` -ADD COLUMN `chat_history_conf` tinyint NOT NULL DEFAULT 0 COMMENT '聊天记录配置(0不记录 1仅记录文本 2记录文本和语音)' AFTER `system_prompt`; - -ALTER TABLE `ai_agent_template` -ADD COLUMN `chat_history_conf` tinyint NOT NULL DEFAULT 0 COMMENT '聊天记录配置(0不记录 1仅记录文本 2记录文本和语音)' AFTER `system_prompt`; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202505122348.sql b/main/manager-api/src/main/resources/db/changelog/202505122348.sql deleted file mode 100644 index 05bbeb84c..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505122348.sql +++ /dev/null @@ -1,6 +0,0 @@ --- 添加总结记忆字段 -ALTER TABLE `ai_agent` -ADD COLUMN `summary_memory` text COMMENT '总结记忆' AFTER `system_prompt`; - -ALTER TABLE `ai_agent_template` -ADD COLUMN `summary_memory` text COMMENT '总结记忆' AFTER `system_prompt`; diff --git a/main/manager-api/src/main/resources/db/changelog/202505142037.sql b/main/manager-api/src/main/resources/db/changelog/202505142037.sql deleted file mode 100644 index 37a490133..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505142037.sql +++ /dev/null @@ -1,7 +0,0 @@ -update ai_agent_template set system_prompt = replace(system_prompt, '我是', '你是'); - -delete from sys_params where id in (500,501,402); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (500, 'end_prompt.enable', 'true', 'boolean', 1, '是否开启结束语'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (501, 'end_prompt.prompt', '请你以“时间过得真快”未来头,用富有感情、依依不舍的话来结束这场对话吧!', 'string', 1, '结束提示词'); - -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (402, 'plugins.get_weather.api_host', 'mj7p3y7naa.re.qweatherapi.com', 'string', 1, '开发者apihost'); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202505151451.sql b/main/manager-api/src/main/resources/db/changelog/202505151451.sql deleted file mode 100644 index 601de4576..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505151451.sql +++ /dev/null @@ -1,18 +0,0 @@ --- 修改自定义TTS接口请求定义 -update `ai_model_provider` set `fields` = -'[{"key":"url","label":"服务地址","type":"string"},{"key":"method","label":"请求方式","type":"string"},{"key":"params","label":"请求参数","type":"dict","dict_name":"params"},{"key":"headers","label":"请求头","type":"dict","dict_name":"headers"},{"key":"format","label":"音频格式","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]' -where `id` = 'SYSTEM_TTS_custom'; - --- 修改自定义TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = '自定义TTS配置说明: -1. 自定义的TTS接口服务,请求参数可自定义,可接入众多TTS服务 -2. 以本地部署的KokoroTTS为例 -3. 如果只有cpu运行:docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest -4. 如果只有gpu运行:docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest -配置说明: -1. 在params中配置请求参数,使用JSON格式 - 例如KokoroTTS:{ "input": "{prompt_text}", "speed": 1, "voice": "zm_yunxi", "stream": true, "download_format": "mp3", "response_format": "mp3", "return_download_link": true } -2. 在headers中配置请求头 -3. 设置返回音频格式' WHERE `id` = 'TTS_CustomTTS'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202505182234.sql b/main/manager-api/src/main/resources/db/changelog/202505182234.sql deleted file mode 100644 index 3873e5d4b..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505182234.sql +++ /dev/null @@ -1,65 +0,0 @@ --- 添加手机短信注册功能的需要的参数 -delete from sys_params where id in (108, 109, 110, 111, 112, 113, 114, 115); -delete from sys_params where id in (610, 611, 612, 613); -INSERT INTO sys_params -(id, param_code, param_value, value_type, param_type, remark, creator, create_date, updater, update_date) - VALUES -(108, 'server.name', 'xiaozhi-esp32-server', 'string', 1, '系统名称', NULL, NULL, NULL, NULL), -(109, 'server.beian_icp_num', 'null', 'string', 1, 'icp备案号,填写null则不设置', NULL, NULL, NULL, NULL), -(110, 'server.beian_ga_num', 'null', 'string', 1, '公安备案号,填写null则不设置', NULL, NULL, NULL, NULL), -(111, 'server.enable_mobile_register', 'false', 'boolean', 1, '是否开启手机注册', NULL, NULL, NULL, NULL), -(112, 'server.sms_max_send_count', '10', 'number', 1, '单号码单日最大短信发送条数', NULL, NULL, NULL, NULL), -(610, 'aliyun.sms.access_key_id', '', 'string', 1, '阿里云平台access_key', NULL, NULL, NULL, NULL), -(611, 'aliyun.sms.access_key_secret', '', 'string', 1, '阿里云平台access_key_secret', NULL, NULL, NULL, NULL), -(612, 'aliyun.sms.sign_name', '', 'string', 1, '阿里云短信签名', NULL, NULL, NULL, NULL), -(613, 'aliyun.sms.sms_code_template_code', '', 'string', 1, '阿里云短信模板', NULL, NULL, NULL, NULL); - -update sys_params set remark = '是否允许管理员以外的人注册' where param_code = 'server.allow_user_register'; - --- 增加手机区域字典 --- 插入固件类型字典类型 -delete from `sys_dict_type` where `id` = 102; -INSERT INTO `sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -(102, 'MOBILE_AREA', '手机区域', '手机区域字典', 0, 1, NOW(), 1, NOW()); - --- 插入固件类型字典数据 -delete from `sys_dict_data` where `dict_type_id` = 102; -INSERT INTO `sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -(102001, 102, '中国大陆', '+86', '中国大陆', 1, 1, NOW(), 1, NOW()), -(102002, 102, '中国香港', '+852', '中国香港', 2, 1, NOW(), 1, NOW()), -(102003, 102, '中国澳门', '+853', '中国澳门', 3, 1, NOW(), 1, NOW()), -(102004, 102, '中国台湾', '+886', '中国台湾', 4, 1, NOW(), 1, NOW()), -(102005, 102, '美国/加拿大', '+1', '美国/加拿大', 5, 1, NOW(), 1, NOW()), -(102006, 102, '英国', '+44', '英国', 6, 1, NOW(), 1, NOW()), -(102007, 102, '法国', '+33', '法国', 7, 1, NOW(), 1, NOW()), -(102008, 102, '意大利', '+39', '意大利', 8, 1, NOW(), 1, NOW()), -(102009, 102, '德国', '+49', '德国', 9, 1, NOW(), 1, NOW()), -(102010, 102, '波兰', '+48', '波兰', 10, 1, NOW(), 1, NOW()), -(102011, 102, '瑞士', '+41', '瑞士', 11, 1, NOW(), 1, NOW()), -(102012, 102, '西班牙', '+34', '西班牙', 12, 1, NOW(), 1, NOW()), -(102013, 102, '丹麦', '+45', '丹麦', 13, 1, NOW(), 1, NOW()), -(102014, 102, '马来西亚', '+60', '马来西亚', 14, 1, NOW(), 1, NOW()), -(102015, 102, '澳大利亚', '+61', '澳大利亚', 15, 1, NOW(), 1, NOW()), -(102016, 102, '印度尼西亚', '+62', '印度尼西亚', 16, 1, NOW(), 1, NOW()), -(102017, 102, '菲律宾', '+63', '菲律宾', 17, 1, NOW(), 1, NOW()), -(102018, 102, '新西兰', '+64', '新西兰', 18, 1, NOW(), 1, NOW()), -(102019, 102, '新加坡', '+65', '新加坡', 19, 1, NOW(), 1, NOW()), -(102020, 102, '泰国', '+66', '泰国', 20, 1, NOW(), 1, NOW()), -(102021, 102, '日本', '+81', '日本', 21, 1, NOW(), 1, NOW()), -(102022, 102, '韩国', '+82', '韩国', 22, 1, NOW(), 1, NOW()), -(102023, 102, '越南', '+84', '越南', 23, 1, NOW(), 1, NOW()), -(102024, 102, '印度', '+91', '印度', 24, 1, NOW(), 1, NOW()), -(102025, 102, '巴基斯坦', '+92', '巴基斯坦', 25, 1, NOW(), 1, NOW()), -(102026, 102, '尼日利亚', '+234', '尼日利亚', 26, 1, NOW(), 1, NOW()), -(102027, 102, '孟加拉国', '+880', '孟加拉国', 27, 1, NOW(), 1, NOW()), -(102028, 102, '沙特阿拉伯', '+966', '沙特阿拉伯', 28, 1, NOW(), 1, NOW()), -(102029, 102, '阿联酋', '+971', '阿联酋', 29, 1, NOW(), 1, NOW()), -(102030, 102, '巴西', '+55', '巴西', 30, 1, NOW(), 1, NOW()), -(102031, 102, '墨西哥', '+52', '墨西哥', 31, 1, NOW(), 1, NOW()), -(102032, 102, '智利', '+56', '智利', 32, 1, NOW(), 1, NOW()), -(102033, 102, '阿根廷', '+54', '阿根廷', 33, 1, NOW(), 1, NOW()), -(102034, 102, '埃及', '+20', '埃及', 34, 1, NOW(), 1, NOW()), -(102035, 102, '南非', '+27', '南非', 35, 1, NOW(), 1, NOW()), -(102036, 102, '肯尼亚', '+254', '肯尼亚', 36, 1, NOW(), 1, NOW()), -(102037, 102, '坦桑尼亚', '+255', '坦桑尼亚', 37, 1, NOW(), 1, NOW()), -(102038, 102, '哈萨克斯坦', '+7', '哈萨克斯坦', 38, 1, NOW(), 1, NOW()); diff --git a/main/manager-api/src/main/resources/db/changelog/202505201744.sql b/main/manager-api/src/main/resources/db/changelog/202505201744.sql deleted file mode 100644 index 7b31b1ccb..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505201744.sql +++ /dev/null @@ -1,3 +0,0 @@ --- 更新ai_model_provider的fields字段,将type为dict的改为string -update ai_model_provider set fields = replace(fields, '"type": "dict"', '"type": "string"') where id not in ('SYSTEM_LLM_fastgpt', 'SYSTEM_TTS_custom'); -update ai_model_provider set fields = replace(fields, '"type":"dict"', '"type": "string"') where id not in ('SYSTEM_LLM_fastgpt', 'SYSTEM_TTS_custom'); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202505271414.sql b/main/manager-api/src/main/resources/db/changelog/202505271414.sql deleted file mode 100644 index 588cd13cb..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505271414.sql +++ /dev/null @@ -1,51 +0,0 @@ --- 本地短期记忆配置可以设置独立的LLM -update `ai_model_provider` set fields = '[{"key":"llm","label":"LLM模型","type":"string"}]' where id = 'SYSTEM_Memory_mem_local_short'; -update `ai_model_config` set config_json = '{\"type\": \"mem_local_short\", \"llm\": \"LLM_ChatGLMLLM\"}' where id = 'Memory_mem_local_short'; - --- 增加火山双流式TTS供应器和模型配置 -delete from `ai_model_provider` where id = 'SYSTEM_TTS_HSDSTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_TTS_HSDSTTS', 'TTS', 'huoshan_double_stream', '火山双流式语音合成', '[{"key":"ws_url","label":"WebSocket地址","type":"string"},{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"resource_id","label":"资源ID","type":"string"},{"key":"speaker","label":"默认音色","type":"string"}]', 13, 1, NOW(), 1, NOW()); - -delete from `ai_model_config` where id = 'TTS_HuoshanDoubleStreamTTS'; -INSERT INTO `ai_model_config` VALUES ('TTS_HuoshanDoubleStreamTTS', 'TTS', 'HuoshanDoubleStreamTTS', '火山双流式语音合成', 0, 1, '{\"type\": \"huoshan_double_stream\", \"ws_url\": \"wss://openspeech.bytedance.com/api/v3/tts/bidirection\", \"appid\": \"你的火山引擎语音合成服务appid\", \"access_token\": \"你的火山引擎语音合成服务access_token\", \"resource_id\": \"volc.service_type.10029\", \"speaker\": \"zh_female_wanwanxiaohe_moon_bigtts\"}', NULL, NULL, 16, NULL, NULL, NULL, NULL); - --- 火山双流式TT模型配置说明文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/speech/service/10007', -`remark` = '火山引擎语音合成服务配置说明: -1. 访问 https://www.volcengine.com/ 注册并开通火山引擎账号 -2. 访问 https://console.volcengine.com/speech/service/10007 开通语音合成大模型,购买音色 -3. 在页面底部获取appid和access_token -5. 资源ID固定为:volc.service_type.10029(大模型语音合成及混音) -6. 填入配置文件中' WHERE `id` = 'TTS_HuoshanDoubleStreamTTS'; - - --- 添加火山双流式TTS音色 -delete from `ai_tts_voice` where tts_model_id = 'TTS_HuoshanDoubleStreamTTS'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0001', 'TTS_HuoshanDoubleStreamTTS', '爽快思思/Skye', 'zh_female_shuangkuaisisi_moon_bigtts', '中文、英文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/Skye.mp3', NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0002', 'TTS_HuoshanDoubleStreamTTS', '温暖阿虎/Alvin', 'zh_male_wennuanahu_moon_bigtts', '中文、英文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/Alvin.mp3', NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0003', 'TTS_HuoshanDoubleStreamTTS', '少年梓辛/Brayan', 'zh_male_shaonianzixin_moon_bigtts', '中文、英文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/Brayan.mp3', NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0004', 'TTS_HuoshanDoubleStreamTTS', '邻家女孩', 'zh_female_linjianvhai_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E9%82%BB%E5%AE%B6%E5%A5%B3%E5%AD%A9.mp3', NULL, 4, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0005', 'TTS_HuoshanDoubleStreamTTS', '渊博小叔', 'zh_male_yuanboxiaoshu_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%B8%8A%E5%8D%9A%E5%B0%8F%E5%8F%94.mp3', NULL, 5, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0006', 'TTS_HuoshanDoubleStreamTTS', '阳光青年', 'zh_male_yangguangqingnian_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E9%98%B3%E5%85%89%E9%9D%92%E5%B9%B4.mp3', NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0007', 'TTS_HuoshanDoubleStreamTTS', '京腔侃爷/Harmony', 'zh_male_jingqiangkanye_moon_bigtts', '中文、英文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/Harmony.mp3', NULL, 7, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0008', 'TTS_HuoshanDoubleStreamTTS', '湾湾小何', 'zh_female_wanwanxiaohe_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%B9%BE%E6%B9%BE%E5%B0%8F%E4%BD%95.mp3', NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0009', 'TTS_HuoshanDoubleStreamTTS', '湾区大叔', 'zh_female_wanqudashu_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%B9%BE%E5%8C%BA%E5%A4%A7%E5%8F%94.mp3', NULL, 9, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0010', 'TTS_HuoshanDoubleStreamTTS', '呆萌川妹', 'zh_female_daimengchuanmei_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E5%91%86%E8%90%8C%E5%B7%9D%E5%A6%B9.mp3', NULL, 10, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0011', 'TTS_HuoshanDoubleStreamTTS', '广州德哥', 'zh_male_guozhoudege_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E5%B9%BF%E5%B7%9E%E5%BE%B7%E5%93%A5.mp3', NULL, 11, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0012', 'TTS_HuoshanDoubleStreamTTS', '北京小爷', 'zh_male_beijingxiaoye_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E5%8C%97%E4%BA%AC%E5%B0%8F%E7%88%B7.mp3', NULL, 12, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0013', 'TTS_HuoshanDoubleStreamTTS', '浩宇小哥', 'zh_male_haoyuxiaoge_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%B5%A9%E5%AE%87%E5%B0%8F%E5%93%A5.mp3', NULL, 13, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0014', 'TTS_HuoshanDoubleStreamTTS', '广西远舟', 'zh_male_guangxiyuanzhou_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E5%B9%BF%E8%A5%BF%E8%BF%9C%E8%88%9F.mp3', NULL, 14, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0015', 'TTS_HuoshanDoubleStreamTTS', '妹坨洁儿', 'zh_female_meituojieer_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E5%A6%B9%E5%9D%A8%E6%B4%81%E5%84%BF.mp3', NULL, 15, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0016', 'TTS_HuoshanDoubleStreamTTS', '豫州子轩', 'zh_male_yuzhouzixuan_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E8%B1%AB%E5%B7%9E%E5%AD%90%E8%BD%A9.mp3', NULL, 16, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0017', 'TTS_HuoshanDoubleStreamTTS', '高冷御姐', 'zh_female_gaolengyujie_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E9%AB%98%E5%86%B7%E5%BE%A1%E5%A7%90.mp3', NULL, 17, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0018', 'TTS_HuoshanDoubleStreamTTS', '傲娇霸总', 'zh_male_aojiaobazong_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E5%82%B2%E5%A8%87%E9%9C%B8%E6%80%BB.mp3', NULL, 18, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0019', 'TTS_HuoshanDoubleStreamTTS', '魅力女友', 'zh_female_meilinvyou_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E9%AD%85%E5%8A%9B%E5%A5%B3%E5%8F%8B.mp3', NULL, 19, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0020', 'TTS_HuoshanDoubleStreamTTS', '深夜播客', 'zh_male_shenyeboke_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%B7%B1%E5%A4%9C%E6%92%AD%E5%AE%A2.mp3', NULL, 20, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0021', 'TTS_HuoshanDoubleStreamTTS', '柔美女友', 'zh_female_sajiaonvyou_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%9F%94%E7%BE%8E%E5%A5%B3%E5%8F%8B.mp3', NULL, 21, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0022', 'TTS_HuoshanDoubleStreamTTS', '撒娇学妹', 'zh_female_yuanqinvyou_moon_bigtts', '中文', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%92%92%E5%A8%87%E5%AD%A6%E5%A6%B9.mp3', NULL, 22, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0023', 'TTS_HuoshanDoubleStreamTTS', 'かずね(和音)', 'multi_male_jingqiangkanye_moon_bigtts', '日语、西语', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/Javier.wav', NULL, 23, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0024', 'TTS_HuoshanDoubleStreamTTS', 'はるこ(晴子)', 'multi_female_shuangkuaisisi_moon_bigtts', '日语、西语', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/Esmeralda.mp3', NULL, 24, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0025', 'TTS_HuoshanDoubleStreamTTS', 'あけみ(朱美)', 'multi_female_gaolengyujie_moon_bigtts', '日语', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/%E6%9C%B1%E7%BE%8E.mp3', NULL, 25, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_HuoshanDoubleStreamTTS_0026', 'TTS_HuoshanDoubleStreamTTS', 'ひろし(広志)', 'multi_male_wanqudashu_moon_bigtts', '日语、西语', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lm_hz_ihsph/ljhwZthlaukjlkulzlp/portal/bigtts/Roberto.wav', NULL, 26, NULL, NULL, NULL, NULL); diff --git a/main/manager-api/src/main/resources/db/changelog/202505292203.sql b/main/manager-api/src/main/resources/db/changelog/202505292203.sql deleted file mode 100644 index 4102c7fab..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202505292203.sql +++ /dev/null @@ -1,189 +0,0 @@ --- =============================== --- 一、在ai_model_provider中插入plugin 记录 --- =============================== -START TRANSACTION; - - --- intent_llm和function_call不设置函数列表 -update `ai_model_provider` set fields = '[{"key":"llm","label":"LLM模型","type":"string"}]' where id = 'SYSTEM_Intent_intent_llm'; -update `ai_model_provider` set fields = '[]' where id = 'SYSTEM_Intent_function_call'; -update `ai_model_config` set config_json = '{\"type\": \"intent_llm\", \"llm\": \"LLM_ChatGLMLLM\"}' where id = 'Intent_intent_llm'; -UPDATE `ai_model_config` SET config_json = '{\"type\": \"function_call\"}' WHERE id = 'Intent_function_call'; - - -delete from ai_model_provider where model_type = 'Plugin'; --- 1. 天气查询 -INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields, - sort, creator, create_date, updater, update_date) -VALUES ('SYSTEM_PLUGIN_WEATHER', - 'Plugin', - 'get_weather', - '天气查询', - JSON_ARRAY( - JSON_OBJECT( - 'key', 'api_key', - 'type', 'string', - 'label', '天气插件 API 密钥', - 'default', (SELECT param_value FROM sys_params WHERE param_code = 'plugins.get_weather.api_key') - ), - JSON_OBJECT( - 'key', 'default_location', - 'type', 'string', - 'label', '默认查询城市', - 'default', - (SELECT param_value FROM sys_params WHERE param_code = 'plugins.get_weather.default_location') - ), - JSON_OBJECT( - 'key', 'api_host', - 'type', 'string', - 'label', '开发者 API Host', - 'default', - (SELECT param_value FROM sys_params WHERE param_code = 'plugins.get_weather.api_host') - ) - ), - 10, 0, NOW(), 0, NOW()); - --- 6. 本地播放音乐 -INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields, - sort, creator, create_date, updater, update_date) -VALUES ('SYSTEM_PLUGIN_MUSIC', - 'Plugin', - 'play_music', - '服务器音乐播放', - JSON_ARRAY(), - 20, 0, NOW(), 0, NOW()); - --- 2. 新闻订阅 -INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields, - sort, creator, create_date, updater, update_date) -VALUES ('SYSTEM_PLUGIN_NEWS_CHINANEWS', - 'Plugin', - 'get_news_from_chinanews', - '中新网新闻', - JSON_ARRAY( - JSON_OBJECT( - 'key', 'default_rss_url', - 'type', 'string', - 'label', '默认 RSS 源', - 'default', - (SELECT param_value FROM sys_params WHERE param_code = 'plugins.get_news.default_rss_url') - ), - JSON_OBJECT( - 'key', 'society_rss_url', - 'type', 'string', - 'label', '社会新闻 RSS 地址', - 'default', - 'https://www.chinanews.com.cn/rss/society.xml' - ), - JSON_OBJECT( - 'key', 'world_rss_url', - 'type', 'string', - 'label', '国际新闻 RSS 地址', - 'default', - 'https://www.chinanews.com.cn/rss/world.xml' - ), - JSON_OBJECT( - 'key', 'finance_rss_url', - 'type', 'string', - 'label', '财经新闻 RSS 地址', - 'default', - 'https://www.chinanews.com.cn/rss/finance.xml' - ) - ), - 30, 0, NOW(), 0, NOW()); - --- 3. 新闻订阅 -INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields, - sort, creator, create_date, updater, update_date) -VALUES ('SYSTEM_PLUGIN_NEWS_NEWSNOW', - 'Plugin', - 'get_news_from_newsnow', - 'newsnow新闻聚合', - JSON_ARRAY( - JSON_OBJECT( - 'key', 'url', - 'type', 'string', - 'label', '接口地址', - 'default', - 'https://newsnow.busiyi.world/api/s?id=' - ) - ), - 40, 0, NOW(), 0, NOW()); - - --- 4. HomeAssistant 状态查询 -INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields, - sort, creator, create_date, updater, update_date) -VALUES ('SYSTEM_PLUGIN_HA_GET_STATE', - 'Plugin', - 'hass_get_state', - 'HomeAssistant设备状态查询', - JSON_ARRAY( - JSON_OBJECT( - 'key', 'base_url', - 'type', 'string', - 'label', 'HA 服务器地址', - 'default', - (SELECT param_value FROM sys_params WHERE param_code = 'plugins.home_assistant.base_url') - ), - JSON_OBJECT( - 'key', 'api_key', - 'type', 'string', - 'label', 'HA API 访问令牌', - 'default', - (SELECT param_value FROM sys_params WHERE param_code = 'plugins.home_assistant.api_key') - ), - JSON_OBJECT( - 'key', 'devices', - 'type', 'array', - 'label', '设备列表(名称,实体ID;…)', - 'default', - (SELECT param_value FROM sys_params WHERE param_code = 'plugins.home_assistant.devices') - ) - ), - 50, 0, NOW(), 0, NOW()); - --- 5. HomeAssistant 状态写入 -INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields, - sort, creator, create_date, updater, update_date) -VALUES ('SYSTEM_PLUGIN_HA_SET_STATE', - 'Plugin', - 'hass_set_state', - 'HomeAssistant设备状态修改', - JSON_ARRAY(), - 60, 0, NOW(), 0, NOW()); - --- 5. HomeAssistant 音乐播放 -INSERT INTO ai_model_provider (id, model_type, provider_code, name, fields, - sort, creator, create_date, updater, update_date) -VALUES ('SYSTEM_PLUGIN_HA_PLAY_MUSIC', - 'Plugin', - 'hass_play_music', - 'HomeAssistant音乐播放', - JSON_ARRAY(), - 70, 0, NOW(), 0, NOW()); - - --- =============================== --- 二、删除sys_params中旧的plugins.*参数 --- =============================== -DELETE -FROM sys_params -WHERE param_code LIKE 'plugins.%'; - - --- =============================== --- 三、添加智能体插件id字段 --- =============================== -CREATE TABLE IF NOT EXISTS ai_agent_plugin_mapping -( - id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '主键', - agent_id VARCHAR(32) NOT NULL COMMENT '智能体ID', - plugin_id VARCHAR(32) NOT NULL COMMENT '插件ID', - param_info JSON NOT NULL COMMENT '参数信息', - UNIQUE KEY uk_agent_provider (agent_id, plugin_id) -) COMMENT 'Agent与插件的唯一映射表'; - - -COMMIT; - diff --git a/main/manager-api/src/main/resources/db/changelog/202506010920.sql b/main/manager-api/src/main/resources/db/changelog/202506010920.sql deleted file mode 100644 index 79898eed9..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506010920.sql +++ /dev/null @@ -1,29 +0,0 @@ --- VLLM模型供应器 -delete from `ai_model_provider` where id = 'SYSTEM_VLLM_openai'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_VLLM_openai', 'VLLM', 'openai', 'OpenAI接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"model_name","label":"模型名称","type":"string"},{"key":"api_key","label":"API密钥","type":"string"}]', 9, 1, NOW(), 1, NOW()); - --- VLLM模型配置 -delete from `ai_model_config` where id = 'VLLM_ChatGLMVLLM'; -INSERT INTO `ai_model_config` VALUES ('VLLM_ChatGLMVLLM', 'VLLM', 'ChatGLMVLLM', '智谱视觉AI', 1, 1, '{\"type\": \"openai\", \"model_name\": \"glm-4v-flash\", \"base_url\": \"https://open.bigmodel.cn/api/paas/v4/\", \"api_key\": \"你的api_key\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); - --- 更新文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://bigmodel.cn/usercenter/proj-mgmt/apikeys', -`remark` = '智谱视觉AI配置说明: -1. 访问 https://bigmodel.cn/usercenter/proj-mgmt/apikeys -2. 注册并获取API密钥 -3. 填入配置文件中' WHERE `id` = 'VLLM_ChatGLMVLLM'; - - --- 添加参数 -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (113, 'server.http_port', '8003', 'number', 1, 'http服务的端口,用于启动视觉分析接口'); -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (114, 'server.vision_explain', 'null', 'string', 1, '视觉分析接口地址,用于下发到设备,多个用;分隔'); - --- 智能体表增加VLLM模型配置 -ALTER TABLE `ai_agent` -ADD COLUMN `vllm_model_id` varchar(32) NULL DEFAULT 'VLLM_ChatGLMVLLM' COMMENT '视觉模型标识' AFTER `llm_model_id`; - --- 智能体模版表增加VLLM模型配置 -ALTER TABLE `ai_agent_template` -ADD COLUMN `vllm_model_id` varchar(32) NULL DEFAULT 'VLLM_ChatGLMVLLM' COMMENT '视觉模型标识' AFTER `llm_model_id`; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202506031639.sql b/main/manager-api/src/main/resources/db/changelog/202506031639.sql deleted file mode 100644 index 95691b423..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506031639.sql +++ /dev/null @@ -1,45 +0,0 @@ --- VLLM模型供应器 -delete from `ai_model_provider` where id = 'SYSTEM_ASR_DoubaoStreamASR'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_DoubaoStreamASR', 'ASR', 'doubao_stream', '火山引擎语音识别(流式)', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"},{"key":"boosting_table_name","label":"热词文件名称","type":"string"},{"key":"correct_table_name","label":"替换词文件名称","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 3, 1, NOW(), 1, NOW()); - - --- VLLM模型配置 -delete from `ai_model_config` where id = 'ASR_DoubaoStreamASR'; -INSERT INTO `ai_model_config` VALUES ('ASR_DoubaoStreamASR', 'ASR', 'DoubaoStreamASR', '豆包语音识别(流式)', 0, 1, '{\"type\": \"doubao_stream\", \"appid\": \"\", \"access_token\": \"\", \"cluster\": \"volcengine_input_common\", \"output_dir\": \"tmp/\"}', NULL, NULL, 3, NULL, NULL, NULL, NULL); - - --- 更新豆包ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/speech/app', -`remark` = '豆包ASR配置说明: -1. 豆包ASR和豆包(流式)ASR的区别是:豆包ASR是按次收费,豆包(流式)ASR是按时收费 -2. 一般来说按次收费的更便宜,但是豆包(流式)ASR使用了大模型技术,效果更好 -3. 需要在火山引擎控制台创建应用并获取appid和access_token -4. 支持中文语音识别 -5. 需要网络连接 -6. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://console.volcengine.com/speech/app -2. 创建新应用 -3. 获取appid和access_token -4. 填入配置文件中 -如需设置热词,请参考:https://www.volcengine.com/docs/6561/155738 -' WHERE `id` = 'ASR_DoubaoASR'; - -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/speech/app', -`remark` = '豆包ASR配置说明: -1. 豆包ASR和豆包(流式)ASR的区别是:豆包ASR是按次收费,豆包(流式)ASR是按时收费 -2. 一般来说按次收费的更便宜,但是豆包(流式)ASR使用了大模型技术,效果更好 -3. 需要在火山引擎控制台创建应用并获取appid和access_token -4. 支持中文语音识别 -5. 需要网络连接 -6. 输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://console.volcengine.com/speech/app -2. 创建新应用 -3. 获取appid和access_token -4. 填入配置文件中 -如需设置热词,请参考:https://www.volcengine.com/docs/6561/155738 -' WHERE `id` = 'ASR_DoubaoStreamASR'; diff --git a/main/manager-api/src/main/resources/db/changelog/202506032232.sql b/main/manager-api/src/main/resources/db/changelog/202506032232.sql deleted file mode 100644 index 616119815..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506032232.sql +++ /dev/null @@ -1,14 +0,0 @@ --- VLLM模型配置 -delete from `ai_model_config` where id = 'VLLM_QwenVLVLLM'; -INSERT INTO `ai_model_config` VALUES ('VLLM_QwenVLVLLM', 'VLLM', 'QwenVLVLLM', '千问视觉模型', 0, 1, '{\"type\": \"openai\", \"model_name\": \"qwen2.5-vl-3b-instruct\", \"base_url\": \"https://dashscope.aliyuncs.com/compatible-mode/v1\", \"api_key\": \"你的api_key\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); - --- 更新文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://bailian.console.aliyun.com/?tab=api#/api/?type=model&url=https%3A%2F%2Fhelp.aliyun.com%2Fdocument_detail%2F2845564.html&renderType=iframe', -`remark` = '千问视觉模型配置说明: -1. 访问 https://bailian.console.aliyun.com/?tab=model#/api-key -2. 注册并获取API密钥 -3. 填入配置文件中' WHERE `id` = 'VLLM_QwenVLVLLM'; - --- 删除参数,这两个参数已挪至python配置文件 -delete from `sys_params` where id in (113,114); diff --git a/main/manager-api/src/main/resources/db/changelog/202506051538.sql b/main/manager-api/src/main/resources/db/changelog/202506051538.sql deleted file mode 100644 index cfe65da76..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506051538.sql +++ /dev/null @@ -1,20 +0,0 @@ --- 增加LinkeraiTTS供应器和模型配置 -delete from `ai_model_provider` where id = 'SYSTEM_TTS_LinkeraiTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_TTS_LinkeraiTTS', 'TTS', 'linkerai', 'Linkerai语音合成', '[{"key":"api_url","label":"API地址","type":"string"},{"key":"audio_format","label":"音频格式","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"voice","label":"默认音色","type":"string"}]', 14, 1, NOW(), 1, NOW()); - -delete from `ai_model_config` where id = 'TTS_LinkeraiTTS'; -INSERT INTO `ai_model_config` VALUES ('TTS_LinkeraiTTS', 'TTS', 'LinkeraiTTS', 'Linkerai语音合成', 0, 1, '{\"type\": \"linkerai\", \"api_url\": \"https://tts.linkerai.cn/tts\", \"audio_format\": \"pcm\", \"access_token\": \"U4YdYXVfpwWnk2t5Gp822zWPCuORyeJL\", \"voice\": \"OUeAo1mhq6IBExi\"}', NULL, NULL, 17, NULL, NULL, NULL, NULL); - --- LinkeraiTTS模型配置说明文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://tts.linkerai.cn/docs', -`remark` = 'Linkerai语音合成服务配置说明: -1. 访问 https://linkerai.cn 注册并获取访问令牌 -2. 默认的access_token供测试使用,请勿用于商业用途 -3. 支持声音克隆功能,可自行上传音频,填入voice参数 -4. 如果voice参数为空,将使用默认声音' WHERE `id` = 'TTS_LinkeraiTTS'; - - -delete from `ai_tts_voice` where tts_model_id = 'TTS_LinkeraiTTS'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_LinkeraiTTS_0001', 'TTS_LinkeraiTTS', '芷若', 'OUeAo1mhq6IBExi', '中文', NULL, NULL, 1, NULL, NULL, NULL, NULL); diff --git a/main/manager-api/src/main/resources/db/changelog/202506080955.sql b/main/manager-api/src/main/resources/db/changelog/202506080955.sql deleted file mode 100644 index 5f5e799e9..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506080955.sql +++ /dev/null @@ -1,3 +0,0 @@ --- 智控台开启唤醒词加速 -update `sys_params` set param_value = '你好小智;你好小志;小爱同学;你好小鑫;你好小新;小美同学;小龙小龙;喵喵同学;小滨小滨;小冰小冰;嘿你好呀' where param_code = 'wakeup_words'; -update `sys_params` set param_value = 'true' where param_code = 'enable_wakeup_words_response_cache'; diff --git a/main/manager-api/src/main/resources/db/changelog/202506091720.sql b/main/manager-api/src/main/resources/db/changelog/202506091720.sql deleted file mode 100644 index 97b457eed..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506091720.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `ai_tts_voice` -ADD COLUMN `reference_audio` VARCHAR(500) DEFAULT NULL COMMENT '参考音频路径' AFTER `remark`, -ADD COLUMN `reference_text` VARCHAR(500) DEFAULT NULL COMMENT '参考文本' AFTER `reference_audio`; diff --git a/main/manager-api/src/main/resources/db/changelog/202506161101.sql b/main/manager-api/src/main/resources/db/changelog/202506161101.sql deleted file mode 100644 index fcfff082c..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506161101.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE ai_agent_plugin_mapping CONVERT TO CHARACTER SET utf8mb4; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202506191643.sql b/main/manager-api/src/main/resources/db/changelog/202506191643.sql deleted file mode 100644 index 205590617..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506191643.sql +++ /dev/null @@ -1,19 +0,0 @@ --- LLM意图识别配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = 'LLM意图识别配置说明: -1. 使用独立的LLM进行意图识别 -2. 默认使用selected_module.LLM的模型 -3. 可以配置使用独立的LLM(如免费的ChatGLMLLM) -4. 通用性强,但会增加处理时间 -配置说明: -1. 在llm字段中指定使用的LLM模型 -2. 如果不指定,则使用selected_module.LLM的模型' WHERE `id` = 'Intent_intent_llm'; - --- 函数调用意图识别配置说明 -UPDATE `ai_model_config` SET -`doc_link` = NULL, -`remark` = '函数调用意图识别配置说明: -1. 使用LLM的function_call功能进行意图识别 -2. 需要所选择的LLM支持function_call -3. 按需调用工具,处理速度快' WHERE `id` = 'Intent_function_call'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202506251620.sql b/main/manager-api/src/main/resources/db/changelog/202506251620.sql deleted file mode 100644 index 9af9acd79..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506251620.sql +++ /dev/null @@ -1,18 +0,0 @@ --- 更新现有的 get_news_from_newsnow 插件配置 -UPDATE ai_model_provider -SET fields = JSON_ARRAY( - JSON_OBJECT( - 'key', 'url', - 'type', 'string', - 'label', '接口地址', - 'default', 'https://newsnow.busiyi.world/api/s?id=' - ), - JSON_OBJECT( - 'key', 'news_sources', - 'type', 'string', - 'label', '新闻源配置', - 'default', '澎湃新闻;百度热搜;财联社' - ) -) -WHERE provider_code = 'get_news_from_newsnow' -AND model_type = 'Plugin'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202506261637.sql b/main/manager-api/src/main/resources/db/changelog/202506261637.sql deleted file mode 100644 index 792e00c2f..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202506261637.sql +++ /dev/null @@ -1,2 +0,0 @@ -delete from `sys_params` where id = 113; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (113, 'server.mcp_endpoint', 'null', 'string', 1, 'mcp接入点地址'); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202507031602.sql b/main/manager-api/src/main/resources/db/changelog/202507031602.sql deleted file mode 100644 index 92edf9b9c..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202507031602.sql +++ /dev/null @@ -1,4 +0,0 @@ --- 添加声纹接口地址参数配置 -delete from `sys_params` where id = 114; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) -VALUES (114, 'server.voice_print', 'null', 'string', 1, '声纹接口地址'); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202507041018.sql b/main/manager-api/src/main/resources/db/changelog/202507041018.sql deleted file mode 100644 index cffcfb169..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202507041018.sql +++ /dev/null @@ -1,12 +0,0 @@ -DROP TABLE IF EXISTS ai_agent_voice_print; -create table ai_agent_voice_print ( - id varchar(32) NOT NULL COMMENT '声纹ID', - agent_id varchar(32) NOT NULL COMMENT '关联的智能体ID', - source_name varchar(50) NOT NULL COMMENT '声纹来源的人的姓名', - introduce varchar(200) COMMENT '描述声纹来源的这个人', - create_date DATETIME COMMENT '创建时间', - creator bigint COMMENT '创建者', - update_date DATETIME COMMENT '修改时间', - updater bigint COMMENT '修改者', - PRIMARY KEY (id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='智能体声纹表' \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202507071130.sql b/main/manager-api/src/main/resources/db/changelog/202507071130.sql deleted file mode 100644 index c3730ef73..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202507071130.sql +++ /dev/null @@ -1,26 +0,0 @@ --- 添加阿里云流式ASR供应器 -delete from `ai_model_provider` where id = 'SYSTEM_ASR_AliyunStreamASR'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_AliyunStreamASR', 'ASR', 'aliyun_stream', '阿里云语音识别(流式)', '[{"key":"appkey","label":"应用AppKey","type":"string"},{"key":"token","label":"临时Token","type":"string"},{"key":"access_key_id","label":"AccessKey ID","type":"string"},{"key":"access_key_secret","label":"AccessKey Secret","type":"string"},{"key":"host","label":"服务地址","type":"string"},{"key":"max_sentence_silence","label":"断句检测时间","type":"number"},{"key":"output_dir","label":"输出目录","type":"string"}]', 6, 1, NOW(), 1, NOW()); - --- 添加阿里云流式ASR模型配置 -delete from `ai_model_config` where id = 'ASR_AliyunStreamASR'; -INSERT INTO `ai_model_config` VALUES ('ASR_AliyunStreamASR', 'ASR', 'AliyunStreamASR', '阿里云语音识别(流式)', 0, 1, '{\"type\": \"aliyun_stream\", \"appkey\": \"\", \"token\": \"\", \"access_key_id\": \"\", \"access_key_secret\": \"\", \"host\": \"nls-gateway-cn-shanghai.aliyuncs.com\", \"max_sentence_silence\": 800, \"output_dir\": \"tmp/\"}', NULL, NULL, 8, NULL, NULL, NULL, NULL); - --- 更新阿里云流式ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://nls-portal.console.aliyun.com/', -`remark` = '阿里云流式ASR配置说明: -1. 阿里云ASR和阿里云(流式)ASR的区别是:阿里云ASR是一次性识别,阿里云(流式)ASR是实时流式识别 -2. 流式ASR具有更低的延迟和更好的实时性,适合语音交互场景 -3. 需要在阿里云智能语音交互控制台创建应用并获取认证信息 -4. 支持中文实时语音识别,支持标点符号预测和逆文本规范化 -5. 需要网络连接,输出文件保存在tmp/目录 -申请步骤: -1. 访问 https://nls-portal.console.aliyun.com/ 开通智能语音交互服务 -2. 访问 https://nls-portal.console.aliyun.com/applist 创建项目并获取appkey -3. 访问 https://nls-portal.console.aliyun.com/overview 获取临时token(或配置access_key_id和access_key_secret自动获取) -4. 如需动态token管理,建议配置access_key_id和access_key_secret -5. max_sentence_silence参数控制断句检测时间(毫秒),默认800ms -如需了解更多参数配置,请参考:https://help.aliyun.com/zh/isi/developer-reference/real-time-speech-recognition -' WHERE `id` = 'ASR_AliyunStreamASR'; diff --git a/main/manager-api/src/main/resources/db/changelog/202507071530.sql b/main/manager-api/src/main/resources/db/changelog/202507071530.sql deleted file mode 100644 index f1cf7a9b2..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202507071530.sql +++ /dev/null @@ -1,56 +0,0 @@ --- 添加阿里云流式TTS供应器 -delete from `ai_model_provider` where id = 'SYSTEM_TTS_AliyunStreamTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_TTS_AliyunStreamTTS', 'TTS', 'aliyun_stream', '阿里云语音合成(流式)', '[{"key":"appkey","label":"应用AppKey","type":"string"},{"key":"token","label":"临时Token","type":"string"},{"key":"access_key_id","label":"AccessKey ID","type":"string"},{"key":"access_key_secret","label":"AccessKey Secret","type":"string"},{"key":"host","label":"服务地址","type":"string"},{"key":"voice","label":"默认音色","type":"string"},{"key":"format","label":"音频格式","type":"string"},{"key":"sample_rate","label":"采样率","type":"number"},{"key":"volume","label":"音量","type":"number"},{"key":"speech_rate","label":"语速","type":"number"},{"key":"pitch_rate","label":"音调","type":"number"},{"key":"output_dir","label":"输出目录","type":"string"}]', 15, 1, NOW(), 1, NOW()); - --- 添加阿里云流式TTS模型配置 -delete from `ai_model_config` where id = 'TTS_AliyunStreamTTS'; -INSERT INTO `ai_model_config` VALUES ('TTS_AliyunStreamTTS', 'TTS', 'AliyunStreamTTS', '阿里云语音合成(流式)', 0, 1, '{\"type\": \"aliyun_stream\", \"appkey\": \"\", \"token\": \"\", \"access_key_id\": \"\", \"access_key_secret\": \"\", \"host\": \"nls-gateway-cn-beijing.aliyuncs.com\", \"voice\": \"longxiaochun\", \"format\": \"pcm\", \"sample_rate\": 16000, \"volume\": 50, \"speech_rate\": 0, \"pitch_rate\": 0, \"output_dir\": \"tmp/\"}', NULL, NULL, 18, NULL, NULL, NULL, NULL); - --- 更新阿里云流式TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://nls-portal.console.aliyun.com/', -`remark` = '阿里云流式TTS配置说明: -1. 阿里云TTS和阿里云(流式)TTS的区别是:阿里云TTS是一次性合成,阿里云(流式)TTS是实时流式合成 -2. 流式TTS具有更低的延迟和更好的实时性,适合语音交互场景 -3. 需要在阿里云智能语音交互控制台创建应用并获取认证信息 -4. 支持CosyVoice大模型音色,音质更加自然 -5. 支持实时调节音量、语速、音调等参数 -申请步骤: -1. 访问 https://nls-portal.console.aliyun.com/ 开通智能语音交互服务 -2. 访问 https://nls-portal.console.aliyun.com/applist 创建项目并获取appkey -3. 访问 https://nls-portal.console.aliyun.com/overview 获取临时token(或配置access_key_id和access_key_secret自动获取) -4. 如需动态token管理,建议配置access_key_id和access_key_secret -5. 可选择北京、上海等不同地域的服务器以优化延迟 -6. voice参数支持CosyVoice大模型音色,如longxiaochun、longyueyue等 -如需了解更多参数配置,请参考:https://help.aliyun.com/zh/isi/developer-reference/real-time-speech-synthesis -' WHERE `id` = 'TTS_AliyunStreamTTS'; - --- 添加阿里云流式TTS音色 -delete from `ai_tts_voice` where tts_model_id = 'TTS_AliyunStreamTTS'; --- 温柔女声系列 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0001', 'TTS_AliyunStreamTTS', '龙小淳-温柔姐姐', 'longxiaochun', '中文及中英文混合', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0002', 'TTS_AliyunStreamTTS', '龙小夏-温柔女声', 'longxiaoxia', '中文及中英文混合', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0003', 'TTS_AliyunStreamTTS', '龙玫-温柔女声', 'longmei', '中文及中英文混合', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0004', 'TTS_AliyunStreamTTS', '龙瑰-温柔女声', 'longgui', '中文及中英文混合', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL); --- 御姐女声系列 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0005', 'TTS_AliyunStreamTTS', '龙玉-御姐女声', 'longyu', '中文及中英文混合', NULL, NULL, NULL, NULL, 5, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0006', 'TTS_AliyunStreamTTS', '龙娇-御姐女声', 'longjiao', '中文及中英文混合', NULL, NULL, NULL, NULL, 6, NULL, NULL, NULL, NULL); --- 男声系列 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0007', 'TTS_AliyunStreamTTS', '龙臣-译制片男声', 'longchen', '中文及中英文混合', NULL, NULL, NULL, NULL, 7, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0008', 'TTS_AliyunStreamTTS', '龙修-青年男声', 'longxiu', '中文及中英文混合', NULL, NULL, NULL, NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0009', 'TTS_AliyunStreamTTS', '龙橙-阳光男声', 'longcheng', '中文及中英文混合', NULL, NULL, NULL, NULL, 9, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0010', 'TTS_AliyunStreamTTS', '龙哲-成熟男声', 'longzhe', '中文及中英文混合', NULL, NULL, NULL, NULL, 10, NULL, NULL, NULL, NULL); --- 专业播报系列 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0011', 'TTS_AliyunStreamTTS', 'Bella2.0-新闻女声', 'loongbella', '中文及中英文混合', NULL, NULL, NULL, NULL, 11, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0012', 'TTS_AliyunStreamTTS', 'Stella2.0-飒爽女声', 'loongstella', '中文及中英文混合', NULL, NULL, NULL, NULL, 12, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0013', 'TTS_AliyunStreamTTS', '龙书-新闻男声', 'longshu', '中文及中英文混合', NULL, NULL, NULL, NULL, 13, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0014', 'TTS_AliyunStreamTTS', '龙婧-严肃女声', 'longjing', '中文及中英文混合', NULL, NULL, NULL, NULL, 14, NULL, NULL, NULL, NULL); --- 特色音色系列 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0015', 'TTS_AliyunStreamTTS', '龙奇-活泼童声', 'longqi', '中文及中英文混合', NULL, NULL, NULL, NULL, 15, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0016', 'TTS_AliyunStreamTTS', '龙华-活泼女童', 'longhua', '中文及中英文混合', NULL, NULL, NULL, NULL, 16, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0017', 'TTS_AliyunStreamTTS', '龙无-无厘头男声', 'longwu', '中文及中英文混合', NULL, NULL, NULL, NULL, 17, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0018', 'TTS_AliyunStreamTTS', '龙大锤-幽默男声', 'longdachui', '中文及中英文混合', NULL, NULL, NULL, NULL, 18, NULL, NULL, NULL, NULL); --- 粤语系列 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0019', 'TTS_AliyunStreamTTS', '龙嘉怡-粤语女声', 'longjiayi', '粤语及粤英混合', NULL, NULL, NULL, NULL, 19, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0020', 'TTS_AliyunStreamTTS', '龙桃-粤语女声', 'longtao', '粤语及粤英混合', NULL, NULL, NULL, NULL, 20, NULL, NULL, NULL, NULL); diff --git a/main/manager-api/src/main/resources/db/changelog/202507081646.sql b/main/manager-api/src/main/resources/db/changelog/202507081646.sql deleted file mode 100644 index 6631ae18b..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202507081646.sql +++ /dev/null @@ -1,3 +0,0 @@ --- 智能体声纹添加新字段 -ALTER TABLE ai_agent_voice_print - ADD COLUMN audio_id VARCHAR(32) NOT NULL COMMENT '音频ID'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202507101203.sql b/main/manager-api/src/main/resources/db/changelog/202507101203.sql deleted file mode 100644 index 66896ef8c..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202507101203.sql +++ /dev/null @@ -1,38 +0,0 @@ --- OpenAI ASR模型供应器 -delete from `ai_model_provider` where id = 'SYSTEM_ASR_OpenaiASR'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_OpenaiASR', 'ASR', 'openai', 'OpenAI语音识别', '[{"key": "base_url", "type": "string", "label": "基础URL"}, {"key": "model_name", "type": "string", "label": "模型名称"}, {"key": "api_key", "type": "string", "label": "API密钥"}, {"key": "output_dir", "type": "string", "label": "输出目录"}]', 9, 1, NOW(), 1, NOW()); - - --- OpenAI ASR模型配置 -delete from `ai_model_config` where id = 'ASR_OpenaiASR'; -INSERT INTO `ai_model_config` VALUES ('ASR_OpenaiASR', 'ASR', 'OpenaiASR', 'OpenAI语音识别', 0, 1, '{\"type\": \"openai\", \"api_key\": \"\", \"base_url\": \"https://api.openai.com/v1/audio/transcriptions\", \"model_name\": \"gpt-4o-mini-transcribe\", \"output_dir\": \"tmp/\"}', NULL, NULL, 9, NULL, NULL, NULL, NULL); - --- groq ASR模型配置 -delete from `ai_model_config` where id = 'ASR_GroqASR'; -INSERT INTO `ai_model_config` VALUES ('ASR_GroqASR', 'ASR', 'GroqASR', 'Groq语音识别', 0, 1, '{\"type\": \"openai\", \"api_key\": \"\", \"base_url\": \"https://api.groq.com/openai/v1/audio/transcriptions\", \"model_name\": \"whisper-large-v3-turbo\", \"output_dir\": \"tmp/\"}', NULL, NULL, 10, NULL, NULL, NULL, NULL); - - --- 更新OpenAI ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://platform.openai.com/docs/api-reference/audio/createTranscription', -`remark` = 'OpenAI ASR配置说明: -1. 需要在OpenAI开放平台创建组织并获取api_key -2. 支持中、英、日、韩等多种语音识别,具体参考文档https://platform.openai.com/docs/guides/speech-to-text -3. 需要网络连接 -4. 输出文件保存在tmp/目录 -申请步骤: -**OpenAi ASR申请步骤:** -1.登录OpenAI Platform。https://auth.openai.com/log-in -2.创建api-key https://platform.openai.com/settings/organization/api-keys -3.模型可以选择gpt-4o-transcribe或GPT-4o mini Transcribe -' WHERE `id` = 'ASR_OpenaiASR'; - --- 更新Groq ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.groq.com/docs/speech-to-text', -`remark` = 'Groq ASR配置说明: -1.登录groq Console。https://console.groq.com/home -2.创建api-key https://console.groq.com/keys -3.模型可以选择whisper-large-v3-turbo或whisper-large-v3(distil-whisper-large-v3-en仅支持英语转录) -' WHERE `id` = 'ASR_GroqASR'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202508081701.sql b/main/manager-api/src/main/resources/db/changelog/202508081701.sql deleted file mode 100644 index 4f427514c..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202508081701.sql +++ /dev/null @@ -1,32 +0,0 @@ --- 添加Index-TTS-vLLM流式TTS供应器 -delete from `ai_model_provider` where id = 'SYSTEM_TTS_IndexStreamTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_TTS_IndexStreamTTS', 'TTS', 'index_stream', 'Index-TTS-vLLM流式语音合成', '[{"key":"api_url","label":"API服务地址","type":"string"},{"key":"voice","label":"默认音色","type":"string"},{"key":"audio_format","label":"音频格式","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 16, 1, NOW(), 1, NOW()); - --- 添加Index-TTS-vLLM流式TTS模型配置 -delete from `ai_model_config` where id = 'TTS_IndexStreamTTS'; -INSERT INTO `ai_model_config` VALUES ('TTS_IndexStreamTTS', 'TTS', 'IndexStreamTTS', 'Index-TTS-vLLM流式语音合成', 0, 1, '{\"type\": \"index_stream\", \"api_url\": \"http://127.0.0.1:11996/tts\", \"voice\": \"jay_klee\", \"audio_format\": \"pcm\", \"output_dir\": \"tmp/\"}', NULL, NULL, 19, NULL, NULL, NULL, NULL); - --- 更新Index-TTS-vLLM流式TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/Ksuriuri/index-tts-vllm', -`remark` = 'Index-TTS-vLLM流式TTS配置说明: -1. Index-TTS-vLLM是基于Index-TTS项目的vLLM推理服务,提供流式语音合成功能 -2. 支持多种音色,音质自然,适合各种语音交互场景 -3. 需要先部署Index-TTS-vLLM服务,然后配置API地址 -4. 支持实时流式合成,具有较低的延迟 -5. 支持自定义音色,可在项目assets文件夹下注册新音色 -部署步骤: -1. 克隆项目:git clone https://github.com/Ksuriuri/index-tts-vllm.git -2. 安装依赖:pip install -r requirements.txt -3. 启动服务:python app.py -4. 服务默认运行在 http://127.0.0.1:11996 -5. 如需其他音色,可到项目assets文件夹下注册 -6. 支持多种音频格式:pcm、wav、mp3等 -如需了解更多配置,请参考:https://github.com/Ksuriuri/index-tts-vllm/blob/master/README.md -' WHERE `id` = 'TTS_IndexStreamTTS'; - --- 添加Index-TTS-vLLM流式TTS音色 -delete from `ai_tts_voice` where tts_model_id = 'TTS_IndexStreamTTS'; --- 默认音色 -INSERT INTO `ai_tts_voice` VALUES ('TTS_IndexStreamTTS_0001', 'TTS_IndexStreamTTS', 'Jay Klee', 'jay_klee', '中文及中英文混合', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); diff --git a/main/manager-api/src/main/resources/db/changelog/202508111734.sql b/main/manager-api/src/main/resources/db/changelog/202508111734.sql deleted file mode 100644 index fb3162b10..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202508111734.sql +++ /dev/null @@ -1,16 +0,0 @@ --- 更新HuoshanDoubleStreamTTS供应器增加语速,音调等配置 -UPDATE `ai_model_provider` -SET fields = '[{"key": "ws_url", "type": "string", "label": "WebSocket地址"}, {"key": "appid", "type": "string", "label": "应用ID"}, {"key": "access_token", "type": "string", "label": "访问令牌"}, {"key": "resource_id", "type": "string", "label": "资源ID"}, {"key": "speaker", "type": "string", "label": "默认音色"}, {"key": "speech_rate", "type": "number", "label": "语速(-50~100)"}, {"key": "loudness_rate", "type": "number", "label": "音量(-50~100)"}, {"key": "pitch", "type": "number", "label": "音高(-12~12)"}]' -WHERE id = 'SYSTEM_TTS_HSDSTTS'; - -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.volcengine.com/speech/service/10007', -`remark` = '火山引擎语音合成服务配置说明: -1. 访问 https://www.volcengine.com/ 注册并开通火山引擎账号 -2. 访问 https://console.volcengine.com/speech/service/10007 开通语音合成大模型,购买音色 -3. 在页面底部获取appid和access_token -5. 资源ID固定为:volc.service_type.10029(大模型语音合成及混音) -6. 语速:-50~100,可不填,正常默认值0,可填-50~100 -7. 音量:-50~100,可不填,正常默认值0,可填-50~100 -8. 音高:-12~12,可不填,正常默认值0,可填-12~12 -9. 填入配置文件中' WHERE `id` = 'TTS_HuoshanDoubleStreamTTS'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202508131557.sql b/main/manager-api/src/main/resources/db/changelog/202508131557.sql deleted file mode 100644 index decfd0db5..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202508131557.sql +++ /dev/null @@ -1,26 +0,0 @@ --- 添加 paddle_speech 流式 TTS 供应器 -DELETE FROM `ai_model_provider` WHERE id = 'SYSTEM_TTS_PaddleSpeechTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) -VALUES ('SYSTEM_TTS_PaddleSpeechTTS', 'TTS', 'paddle_speech', 'PaddleSpeechTTS', -'[{"key":"protocol","label":"协议类型","type":"string","options":["websocket","http"]},{"key":"url","label":"服务地址","type":"string"},{"key":"spk_id","label":"音色","type":"int"},{"key":"sample_rate","label":"采样率","type":"float"},{"key":"speed","label":"语速","type":"float"},{"key":"volume","label":"音量","type":"float"},{"key":"save_path","label":"保存路径","type":"string"}]', -17, 1, NOW(), 1, NOW()); - --- 添加 paddle_speech 流式 TTS 模型配置 -DELETE FROM `ai_model_config` WHERE id = 'TTS_PaddleSpeechTTS'; -INSERT INTO `ai_model_config` VALUES ('TTS_PaddleSpeechTTS', 'TTS', 'PaddleSpeechTTS', 'PaddleSpeechTTS', 0, 1, -'{"type": "paddle_speech", "protocol": "websocket", "url": "ws://127.0.0.1:8092/paddlespeech/tts/streaming", "spk_id": "0", "sample_rate": 24000, "speed": 1.0, "volume": 1.0, "save_path": "./streaming_tts.wav"}', -NULL, NULL, 20, NULL, NULL, NULL, NULL); - --- 更新 PaddleSpeechTTS 配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://github.com/PaddlePaddle/PaddleSpeech', -`remark` = 'PaddleSpeechTTS 配置说明: -1. PaddleSpeech 是百度飞桨开源的语音合成工具,支持本地离线部署和模型训练。paddlepaddle百度飞浆框架地址:https://www.paddlepaddle.org.cn/ -2. 支持 WebSocket 和 HTTP 协议,默认使用 WebSocket 进行流式传输(参考部署文档:https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/paddlespeech-deploy.md)。 -3. 使用前要在本地部署 paddlespeech 服务,服务默认运行在 ws://127.0.0.1:8092/paddlespeech/tts/streaming -4. 支持自定义发音人、语速、音量和采样率。 -' WHERE `id` = 'TTS_PaddleSpeechTTS'; - --- 删除旧音色并添加默认音色 -DELETE FROM `ai_tts_voice` WHERE tts_model_id = 'TTS_PaddleSpeechTTS'; -INSERT INTO `ai_tts_voice` VALUES ('TTS_PaddleSpeechTTS_0000', 'TTS_PaddleSpeechTTS', '默认', '0', '中文', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202508271113.sql b/main/manager-api/src/main/resources/db/changelog/202508271113.sql deleted file mode 100644 index 6d0208036..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202508271113.sql +++ /dev/null @@ -1,24 +0,0 @@ --- VOSK ASR模型供应器 -delete from `ai_model_provider` where id = 'SYSTEM_ASR_VoskASR'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_VoskASR', 'ASR', 'vosk', 'VOSK离线语音识别', '[{"key": "model_path", "type": "string", "label": "模型路径"}, {"key": "output_dir", "type": "string", "label": "输出目录"}]', 11, 1, NOW(), 1, NOW()); - --- VOSK ASR模型配置 -delete from `ai_model_config` where id = 'ASR_VoskASR'; -INSERT INTO `ai_model_config` VALUES ('ASR_VoskASR', 'ASR', 'VoskASR', 'VOSK离线语音识别', 0, 1, '{\"type\": \"vosk\", \"model_path\": \"\", \"output_dir\": \"tmp/\"}', NULL, NULL, 11, NULL, NULL, NULL, NULL); - --- 更新VOSK ASR配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://alphacephei.com/vosk/', -`remark` = 'VOSK ASR配置说明: -1. VOSK是一个离线语音识别库,支持多种语言 -2. 需要先下载模型文件:https://alphacephei.com/vosk/models -3. 中文模型推荐使用vosk-model-small-cn-0.22或vosk-model-cn-0.22 -4. 完全离线运行,无需网络连接 -5. 输出文件保存在tmp/目录 -使用步骤: -1. 访问 https://alphacephei.com/vosk/models 下载中文模型 -2. 解压模型文件到项目目录下的models/vosk/文件夹 -3. 在配置中指定正确的模型路径 -4. 注意:VOSK中文模型输出不带标点符号,词与词之间会有空格 -' WHERE `id` = 'ASR_VoskASR'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202509051745.sql b/main/manager-api/src/main/resources/db/changelog/202509051745.sql deleted file mode 100644 index 6dc922227..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509051745.sql +++ /dev/null @@ -1,45 +0,0 @@ --- 添加 MinimaxHTTPStream 流式 TTS 供应器 -delete from `ai_model_provider` where id = 'SYSTEM_TTS_MinimaxStreamTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_TTS_MinimaxStreamTTS', 'TTS', 'minimax_httpstream', 'Minimax流式语音合成', '[{"key":"group_id","label":"组ID","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"model","label":"模型","type":"string"},{"key":"voice_id","label":"音色ID","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"voice_setting","label":"音色设置","type":"dict","dict_name":"voice_setting"},{"key":"pronunciation_dict","label":"发音字典","type":"dict","dict_name":"pronunciation_dict"},{"key":"audio_setting","label":"音频设置","type":"dict","dict_name":"audio_setting"},{"key":"timber_weights","label":"音色权重","type":"string"}]', 18, 1, NOW(), 1, NOW()); - --- 添加Minimax流式TTS模型配置 -delete from `ai_model_config` where id = 'TTS_MinimaxStreamTTS'; -INSERT INTO `ai_model_config` VALUES ('TTS_MinimaxStreamTTS', 'TTS', 'MinimaxStreamTTS', 'Minimax流式语音合成', 0, 1, '{"type": "minimax_httpstream", "group_id": "", "api_key": "", "model": "speech-01-turbo", "voice_id": "female-shaonv", "output_dir": "tmp/", "voice_setting": {"speed": 1, "vol": 1, "pitch": 0, "emotion": "happy"}, "pronunciation_dict": {"tone": ["处理/(chu3)(li3)", "危险/dangerous"]}, "audio_setting": {"sample_rate": 24000, "bitrate": 128000, "format": "pcm", "channel": 1}}', NULL, NULL, 21, NULL, NULL, NULL, NULL); - --- 更新Minimax流式TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://platform.minimaxi.com/', -`remark` = 'Minimax流式TTS配置说明: -1. 需要先申请Minimax API Key -2. 需要填写Group ID -3. 支持多种音色设置和音频参数调整 -4. 支持实时流式合成,具有较低的延迟 -5. 支持自定义发音字典和音色权重 -6. 隐藏参数配置:声音设定(voice_setting)、发音字典(pronunciation_dict)、音色权重(timber_weights) - - 语速(speed): 范围[0.5,2],默认1.0,取值越大语速越快 - - 音量(vol): 范围(0,10],默认1.0,取值越大音量越高 - - 音调(pitch): 范围[-12,12],默认0,取值需为整数 - - 情绪(emotion): 控制合成语音的情绪,支持7种值:["happy", "sad", "angry", "fearful", "disgusted", "surprised", "calm"],该参数仅对 speech-2.5-hd-preview、speech-2.5-turbo-preview、speech-02-hd、speech-02-turbo、speech-01-turbo、speech-01-hd 生效 - - timbre_weights与voice_id二选一必填 - - voice_id(请求的音色id,须和weight参数同步填写) - - weight(权重,最多支持4种音色混合。范围[1,100]) -' WHERE `id` = 'TTS_MinimaxStreamTTS'; - --- 添加Minimax流式TTS音色 -delete from `ai_tts_voice` where tts_model_id = 'TTS_MinimaxStreamTTS'; - --- 默认音色 -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0001', 'TTS_MinimaxStreamTTS', '少女音', 'female-shaonv', '中文', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0002', 'TTS_MinimaxStreamTTS', '成熟女声', 'female-chengshu', '中文', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0003', 'TTS_MinimaxStreamTTS', '霸道少爷', 'badao_shaoye', '中文', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0004', 'TTS_MinimaxStreamTTS', '病娇弟弟', 'bingjiao_didi', '中文', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0005', 'TTS_MinimaxStreamTTS', '纯真学弟', 'chunzhen_xuedi', '中文', NULL, NULL, NULL, NULL, 5, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0006', 'TTS_MinimaxStreamTTS', '冷淡学长', 'lengdan_xiongzhang', '中文', NULL, NULL, NULL, NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0007', 'TTS_MinimaxStreamTTS', '甜美小玲', 'tianxin_xiaoling', '中文', NULL, NULL, NULL, NULL, 7, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0008', 'TTS_MinimaxStreamTTS', '俏皮萌妹', 'qiaopi_mengmei', '中文', NULL, NULL, NULL, NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0009', 'TTS_MinimaxStreamTTS', '妩媚御姐', 'wumei_yujie', '中文', NULL, NULL, NULL, NULL, 9, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0010', 'TTS_MinimaxStreamTTS', '嗲嗲学妹', 'diadia_xuemei', '中文', NULL, NULL, NULL, NULL, 7, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0011', 'TTS_MinimaxStreamTTS', '淡雅学姐', 'danya_xuejie', '中文', NULL, NULL, NULL, NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0012', 'TTS_MinimaxStreamTTS', 'Santa Claus', 'Santa_Claus', '中文', NULL, NULL, NULL, NULL, 9, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_MinimaxStreamTTS_0013', 'TTS_MinimaxStreamTTS', 'Grinch', 'Grinch', '中文', NULL, NULL, NULL, NULL, 10, NULL, NULL, NULL, NULL); diff --git a/main/manager-api/src/main/resources/db/changelog/202509080922.sql b/main/manager-api/src/main/resources/db/changelog/202509080922.sql deleted file mode 100644 index 424b3cd85..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509080922.sql +++ /dev/null @@ -1,8 +0,0 @@ -delete from `sys_params` where param_code = 'server.mqtt_gateway'; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (116, 'server.mqtt_gateway', 'null', 'string', 1, 'mqtt gateway 配置'); - -delete from `sys_params` where param_code = 'server.mqtt_signature_key'; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (117, 'server.mqtt_signature_key', 'null', 'string', 1, 'mqtt 密钥 配置'); - -delete from `sys_params` where param_code = 'server.udp_gateway'; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (118, 'server.udp_gateway', 'null', 'string', 1, 'udp gateway 配置'); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202509081140.sql b/main/manager-api/src/main/resources/db/changelog/202509081140.sql deleted file mode 100644 index 9dec9d041..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509081140.sql +++ /dev/null @@ -1,4 +0,0 @@ --- 添加声纹识别相似度阈值参数配置 -delete from `sys_params` where id = 115; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) -VALUES (115, 'server.voiceprint_similarity_threshold', '0.4', 'string', 1, '声纹识别相似度阈值,范围0.0-1.0,默认0.4,数值越高越严格'); diff --git a/main/manager-api/src/main/resources/db/changelog/202509091042.sql b/main/manager-api/src/main/resources/db/changelog/202509091042.sql deleted file mode 100644 index 5392738a9..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509091042.sql +++ /dev/null @@ -1,10 +0,0 @@ --- 删除非流式MiniMax TTS配置,保留流式版本 - --- 删除旧的非流式MiniMax TTS模型配置 -DELETE FROM `ai_model_config` WHERE `id` = 'TTS_MinimaxTTS'; - --- 删除旧的非流式MiniMax TTS供应器配置 -DELETE FROM `ai_model_provider` WHERE `id` = 'SYSTEM_TTS_minimax'; - --- 删除旧的非流式MiniMax TTS音色配置 -DELETE FROM `ai_tts_voice` WHERE `tts_model_id` = 'TTS_MinimaxTTS'; diff --git a/main/manager-api/src/main/resources/db/changelog/202509091633.sql b/main/manager-api/src/main/resources/db/changelog/202509091633.sql deleted file mode 100644 index 087bab411..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509091633.sql +++ /dev/null @@ -1,16 +0,0 @@ --- 添加通义千问Qwen3-ASR-Flash语音识别服务配置 -delete from `ai_model_provider` where id = 'SYSTEM_ASR_Qwen3Flash'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_Qwen3Flash', 'ASR', 'qwen3_asr_flash', 'Qwen3-ASR-Flash语音识别', '[{"key":"api_key","label":"API密钥","type":"password"},{"key":"base_url","label":"服务地址","type":"string"},{"key":"model_name","label":"模型名称","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 17, 1, NOW(), 1, NOW()); - -delete from `ai_model_config` where id = 'ASR_Qwen3Flash'; -INSERT INTO `ai_model_config` VALUES ('ASR_Qwen3Flash', 'ASR', 'Qwen3-ASR-Flash', '通义千问语音识别服务', 0, 1, '{"type": "qwen3_asr_flash", "api_key": "", "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1", "model_name": "qwen3-asr-flash", "output_dir": "tmp/", "enable_lid": true, "enable_itn": true}', 'https://help.aliyun.com/zh/bailian/', '支持多语言识别、歌唱识别、噪声拒识功能', 20, NULL, NULL, NULL, NULL); - --- 更新Qwen3-ASR-Flash模型配置的说明文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://bailian.console.aliyun.com/?apiKey=1&tab=doc#/doc/?type=model&url=2979031', -`remark` = '通义千问Qwen3-ASR-Flash配置说明: -1. 登录阿里云百炼平台https://bailian.console.aliyun.com/ -2. 创建API-KEY https://bailian.console.aliyun.com/#/api-key -3.Qwen3-ASR-Flash基于通义千问多模态基座,支持多语言识别、歌唱识别、噪声拒识等功能 -' WHERE `id` = 'ASR_Qwen3Flash'; diff --git a/main/manager-api/src/main/resources/db/changelog/202509161610.sql b/main/manager-api/src/main/resources/db/changelog/202509161610.sql deleted file mode 100644 index df4b1fcbf..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509161610.sql +++ /dev/null @@ -1,3 +0,0 @@ -delete from `sys_params` where param_code = 'server.mqtt_manager_api'; -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) -VALUES (119, 'server.mqtt_manager_api', 'null', 'string', 1, 'MQTT网关管理API的地址'); diff --git a/main/manager-api/src/main/resources/db/changelog/202509161701.sql b/main/manager-api/src/main/resources/db/changelog/202509161701.sql deleted file mode 100644 index fe7b0a763..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509161701.sql +++ /dev/null @@ -1,54 +0,0 @@ --- 添加阿里百炼流式TTS 供应器 -delete from `ai_model_provider` where id = 'SYSTEM_TTS_AliBLStreamTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_TTS_AliBLStreamTTS', 'TTS', 'alibl_stream', '阿里百炼流式语音合成', '[{"key":"api_key","label":"API密钥","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"model","label":"模型","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"format","label":"音频格式","type":"string"},{"key":"sample_rate","label":"采样率","type":"number"},{"key": "volume", "type": "number", "label": "音量"},{"key": "rate", "type": "number", "label": "语速"},{"key": "pitch", "type": "number", "label": "音调"}]', 19, 1, NOW(), 1, NOW()); - --- 添加阿里百炼流式TTS模型配置 -delete from `ai_model_config` where id = 'TTS_AliBLStreamTTS'; -INSERT INTO `ai_model_config` VALUES ('TTS_AliBLStreamTTS', 'TTS', 'AliBLStreamTTS', '阿里百炼流式语音合成', 0, 1, '{\"type\": \"alibl_stream\", \"appkey\": \"\", \"output_dir\": \"tmp/\", \"model\": \"cosyvoice-v2\", \"voice\": \"longcheng_v2\", \"format\": \"pcm\", \"sample_rate\": 24000, \"volume\": 50, \"rate\": 1, \"pitch\": 1}', NULL, NULL, 22, NULL, NULL, NULL, NULL); - --- 更新阿里百炼流式TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://bailian.console.aliyun.com/?apiKey=1#/api-key', -`remark` = '阿里百炼流式TTS说明: -1. 访问 https://bailian.console.aliyun.com/?apiKey=1#/api-key 创建项目并获取appkey -2. 支持实时流式合成,具有较低的延迟 -3. 支持多种音色设置和音频参数调整 -4. 支持CosyVoice-V3大模型音色,价格实惠(0.4元/万字符) -5. 支持实时调节音量、语速、音调等参数 -6. 如果需要使用CosyVoice-V3模型和一些限制类型的音色,需要联系阿里百炼客服申请 -' WHERE `id` = 'TTS_AliBLStreamTTS'; - --- 添加阿里百炼流式TTS音色 -delete from `ai_tts_voice` where tts_model_id = 'TTS_AliBLStreamTTS'; - --- 语音助手 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0001', 'TTS_AliBLStreamTTS', '龙小淳-知性积极女', 'longxiaochun_v2', '中文及中英文混合', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0002', 'TTS_AliBLStreamTTS', '龙小夏-沉稳权威女', 'longxiaoxia_v2', '中文及中英文混合', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL); - --- 直播带货 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0003', 'TTS_AliBLStreamTTS', '龙安燃-活泼质感女', 'longanran', '中文及中英文混合', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0004', 'TTS_AliBLStreamTTS', '龙安宣-经典直播女', 'longanxuan', '中文及中英文混合', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL); - --- 社交陪伴 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0005', 'TTS_AliBLStreamTTS', '龙寒-温暖痴情男', 'longhan_v2', '中文及中英文混合', NULL, NULL, NULL, NULL, 5, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0006', 'TTS_AliBLStreamTTS', '龙颜-温暖春风女', 'longyan_v2', '中文及中英文混合', NULL, NULL, NULL, NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0007', 'TTS_AliBLStreamTTS', '龙菲菲-甜美矫情女', 'longfeifei_v2', '中文及中英文混合', NULL, NULL, NULL, NULL, 7, NULL, NULL, NULL, NULL); - --- 方言 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0008', 'TTS_AliBLStreamTTS', '龙老铁-东北直率男', 'longlaotie_v2', '中文(东北)及中英文混合', NULL, NULL, NULL, NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0009', 'TTS_AliBLStreamTTS', '龙嘉怡-知性粤语女', 'longjiayi_v2', '中文(粤语)及中英文混合', NULL, NULL, NULL, NULL, 9, NULL, NULL, NULL, NULL); - --- 童声 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0010', 'TTS_AliBLStreamTTS', '龙杰力豆-阳光顽皮男', 'longjielidou_v2', '中文及中英文混合', NULL, NULL, NULL, NULL, 10, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0011', 'TTS_AliBLStreamTTS', '龙铃-稚气呆板女', 'longling_v2', '中文及中英文混合', NULL, NULL, NULL, NULL, 11, NULL, NULL, NULL, NULL); - --- 诗歌朗诵 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0012', 'TTS_AliBLStreamTTS', '李白-古代诗仙男', 'libai_v2', '中文及中英文混合', NULL, NULL, NULL, NULL, 12, NULL, NULL, NULL, NULL); - --- 出海营销 -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0013', 'TTS_AliBLStreamTTS', 'loongeva-知性英文女', 'loongeva_v2', '英式英文', NULL, NULL, NULL, NULL, 13, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0014', 'TTS_AliBLStreamTTS', 'loongbrian-沉稳英文男', 'loongbrian_v2', '英式英文', NULL, NULL, NULL, NULL, 14, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0015', 'TTS_AliBLStreamTTS', 'loongkyong-韩语女', 'loongkyong_v2', '韩语', NULL, NULL, NULL, NULL, 15, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0016', 'TTS_AliBLStreamTTS', 'loongtomoka-日语女', 'loongtomoka_v2', '日语', NULL, NULL, NULL, NULL, 16, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_AliBLStreamTTS_0017', 'TTS_AliBLStreamTTS', 'loongtomoya-日语男', 'loongtomoya_v2', '日语', NULL, NULL, NULL, NULL, 17, NULL, NULL, NULL, NULL); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202509191545.sql b/main/manager-api/src/main/resources/db/changelog/202509191545.sql deleted file mode 100644 index a19929773..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509191545.sql +++ /dev/null @@ -1,41 +0,0 @@ --- 添加讯飞流式TTS供应器 -delete from `ai_model_provider` where id = 'SYSTEM_TTS_XunFeiStreamTTS'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_TTS_XunFeiStreamTTS', 'TTS', 'xunfei_stream', '讯飞流式语音合成', '[{"key":"app_id","label":"APP_ID","type":"string"},{"key":"api_secret","label":"API_Secret","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"format","label":"音频格式","type":"string"},{"key":"sample_rate","label":"采样率","type":"number"},{"key": "volume", "type": "number", "label": "音量"},{"key": "speed", "type": "number", "label": "语速"},{"key": "pitch", "type": "number", "label": "音调"},{"key": "oral_level", "type": "number", "label": "口语化等级"},{"key": "spark_assist", "type": "number", "label": "是否口语化"},{"key": "stop_split", "type": "number", "label": "服务端拆句"},{"key": "remain", "type": "number", "label": "保留书面语"}]', 20, 1, NOW(), 1, NOW()); - --- 添加讯飞流式TTS模型配置 -delete from `ai_model_config` where id = 'TTS_XunFeiStreamTTS'; -INSERT INTO `ai_model_config` VALUES ('TTS_XunFeiStreamTTS', 'TTS', 'XunFeiStreamTTS', '讯飞流式语音合成', 0, 1, '{\"type\": \"xunfei_stream\", \"app_id\": \"\", \"api_secret\": \"\", \"api_key\": \"\", \"output_dir\": \"tmp/\", \"voice\": \"x5_lingxiaoxuan_flow\", \"format\": \"raw\", \"sample_rate\": 24000, \"volume\": 50, \"speed\": 50, \"pitch\": 50, \"oral_level\": \"mid\", \"spark_assist\": 1, \"stop_split\": 0, \"remain\": 0}', NULL, NULL, 23, NULL, NULL, NULL, NULL); - --- 更新讯飞流式TTS配置说明 -UPDATE `ai_model_config` SET -`doc_link` = 'https://console.xfyun.cn/app/myapp', -`remark` = '讯飞流式TTS说明: -1. 登录讯飞语音技术平台 https://console.xfyun.cn/app/myapp 创建相关应用 -2. 选择需要的服务获取api相关配置 https://console.xfyun.cn/services/uts -3. 为需要使用的应用(APPID)购买相关服务 例如:超拟人合成 https://console.xfyun.cn/services/uts -5. 支持实时双流式通信,具有较低的延迟 -6. 支持口语化设置和音频参数调整 注意:V5音色不支持相关口语化配置 -7. 支持实时调节音量、语速、音调等参数 -' WHERE `id` = 'TTS_XunFeiStreamTTS'; - --- 添加讯飞流式TTS音色 -delete from `ai_tts_voice` where tts_model_id = 'TTS_XunFeiStreamTTS'; - --- 基础角色 -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0001', 'TTS_XunFeiStreamTTS', '聆小璇', 'x5_lingxiaoxuan_flow', '中文', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0002', 'TTS_XunFeiStreamTTS', '聆飞逸', 'x5_lingfeiyi_flow', '中文', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0003', 'TTS_XunFeiStreamTTS', '聆小玥', 'x5_lingxiaoyue_flow', '中文', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0004', 'TTS_XunFeiStreamTTS', '聆玉昭', 'x5_lingyuzhao_flow', '中文', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0005', 'TTS_XunFeiStreamTTS', '聆玉言', 'x5_lingyuyan_flow', '中文', NULL, NULL, NULL, NULL, 5, NULL, NULL, NULL, NULL); - --- 需要添加对应的角色音色 -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0006', 'TTS_XunFeiStreamTTS', '聆飞哲', 'x4_lingfeizhe_oral', '中文', NULL, NULL, NULL, NULL, 6, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0007', 'TTS_XunFeiStreamTTS', '聆小璃', 'x4_lingxiaoli_oral', '中文', NULL, NULL, NULL, NULL, 7, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0008', 'TTS_XunFeiStreamTTS', '聆小糖', 'x5_lingxiaotang_flow', '中文', NULL, NULL, NULL, NULL, 8, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0009', 'TTS_XunFeiStreamTTS', '聆小琪', 'x4_lingxiaoqi_oral', '中文', NULL, NULL, NULL, NULL, 9, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0010', 'TTS_XunFeiStreamTTS', '聆佑佑-童年女声', 'x4_lingyouyou_oral', '中文', NULL, NULL, NULL, NULL, 10, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0011', 'TTS_XunFeiStreamTTS', '子津', 'x4_zijin_oral', '天津话', NULL, NULL, NULL, NULL, 11, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0012', 'TTS_XunFeiStreamTTS', '子阳', 'x4_ziyang_oral', '东北话', NULL, NULL, NULL, NULL, 12, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0013', 'TTS_XunFeiStreamTTS', 'Grant', 'x5_EnUs_Grant_flow', '英文', NULL, NULL, NULL, NULL, 13, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0014', 'TTS_XunFeiStreamTTS', 'Lila', 'x5_EnUs_Lila_flow', '英文', NULL, NULL, NULL, NULL, 14, NULL, NULL, NULL, NULL); diff --git a/main/manager-api/src/main/resources/db/changelog/202509220926.sql b/main/manager-api/src/main/resources/db/changelog/202509220926.sql deleted file mode 100644 index 060fa4d95..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509220926.sql +++ /dev/null @@ -1,26 +0,0 @@ --- 添加讯飞流式语音识别服务配置 -delete from `ai_model_provider` where id = 'SYSTEM_ASR_XunfeiStream'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_ASR_XunfeiStream', 'ASR', 'xunfei_stream', '讯飞流式语音识别', '[{"key":"app_id","label":"应用ID","type":"string"},{"key":"api_key","label":"API_KEY","type":"password"},{"key":"api_secret","label":"API_SECRET","type":"password"},{"key":"domain","label":"识别领域","type":"string"},{"key":"language","label":"识别语言","type":"string"},{"key":"accent","label":"方言","type":"string"},{"key":"dwa","label":"动态修正","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 18, 1, NOW(), 1, NOW()); - -delete from `ai_model_config` where id = 'ASR_XunfeiStream'; -INSERT INTO `ai_model_config` VALUES ('ASR_XunfeiStream', 'ASR', '讯飞流式语音识别', '讯飞流式语音识别服务', 0, 1, '{"type": "xunfei_stream", "app_id": "", "api_key": "", "api_secret": "", "domain": "slm", "language": "zh_cn", "accent": "mandarin", "dwa": "wpgs", "output_dir": "tmp/"}', 'https://www.xfyun.cn/doc/spark/spark_zh_iat.html', '支持实时流式语音识别,适用于中文普通话及多种方言识别', 21, NULL, NULL, NULL, NULL); - --- 更新讯飞流式语音识别模型配置的说明文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://www.xfyun.cn/doc/spark/spark_zh_iat.html', -`remark` = '讯飞流式语音识别配置说明: -1. 登录讯飞开放平台 https://www.xfyun.cn/ -2. 创建语音识别应用获取APPID、APISecret、APIKey -3. 参数说明: - - app_id: 应用ID,在讯飞开放平台创建应用后获得 - - api_key: API密钥,用于接口鉴权 - - api_secret: API密钥,用于生成签名 - - domain: 识别领域,默认slm(智能化语音转写) - - language: 识别语言,默认zh_cn(中文) - - accent: 方言类型,默认mandarin(普通话),支持cantonese(粤语)等 - - dwa: 动态修正,默认wpgs(开启动态修正) - - output_dir: 音频文件输出目录,默认tmp/ -4. 支持实时流式识别,适用于实时语音交互场景 -5. 支持多种方言和语言识别 -' WHERE `id` = 'ASR_XunfeiStream'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202509220958.sql b/main/manager-api/src/main/resources/db/changelog/202509220958.sql deleted file mode 100644 index b05faa1c1..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509220958.sql +++ /dev/null @@ -1,19 +0,0 @@ -delete from `ai_model_config` where id = 'LLM_XunfeiSparkLLM'; -INSERT INTO `ai_model_config` VALUES ('LLM_XunfeiSparkLLM', 'LLM', '讯飞星火认知大模型', '讯飞星火认知大模型', 0, 1, '{"type": "openai", "model_name": "generalv3.5", "base_url": "https://spark-api-open.xf-yun.com/v1", "api_password": "你的api_password", "temperature": 0.5, "max_tokens": 2048, "top_p": 1.0, "frequency_penalty": 0.0}', 'https://www.xfyun.cn/doc/spark/HTTP%E8%B0%83%E7%94%A8%E6%96%87%E6%A1%A3.html', '讯飞星火认知大模型,支持多轮对话、文本生成等功能', 14, NULL, NULL, NULL, NULL); - --- 更新讯飞星火认知大模型配置的说明文档 -UPDATE `ai_model_config` SET -`doc_link` = 'https://www.xfyun.cn/doc/spark/HTTP%E8%B0%83%E7%94%A8%E6%96%87%E6%A1%A3.html', -`remark` = '讯飞星火认知大模型配置说明: -1. 登录讯飞开放平台 https://www.xfyun.cn/,每一个模型对应每一个api_password,更改模型时需要查看对应模型的api_password -2. 创建星火认知大模型应用获取API Password -3. 参数说明: - - api_password: API Password,在讯飞开放平台创建应用后获得 - - model_name: 模型名称,支持generalv3.5、generalv3等版本 - - base_url: API地址,默认https://spark-api-open.xf-yun.com/v1 - - temperature: 温度参数,控制生成随机性,范围0-1,默认0.5 - - max_tokens: 最大输出token数,默认2048 - - top_p: 核心采样参数,控制词汇多样性,默认1.0 - - frequency_penalty: 频率惩罚,降低重复内容,默认0.0 -4. 每一个模型对应每一个api_password,更改模型时需要查看对应模型的api_password。 -' WHERE `id` = 'LLM_XunfeiSparkLLM'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202509221530.sql b/main/manager-api/src/main/resources/db/changelog/202509221530.sql deleted file mode 100644 index 078fbfae3..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202509221530.sql +++ /dev/null @@ -1,7 +0,0 @@ --- 添加SM2国密算法密钥参数 --- 用于服务器端SM2加密解密功能 - --- 添加SM2密钥参数 -INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES -(120, 'server.public_key', '', 'string', 1, '服务器SM2公钥'), -(121, 'server.private_key', '', 'string', 1, '服务器SM2私钥'); \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202510071522.sql b/main/manager-api/src/main/resources/db/changelog/202510071522.sql deleted file mode 100644 index f53d42279..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202510071522.sql +++ /dev/null @@ -1,19 +0,0 @@ --- 声音克隆表 -DROP TABLE IF EXISTS `ai_voice_clone`; -CREATE TABLE `ai_voice_clone` ( - `id` VARCHAR(32) NOT NULL COMMENT '唯一标识', - `name` VARCHAR(64) COMMENT '声音名称', - `model_id` VARCHAR(32) COMMENT '模型id', - `voice_id` VARCHAR(32) COMMENT '声音id', - `user_id` BIGINT COMMENT '用户 ID(关联用户表)', - `voice` LONGBLOB COMMENT '声音', - `train_status` TINYINT(1) DEFAULT 0 COMMENT '训练状态:0待训练 1训练中 2训练成功 3训练失败', - `train_error` VARCHAR(255) COMMENT '训练错误原因', - `creator` BIGINT COMMENT '创建者 ID', - `create_date` DATETIME COMMENT '创建时间', - PRIMARY KEY (`id`), - INDEX idx_ai_voice_clone_user_id_model_id_train_status (model_id,user_id, train_status), - INDEX idx_ai_voice_clone_voice_id (voice_id), - INDEX idx_ai_voice_clone_user_id (user_id), - INDEX idx_ai_voice_clone_model_id_voice_id (model_id, voice_id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='声音克隆表'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202510191042.sql b/main/manager-api/src/main/resources/db/changelog/202510191042.sql deleted file mode 100644 index 1511645bd..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202510191042.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE `ai_model_config` SET model_code = 'XunfeiSparkLLM' WHERE id = 'LLM_XunfeiSparkLLM'; -UPDATE `ai_model_config` SET model_code = 'XunfeiStreamASR' WHERE id = 'ASR_XunfeiStream'; \ No newline at end of file diff --git a/main/manager-api/src/main/resources/db/changelog/202511051120.sql b/main/manager-api/src/main/resources/db/changelog/202511051120.sql deleted file mode 100644 index ccc4322d6..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202511051120.sql +++ /dev/null @@ -1,68 +0,0 @@ --- 添加 ElevenLabs 和 Cartesia TTS 供应器和模型配置 - --- ==================== ElevenLabs TTS ==================== - --- 添加 ElevenLabs TTS 供应器 -DELETE FROM `ai_model_provider` WHERE id = 'TTS_ElevenLabs'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('TTS_ElevenLabs', 'TTS', 'elevenlabs', 'ElevenLabs TTS', '[{"key":"api_key","label":"API Key","type":"string"},{"key":"voice_id","label":"Voice ID","type":"string"},{"key":"model","label":"Model","type":"string"},{"key":"output_format","label":"Output Format","type":"string"},{"key":"stability","label":"Stability","type":"number"},{"key":"similarity_boost","label":"Similarity Boost","type":"number"},{"key":"style","label":"Style","type":"number"},{"key":"use_speaker_boost","label":"Use Speaker Boost","type":"string"},{"key":"optimize_streaming_latency","label":"Optimize Streaming Latency","type":"number"},{"key":"output_dir","label":"Output Directory","type":"string"}]', 21, 1, NOW(), 1, NOW()); - --- 添加 ElevenLabs TTS 模型配置 -DELETE FROM `ai_model_config` WHERE id = 'TTS_ElevenLabs'; -INSERT INTO `ai_model_config` VALUES ( - 'TTS_ElevenLabs', - 'TTS', - 'ElevenLabs', - 'ElevenLabs TTS', - 0, - 1, - '{\"type\": \"elevenlabs\", \"api_key\": \"\", \"voice_id\": \"21m00Tcm4TlvDq8ikWAM\", \"model\": \"eleven_multilingual_v2\", \"output_format\": \"pcm_16000\", \"stability\": 0.5, \"similarity_boost\": 0.75, \"style\": 0.0, \"use_speaker_boost\": true, \"optimize_streaming_latency\": 3, \"output_dir\": \"tmp/\"}', - 'https://elevenlabs.io/docs/introduction', - 'ElevenLabs TTS 配置说明:\n1. ElevenLabs 提供高质量、情感丰富的语音合成服务\n2. 支持多语言(包括英文、中文等)和声音克隆功能\n3. 使用官方 Python SDK,延迟低、质量高\n4. API Key 获取:访问 https://elevenlabs.io/ 注册并获取\n5. Voice ID 可在 ElevenLabs 控制台中找到预设音色或创建自定义音色\n6. Model 推荐使用 eleven_multilingual_v2(多语言)或 eleven_turbo_v2(低延迟)\n7. Stability (0-1): 控制语音稳定性,越高越稳定但变化少\n8. Similarity Boost (0-1): 控制与原音色的相似度\n9. Style (0-1): 控制语音风格强度\n10. Optimize Streaming Latency (0-4): 优化流式延迟,推荐 2-3', - 23, - NULL, - NULL, - NULL, - NULL -); - --- 添加 ElevenLabs 音色配置 -DELETE FROM `ai_tts_voice` WHERE id IN ('TTS_ElevenLabs0001', 'TTS_ElevenLabs0002', 'TTS_ElevenLabs0003', 'TTS_ElevenLabs0004'); -INSERT INTO `ai_tts_voice` VALUES ('TTS_ElevenLabs0001', 'TTS_ElevenLabs', 'Rachel - Female', '21m00Tcm4TlvDq8ikWAM', 'English', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_ElevenLabs0002', 'TTS_ElevenLabs', 'Drew - Male', '29vD33N1CtxCmqQRPOHJ', 'English', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_ElevenLabs0003', 'TTS_ElevenLabs', 'Clyde - Male', '2EiwWnXFnvU5JabPnv8n', 'English', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_ElevenLabs0004', 'TTS_ElevenLabs', 'Bella - Female', 'EXAVITQu4vr4xnSDxMaL', 'English', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL); - --- ==================== Cartesia TTS ==================== - --- 添加 Cartesia TTS 供应器 -DELETE FROM `ai_model_provider` WHERE id = 'TTS_Cartesia'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('TTS_Cartesia', 'TTS', 'cartesia', 'Cartesia TTS', '[{"key":"api_key","label":"API Key","type":"string"},{"key":"voice_id","label":"Voice ID","type":"string"},{"key":"model","label":"Model","type":"string"},{"key":"language","label":"Language","type":"string"},{"key":"encoding","label":"Encoding","type":"string"},{"key":"sample_rate","label":"Sample Rate","type":"number"},{"key":"output_dir","label":"Output Directory","type":"string"}]', 22, 1, NOW(), 1, NOW()); - --- 添加 Cartesia TTS 模型配置 -DELETE FROM `ai_model_config` WHERE id = 'TTS_Cartesia'; -INSERT INTO `ai_model_config` VALUES ( - 'TTS_Cartesia', - 'TTS', - 'Cartesia', - 'Cartesia TTS', - 0, - 1, - '{\"type\": \"cartesia\", \"api_key\": \"\", \"voice_id\": \"a0e99841-438c-4a64-b679-ae501e7d6091\", \"model\": \"sonic-3\", \"language\": \"en\", \"encoding\": \"pcm_s16le\", \"sample_rate\": 24000, \"output_dir\": \"tmp/\"}', - 'https://docs.cartesia.ai/', - 'Cartesia TTS 配置说明:\n1. Cartesia 提供超低延迟的流式语音合成服务\n2. 使用官方 Python SDK,首包延迟极低(通常 < 200ms)\n3. 支持多种语言和声音(英语、西班牙语、法语、德语、中文等)\n4. API Key 获取:访问 https://cartesia.ai/ 注册并获取\n5. Voice ID 可在 Cartesia 控制台查看预设音色\n6. Model 选项:sonic-english(英语)、sonic-multilingual(多语言)\n7. Encoding: pcm_s16le(推荐)、pcm_mulaw 等\n8. Sample Rate: 8000/16000/24000/44100(推荐 24000)\n9. 特别适合需要实时交互的场景(如语音助手、客服)', - 24, - NULL, - NULL, - NULL, - NULL -); - --- 添加 Cartesia 音色配置 -DELETE FROM `ai_tts_voice` WHERE id IN ('TTS_Cartesia0001', 'TTS_Cartesia0002', 'TTS_Cartesia0003', 'TTS_Cartesia0004'); -INSERT INTO `ai_tts_voice` VALUES ('TTS_Cartesia0001', 'TTS_Cartesia', 'Barbershop Man', 'a0e99841-438c-4a64-b679-ae501e7d6091', 'English', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_Cartesia0002', 'TTS_Cartesia', 'Kentucky Man', '41534e16-2966-4c6b-9670-111411def906', 'English', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_Cartesia0003', 'TTS_Cartesia', 'British Lady', '79a125e8-cd45-4c13-8a67-188112f4dd22', 'English', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL); -INSERT INTO `ai_tts_voice` VALUES ('TTS_Cartesia0004', 'TTS_Cartesia', 'Friendly Reader', '69267136-1bdc-412f-ad78-0caad210fb40', 'English', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL); - diff --git a/main/manager-api/src/main/resources/db/changelog/202511061415.sql b/main/manager-api/src/main/resources/db/changelog/202511061415.sql deleted file mode 100644 index 5b18db0db..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202511061415.sql +++ /dev/null @@ -1,26 +0,0 @@ --- 添加memU记忆配置 --- memU是一个开源的AI记忆框架,提供长期记忆管理服务 - --- 添加memU Memory Provider -delete from `ai_model_provider` where id = 'SYSTEM_Memory_memu'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('SYSTEM_Memory_memu', 'Memory', 'memu', 'memU记忆', '[{"key":"api_key","label":"API密钥","type":"password"},{"key":"base_url","label":"API地址","type":"string"},{"key":"user_name","label":"用户名称","type":"string"},{"key":"agent_name","label":"Agent名称","type":"string"}]', 4, 1, NOW(), 1, NOW()); - --- 添加memU Memory Config -delete from `ai_model_config` where id = 'Memory_memu'; -INSERT INTO `ai_model_config` VALUES ( - 'Memory_memu', - 'Memory', - 'memu', - 'memU记忆', - 0, - 1, - '{"type": "memu", "api_key": "mu_SJPB0t8dtY0IwL0B0RjpiVKbTEI4w8MD8YkYSVItNzxe-t3DlOtHIJnp53tJ-kr6BL06-uPN0U5WPGs4EpT5iuMZMsrfI1KYvVfg1w", "base_url": "https://api.memu.so", "user_name": "用户", "agent_name": "小智"}', - 'https://memu.pro/docs#memory', - 'memU是一个开源的AI记忆框架,提供自主管理、组织和演进AI记忆的高级代理记忆系统。支持自动分类、语义搜索和长期记忆管理。', - 4, - NULL, - NULL, - NULL, - NULL -); diff --git a/main/manager-api/src/main/resources/db/changelog/202511071245.sql b/main/manager-api/src/main/resources/db/changelog/202511071245.sql deleted file mode 100644 index ab09b80bc..000000000 --- a/main/manager-api/src/main/resources/db/changelog/202511071245.sql +++ /dev/null @@ -1,43 +0,0 @@ --- Add Deepgram TTS Provider and Model Configuration - --- ==================== Deepgram TTS ==================== - --- Add Deepgram TTS Provider -DELETE FROM `ai_model_provider` WHERE id = 'TTS_Deepgram'; -INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES -('TTS_Deepgram', 'TTS', 'deepgram', 'Deepgram TTS', '[{"key":"api_key","label":"API Key","type":"string"},{"key":"model","label":"Model","type":"string"}]', 20, 1, NOW(), 1, NOW()); - --- Add Deepgram TTS Model Configuration -DELETE FROM `ai_model_config` WHERE id = 'TTS_Deepgram'; -INSERT INTO `ai_model_config` ( - `id`, - `model_type`, - `model_code`, - `model_name`, - `is_default`, - `is_enabled`, - `config_json`, - `doc_link`, - `remark`, - `sort`, - `creator`, - `create_date`, - `updater`, - `update_date` -) VALUES ( - 'TTS_Deepgram', - 'TTS', - 'Deepgram', - 'Deepgram TTS', - 0, - 1, - '{"type": "deepgram", "api_key": "", "model": "aura-2-thalia-en"}', - 'https://developers.deepgram.com/docs/text-to-speech', - 'Deepgram TTS Configuration:\n1. Deepgram provides high-quality, low-latency AI text-to-speech service\n2. Uses official Deepgram Python SDK (deepgram-sdk)\n3. Supports multiple languages and Aura 2 voice models\n4. API Key: Register at https://console.deepgram.com/ to get your API key\n5. Model: Deepgram voice models directly specify the voice (e.g., aura-2-thalia-en, aura-2-stella-en, aura-2-orion-en)\n6. Available Models:\n - Female: aura-2-asteria-en, aura-2-luna-en, aura-2-stella-en, aura-2-athena-en\n - Male: aura-2-orion-en, aura-2-arcas-en, aura-2-perseus-en, aura-2-zeus-en\n7. Features: Natural voices, multi-language support, low latency\n8. Perfect for real-time voice applications and conversational AI', - 22, - NULL, - NULL, - NULL, - NULL -); - diff --git a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml deleted file mode 100755 index 5f7efe393..000000000 --- a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml +++ /dev/null @@ -1,425 +0,0 @@ -# 规范约定: -# id生成根据时间时分,文件名对应id,常变数据可以根据模块命名自定义 -# 每次对数据表进行改动时,只允许新建新对changeSet,不允许对上一个changeSet配置及文件进行修改 -databaseChangeLog: - - changeSet: - id: 202503141335 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202503141335.sql - - changeSet: - id: 202503141346 - author: czc - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202503141346.sql - - changeSet: - id: 202504082211 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504082211.sql - - changeSet: - id: 202504092335 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504092335.sql - - changeSet: - id: 202504112044 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504112044.sql - - changeSet: - id: 202504112058 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504112058.sql - - changeSet: - id: 202504151206 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504151206.sql - - changeSet: - id: 202504181536 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504181536.sql - - changeSet: - id: 202504221135 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504221135.sql - - changeSet: - id: 202504221555 - author: John - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504221555.sql - - changeSet: - id: 202504251422 - author: jiangkunyin - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504251422.sql - - changeSet: - id: 202504291043 - author: jiangkunyin - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504291043.sql - - changeSet: - id: 202504301341 - author: Goody - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202504301341.sql - - changeSet: - id: 202505022134 - author: Goody - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505022134.sql - - changeSet: - id: 202505081146 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505081146.sql - - changeSet: - id: 202505091555 - author: whosmyqueen - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505091555.sql - - changeSet: - id: 202505111914 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505111914.sql - - changeSet: - id: 202505122348 - author: ljwwd2 - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505122348.sql - - changeSet: - id: 202505142037 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505142037.sql - - changeSet: - id: 202505182234 - author: amen - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505182234.sql - - changeSet: - id: 202505201744 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505201744.sql - - changeSet: - id: 202505151451 - author: hsoftxl - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505151451.sql - - changeSet: - id: 202505271414 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505271414.sql - - changeSet: - id: 202505292203 - author: CAIXYPROMISE - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202505292203.sql - - changeSet: - id: 202506010920 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506010920.sql - - changeSet: - id: 202506031639 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506031639.sql - - changeSet: - id: 202506032232 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506032232.sql - - changeSet: - id: 202506051538 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506051538.sql - - changeSet: - id: 202506080955 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506080955.sql - - changeSet: - id: 202506091720 - author: shane0411 - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506091720.sql - - changeSet: - id: 202506161101 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506161101.sql - - changeSet: - id: 202506191643 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506191643.sql - - changeSet: - id: 202506251620 - author: Tink - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506251620.sql - - changeSet: - id: 202506261637 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202506261637.sql - - changeSet: - id: 202507101203 - author: luruxian - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202507101203.sql - - changeSet: - id: 202507071130 - author: cgd - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202507071130.sql - - changeSet: - id: 202507071530 - author: cgd - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202507071530.sql - - changeSet: - id: 202507031602 - author: zjy - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202507031602.sql - - changeSet: - id: 202507041018 - author: zjy - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202507041018.sql - - changeSet: - id: 202507081646 - author: zjy - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202507081646.sql - - changeSet: - id: 202508081701 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202508081701.sql - - changeSet: - id: 202508111734 - author: RanChen - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202508111734.sql - - changeSet: - id: 202508131557 - author: RanChen - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202508131557.sql - - changeSet: - id: 202508271113 - author: cgd - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202508271113.sql - - changeSet: - id: 202509051745 - author: RanChen - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509051745.sql - - changeSet: - id: 202509081140 - author: cgd - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509081140.sql - - changeSet: - id: 202509091042 - author: cgd - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509091042.sql - - changeSet: - id: 202509091633 - author: fyb - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509091633.sql - - changeSet: - id: 202509080922 - author: fyb - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509080922.sql - - changeSet: - id: 202509161610 - author: fyb - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509161610.sql - - changeSet: - id: 202509161701 - author: RanChen - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509161701.sql - - changeSet: - id: 202509221530 - author: cgd - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509221530.sql - - changeSet: - id: 202509191545 - author: RanChen - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509191545.sql - - changeSet: - id: 202509220926 - author: fyb - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509220926.sql - - - changeSet: - id: 202509220958 - author: fyb - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202509220958.sql - - changeSet: - id: 202510071522 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202510071522.sql - - changeSet: - id: 202510191042 - author: hrz - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202510191042.sql - - changeSet: - id: 202511051120 - author: pany - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202511051120.sql - - changeSet: - id: 202511061415 - author: leo - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202511061415.sql - - changeSet: - id: 202511071245 - author: harold - changes: - - sqlFile: - encoding: utf8 - path: classpath:db/changelog/202511071245.sql diff --git a/main/manager-api/src/main/resources/i18n/messages.properties b/main/manager-api/src/main/resources/i18n/messages.properties deleted file mode 100644 index 776895699..000000000 --- a/main/manager-api/src/main/resources/i18n/messages.properties +++ /dev/null @@ -1,171 +0,0 @@ -#\u7B80\u4F53\u4E2D\u6587 -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 -10004=\u8D26\u53F7\u6216\u5BC6\u7801\u9519\u8BEF -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 -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=\u5BC6\u7801\u957F\u5EA6\u4E0D\u8DB3{0}\u4F4D -10031=\u5BC6\u7801\u5FC5\u987B\u540C\u65F6\u5305\u542B\u6570\u5B57\u3001\u5927\u5C0F\u5199\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 - -10034=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A -10035=\u53C2\u6570\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A -10036=\u4E0D\u652F\u6301\u7684\u53C2\u6570\u7C7B\u578B -10037=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684\u6570\u5B57 -10038=\u53C2\u6570\u503C\u5FC5\u987B\u662Ftrue\u6216false -10039=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684JSON\u6570\u7EC4\u683C\u5F0F -10040=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684JSON\u683C\u5F0F - -10041=\u8BBE\u5907\u672A\u627E\u5230 -10042={0} -10043=\u5220\u9664\u6570\u636E\u5931\u8D25 -10044=\u7528\u6237\u672A\u767B\u5F55 -10045=WebSocket\u8FDE\u63A5\u5931\u8D25\u6216\u8FDE\u63A5\u8D85\u65F6 -10046=\u4FDD\u5B58\u58F0\u7EB9\u9519\u8BEF\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 -10047=\u6BCF\u65E5\u53D1\u9001\u6B21\u6570\u5DF2\u8FBE\u4E0A\u9650 -10048=\u65E7\u5BC6\u7801\u8F93\u5165\u9519\u8BEF -10049=\u8BBE\u7F6E\u7684LLM\u4E0D\u662Fopenai\u548Collama -10050=token\u751F\u6210\u5931\u8D25 -10051=\u8D44\u6E90\u4E0D\u5B58\u5728 -10052=\u9ED8\u8BA4\u667A\u80FD\u4F53\u672A\u627E\u5230 -10053=\u667A\u80FD\u4F53\u672A\u627E\u5230 -10054=\u58F0\u7EB9\u63A5\u53E3\u672A\u914D\u7F6E\uFF0C\u8BF7\u5148\u5728\u53C2\u6570\u914D\u7F6E\u4E2D\u914D\u7F6E\u58F0\u7EB9\u63A5\u53E3\u5730\u5740(server.voice_print) -10055=\u77ED\u4FE1\u53D1\u9001\u5931\u8D25 -10056=\u77ED\u4FE1\u8FDE\u63A5\u5EFA\u7ACB\u5931\u8D25 -10057=\u667A\u80FD\u4F53\u7684\u58F0\u7EB9\u521B\u5EFA\u5931\u8D25 -10058=\u667A\u80FD\u4F53\u7684\u5BF9\u5E94\u58F0\u7EB9\u66F4\u65B0\u5931\u8D25 -10059=\u667A\u80FD\u4F53\u7684\u5BF9\u5E94\u58F0\u7EB9\u5220\u9664\u5931\u8D25 -10060=\u53D1\u9001\u592A\u9891\u7E41\uFF0C\u8BF7{0}\u79D2\u540E\u518D\u8BD5 -10061=\u6FC0\u6D3B\u7801\u4E0D\u80FD\u4E3A\u7A7A -10062=\u6FC0\u6D3B\u7801\u9519\u8BEF -10063=\u8BBE\u5907\u5DF2\u6FC0\u6D3B -10064=\u8BE5\u6A21\u578B\u4E3A\u9ED8\u8BA4\u6A21\u578B\uFF0C\u8BF7\u5148\u8BBE\u7F6E\u5176\u4ED6\u6A21\u578B\u4E3A\u9ED8\u8BA4\u6A21\u578B -10065=\u65B0\u589E\u6570\u636E\u5931\u8D25 -10066=\u4FEE\u6539\u6570\u636E\u5931\u8D25 -10067=\u56FE\u5F62\u9A8C\u8BC1\u7801\u9519\u8BEF -10068=\u6CA1\u6709\u5F00\u542F\u624B\u673A\u6CE8\u518C\uFF0C\u6CA1\u6CD5\u4F7F\u7528\u77ED\u4FE1\u9A8C\u8BC1\u7801\u529F\u80FD -10069=\u7528\u6237\u540D\u4E0D\u662F\u624B\u673A\u53F7\u7801\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165 -10070=\u6B64\u624B\u673A\u53F7\u7801\u5DF2\u7ECF\u6CE8\u518C\u8FC7 -10071=\u8F93\u5165\u7684\u624B\u673A\u53F7\u7801\u672A\u6CE8\u518C -10072=\u5F53\u524D\u4E0D\u5141\u8BB8\u666E\u901A\u7528\u6237\u6CE8\u518C -10073=\u6CA1\u6709\u5F00\u542F\u624B\u673A\u6CE8\u518C\uFF0C\u6CA1\u6CD5\u4F7F\u7528\u627E\u56DE\u5BC6\u7801\u529F\u80FD -10074=\u8F93\u5165\u7684\u624B\u673A\u53F7\u7801\u683C\u5F0F\u4E0D\u6B63\u786E -10075=\u8F93\u5165\u7684\u624B\u673A\u9A8C\u8BC1\u7801\u9519\u8BEF -10076=\u5B57\u5178\u7C7B\u578B\u4E0D\u5B58\u5728 -10077=\u5B57\u5178\u7C7B\u578B\u7F16\u7801\u91CD\u590D -10078=\u8BFB\u53D6\u8D44\u6E90\u5931\u8D25 -10079=LLM\u5927\u6A21\u578B\u548CIntent\u610F\u56FE\u8BC6\u522B\uFF0C\u9009\u62E9\u53C2\u6570\u4E0D\u5339\u914D -10080=\u6B64\u58F0\u97F3\u58F0\u7EB9\u5BF9\u5E94\u7684\u4EBA\uFF08{0}\uFF09\u5DF2\u7ECF\u6CE8\u518C\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u58F0\u97F3\u6CE8\u518C -10081=\u5220\u9664\u58F0\u7EB9\u51FA\u73B0\u9519\u8BEF -10082=\u6B64\u6B21\u4FEE\u6539\u4E0D\u5141\u8BB8\uFF0C\u6B64\u58F0\u97F3\u5DF2\u7ECF\u6CE8\u518C\u4E3A\u58F0\u7EB9\u4E86\uFF08{0}\uFF09 -10083=\u4FEE\u6539\u58F0\u7EB9\u9519\u8BEF\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 -10084=\u58F0\u7EB9\u63A5\u53E3\u5730\u5740\u5B58\u5728\u9519\u8BEF\uFF0C\u8BF7\u8FDB\u5165\u53C2\u6570\u7BA1\u7406\u4FEE\u6539\u58F0\u7EB9\u63A5\u53E3\u5730\u5740 -10085=\u97F3\u9891\u6570\u636E\u4E0D\u5C5E\u4E8E\u8FD9\u4E2A\u667A\u80FD\u4F53 -10086=\u97F3\u9891\u6570\u636E\u662F\u7A7A\u7684\u8BF7\u68C0\u67E5\u4E0A\u4F20\u6570\u636E -10087=\u58F0\u7EB9\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u6C42\u4E0D\u6210\u529F -10088=\u58F0\u7EB9\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u6C42\u5904\u7406\u5931\u8D25 -10089=\u58F0\u7EB9\u6CE8\u9500\u5931\u8D25\uFF0C\u8BF7\u6C42\u4E0D\u6210\u529F -10090=\u58F0\u7EB9\u6CE8\u9500\u5931\u8D25\uFF0C\u8BF7\u6C42\u5904\u7406\u5931\u8D25 -10091=\u4F9B\u5E94\u5668\u4E0D\u5B58\u5728 -10092=\u8BBE\u7F6E\u7684LLM\u4E0D\u5B58\u5728 -10093=\u8BE5\u6A21\u578B\u914D\u7F6E\u5DF2\u88AB\u667A\u80FD\u4F53{0}\u5F15\u7528\uFF0C\u65E0\u6CD5\u5220\u9664 -10094=\u8BE5LLM\u6A21\u578B\u5DF2\u88AB\u610F\u56FE\u8BC6\u522B\u914D\u7F6E\u5F15\u7528\uFF0C\u65E0\u6CD5\u5220\u9664 -10095=\u65E0\u6548\u670D\u52A1\u7AEF\u64CD\u4F5C -10096=\u672A\u914D\u7F6E\u670D\u52A1\u7AEFWebSocket\u5730\u5740 -10097=\u76EE\u6807WebSocket\u5730\u5740\u4E0D\u5B58\u5728 -10098=WebSocket\u5730\u5740\u5217\u8868\u4E0D\u80FD\u4E3A\u7A7A -10099=WebSocket\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10100=WebSocket\u5730\u5740\u683C\u5F0F\u4E0D\u6B63\u786E -10101=WebSocket\u8FDE\u63A5\u6D4B\u8BD5\u5931\u8D25 -10102=OTA\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A -10103=OTA\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10104=OTA\u5730\u5740\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 -10105=OTA\u5730\u5740\u5FC5\u987B\u4EE5/ota/\u7ED3\u5C3E -10106=OTA\u63A5\u53E3\u8BBF\u95EE\u5931\u8D25 -10107=OTA\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u683C\u5F0F\u4E0D\u6B63\u786E -10108=OTA\u63A5\u53E3\u9A8C\u8BC1\u5931\u8D25 -10109=MCP\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A -10110=MCP\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10111=\u4E0D\u662F\u6B63\u786E\u7684MCP\u5730\u5740 -10112=MCP\u63A5\u53E3\u8BBF\u95EE\u5931\u8D25 -10113=MCP\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u683C\u5F0F\u4E0D\u6B63\u786E -10114=MCP\u63A5\u53E3\u9A8C\u8BC1\u5931\u8D25 -10115=\u58F0\u7EB9\u63A5\u53E3\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A -10116=\u58F0\u7EB9\u63A5\u53E3\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10117=\u4E0D\u662F\u6B63\u786E\u7684\u58F0\u7EB9\u63A5\u53E3\u5730\u5740 -10118=\u58F0\u7EB9\u63A5\u53E3\u5730\u5740\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 -10119=\u58F0\u7EB9\u63A5\u53E3\u8BBF\u95EE\u5931\u8D25 -10120=\u58F0\u7EB9\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u683C\u5F0F\u4E0D\u6B63\u786E -10121=\u58F0\u7EB9\u63A5\u53E3\u9A8C\u8BC1\u5931\u8D25 -10122=mqtt\u5BC6\u94A5\u4E0D\u80FD\u4E3A\u7A7A -10123=\u60A8\u7684mqtt\u5BC6\u94A5\u957F\u5EA6\u4E0D\u5B89\u5168\uFF0C\u5B57\u7B26\u6570\u9700\u8981\u81F3\u5C118\u4E2A\u5B57\u7B26\u4E14\u5FC5\u987B\u540C\u65F6\u5305\u542B\u5927\u5C0F\u5199\u5B57\u6BCD -10124=\u60A8\u7684mqtt\u5BC6\u94A5\u957F\u5EA6\u4E0D\u5B89\u5168\uFF0Cmqtt\u5BC6\u94A5\u5FC5\u987B\u540C\u65F6\u5305\u542B\u5927\u5C0F\u5199\u5B57\u6BCD -10125=\u60A8\u7684mqtt\u5BC6\u94A5\u5305\u542B\u5F31\u5BC6\u7801 -10128=\u5B57\u5178\u6807\u7B7E\u91CD\u590D -10129=SM2\u5BC6\u94A5\u672A\u914D\u7F6E -10130=SM2\u89E3\u5BC6\u5931\u8D25 -10131=modelType\u548CprovideCode\u4E0D\u80FD\u4E3A\u7A7A -10132=\u6CA1\u6709\u6743\u9650\u67E5\u770B\u8BE5\u667A\u80FD\u4F53\u7684\u804A\u5929\u8BB0\u5F55 -10133=\u4F1A\u8BDDID\u4E0D\u80FD\u4E3A\u7A7A -10134=\u667A\u80FD\u4F53ID\u4E0D\u80FD\u4E3A\u7A7A -10135=\u804A\u5929\u8BB0\u5F55\u4E0B\u8F7D\u5931\u8D25 -10136=\u4E0B\u8F7D\u94FE\u63A5\u5DF2\u8FC7\u671F\u6216\u65E0\u6548 -10137=\u4E0B\u8F7D\u94FE\u63A5\u65E0\u6548 -10138=\u7528\u6237 -10139=\u667A\u4F53 -10140=\u97F3\u9891\u6587\u4EF6\u4E0D\u80FD\u4E3A\u7A7A -10141=\u53EA\u652F\u6301\u97F3\u9891\u6587\u4EF6 -10142=\u97F3\u9891\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC710MB -10143=\u4E0A\u4F20\u5931\u8D25 -10144=\u58F0\u97F3\u514B\u9686\u8BB0\u5F55\u4E0D\u5B58\u5728 -10145=\u97F3\u8272\u8D44\u6E90\u4FE1\u606F\u4E0D\u80FD\u4E3A\u7A7A -10146=\u5E73\u53F0\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A -10147=\u97F3\u8272ID\u4E0D\u80FD\u4E3A\u7A7A -10148=\u5F52\u5C5E\u8D26\u53F7\u4E0D\u80FD\u4E3A\u7A7A -10149=\u5220\u9664\u7684\u97F3\u8272\u8D44\u6E90ID\u4E0D\u80FD\u4E3A\u7A7A -10150=\u60A8\u6CA1\u6709\u6743\u9650\u64CD\u4F5C\u8BE5\u8BB0\u5F55 -10151=\u8BF7\u5148\u4E0A\u4F20\u97F3\u9891\u6587\u4EF6 -10152=\u6A21\u578B\u914D\u7F6E\u672A\u627E\u5230 -10153=\u6A21\u578B\u7C7B\u578B\u672A\u627E\u5230 -10154=\u8BAD\u7EC3\u5931\u8D25 -10155=\u706B\u5C71\u5F15\u64CE\u7F3A\u5C11\u914D\u7F6E -10156=\u54CD\u5E94\u683C\u5F0F\u9519\u8BEF\uFF0C\u7F3A\u5C11BaseResp\u5B57\u6BB5 -10157=\u8BF7\u6C42\u5931\u8D25 -10158=\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801{0} -10159=\u97F3\u8272ID\u5DF2\u5B58\u5728 -10160=\u706B\u5C71\u5F15\u64CE\u97F3\u8272ID\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5S_\u5F00\u5934 -10161=Mac\u5730\u5740\u5DF2\u5B58\u5728 -10162=\u6A21\u578B\u4F9B\u5E94\u5668\u4E0D\u5B58\u5728 \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/messages_en_US.properties b/main/manager-api/src/main/resources/i18n/messages_en_US.properties deleted file mode 100644 index 04354f63e..000000000 --- a/main/manager-api/src/main/resources/i18n/messages_en_US.properties +++ /dev/null @@ -1,171 +0,0 @@ -#English -500=Server internal exception -401=Unauthorized -403=Access denied, no permissions -10001={0} cannot be empty -10002=The record already exists in the database -10003=Failed to get parameters -10004=The account number or password is incorrect. -10005=Account has been deactivated -10006=Unique ID cannot be empty -10007=The verification code is incorrect -10008=First delete submenu or button -10009=The original password is incorrect -10010=The account or password is incorrect, you can try {0} more 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=The model diagram is incorrect, please check -10018=Export failed, model ID is {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 files in zip, bar, bpmn, bpmn20.xml format - -10024=Failed to upload file {0} -10025=Failed to send SMS {0} -10026=Email template does not exist - -10027=Redis service exception -10028=Timed task failed -10029=Cannot contain illegal characters - -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 - -10034=Parameter value cannot be empty -10035=Parameter type cannot be empty -10036=Unsupported parameter type -10037=Parameter value must be a valid number -10038=Parameter value must be true or false -10039=Parameter value must be a valid JSON array format -10040=Parameter value must be a valid JSON format - -10041=Device not found -10042={0} -10043=Failed to delete data -10044=User not logged in -10045=WebSocket connection failed or timeout -10046=Failed to save voiceprint, please contact administrator -10047=Daily sending limit reached -10048=Old password is incorrect -10049=The set LLM is not openai or ollama -10050=Failed to generate token -10051=Resource not found -10052=Default agent not found -10053=Agent not found -10054=Voiceprint interface not configured, please configure voiceprint interface address (server.voice_print) in parameter configuration first -10055=Failed to send SMS -10056=Failed to establish SMS connection -10057=Failed to create voiceprint for agent -10058=Failed to update voiceprint for agent -10059=Failed to delete voiceprint for agent -10060=Sending too frequently, please try again after {0} seconds -10061=Activation code cannot be empty -10062=Activation code error -10063=Device already activated -10064=This model is the default model, please set another model as default first -10065=Failed to add data -10066=Failed to update data -10067=Graphic verification code error -10068=Mobile registration is not enabled, SMS verification code function cannot be used -10069=Username is not a mobile phone number, please re-enter -10070=This mobile phone number has already been registered -10071=The entered mobile phone number is not registered -10072=Ordinary user registration is not allowed currently -10073=Mobile registration is not enabled, password retrieval function cannot be used -10074=The entered mobile phone number format is incorrect -10075=The entered SMS verification code is incorrect -10076=Dictionary type does not exist -10077=Dictionary type code is duplicated -10078=Failed to read resource -10079=LLM model and Intent recognition, parameter selection does not match -10080=This voiceprint belongs to {0} who has already registered, please select another voice -10081=Error occurred while deleting voiceprint -10082=Modification not allowed, this voice has already been registered as a voiceprint ({0}) -10083=Error modifying voiceprint, please contact administrator -10084=Voiceprint interface address error, please go to parameter management to modify the voiceprint interface address -10085=Audio data does not belong to this agent -10086=Audio data is empty, please check uploaded data -10087=Voiceprint registration failed, request unsuccessful -10088=Voiceprint registration failed, request processing failed -10089=Voiceprint cancellation failed, request unsuccessful -10090=Voiceprint cancellation failed, request processing failed -10091=Model provider does not exist -10092=The configured LLM does not exist -10093=This model configuration is referenced by agent {0} and cannot be deleted -10094=This LLM model is referenced by intent recognition configuration and cannot be deleted -10095=Invalid server operation -10096=Server WebSocket address not configured -10097=Target WebSocket address does not exist -10098=WebSocket address list cannot be empty -10099=WebSocket address cannot use localhost or 127.0.0.1 -10100=WebSocket address format is incorrect -10101=WebSocket connection test failed -10102=OTA address cannot be empty -10103=OTA address cannot use localhost or 127.0.0.1 -10104=OTA address must start with http or https -10105=OTA address must end with /ota/ -10106=OTA interface access failed -10107=OTA interface return content format is incorrect -10108=OTA interface validation failed -10109=MCP address cannot be empty -10110=MCP address cannot use localhost or 127.0.0.1 -10111=Not a valid MCP address -10112=MCP interface access failed -10113=MCP interface return content format is incorrect -10114=MCP interface validation failed -10115=Voiceprint interface address cannot be empty -10116=Voiceprint interface address cannot use localhost or 127.0.0.1 -10117=Not a valid voiceprint interface address -10118=Voiceprint interface address must start with http or https -10119=Voiceprint interface access failed -10120=Voiceprint interface return content format is incorrect -10121=Voiceprint interface validation failed -10122=MQTT secret cannot be empty -10123=Your MQTT secret is not secure, it needs to be at least 8 characters and must contain both uppercase and lowercase letters -10124=Your MQTT secret is not secure, MQTT secret must contain both uppercase and lowercase letters -10125=Your MQTT secret contains weak password -10128=Dictionary label is duplicated -10129=SM2 key not configured -10130=SM2 decryption failed -10131=modelType and provideCode cannot be empty -10132=No permission to view the chat history of this agent -10133=Session ID cannot be empty -10134=Agent ID cannot be empty -10135=Chat history download failed -10136=Download link expired or invalid -10137=Download link invalid -10138=User -10139=Agent -10140=Audio file cannot be empty -10141=Only audio files are supported -10142=Audio file size cannot exceed 10MB -10143=Upload failed -10144=Voice clone record does not exist -10145=Voice resource information cannot be empty -10146=TTS platform name cannot be empty -10147=Voice ID cannot be empty -10148=Owner account cannot be empty -10149=Voice resource ID to delete cannot be empty -10150=You do not have permission to operate this record -10151=Please upload audio file first -10152=Model configuration not found -10153=Model type not found -10154=Training failed: {0} -10155=Huoshan Engine configuration missing -10156=Response format error, missing BaseResp field -10157=Request failed -10158=Clone Voice: -10159=Voice ID already exists -10160=Huoshan Engine voice ID format error, must start with S_ -10161=Mac address already exists -10162=Model provider does not exist \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties b/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties deleted file mode 100644 index 6fb10371a..000000000 --- a/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,171 +0,0 @@ -#\u7B80\u4F53\u4E2D\u6587 -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 -10004=\u8D26\u53F7\u6216\u5BC6\u7801\u9519\u8BEF -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 -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=\u5BC6\u7801\u957F\u5EA6\u4E0D\u8DB3{0}\u4F4D -10031=\u5BC6\u7801\u5FC5\u987B\u540C\u65F6\u5305\u542B\u6570\u5B57\u3001\u5927\u5C0F\u5199\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 - -10034=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A -10035=\u53C2\u6570\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A -10036=\u4E0D\u652F\u6301\u7684\u53C2\u6570\u7C7B\u578B -10037=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684\u6570\u5B57 -10038=\u53C2\u6570\u503C\u5FC5\u987B\u662Ftrue\u6216false -10039=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684JSON\u6570\u7EC4\u683C\u5F0F -10040=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684JSON\u683C\u5F0F - -10041=\u8BBE\u5907\u672A\u627E\u5230 -10042={0} -10043=\u5220\u9664\u6570\u636E\u5931\u8D25 -10044=\u7528\u6237\u672A\u767B\u5F55 -10045=WebSocket\u8FDE\u63A5\u5931\u8D25\u6216\u8FDE\u63A5\u8D85\u65F6 -10046=\u4FDD\u5B58\u58F0\u7EB9\u9519\u8BEF\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 -10047=\u6BCF\u65E5\u53D1\u9001\u6B21\u6570\u5DF2\u8FBE\u4E0A\u9650 -10048=\u65E7\u5BC6\u7801\u8F93\u5165\u9519\u8BEF -10049=\u8BBE\u7F6E\u7684LLM\u4E0D\u662Fopenai\u548Collama -10050=token\u751F\u6210\u5931\u8D25 -10051=\u8D44\u6E90\u4E0D\u5B58\u5728 -10052=\u9ED8\u8BA4\u667A\u80FD\u4F53\u672A\u627E\u5230 -10053=\u667A\u80FD\u4F53\u672A\u627E\u5230 -10054=\u58F0\u7EB9\u63A5\u53E3\u672A\u914D\u7F6E\uFF0C\u8BF7\u5148\u5728\u53C2\u6570\u914D\u7F6E\u4E2D\u914D\u7F6E\u58F0\u7EB9\u63A5\u53E3\u5730\u5740(server.voice_print) -10055=\u77ED\u4FE1\u53D1\u9001\u5931\u8D25 -10056=\u77ED\u4FE1\u8FDE\u63A5\u5EFA\u7ACB\u5931\u8D25 -10057=\u667A\u80FD\u4F53\u7684\u58F0\u7EB9\u521B\u5EFA\u5931\u8D25 -10058=\u667A\u80FD\u4F53\u7684\u5BF9\u5E94\u58F0\u7EB9\u66F4\u65B0\u5931\u8D25 -10059=\u667A\u80FD\u4F53\u7684\u5BF9\u5E94\u58F0\u7EB9\u5220\u9664\u5931\u8D25 -10060=\u53D1\u9001\u592A\u9891\u7E41\uFF0C\u8BF7{0}\u79D2\u540E\u518D\u8BD5 -10061=\u6FC0\u6D3B\u7801\u4E0D\u80FD\u4E3A\u7A7A -10062=\u6FC0\u6D3B\u7801\u9519\u8BEF -10063=\u8BBE\u5907\u5DF2\u6FC0\u6D3B -10064=\u8BE5\u6A21\u578B\u4E3A\u9ED8\u8BA4\u6A21\u578B\uFF0C\u8BF7\u5148\u8BBE\u7F6E\u5176\u4ED6\u6A21\u578B\u4E3A\u9ED8\u8BA4\u6A21\u578B -10065=\u65B0\u589E\u6570\u636E\u5931\u8D25 -10066=\u4FEE\u6539\u6570\u636E\u5931\u8D25 -10067=\u56FE\u5F62\u9A8C\u8BC1\u7801\u9519\u8BEF -10068=\u6CA1\u6709\u5F00\u542F\u624B\u673A\u6CE8\u518C\uFF0C\u6CA1\u6CD5\u4F7F\u7528\u77ED\u4FE1\u9A8C\u8BC1\u7801\u529F\u80FD -10069=\u7528\u6237\u540D\u4E0D\u662F\u624B\u673A\u53F7\u7801\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165 -10070=\u6B64\u624B\u673A\u53F7\u7801\u5DF2\u7ECF\u6CE8\u518C\u8FC7 -10071=\u8F93\u5165\u7684\u624B\u673A\u53F7\u7801\u672A\u6CE8\u518C -10072=\u5F53\u524D\u4E0D\u5141\u8BB8\u666E\u901A\u7528\u6237\u6CE8\u518C -10073=\u6CA1\u6709\u5F00\u542F\u624B\u673A\u6CE8\u518C\uFF0C\u6CA1\u6CD5\u4F7F\u7528\u627E\u56DE\u5BC6\u7801\u529F\u80FD -10074=\u8F93\u5165\u7684\u624B\u673A\u53F7\u7801\u683C\u5F0F\u4E0D\u6B63\u786E -10075=\u8F93\u5165\u7684\u624B\u673A\u9A8C\u8BC1\u7801\u9519\u8BEF -10076=\u5B57\u5178\u7C7B\u578B\u4E0D\u5B58\u5728 -10077=\u5B57\u5178\u7C7B\u578B\u7F16\u7801\u91CD\u590D -10078=\u8BFB\u53D6\u8D44\u6E90\u5931\u8D25 -10079=LLM\u5927\u6A21\u578B\u548CIntent\u610F\u56FE\u8BC6\u522B\uFF0C\u9009\u62E9\u53C2\u6570\u4E0D\u5339\u914D -10080=\u6B64\u58F0\u97F3\u58F0\u7EB9\u5BF9\u5E94\u7684\u4EBA\uFF08{0}\uFF09\u5DF2\u7ECF\u6CE8\u518C\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u58F0\u97F3\u6CE8\u518C -10081=\u5220\u9664\u58F0\u7EB9\u51FA\u73B0\u9519\u8BEF -10082=\u6B64\u6B21\u4FEE\u6539\u4E0D\u5141\u8BB8\uFF0C\u6B64\u58F0\u97F3\u5DF2\u7ECF\u6CE8\u518C\u4E3A\u58F0\u7EB9\u4E86\uFF08{0}\uFF09 -10083=\u4FEE\u6539\u58F0\u7EB9\u9519\u8BEF\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 -10084=\u58F0\u7EB9\u63A5\u53E3\u5730\u5740\u5B58\u5728\u9519\u8BEF\uFF0C\u8BF7\u8FDB\u5165\u53C2\u6570\u7BA1\u7406\u4FEE\u6539\u58F0\u7EB9\u63A5\u53E3\u5730\u5740 -10085=\u97F3\u9891\u6570\u636E\u4E0D\u5C5E\u4E8E\u8FD9\u4E2A\u667A\u80FD\u4F53 -10086=\u97F3\u9891\u6570\u636E\u662F\u7A7A\u7684\u8BF7\u68C0\u67E5\u4E0A\u4F20\u6570\u636E -10087=\u58F0\u7EB9\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u6C42\u4E0D\u6210\u529F -10088=\u58F0\u7EB9\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u6C42\u5904\u7406\u5931\u8D25 -10089=\u58F0\u7EB9\u6CE8\u9500\u5931\u8D25\uFF0C\u8BF7\u6C42\u4E0D\u6210\u529F -10090=\u58F0\u7EB9\u6CE8\u9500\u5931\u8D25\uFF0C\u8BF7\u6C42\u5904\u7406\u5931\u8D25 -10091=\u4F9B\u5E94\u5668\u4E0D\u5B58\u5728 -10092=\u8BBE\u7F6E\u7684LLM\u4E0D\u5B58\u5728 -10093=\u8BE5\u6A21\u578B\u914D\u7F6E\u5DF2\u88AB\u667A\u80FD\u4F53{0}\u5F15\u7528\uFF0C\u65E0\u6CD5\u5220\u9664 -10094=\u8BE5LLM\u6A21\u578B\u5DF2\u88AB\u610F\u56FE\u8BC6\u522B\u914D\u7F6E\u5F15\u7528\uFF0C\u65E0\u6CD5\u5220\u9664 -10095=\u65E0\u6548\u670D\u52A1\u7AEF\u64CD\u4F5C -10096=\u672A\u914D\u7F6E\u670D\u52A1\u7AEFWebSocket\u5730\u5740 -10097=\u76EE\u6807WebSocket\u5730\u5740\u4E0D\u5B58\u5728 -10098=WebSocket\u5730\u5740\u5217\u8868\u4E0D\u80FD\u4E3A\u7A7A -10099=WebSocket\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10100=WebSocket\u5730\u5740\u683C\u5F0F\u4E0D\u6B63\u786E -10101=WebSocket\u8FDE\u63A5\u6D4B\u8BD5\u5931\u8D25 -10102=OTA\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A -10103=OTA\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10104=OTA\u5730\u5740\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 -10105=OTA\u5730\u5740\u5FC5\u987B\u4EE5/ota/\u7ED3\u5C3E -10106=OTA\u63A5\u53E3\u8BBF\u95EE\u5931\u8D25 -10107=OTA\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u683C\u5F0F\u4E0D\u6B63\u786E -10108=OTA\u63A5\u53E3\u9A8C\u8BC1\u5931\u8D25 -10109=MCP\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A -10110=MCP\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10111=\u4E0D\u662F\u6B63\u786E\u7684MCP\u5730\u5740 -10112=MCP\u63A5\u53E3\u8BBF\u95EE\u5931\u8D25 -10113=MCP\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u683C\u5F0F\u4E0D\u6B63\u786E -10114=MCP\u63A5\u53E3\u9A8C\u8BC1\u5931\u8D25 -10115=\u58F0\u7EB9\u63A5\u53E3\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A -10116=\u58F0\u7EB9\u63A5\u53E3\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10117=\u4E0D\u662F\u6B63\u786E\u7684\u58F0\u7EB9\u63A5\u53E3\u5730\u5740 -10118=\u58F0\u7EB9\u63A5\u53E3\u5730\u5740\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 -10119=\u58F0\u7EB9\u63A5\u53E3\u8BBF\u95EE\u5931\u8D25 -10120=\u58F0\u7EB9\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u683C\u5F0F\u4E0D\u6B63\u786E -10121=\u58F0\u7EB9\u63A5\u53E3\u9A8C\u8BC1\u5931\u8D25 -10122=mqtt\u5BC6\u94A5\u4E0D\u80FD\u4E3A\u7A7A -10123=\u60A8\u7684mqtt\u5BC6\u94A5\u957F\u5EA6\u4E0D\u5B89\u5168\uFF0C\u5B57\u7B26\u6570\u9700\u8981\u81F3\u5C118\u4E2A\u5B57\u7B26\u4E14\u5FC5\u987B\u540C\u65F6\u5305\u542B\u5927\u5C0F\u5199\u5B57\u6BCD -10124=\u60A8\u7684mqtt\u5BC6\u94A5\u957F\u5EA6\u4E0D\u5B89\u5168\uFF0Cmqtt\u5BC6\u94A5\u5FC5\u987B\u540C\u65F6\u5305\u542B\u5927\u5C0F\u5199\u5B57\u6BCD -10125=\u60A8\u7684mqtt\u5BC6\u94A5\u5305\u542B\u5F31\u5BC6\u7801 -10128=\u5B57\u5178\u6807\u7B7E\u91CD\u590D -10129=SM2\u5BC6\u94A5\u672A\u914D\u7F6E -10130=SM2\u89E3\u5BC6\u5931\u8D25 -10131=modelType\u548CprovideCode\u4E0D\u80FD\u4E3A\u7A7A -10132=\u6CA1\u6709\u6743\u9650\u67E5\u770B\u8BE5\u667A\u80FD\u4F53\u7684\u804A\u5929\u8BB0\u5F55 -10133=\u4F1A\u8BDDID\u4E0D\u80FD\u4E3A\u7A7A -10134=\u667A\u80FD\u4F53ID\u4E0D\u80FD\u4E3A\u7A7A -10135=\u804A\u5929\u8BB0\u5F55\u4E0B\u8F7D\u5931\u8D25 -10136=\u4E0B\u8F7D\u94FE\u63A5\u5DF2\u8FC7\u671F\u6216\u65E0\u6548 -10137=\u4E0B\u8F7D\u94FE\u63A5\u65E0\u6548 -10138=\u7528\u6237 -10139=\u667A\u4F53 -10140=\u97F3\u9891\u6587\u4EF6\u4E0D\u80FD\u4E3A\u7A7A -10141=\u53EA\u652F\u6301\u97F3\u9891\u6587\u4EF6 -10142=\u97F3\u9891\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC710MB -10143=\u4E0A\u4F20\u5931\u8D25 -10144=\u58F0\u97F3\u514B\u9686\u8BB0\u5F55\u4E0D\u5B58\u5728 -10145=\u97F3\u8272\u8D44\u6E90\u4FE1\u606F\u4E0D\u80FD\u4E3A\u7A7A -10146=\u5E73\u53F0\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A -10147=\u97F3\u8272ID\u4E0D\u80FD\u4E3A\u7A7A -10148=\u5F52\u5C5E\u8D26\u53F7\u4E0D\u80FD\u4E3A\u7A7A -10149=\u5220\u9664\u7684\u97F3\u8272\u8D44\u6E90ID\u4E0D\u80FD\u4E3A\u7A7A -10150=\u60A8\u6CA1\u6709\u6743\u9650\u64CD\u4F5C\u8BE5\u8BB0\u5F55 -10151=\u8BF7\u5148\u4E0A\u4F20\u97F3\u9891\u6587\u4EF6 -10152=\u6A21\u578B\u914D\u7F6E\u672A\u627E\u5230 -10153=\u6A21\u578B\u7C7B\u578B\u672A\u627E\u5230 -10154=\u8BAD\u7EC3\u5931\u8D25 -10155=\u706B\u5C71\u5F15\u64CE\u7F3A\u5C11\u914D\u7F6E -10156=\u54CD\u5E94\u683C\u5F0F\u9519\u8BEF\uFF0C\u7F3A\u5C11BaseResp\u5B57\u6BB5 -10157=\u8BF7\u6C42\u5931\u8D25 -10158=\u514B\u9686\u8272\u97F3: -10159=\u97F3\u8272ID\u5DF2\u5B58\u5728 -10160=\u706B\u5C71\u5F15\u64CE\u97F3\u8272ID\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5S_\u5F00\u5934 -10161=Mac\u5730\u5740\u5DF2\u5B58\u5728 -10162=\u6A21\u578B\u4F9B\u5E94\u5668\u4E0D\u5B58\u5728 \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/messages_zh_TW.properties b/main/manager-api/src/main/resources/i18n/messages_zh_TW.properties deleted file mode 100644 index 0f5d316ce..000000000 --- a/main/manager-api/src/main/resources/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,172 +0,0 @@ -#\u7E41\u9AD4\u4E2D\u6587 -500=\u670D\u52D9\u5668\u5167\u90E8\u7570\u5E38 -401=\u672A\u6388\u6B0A -403=\u62D2\u7D55\u8A2A\u554F\uFF0C\u6C92\u6709\u6743\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 -10004=\u8CEC\u865F\u6216\u5BC6\u78BC\u932F\u8AA4 -10005=\u8CEC\u865F\u5DF2\u88AB\u505C\u7528 -10006=\u552F\u4E00\u6A19\u8B58\u4E0D\u80FD\u70BA\u7A7A -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=\u5E33\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=\u5BC6\u78BC\u9577\u5EA6\u4E0D\u8DB3{0}\u4F4D -10031=\u5BC6\u78BC\u5FC5\u9808\u540C\u6642\u5305\u542B\u6578\u5B57\u3001\u5927\u5C0F\u5BEB\u5B57\u6BCD\u548C\u7279\u6B8A\u5B57\u7B26\u7D44\u6210 -10032=\u522A\u9664\u672C\u6578\u64DA\u7570\u5E38 -10033=\u8A2D\u5099\u9A57\u8B49\u78BC\u932F\u8AA4 - -10034=\u53C3\u6578\u503C\u4E0D\u80FD\u70BA\u7A7A -10035=\u53C3\u6578\u985E\u578B\u4E0D\u80FD\u70BA\u7A7A -10036=\u4E0D\u652F\u6301\u7684\u53C3\u6578\u985E\u578B -10037=\u53C3\u6578\u503C\u5FC5\u9808\u662F\u6709\u6548\u7684\u6578\u5B57 -10038=\u53C3\u6578\u503C\u5FC5\u9808\u662Ftrue\u6216false -10039=\u53C3\u6578\u503C\u5FC5\u9808\u662F\u6709\u6548\u7684JSON\u6578\u7D44\u683C\u5F0F -10040=\u53C3\u6578\u503C\u5FC5\u9808\u662F\u6709\u6548\u7684JSON\u683C\u5F0F - -10041=\u8A2D\u5099\u672A\u627E\u5230 -10042={0} -10043=\u522A\u9664\u6578\u64DA\u5931\u6557 -10044=\u7528\u6236\u672A\u767B\u9304 -10045=WebSocket\u9023\u63A5\u5931\u6557\u6216\u9023\u63A5\u8D85\u6642 -10046=\u4FDD\u5B58\u8072\u7D0B\u932F\u8AA4\uFF0C\u8ACB\u806F\u7E6B\u7BA1\u7406\u54E1 -10047=\u6BCF\u65E5\u767C\u9001\u6B21\u6578\u5DF2\u9054\u4E0A\u9650 -10048=\u820A\u5BC6\u78BC\u8F38\u5165\u932F\u8AA4 -10049=\u8A2D\u7F6E\u7684LLM\u4E0D\u662Fopenai\u548Collama -10050=token\u751F\u6210\u5931\u6557 -10051=\u8CC7\u6E90\u4E0D\u5B58\u5728 -10052=\u9ED8\u8A8D\u667A\u80FD\u9AD4\u672A\u627E\u5230 -10053=\u667A\u80FD\u9AD4\u672A\u627E\u5230 -10054=\u8072\u7D0B\u63A5\u53E3\u672A\u914D\u7F6E\uFF0C\u8ACB\u5148\u5728\u53C3\u6578\u914D\u7F6E\u4E2D\u914D\u7F6E\u8072\u7D0B\u63A5\u53E3\u5730\u5740(server.voice_print) -10055=\u77ED\u4FE1\u767C\u9001\u5931\u6557 -10056=\u77ED\u4FE1\u9023\u63A5\u5EFA\u7ACB\u5931\u6557 -10057=\u667A\u80FD\u9AD4\u7684\u8072\u7D0B\u5275\u5EFA\u5931\u6557 -10058=\u667A\u80FD\u9AD4\u7684\u5C0D\u61C9\u8072\u7D0B\u66F4\u65B0\u5931\u6557 -10059=\u667A\u80FD\u9AD4\u7684\u5C0D\u61C9\u8072\u7D0B\u522A\u9664\u5931\u6557 -10060=\u767C\u9001\u592A\u983B\u7E41\uFF0C\u8ACB{0}\u79D2\u5F8C\u518D\u8A66 -10061=\u6FC0\u6D3B\u78BC\u4E0D\u80FD\u70BA\u7A7A -10062=\u6FC0\u6D3B\u78BC\u932F\u8AA4 -10063=\u8A2D\u5099\u5DF2\u6FC0\u6D3B -10064=\u8A72\u6A21\u578B\u70BA\u9810\u8A2D\u6A21\u578B\uFF0C\u8ACB\u5148\u8A2D\u7F6E\u5176\u4ED6\u6A21\u578B\u70BA\u9810\u8A2D\u6A21\u578B -10065=\u65B0\u589E\u6578\u64DA\u5931\u6557 -10066=\u66F4\u65B0\u6578\u64DA\u5931\u6557 -10067=\u5716\u5F62\u9A57\u8B49\u78BC\u932F\u8AA4 -10068=\u672A\u958B\u555F\u624B\u6A5F\u8A3B\u518A\uFF0C\u7121\u6CD5\u4F7F\u7528\u77ED\u4FE1\u9A57\u8B49\u78BC\u529F\u80FD -10069=\u7528\u6236\u540D\u4E0D\u662F\u624B\u6A5F\u865F\u78BC\uFF0C\u8ACB\u91CD\u65B0\u8F38\u5165 -10070=\u8A72\u624B\u6A5F\u865F\u78BC\u5DF2\u8A3B\u518A -10071=\u8F38\u5165\u7684\u624B\u6A5F\u865F\u78BC\u672A\u8A3B\u518A -10072=\u76EE\u524D\u4E0D\u5141\u8A31\u666E\u901A\u7528\u6236\u8A3B\u518A -10073=\u672A\u958B\u555F\u624B\u6A5F\u8A3B\u518A\uFF0C\u7121\u6CD5\u4F7F\u7528\u5BC6\u78BC\u627E\u56DE\u529F\u80FD -10074=\u8F38\u5165\u7684\u624B\u6A5F\u865F\u78BC\u683C\u5F0F\u4E0D\u6B63\u78BA -10075=\u8F38\u5165\u7684\u77ED\u4FE1\u9A57\u8B49\u78BC\u4E0D\u6B63\u78BA -10076=\u5B57\u5178\u985E\u578B\u4E0D\u5B58\u5728 -10077=\u5B57\u5178\u985E\u578B\u7DE8\u78BC\u91CD\u8907 -10078=\u8B80\u53D6\u8CC7\u6E90\u5931\u6557 -10079=LLM\u6A21\u578B\u8207\u610F\u5716\u8B58\u5225\u3001\u53C3\u6578\u9078\u64C7\u4E0D\u5339\u914D -10080=\u6B64\u8072\u7D0B\u5C6C\u65BC\u5DF2\u8A3B\u518A\u7684{0}\uFF0C\u8ACB\u9078\u64C7\u5176\u4ED6\u8072\u97F3 -10081=\u522A\u9664\u8072\u7D0B\u6642\u767C\u751F\u932F\u8AA4 -10082=\u4E0D\u5141\u8A31\u4FEE\u6539\uFF0C\u6B64\u8072\u97F3\u5DF2\u8A3B\u518A\u70BA\u8072\u7D0B({0}) -10083=\u4FEE\u6539\u8072\u7D0B\u932F\u8AA4\uFF0C\u8ACB\u806F\u7E6B\u7BA1\u7406\u54E1 -10084=\u8072\u7D0B\u63A5\u53E3\u5730\u5740\u932F\u8AA4\uFF0C\u8ACB\u524D\u5F80\u53C3\u6578\u7BA1\u7406\u4FEE\u6539\u8072\u7D0B\u63A5\u53E3\u5730\u5740 -10085=\u97F3\u983B\u6578\u64DA\u4E0D\u5C6C\u65BC\u6B64\u667A\u80FD\u9AD4 -10086=\u97F3\u983B\u6578\u64DA\u70BA\u7A7A\uFF0C\u8ACB\u6AA2\u67E5\u4E0A\u50B3\u6578\u64DA -10087=\u8072\u7D0B\u8A3B\u518A\u5931\u6557\uFF0C\u8ACB\u6C42\u672A\u6210\u529F -10088=\u8072\u7D0B\u8A3B\u518A\u5931\u6557\uFF0C\u8ACB\u6C42\u8655\u7406\u5931\u6557 -10089=\u8072\u7D0B\u8A3B\u92B7\u5931\u6557\uFF0C\u8ACB\u6C42\u672A\u6210\u529F -10090=\u8072\u7D0B\u8A3B\u92B7\u5931\u6557\uFF0C\u8ACB\u6C42\u8655\u7406\u5931\u6557 -10091=\u6A21\u578B\u63D0\u4F9B\u5546\u4E0D\u5B58\u5728 -10092=\u914D\u7F6E\u7684LLM\u4E0D\u5B58\u5728 -10093=\u6B64\u6A21\u578B\u914D\u7F6E\u88AB\u667A\u80FD\u9AD4{0}\u5F15\u7528\uFF0C\u7121\u6CD5\u522A\u9664 -10094=\u6B64LLM\u6A21\u578B\u88AB\u610F\u5716\u8B58\u5225\u914D\u7F6E\u5F15\u7528\uFF0C\u7121\u6CD5\u522A\u9664 -10095=\u7121\u6548\u7684\u670D\u52D9\u5668\u64CD\u4F5C -10096=\u672A\u914D\u7F6E\u670D\u52D9\u5668WebSocket\u5730\u5740 -10097=\u76EE\u6A19WebSocket\u5730\u5740\u4E0D\u5B58\u5728 -10098=WebSocket\u5730\u5740\u5217\u8868\u4E0D\u80FD\u70BA\u7A7A -10099=WebSocket\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10100=WebSocket\u5730\u5740\u683C\u5F0F\u4E0D\u6B63\u78BA -10101=WebSocket\u9023\u63A5\u6E2C\u8A66\u5931\u6557 -10102=OTA\u5730\u5740\u4E0D\u80FD\u70BA\u7A7A -10103=OTA\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10104=OTA\u5730\u5740\u5FC5\u9808\u4EE5http\u6216https\u958B\u982D -10105=OTA\u5730\u5740\u5FC5\u9808\u4EE5/ota/\u7D50\u5C3E -10106=OTA\u63A5\u53E3\u8A2A\u554F\u5931\u6557 -10107=OTA\u63A5\u53E3\u8FD4\u56DE\u5167\u5BB9\u683C\u5F0F\u4E0D\u6B63\u78BA -10108=OTA\u63A5\u53E3\u9A57\u8B49\u5931\u6557 -10109=MCP\u5730\u5740\u4E0D\u80FD\u70BA\u7A7A -10110=MCP\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10111=\u4E0D\u662F\u6709\u6548\u7684MCP\u5730\u5740 -10112=MCP\u63A5\u53E3\u8A2A\u554F\u5931\u6557 -10113=MCP\u63A5\u53E3\u8FD4\u56DE\u5167\u5BB9\u683C\u5F0F\u4E0D\u6B63\u78BA -10114=MCP\u63A5\u53E3\u9A57\u8B49\u5931\u6557 -10115=\u8072\u7D0B\u63A5\u53E3\u5730\u5740\u4E0D\u80FD\u70BA\u7A7A -10116=\u8072\u7D0B\u63A5\u53E3\u5730\u5740\u4E0D\u80FD\u4F7F\u7528localhost\u6216127.0.0.1 -10117=\u4E0D\u662F\u6709\u6548\u7684\u8072\u7D0B\u63A5\u53E3\u5730\u5740 -10118=\u8072\u7D0B\u63A5\u53E3\u5730\u5740\u5FC5\u9808\u4EE5http\u6216https\u958B\u982D -10119=\u8072\u7D0B\u63A5\u53E3\u8A2A\u554F\u5931\u6557 -10120=\u8072\u7D0B\u63A5\u53E3\u8FD4\u56DE\u5167\u5BB9\u683C\u5F0F\u4E0D\u6B63\u78BA -10121=\u8072\u7D0B\u63A5\u53E3\u9A57\u8B49\u5931\u6557 -10122=MQTT\u5BC6\u9470\u4E0D\u80FD\u70BA\u7A7A -10123=\u60A8\u7684MQTT\u5BC6\u9470\u4E0D\u5B89\u5168\uFF0C\u9700\u81F3\u5C118\u500B\u5B57\u7B26\u4E14\u5FC5\u9808\u540C\u6642\u5305\u542B\u5927\u5C0F\u5BEB\u5B57\u6BCD -10124=\u60A8\u7684MQTT\u5BC6\u9470\u4E0D\u5B89\u5168\uFF0CMQTT\u5BC6\u9470\u5FC5\u9808\u540C\u6642\u5305\u542B\u5927\u5C0F\u5BEB\u5B57\u6BCD -10125=\u60A8\u7684MQTT\u5BC6\u9470\u5305\u542B\u5F31\u5BC6\u78BC -10128=\u5B57\u5178\u6A19\u7C64\u91CD\u8907 -10129=SM2\u5BC6\u9470\u672A\u914D\u7F6E -10130=SM2\u89E3\u5BC6\u5931\u6557 -10131=modelType\u548CprovideCode\u4E0D\u80FD\u70BA\u7A7A -10132=\u6C92\u6709\u6B0A\u9650\u67E5\u770B\u8A72\u667A\u80FD\u9AD4\u7684\u804A\u5929\u8A18\u9304 -10133=\u6703\u8A71ID\u4E0D\u80FD\u70BA\u7A7A -10134=\u667A\u80FD\u9AD4ID\u4E0D\u80FD\u70BA\u7A7A -10135=\u804A\u5929\u8A18\u9304\u4E0B\u8F09\u5931\u6557 -10136=\u4E0B\u8F09\u93C8\u63A5\u5DF2\u904E\u671F\u6216\u7121\u6548 -10137=\u4E0B\u8F09\u93C8\u63A5\u7121\u6548 -10138=\u7528\u6236 -10139=\u667A\u9AD4 -10140=\u97F3\u983B\u6587\u4EF6\u4E0D\u80FD\u70BA\u7A7A -10141=\u53EA\u652F\u6301\u97F3\u983B\u6587\u4EF6 -10142=\u97F3\u983B\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u904E10MB -10143=\u4E0A\u50B3\u5931\u6557 -10144=\u8072\u97F3\u514B\u9686\u8A18\u9304\u4E0D\u5B58\u5728 -10145=\u97F3\u8272\u8CC7\u6E90\u4FE1\u606F\u4E0D\u80FD\u70BA\u7A7A -10146=\u5E73\u53F0\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A -10147=\u97F3\u8272ID\u4E0D\u80FD\u70BA\u7A7A -10148=\u6B78\u5C6C\u5E33\u865F\u4E0D\u80FD\u70BA\u7A7A -10149=\u522A\u9664\u7684\u97F3\u8272\u8CC7\u6E90ID\u4E0D\u80FD\u70BA\u7A7A -10150=\u60A8\u6C92\u6709\u6B0A\u9650\u64CD\u4F5C\u8A72\u8A18\u9304 -10151=\u8ACB\u5148\u4E0A\u50B3\u97F3\u983B\u6587\u4EF6 -10152=\u6A21\u578B\u914D\u7F6E\u672A\u627E\u5230 -10153=\u6A21\u578B\u985E\u578B\u672A\u627E\u5230 -10154=\u6A21\u578B\u8AB2\u7DF4\u5931\u6557: {0} -10155=\u706B\u5C71\u5F15\u64CE\u7F3A\u5C11appid\u6216access_token -10156=\u97FF\u61C9\u683C\u5F0F\u932F\u8AA4\uFF0C\u7F3A\u5C11BaseResp\u5B57\u6BB5 -10157=\u8ACB\u6C42\u5931\u6557 -10158=\u514B\u9686\u8A9E\u97F3: -10159=\u97F3\u8272ID\u5DF2\u5B58\u5728 -10160=\u706B\u5C71\u5F15\u64CE\u97F3\u8272ID\u683C\u5F0F\u932F\u8AA4\uFF0C\u5FC5\u9808\u4EE5S_\u958B\u982D -10161=Mac\u5730\u5740\u5DF2\u5B58\u5728 -10162=\u6A21\u578B\u63D0\u4F9B\u5546\u4E0D\u5B58\u5728 - diff --git a/main/manager-api/src/main/resources/i18n/validation.properties b/main/manager-api/src/main/resources/i18n/validation.properties deleted file mode 100644 index 3a10bf235..000000000 --- a/main/manager-api/src/main/resources/i18n/validation.properties +++ /dev/null @@ -1,35 +0,0 @@ -#\u7B80\u4F53\u4E2D\u6587 -id.require=ID\u4E0D\u80FD\u4E3A\u7A7A -id.null=ID\u5FC5\u987B\u4E3A\u7A7A - -sort.number=\u6392\u5E8F\u503C\u4E0D\u80FD\u5C0F\u4E8E0 -page.number=\u9875\u6570\u4E0D\u80FD\u5C0F\u4E8E0 -limit.number=\u5217\u6570\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 -sysparams.valuetype.require=\u503C\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A -sysparams.valuetype.pattern=\u503C\u7C7B\u578B\u5FC5\u987B\u662F string\u3001number\u3001boolean \u6216 array - -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 - - -timbre.languages.require=\u97F3\u8272\u7684\u8BED\u8A00\u4E0D\u53EF\u4EE5\u4E3A\u7A7A -timbre.name.require=\u97F3\u8272\u7684\u540D\u79F0\u4E0D\u53EF\u4EE5\u4E3A\u7A7A -timbre.ttsModelId.require=\u97F3\u8272\u7684tts\u4E3B\u952E\u4E0D\u53EF\u4EE5\u4E3A\u7A7A -timbre.ttsVoice.require=\u97F3\u8272\u7684\u7F16\u7801\u4E0D\u53EF\u4EE5\u4E3A\u7A7A - -ota.device.not.found=\u8BBE\u5907\u672A\u627E\u5230 -ota.device.need.bind={0} diff --git a/main/manager-api/src/main/resources/i18n/validation_en_US.properties b/main/manager-api/src/main/resources/i18n/validation_en_US.properties deleted file mode 100644 index 342cada39..000000000 --- a/main/manager-api/src/main/resources/i18n/validation_en_US.properties +++ /dev/null @@ -1,34 +0,0 @@ -#English -id.require=ID can not be empty -id.null=ID has to be empty - -sort.number=The sort value cannot be less than 0 -page.number=The page value cannot be less than 0 -limit.number=The limit 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 -sysparams.valuetype.require=Value type cannot be empty -sysparams.valuetype.pattern=Value type must be string, number, boolean or array - -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.error=Incorrect email format -sysuser.deptId.require=Departments cannot be empty -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 - -timbre.languages.require=The language of the timbre cannot be empty -timbre.name.require=The name of the timbre cannot be empty -timbre.ttsModelId.require=The TTS model ID of the timbre cannot be empty -timbre.ttsVoice.require=The TTS voice of the timbre cannot be empty - -ota.device.not.found=Device not found -ota.device.need.bind={0} \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/validation_zh_CN.properties b/main/manager-api/src/main/resources/i18n/validation_zh_CN.properties deleted file mode 100644 index eaa50eb77..000000000 --- a/main/manager-api/src/main/resources/i18n/validation_zh_CN.properties +++ /dev/null @@ -1,34 +0,0 @@ -#\u7B80\u4F53\u4E2D\u6587 -id.require=ID\u4E0D\u80FD\u4E3A\u7A7A -id.null=ID\u5FC5\u987B\u4E3A\u7A7A - -sort.number=\u6392\u5E8F\u503C\u4E0D\u80FD\u5C0F\u4E8E0 -page.number=\u9801\u6578\u4E0D\u80FD\u5C0F\u4E8E0 -limit.number=\u5217\u6578\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 -sysparams.valuetype.require=\u503C\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A -sysparams.valuetype.pattern=\u503C\u7C7B\u578B\u5FC5\u987B\u662F string\u3001number\u3001boolean \u6216 array - -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 - -timbre.languages.require=\u97F3\u8272\u7684\u8A9E\u8A00\u4E0D\u53EF\u4EE5\u70BA\u7A7A -timbre.name.require=\u97F3\u8272\u7684\u540D\u7A31\u4E0D\u53EF\u4EE5\u70BA\u7A7A -timbre.ttsModelId.require=\u97F3\u8272\u7684tts\u4E3B\u9375\u4E0D\u53EF\u4EE5\u70BA\u7A7A -timbre.ttsVoice.require=\u97F3\u8272\u7684\u7DE8\u78BC\u4E0D\u53EF\u4EE5\u70BA\u7A7A - -ota.device.not.found=\u8A2D\u5099\u672A\u627E\u5230 -ota.device.need.bind={0} \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/validation_zh_TW.properties b/main/manager-api/src/main/resources/i18n/validation_zh_TW.properties deleted file mode 100644 index 4e3a271ae..000000000 --- a/main/manager-api/src/main/resources/i18n/validation_zh_TW.properties +++ /dev/null @@ -1,34 +0,0 @@ -#\u7B80\u4F53\u4E2D\u6587 -id.require=ID\u4E0D\u80FD\u4E3A\u7A7A -id.null=ID\u5FC5\u987B\u4E3A\u7A7A - -sort.number=\u6392\u5E8F\u503C\u4E0D\u80FD\u5C0F\u4E8E0 -page.number=\u9875\u6570\u4E0D\u80FD\u5C0F\u4E8E0 -limit.number=\u5217\u6570\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=\u53C3\u6578\u7DE8\u78BC\u4E0D\u80FD\u70BA\u7A7A -sysparams.paramvalue.require=\u53C3\u6578\u503C\u4E0D\u80FD\u70BA\u7A7A -sysparams.valuetype.require=\u503C\u985E\u578B\u4E0D\u80FD\u70BA\u7A7A -sysparams.valuetype.pattern=\u503C\u985E\u578B\u5FC5\u9808\u662F string\u3001number\u3001boolean \u6216 array - -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 - -timbre.languages.require=\u97F3\u8272\u7684\u8BED\u8A00\u4E0D\u53EF\u4EE5\u4E3A\u7A7A -timbre.name.require=\u97F3\u8272\u7684\u540D\u79F0\u4E0D\u53EF\u4EE5\u4E3A\u7A7A -timbre.ttsModelId.require=\u97F3\u8272\u7684tts\u4E3B\u952E\u4E0D\u53EF\u4EE5\u4E3A\u7A7A -timbre.ttsVoice.require=\u97F3\u8272\u7684\u7F16\u7801\u4E0D\u53EF\u4EE5\u4E3A\u7A7A - -ota.device.not.found=\u8A2D\u5099\u672A\u627E\u5230 -ota.device.need.bind={0} \ No newline at end of file diff --git a/main/manager-api/src/main/resources/logback-spring.xml b/main/manager-api/src/main/resources/logback-spring.xml deleted file mode 100644 index c69d03c03..000000000 --- a/main/manager-api/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - ${LOG_HOME} - true - - - - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}) - %msg%n - UTF-8 - - - - - - ${LOG_HOME}/xiaozhi-esp32-api.log - - ${LOG_HOME}/xiaozhi-esp32-api.%d{yyyy-MM-dd}.%i.log - 10MB - 30 - 2GB - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - UTF-8 - - - - - - ${LOG_HOME}/error.log - - ERROR - - - ${LOG_HOME}/error.%d{yyyy-MM-dd}.%i.log - 10MB - 30 - 1GB - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - UTF-8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${LOG_HOME}/xiaozhi-esp32-api.log - - ${LOG_HOME}/xiaozhi-esp32-api.%d{yyyy-MM-dd}.%i.log - 10MB - 30 - 2GB - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - UTF-8 - - - - - - ${LOG_HOME}/error.log - - ERROR - - - ${LOG_HOME}/error.%d{yyyy-MM-dd}.%i.log - 10MB - 30 - 1GB - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - UTF-8 - - - - - - - - - - - - - - - - - - - true - - diff --git a/main/manager-api/src/main/resources/lua/emptyAll.lua b/main/manager-api/src/main/resources/lua/emptyAll.lua deleted file mode 100644 index 2626a8949..000000000 --- a/main/manager-api/src/main/resources/lua/emptyAll.lua +++ /dev/null @@ -1 +0,0 @@ -redis.call('FLUSHDB') \ No newline at end of file diff --git a/main/manager-api/src/main/resources/lua/getKeyOrCreate.lua b/main/manager-api/src/main/resources/lua/getKeyOrCreate.lua deleted file mode 100644 index bc375b120..000000000 --- a/main/manager-api/src/main/resources/lua/getKeyOrCreate.lua +++ /dev/null @@ -1,11 +0,0 @@ -local value = redis.call('GET', KEYS[1]) --- value 如果为空着设置值 -if not value then - local result = redis.call('SET', KEYS[1], ARGV[1]) - -- 检查 ARGV[2] 是否存在且大于 0 - local expireTime = tonumber(ARGV[2]) - if expireTime and expireTime > 0 then - redis.call('EXPIRE', KEYS[1], expireTime) - end -end -return value \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/agent/AgentDao.xml b/main/manager-api/src/main/resources/mapper/agent/AgentDao.xml deleted file mode 100644 index 439be0965..000000000 --- a/main/manager-api/src/main/resources/mapper/agent/AgentDao.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/agent/AgentPluginMappingMapper.xml b/main/manager-api/src/main/resources/mapper/agent/AgentPluginMappingMapper.xml deleted file mode 100644 index 659fcd6e4..000000000 --- a/main/manager-api/src/main/resources/mapper/agent/AgentPluginMappingMapper.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - id,agent_id,plugin_id - - - - - - - diff --git a/main/manager-api/src/main/resources/mapper/agent/AgentTemplateMapper.xml b/main/manager-api/src/main/resources/mapper/agent/AgentTemplateMapper.xml deleted file mode 100644 index bc372f8a4..000000000 --- a/main/manager-api/src/main/resources/mapper/agent/AgentTemplateMapper.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/main/manager-api/src/main/resources/mapper/agent/AiAgentChatHistoryDao.xml b/main/manager-api/src/main/resources/mapper/agent/AiAgentChatHistoryDao.xml deleted file mode 100644 index 3e80f7fd5..000000000 --- a/main/manager-api/src/main/resources/mapper/agent/AiAgentChatHistoryDao.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - id, mac_address, agent_id, session_id, sort, chat_type, content, audio, audio_url, - created_at, updated_at - - - - DELETE FROM ai_agent_chat_audio - WHERE id IN ( - SELECT audio_id - FROM ai_agent_chat_history - WHERE agent_id = #{agentId} - ) - - - - UPDATE ai_agent_chat_history - SET audio_id = NULL - WHERE agent_id = #{agentId} - - - - DELETE FROM ai_agent_chat_history - WHERE agent_id = #{agentId} - - diff --git a/main/manager-api/src/main/resources/mapper/device/DeviceDao.xml b/main/manager-api/src/main/resources/mapper/device/DeviceDao.xml deleted file mode 100644 index 54de47c92..000000000 --- a/main/manager-api/src/main/resources/mapper/device/DeviceDao.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/model/ModelConfigDao.xml b/main/manager-api/src/main/resources/mapper/model/ModelConfigDao.xml deleted file mode 100644 index f6f8b3e71..000000000 --- a/main/manager-api/src/main/resources/mapper/model/ModelConfigDao.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/model/ModelProviderDao.xml b/main/manager-api/src/main/resources/mapper/model/ModelProviderDao.xml deleted file mode 100644 index b17e24fce..000000000 --- a/main/manager-api/src/main/resources/mapper/model/ModelProviderDao.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/security/SysUserTokenDao.xml b/main/manager-api/src/main/resources/mapper/security/SysUserTokenDao.xml deleted file mode 100644 index 4f49414a0..000000000 --- a/main/manager-api/src/main/resources/mapper/security/SysUserTokenDao.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - update sys_user_token set expire_date = #{expireDate} where user_id = #{userId} - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/sys/SysDictDataDao.xml b/main/manager-api/src/main/resources/mapper/sys/SysDictDataDao.xml deleted file mode 100644 index 398488316..000000000 --- a/main/manager-api/src/main/resources/mapper/sys/SysDictDataDao.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/sys/SysDictTypeDao.xml b/main/manager-api/src/main/resources/mapper/sys/SysDictTypeDao.xml deleted file mode 100644 index 825db02b6..000000000 --- a/main/manager-api/src/main/resources/mapper/sys/SysDictTypeDao.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/sys/SysParamsDao.xml b/main/manager-api/src/main/resources/mapper/sys/SysParamsDao.xml deleted file mode 100644 index 8faf43116..000000000 --- a/main/manager-api/src/main/resources/mapper/sys/SysParamsDao.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - update sys_params set param_value = #{paramValue} where param_code = #{paramCode} - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/sys/SysUserDao.xml b/main/manager-api/src/main/resources/mapper/sys/SysUserDao.xml deleted file mode 100644 index 007e91c46..000000000 --- a/main/manager-api/src/main/resources/mapper/sys/SysUserDao.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/main/manager-api/src/main/resources/mapper/voiceclone/VoiceCloneDao.xml b/main/manager-api/src/main/resources/mapper/voiceclone/VoiceCloneDao.xml deleted file mode 100644 index d76585920..000000000 --- a/main/manager-api/src/main/resources/mapper/voiceclone/VoiceCloneDao.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/main/manager-api/src/test/java/xiaozhi/common/utils/AESUtilsTest.java b/main/manager-api/src/test/java/xiaozhi/common/utils/AESUtilsTest.java deleted file mode 100644 index c4f371157..000000000 --- a/main/manager-api/src/test/java/xiaozhi/common/utils/AESUtilsTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package xiaozhi.common.utils; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -public class AESUtilsTest { - - @Test - public void testEncryptAndDecrypt() { - String key = "xiaozhi1234567890"; - String plainText = "Hello, 小智!"; - - System.out.println("原始文本: " + plainText); - System.out.println("密钥: " + key); - - // 加密 - String encrypted = AESUtils.encrypt(key, plainText); - System.out.println("加密结果: " + encrypted); - - // 解密 - String decrypted = AESUtils.decrypt(key, encrypted); - System.out.println("解密结果: " + decrypted); - - // 验证 - assertEquals(plainText, decrypted, "加解密结果应该一致"); - System.out.println("加解密一致性: " + plainText.equals(decrypted)); - } - - @Test - public void testDifferentKeyLengths() { - String[] keys = { - "1234567890123456", // 16位 - "123456789012345678901234", // 24位 - "12345678901234567890123456789012", // 32位 - "short", // 短密钥 - "verylongkeythatwillbetruncatedto32bytes" // 长密钥 - }; - - String plainText = "测试文本"; - - for (String key : keys) { - String encrypted = AESUtils.encrypt(key, plainText); - String decrypted = AESUtils.decrypt(key, encrypted); - assertEquals(plainText, decrypted, "密钥长度: " + key.length()); - } - } - - @Test - public void testSpecialCharacters() { - String key = "xiaozhi1234567890"; - String[] testTexts = { - "Hello World", - "你好世界", - "Hello, 小智!", - "特殊字符: !@#$%^&*()", - "数字123和中文混合", - "Emoji: 😀🎉🚀", - "空字符串测试", - "" - }; - - for (String text : testTexts) { - String encrypted = AESUtils.encrypt(key, text); - String decrypted = AESUtils.decrypt(key, encrypted); - assertEquals(text, decrypted, "测试文本: " + text); - } - } - - @Test - public void testCrossLanguageCompatibility() { - // 这些是Python版本生成的加密结果,用于测试跨语言兼容性 - String key = "xiaozhi1234567890"; - String plainText = "Hello, 小智!"; - - // Python版本生成的加密结果(需要运行Python测试后获取) - // String pythonEncrypted = "从Python测试中获取的加密结果"; - // String decrypted = AESUtils.decrypt(key, pythonEncrypted); - // assertEquals(plainText, decrypted, "Java应该能解密Python加密的结果"); - - // 生成Java加密结果供Python测试 - String javaEncrypted = AESUtils.encrypt(key, plainText); - System.out.println("Java加密结果供Python测试: " + javaEncrypted); - } -} \ No newline at end of file diff --git a/main/manager-api/src/test/java/xiaozhi/modules/device/DeviceTest.java b/main/manager-api/src/test/java/xiaozhi/modules/device/DeviceTest.java deleted file mode 100644 index 37f67cab6..000000000 --- a/main/manager-api/src/test/java/xiaozhi/modules/device/DeviceTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package xiaozhi.modules.device; - -import java.util.HashMap; -import java.util.UUID; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; - -import lombok.extern.slf4j.Slf4j; -import xiaozhi.common.redis.RedisUtils; -import xiaozhi.modules.sys.dto.SysUserDTO; -import xiaozhi.modules.sys.service.SysUserService; - -@Slf4j -@SpringBootTest -@ActiveProfiles("dev") -@DisplayName("设备测试") -public class DeviceTest { - - @Autowired - private RedisUtils redisUtils; - @Autowired - private SysUserService sysUserService; - - @Test - public void testSaveUser() { - SysUserDTO userDTO = new SysUserDTO(); - userDTO.setUsername("test"); - userDTO.setPassword(UUID.randomUUID().toString()); - sysUserService.save(userDTO); - } - - @Test - @DisplayName("测试写入设备信息") - public void testWriteDeviceInfo() { - log.info("开始测试写入设备信息..."); - // 模拟设备MAC地址 - String macAddress = "00:11:22:33:44:66"; - // 模拟设备验证码 - String deviceCode = "123456"; - - HashMap map = new HashMap<>(); - map.put("mac_address", macAddress); - map.put("activation_code", deviceCode); - map.put("board", "硬件型号"); - map.put("app_version", "0.3.13"); - - String safeDeviceId = macAddress.replace(":", "_").toLowerCase(); - String cacheDeviceKey = String.format("ota:activation:data:%s", safeDeviceId); - redisUtils.set(cacheDeviceKey, map, 300); - - String redisKey = "ota:activation:code:" + deviceCode; - log.info("Redis Key: {}", redisKey); - - // 将设备信息写入Redis - redisUtils.set(redisKey, macAddress, 300); - log.info("设备信息已写入Redis"); - - // 验证是否写入成功 - String savedMacAddress = (String) redisUtils.get(redisKey); - log.info("从Redis读取的MAC地址: {}", savedMacAddress); - - // 使用断言验证 - Assertions.assertNotNull(savedMacAddress, "从Redis读取的MAC地址不应为空"); - Assertions.assertEquals(macAddress, savedMacAddress, "保存的MAC地址与原始MAC地址不匹配"); - - log.info("测试完成"); - } -} \ No newline at end of file diff --git a/main/manager-api/src/test/java/xiaozhi/modules/sys/loginControllerTest.java b/main/manager-api/src/test/java/xiaozhi/modules/sys/loginControllerTest.java deleted file mode 100644 index 1175223b5..000000000 --- a/main/manager-api/src/test/java/xiaozhi/modules/sys/loginControllerTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package xiaozhi.modules.sys; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; - -import lombok.extern.slf4j.Slf4j; -import xiaozhi.modules.security.controller.LoginController; -import xiaozhi.modules.security.dto.LoginDTO; -import xiaozhi.modules.security.dto.SmsVerificationDTO; -import xiaozhi.modules.sys.dto.RetrievePasswordDTO; - -@Slf4j -@SpringBootTest -@ActiveProfiles("dev") -class loginControllerTest { - - @Autowired - LoginController loginController; - - @Test - public void testRegister() { - LoginDTO loginDTO = new LoginDTO(); - loginDTO.setUsername("手机号码"); - loginDTO.setPassword("密码"); - loginController.register(loginDTO); - } - - @Test - public void testSmsVerification() { - try { - SmsVerificationDTO smsVerificationDTO = new SmsVerificationDTO(); - smsVerificationDTO.setPhone("手机号码"); - smsVerificationDTO.setCaptchaId("123456"); - smsVerificationDTO.setCaptcha("123456"); - loginController.smsVerification(smsVerificationDTO); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - } - - @Test - public void testRetrievePassword() { - try { - RetrievePasswordDTO retrievePasswordDTO = new RetrievePasswordDTO(); - retrievePasswordDTO.setCode("123456"); - retrievePasswordDTO.setPhone("手机号码"); - retrievePasswordDTO.setPassword("密码"); - loginController.retrievePassword(retrievePasswordDTO); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - - } - -} \ No newline at end of file diff --git a/main/manager-api/src/test/resources/application.yml b/main/manager-api/src/test/resources/application.yml deleted file mode 100644 index 099e81941..000000000 --- a/main/manager-api/src/test/resources/application.yml +++ /dev/null @@ -1,22 +0,0 @@ -spring: - data: - redis: - host: localhost - port: 6379 - database: 0 - timeout: 10s - lettuce: - pool: - min-idle: 0 - max-idle: 8 - max-active: 8 - max-wait: -1ms - -renren: - redis: - open: true - -logging: - level: - xiaozhi.modules.device: DEBUG - org.springframework.data.redis: DEBUG \ No newline at end of file diff --git a/main/manager-mobile/.commitlintrc.cjs b/main/manager-mobile/.commitlintrc.cjs deleted file mode 100644 index 98ee7dfc2..000000000 --- a/main/manager-mobile/.commitlintrc.cjs +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - extends: ['@commitlint/config-conventional'], -} diff --git a/main/manager-mobile/.editorconfig b/main/manager-mobile/.editorconfig deleted file mode 100644 index 7f0986477..000000000 --- a/main/manager-mobile/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -root = true - -[*] # 表示所有文件适用 -charset = utf-8 # 设置文件字符集为 utf-8 -indent_style = space # 缩进风格(tab | space) -indent_size = 2 # 缩进大小 -end_of_line = lf # 控制换行类型(lf | cr | crlf) -trim_trailing_whitespace = true # 去除行首的任意空白字符 -insert_final_newline = true # 始终在文件末尾插入一个新行 - -[*.md] # 表示仅 md 文件适用以下规则 -max_line_length = off # 关闭最大行长度限制 -trim_trailing_whitespace = false # 关闭末尾空格修剪 diff --git a/main/manager-mobile/.gitignore b/main/manager-mobile/.gitignore deleted file mode 100644 index 34ddbdf3d..000000000 --- a/main/manager-mobile/.gitignore +++ /dev/null @@ -1,44 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -.DS_Store -dist -*.local - -# Editor directories and files -.idea -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? -.hbuilderx - -.stylelintcache -.eslintcache - -docs/.vitepress/dist -docs/.vitepress/cache - -src/types - -# lock 文件还是不要了,我主要的版本写死就好了 -# pnpm-lock.yaml -# package-lock.json - -# TIPS:如果某些文件已经加入了版本管理,现在重新加入 .gitignore 是不生效的,需要执行下面的操作 -# `git rm -r --cached .` 然后提交 commit 即可。 - -# git rm -r --cached file1 file2 ## 针对某些文件 -# git rm -r --cached dir1 dir2 ## 针对某些文件夹 -# git rm -r --cached . ## 针对所有文件 - -# 更新 uni-app 官方版本 -# npx @dcloudio/uvm@latest diff --git a/main/manager-mobile/.npmrc b/main/manager-mobile/.npmrc deleted file mode 100644 index 10ecfe224..000000000 --- a/main/manager-mobile/.npmrc +++ /dev/null @@ -1,8 +0,0 @@ -# registry = https://registry.npmjs.org -registry = https://registry.npmmirror.com - -strict-peer-dependencies=false -auto-install-peers=true -shamefully-hoist=true -ignore-workspace-root-check=true -install-workspace-root=true diff --git a/main/manager-mobile/LICENSE b/main/manager-mobile/LICENSE deleted file mode 100644 index 8738d3b5d..000000000 --- a/main/manager-mobile/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2025 Junsen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/main/manager-mobile/README.md b/main/manager-mobile/README.md deleted file mode 100644 index 3a4f33a38..000000000 --- a/main/manager-mobile/README.md +++ /dev/null @@ -1,170 +0,0 @@ -## 智控台移动版(manager-mobile) -基于 uni-app v3 + Vue 3 + Vite 的跨端移动管理端,支持 App(Android & iOS)和微信小程序。 - -### 平台兼容性 - -| H5 | iOS | Android | 微信小程序 | -| -- | --- | ------- | ---------- | -| √ | √ | √ | √ | - -提示:不同 UI 组件在不同平台的适配度略有差异,请以对应组件库文档为准。 - -### 开发环境要求 -- Node >= 18 -- pnpm >= 7.30(建议使用项目中声明的 `pnpm@10.x`) -- 可选:HBuilderX(App 调试/打包)、微信开发者工具(微信小程序) - -### 快速开始 -1) 配置环境变量 - - 复制 `env/.env.example` 为 `env/.env.development` - - 根据实际情况修改配置项(特别是 `VITE_SERVER_BASEURL`、`VITE_UNI_APPID`、`VITE_WX_APPID`) - -2) 安装依赖 - -```bash -pnpm i -``` - -3) 本地开发(热更新) -- h5: `pnpm dev:h5`,然后观察启动日志显示的ip端口号 -- 微信小程序:`pnpm dev:mp` 或 `pnpm dev:mp-weixin`,然后用微信开发者工具导入 `dist/dev/mp-weixin` -- App:用 HBuilderX 导入 `manager-mobile`,然后参考下面的教程就能运行了 - -### 环境变量与配置 -项目使用自定义 `env` 目录存放环境文件,按 Vite 规范命名:`.env.development`、`.env.production` 等。 - -关键变量(部分): -- VITE_APP_TITLE:应用名称(写入 `manifest.config.ts`) -- VITE_UNI_APPID:uni-app 应用 appid(App) -- VITE_WX_APPID:微信小程序 appid(mp-weixin) -- VITE_FALLBACK_LOCALE:默认语言,如 `zh-Hans` -- VITE_SERVER_BASEURL:服务端基础地址(HTTP 请求 baseURL) -- VITE_DELETE_CONSOLE:构建时是否移除 console(`true`/`false`) -- VITE_SHOW_SOURCEMAP:是否生成 sourcemap(默认关闭) -- VITE_LOGIN_URL:未登录跳转的登录页路径(路由拦截器使用) - -示例(`env/.env.development`): -```env -VITE_APP_TITLE=小智 -VITE_FALLBACK_LOCALE=zh-Hans -VITE_UNI_APPID= -VITE_WX_APPID= - -VITE_SERVER_BASEURL=http://localhost:8080 - -VITE_DELETE_CONSOLE=false -VITE_SHOW_SOURCEMAP=false -VITE_LOGIN_URL=/pages/login/index -``` - -说明: -- `manifest.config.ts` 会从 `env` 读取标题、appid、语言等配置。 - -### 重要注意事项 -⚠️ **部署前必须修改的配置项:** - -1. **应用 ID 配置** - - `VITE_UNI_APPID`:需要在 [DCloud 开发者中心](https://dev.dcloud.net.cn/) 创建应用并获取 AppID - - `VITE_WX_APPID`:需要在 [微信公众平台](https://mp.weixin.qq.com/) 注册小程序并获取 AppID - -2. **服务端地址** - - `VITE_SERVER_BASEURL`:修改为您的实际服务端地址 - -3. **应用信息** - - `VITE_APP_TITLE`:修改为您的应用名称 - - 更新 `src/static/logo.png` 等图标资源 - -4. **其他配置** - - 检查 `manifest.config.ts` 中的应用配置信息 - - 根据需要修改 `src/layouts/fg-tabbar/tabbarList.ts` 中的 tabbar 配置 - -### 详细操作指南 - -#### 1. 获取 uni-app AppID -![生成AppID](../../docs/images/manager-mobile/生成appid.png) -- 复制生成的 AppID 到环境变量 `VITE_UNI_APPID` 中 - -#### 2. 本地运行步骤 -![本地运行](../../docs/images/manager-mobile/本地运行.png) - -**App 本地调试:** -1. 用 HBuilderX 导入 `manager-mobile` 目录 -2. 重新识别项目 -3. 连接手机或使用模拟器进行真机调试 - -**项目识别问题解决:** -![重新识别项目](../../docs/images/manager-mobile/重新识别项目.png) - -如果 HBuilderX 无法正确识别项目类型: -- 在项目根目录右键选择"重新识别项目类型" -- 确保项目被识别为 "uni-app" 项目 - -### 路由与鉴权 -- 在 `src/main.ts` 中注册了路由拦截插件 `routeInterceptor`。 -- 黑名单拦截:仅对配置为需要登录的页面进行校验(来源 `@/utils` 的 `getNeedLoginPages`)。 -- 登录判断:基于用户信息(`pinia` 的 `useUserStore`),未登录将跳转到 `VITE_LOGIN_URL`,并附带重定向回原页面的参数。 - -### 网络请求 -- 基于 `alova` + `@alova/adapter-uniapp`,统一在 `src/http/request/alova.ts` 创建实例。 -- `baseURL` 读取环境配置(`getEnvBaseUrl`),可通过 `method.config.meta.domain` 动态切换域名。 -- 认证:默认从本地 `token`(`uni.getStorageSync('token')`)注入 `Authorization` 头,缺失则重定向登录。 -- 响应:统一处理 `statusCode !== 200` 的 HTTP 错误与业务 `code !== 0` 的错误;`401` 会清除 token 并跳转登录。 - -### 构建与发布 - -**微信小程序:** -1. 确保已配置正确的 `VITE_WX_APPID` -2. 运行 `pnpm build:mp`,产物在 `dist/build/mp-weixin` -3. 用微信开发者工具导入项目目录,并上传代码 -4. 在微信公众平台提交审核 - -**Android & iOS App:** - -#### 3. App 打包发行步骤 - -**步骤一:准备打包** -![打包发行步骤1](../../docs/images/manager-mobile/打包发行步骤1.png) - -1. 确保已配置正确的 `VITE_UNI_APPID` -2. 运行 `pnpm build:app`,产物在 `dist/build/app` -3. 用 HBuilderX 导入项目目录 -4. 在 HBuilderX 中点击"发行" → "原生App-云打包" - -**步骤二:配置打包参数** -![打包发行步骤2](../../docs/images/manager-mobile/打包发行步骤2.png) - -1. **应用图标和启动图**:上传应用图标和启动页面图片 -2. **应用版本号**:设置版本号和版本名称 -3. **签名证书**: - - Android:上传 keystore 证书文件 - - iOS:配置开发者证书和描述文件 -4. **包名配置**:设置应用的包名(Bundle ID) -5. **打包类型**:选择测试包或正式包 -6. 点击"打包"开始云打包流程 - -**发布到应用商店:** -- **Android**:将生成的 APK 文件上传到各大 Android 应用市场 -- **iOS**:将生成的 IPA 文件通过 App Store Connect 上传到 App Store(需要 Apple 开发者账号) - -### 约定与工程化 -- 页面与分包:由 `@uni-helper/vite-plugin-uni-pages` 与 `pages.config.ts` 统一生成;tabbar 配置在 `src/layouts/fg-tabbar/tabbarList.ts`。 -- 组件与 hooks 自动导入:见 `vite.config.ts` 中 `unplugin-auto-import` 与 `@uni-helper/vite-plugin-uni-components`。 -- 样式:使用 UnoCSS 与 `src/style/index.scss`。 -- 状态管理:`pinia` + `pinia-plugin-persistedstate`。 -- 代码规范:内置 `eslint`、`husky`、`lint-staged`,提交前自动格式化(`lint-staged`)。 - -### 常用脚本 -```bash -# 开发 -pnpm dev:mp # 等价 dev:mp-weixin - -# 构建 -pnpm build:mp # 等价 build:mp-weixin - -# 其他 -pnpm type-check -pnpm lint && pnpm lint:fix -``` - -### License -MIT diff --git a/main/manager-mobile/env/.env b/main/manager-mobile/env/.env deleted file mode 100644 index e0f4eea67..000000000 --- a/main/manager-mobile/env/.env +++ /dev/null @@ -1,19 +0,0 @@ -VITE_APP_TITLE = '小智' -VITE_APP_PORT = 9000 - -VITE_UNI_APPID = '__UNI__36A515E' -VITE_WX_APPID = 'wxa2abb91f64032a2b' - -# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base -VITE_APP_PUBLIC_BASE=/ - -# 登录页面 -VITE_LOGIN_URL = '/pages/login/index' -# 第一个请求地址 -VITE_SERVER_BASEURL = 'https://2662r3426b.vicp.fun/xiaozhi' - -VITE_UPLOAD_BASEURL = '/otaMag/upload' - -# h5是否需要配置代理 -VITE_APP_PROXY=true -VITE_APP_PROXY_PREFIX = '/xiaozhi' \ No newline at end of file diff --git a/main/manager-mobile/env/.env.development b/main/manager-mobile/env/.env.development deleted file mode 100644 index 04fa27397..000000000 --- a/main/manager-mobile/env/.env.development +++ /dev/null @@ -1,6 +0,0 @@ -# 变量必须以 VITE_ 为前缀才能暴露给外部读取 -NODE_ENV = 'development' -# 是否去除console 和 debugger -VITE_DELETE_CONSOLE = false -# 是否开启sourcemap -VITE_SHOW_SOURCEMAP = true diff --git a/main/manager-mobile/env/.env.production b/main/manager-mobile/env/.env.production deleted file mode 100644 index 8a1b50ca6..000000000 --- a/main/manager-mobile/env/.env.production +++ /dev/null @@ -1,6 +0,0 @@ -# 变量必须以 VITE_ 为前缀才能暴露给外部读取 -NODE_ENV = 'development' -# 是否去除console 和 debugger -VITE_DELETE_CONSOLE = true -# 是否开启sourcemap -VITE_SHOW_SOURCEMAP = false diff --git a/main/manager-mobile/env/.env.test b/main/manager-mobile/env/.env.test deleted file mode 100644 index e22f765a4..000000000 --- a/main/manager-mobile/env/.env.test +++ /dev/null @@ -1,4 +0,0 @@ -# 变量必须以 VITE_ 为前缀才能暴露给外部读取 -NODE_ENV = 'development' -# 是否去除console 和 debugger -VITE_DELETE_CONSOLE = false diff --git a/main/manager-mobile/eslint.config.mjs b/main/manager-mobile/eslint.config.mjs deleted file mode 100644 index 54ce246d6..000000000 --- a/main/manager-mobile/eslint.config.mjs +++ /dev/null @@ -1,43 +0,0 @@ -import uniHelper from '@uni-helper/eslint-config' - -export default uniHelper({ - unocss: true, - vue: true, - markdown: false, - ignores: [ - 'src/uni_modules/', - 'dist', - // unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用 - 'auto-import.d.ts', - // vite-plugin-uni-pages 生成的类型文件,每次切换分支都一堆不同的,所以直接 .gitignore - 'uni-pages.d.ts', - // 插件生成的文件 - 'src/pages.json', - 'src/manifest.json', - // 忽略自动生成文件 - 'src/service/app/**', - ], - rules: { - 'no-console': 'off', - 'no-unused-vars': 'off', - 'vue/no-unused-refs': 'off', - 'unused-imports/no-unused-vars': 'off', - 'eslint-comments/no-unlimited-disable': 'off', - 'jsdoc/check-param-names': 'off', - 'jsdoc/require-returns-description': 'off', - 'ts/no-empty-object-type': 'off', - 'no-extend-native': 'off', - }, - formatters: { - /** - * Format CSS, LESS, SCSS files, also the ` diff --git a/main/manager-mobile/src/api/agent/agent.ts b/main/manager-mobile/src/api/agent/agent.ts deleted file mode 100644 index 09f352f24..000000000 --- a/main/manager-mobile/src/api/agent/agent.ts +++ /dev/null @@ -1,185 +0,0 @@ -import type { - Agent, - AgentCreateData, - AgentDetail, - ModelOption, - RoleTemplate, -} from './types' -import { http } from '@/http/request/alova' - -// 获取智能体详情 -export function getAgentDetail(id: string) { - return http.Get(`/agent/${id}`, { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 获取角色模板列表 -export function getRoleTemplates() { - return http.Get('/agent/template', { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 获取模型选项 -export function getModelOptions(modelType: string, modelName: string = '') { - return http.Get('/models/names', { - params: { - modelType, - modelName, - }, - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 获取智能体列表 -export function getAgentList() { - return http.Get('/agent/list', { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 创建智能体 -export function createAgent(data: AgentCreateData) { - return http.Post('/agent', data, { - meta: { - ignoreAuth: false, - toast: true, - }, - }) -} - -// 删除智能体 -export function deleteAgent(id: string) { - return http.Delete(`/agent/${id}`, { - meta: { - ignoreAuth: false, - toast: true, - }, - }) -} - -// 获取TTS音色列表 -export function getTTSVoices(ttsModelId: string, voiceName: string = '') { - return http.Get<{ id: string, name: string }[]>(`/models/${ttsModelId}/voices`, { - params: { - voiceName, - }, - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 更新智能体 -export function updateAgent(id: string, data: Partial) { - return http.Put(`/agent/${id}`, data, { - meta: { - ignoreAuth: false, - toast: true, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 获取插件列表 -export function getPluginFunctions() { - return http.Get(`/models/provider/plugin/names`, { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 获取mcp接入点 -export function getMcpAddress(agentId: string) { - return http.Get(`/agent/mcp/address/${agentId}`, { - meta: { - ignoreAuth: false, - toast: false, - }, - }) -} - -// 获取mcp工具 -export function getMcpTools(agentId: string) { - return http.Get(`/agent/mcp/tools/${agentId}`, { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 获取声纹列表 -export function getVoicePrintList(agentId: string) { - return http.Get(`/agent/voice-print/list/${agentId}`, { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 获取语音对话记录 -export function getChatHistoryUser(agentId: string) { - return http.Get(`/agent/${agentId}/chat-history/user`, { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 新增声纹说话人 -export function createVoicePrint(data: { agentId: string, audioId: string, sourceName: string, introduce: string }) { - return http.Post('/agent/voice-print', data, { - meta: { - ignoreAuth: false, - toast: true, - }, - }) -} diff --git a/main/manager-mobile/src/api/agent/types.ts b/main/manager-mobile/src/api/agent/types.ts deleted file mode 100644 index 66559a23c..000000000 --- a/main/manager-mobile/src/api/agent/types.ts +++ /dev/null @@ -1,107 +0,0 @@ -// 智能体列表数据类型 -export interface Agent { - id: string - agentName: string - ttsModelName: string - ttsVoiceName: string - llmModelName: string - vllmModelName: string - memModelId: string - systemPrompt: string - summaryMemory: string | null - lastConnectedAt: string | null - deviceCount: number -} - -// 智能体创建数据类型 -export interface AgentCreateData { - agentName: string -} - -// 智能体详情数据类型 -export interface AgentDetail { - id: string - userId: string - agentCode: string - agentName: string - asrModelId: string - vadModelId: string - llmModelId: string - vllmModelId: string - ttsModelId: string - ttsVoiceId: string - memModelId: string - intentModelId: string - chatHistoryConf: number - systemPrompt: string - summaryMemory: string - langCode: string - language: string - sort: number - creator: string - createdAt: string - updater: string - updatedAt: string - functions: AgentFunction[] -} - -export interface AgentFunction { - id?: string - agentId?: string - pluginId: string - paramInfo: Record | null -} - -// 角色模板数据类型 -export interface RoleTemplate { - id: string - agentCode: string - agentName: string - asrModelId: string - vadModelId: string - llmModelId: string - vllmModelId: string - ttsModelId: string - ttsVoiceId: string - memModelId: string - intentModelId: string - chatHistoryConf: number - systemPrompt: string - summaryMemory: string - langCode: string - language: string - sort: number - creator: string - createdAt: string - updater: string - updatedAt: string -} - -// 模型选项数据类型 -export interface ModelOption { - id: string - modelName: string -} - -export interface PluginField { - key: string - type: string - label: string - default: string - selected?: boolean - editing?: boolean -} - -export interface PluginDefinition { - id: string - modelType: string - providerCode: string - name: string - fields: PluginField[] // 注意:原始是字符串,需要先 JSON.parse - sort: number - updater: string - updateDate: string - creator: string - createDate: string - [key: string]: any -} diff --git a/main/manager-mobile/src/api/auth.ts b/main/manager-mobile/src/api/auth.ts deleted file mode 100644 index f9750a089..000000000 --- a/main/manager-mobile/src/api/auth.ts +++ /dev/null @@ -1,143 +0,0 @@ -import { http } from '@/http/request/alova' - -// 登录接口数据类型 -export interface LoginData { - username: string - password: string - captchaId: string - areaCode?: string - mobile?: string -} - -// 登录响应数据类型 -export interface LoginResponse { - token: string - expire: number - clientHash: string -} - -// 验证码响应数据类型 -export interface CaptchaResponse { - captchaId: string - captchaImage: string -} - -// 获取验证码 -export function getCaptcha(uuid: string) { - return http.Get('/user/captcha', { - params: { uuid }, - meta: { - ignoreAuth: true, - toast: false, - }, - }) -} - -// 用户登录 -export function login(data: LoginData) { - return http.Post('/user/login', data, { - meta: { - ignoreAuth: true, - toast: true, - }, - }) -} - -// 用户信息响应数据类型 -export interface UserInfo { - id: number - username: string - realName: string - email: string - mobile: string - status: number - superAdmin: number -} - -// 公共配置响应数据类型 -export interface PublicConfig { - enableMobileRegister: boolean - version: string - year: string - allowUserRegister: boolean - mobileAreaList: Array<{ - name: string - key: string - }> - beianIcpNum: string - beianGaNum: string - name: string - sm2PublicKey: string -} - -// 获取用户信息 -export function getUserInfo() { - return http.Get('/user/info', { - meta: { - ignoreAuth: false, - toast: false, - }, - }) -} - -// 获取公共配置 -export function getPublicConfig() { - return http.Get('/user/pub-config', { - meta: { - ignoreAuth: true, - toast: false, - }, - }) -} - -// 注册数据类型 -export interface RegisterData { - username: string - password: string - captchaId: string - areaCode: string - mobile: string - mobileCaptcha: string -} - -// 发送短信验证码 -export function sendSmsCode(data: { - phone: string - captcha: string - captchaId: string -}) { - return http.Post('/user/smsVerification', data, { - meta: { - ignoreAuth: true, - toast: false, - }, - }) -} - -// 用户注册 -export function register(data: RegisterData) { - return http.Post('/user/register', data, { - meta: { - ignoreAuth: true, - toast: true, - }, - }) -} - -// 忘记密码数据类型 -export interface ForgotPasswordData { - phone: string - code: string - password: string - captchaId: string -} - -// 忘记密码(找回密码) -export function retrievePassword(data: ForgotPasswordData) { - return http.Put('/user/retrieve-password', data, { - meta: { - ignoreAuth: true, - toast: true, - }, - }) -} diff --git a/main/manager-mobile/src/api/chat-history/chat-history.ts b/main/manager-mobile/src/api/chat-history/chat-history.ts deleted file mode 100644 index 89c3f1ef7..000000000 --- a/main/manager-mobile/src/api/chat-history/chat-history.ts +++ /dev/null @@ -1,60 +0,0 @@ -import type { - ChatMessage, - ChatSessionsResponse, - GetSessionsParams, -} from './types' -import { http } from '@/http/request/alova' - -/** - * 获取聊天会话列表 - * @param agentId 智能体ID - * @param params 分页参数 - */ -export function getChatSessions(agentId: string, params: GetSessionsParams) { - return http.Get(`/agent/${agentId}/sessions`, { - params, - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -/** - * 获取聊天记录详情 - * @param agentId 智能体ID - * @param sessionId 会话ID - */ -export function getChatHistory(agentId: string, sessionId: string) { - return http.Get(`/agent/${agentId}/chat-history/${sessionId}`, { - meta: { - ignoreAuth: false, - toast: false, - }, - }) -} - -/** - * 获取音频下载ID - * @param audioId 音频ID - */ -export function getAudioId(audioId: string) { - return http.Post(`/agent/audio/${audioId}`, {}, { - meta: { - ignoreAuth: false, - toast: false, - }, - }) -} - -/** - * 获取音频播放地址 - * @param downloadId 下载ID - */ -export function getAudioPlayUrl(downloadId: string) { - // 根据需求文档,这个是直接返回二进制的,所以我们直接构造URL - return `/agent/play/${downloadId}` -} diff --git a/main/manager-mobile/src/api/chat-history/index.ts b/main/manager-mobile/src/api/chat-history/index.ts deleted file mode 100644 index ecf782a43..000000000 --- a/main/manager-mobile/src/api/chat-history/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './chat-history' -export * from './types' diff --git a/main/manager-mobile/src/api/chat-history/types.ts b/main/manager-mobile/src/api/chat-history/types.ts deleted file mode 100644 index b895ed475..000000000 --- a/main/manager-mobile/src/api/chat-history/types.ts +++ /dev/null @@ -1,38 +0,0 @@ -// 聊天会话列表项 -export interface ChatSession { - sessionId: string - createdAt: string - chatCount: number -} - -// 聊天会话列表响应 -export interface ChatSessionsResponse { - total: number - list: ChatSession[] -} - -// 聊天消息 -export interface ChatMessage { - createdAt: string - chatType: 1 | 2 // 1是用户,2是AI - content: string - audioId: string | null - macAddress: string -} - -// 用户消息内容(需要解析JSON) -export interface UserMessageContent { - speaker: string - content: string -} - -// 获取聊天会话列表参数 -export interface GetSessionsParams { - page: number - limit: number -} - -// 音频播放相关 -export interface AudioResponse { - data: string // 音频下载ID -} diff --git a/main/manager-mobile/src/api/device/device.ts b/main/manager-mobile/src/api/device/device.ts deleted file mode 100644 index fc9d5f69b..000000000 --- a/main/manager-mobile/src/api/device/device.ts +++ /dev/null @@ -1,55 +0,0 @@ -import type { Device, FirmwareType } from './types' -import { http } from '@/http/request/alova' - -/** - * 获取设备类型列表 - */ -export function getFirmwareTypes() { - return http.Get('/admin/dict/data/type/FIRMWARE_TYPE') -} - -/** - * 获取绑定设备列表 - * @param agentId 智能体ID - */ -export function getBindDevices(agentId: string) { - return http.Get(`/device/bind/${agentId}`, { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -/** - * 添加设备 - * @param agentId 智能体ID - * @param code 验证码 - */ -export function bindDevice(agentId: string, code: string) { - return http.Post(`/device/bind/${agentId}/${code}`, null) -} - -/** - * 设置设备OTA升级开关 - * @param deviceId 设备ID (MAC地址) - * @param autoUpdate 是否自动升级 0|1 - */ -export function updateDeviceAutoUpdate(deviceId: string, autoUpdate: number) { - return http.Put(`/device/update/${deviceId}`, { - autoUpdate, - }) -} - -/** - * 解绑设备 - * @param deviceId 设备ID (MAC地址) - */ -export function unbindDevice(deviceId: string) { - return http.Post('/device/unbind', { - deviceId, - }) -} diff --git a/main/manager-mobile/src/api/device/index.ts b/main/manager-mobile/src/api/device/index.ts deleted file mode 100644 index aa5f61790..000000000 --- a/main/manager-mobile/src/api/device/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './device' -export * from './types' diff --git a/main/manager-mobile/src/api/device/types.ts b/main/manager-mobile/src/api/device/types.ts deleted file mode 100644 index 4b6165c53..000000000 --- a/main/manager-mobile/src/api/device/types.ts +++ /dev/null @@ -1,21 +0,0 @@ -export interface FirmwareType { - name: string - key: string -} - -export interface Device { - id: string - userId: string - macAddress: string - lastConnectedAt: string - autoUpdate: number - board: string - alias?: string - agentId: string - appVersion: string - sort: number - updater?: string - updateDate: string - creator: string - createDate: string -} diff --git a/main/manager-mobile/src/api/voiceprint/index.ts b/main/manager-mobile/src/api/voiceprint/index.ts deleted file mode 100644 index af56e69ac..000000000 --- a/main/manager-mobile/src/api/voiceprint/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './types' -export * from './voiceprint' diff --git a/main/manager-mobile/src/api/voiceprint/types.ts b/main/manager-mobile/src/api/voiceprint/types.ts deleted file mode 100644 index 726b17833..000000000 --- a/main/manager-mobile/src/api/voiceprint/types.ts +++ /dev/null @@ -1,29 +0,0 @@ -// 声纹信息响应类型 -export interface VoicePrint { - id: string - audioId: string - sourceName: string - introduce: string - createDate: string -} - -// 语音对话记录类型 -export interface ChatHistory { - content: string - audioId: string -} - -// 创建说话人数据类型 -export interface CreateSpeakerData { - agentId: string - audioId: string - sourceName: string - introduce: string -} - -// 通用响应类型 -export interface ApiResponse { - code: number - msg: string - data: T -} diff --git a/main/manager-mobile/src/api/voiceprint/voiceprint.ts b/main/manager-mobile/src/api/voiceprint/voiceprint.ts deleted file mode 100644 index 600696dd1..000000000 --- a/main/manager-mobile/src/api/voiceprint/voiceprint.ts +++ /dev/null @@ -1,62 +0,0 @@ -import type { - ChatHistory, - CreateSpeakerData, - VoicePrint, -} from './types' -import { http } from '@/http/request/alova' - -// 获取声纹列表 -export function getVoicePrintList(agentId: string) { - return http.Get(`/agent/voice-print/list/${agentId}`, { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 获取语音对话记录(用于选择声纹向量) -export function getChatHistory(agentId: string) { - return http.Get(`/agent/${agentId}/chat-history/user`, { - meta: { - ignoreAuth: false, - toast: false, - }, - cacheFor: { - expire: 0, - }, - }) -} - -// 新增说话人 -export function createVoicePrint(data: CreateSpeakerData) { - return http.Post('/agent/voice-print', data, { - meta: { - ignoreAuth: false, - toast: true, - }, - }) -} - -// 删除声纹 -export function deleteVoicePrint(id: string) { - return http.Delete(`/agent/voice-print/${id}`, { - meta: { - ignoreAuth: false, - toast: true, - }, - }) -} - -// 更新声纹信息 -export function updateVoicePrint(data: VoicePrint) { - return http.Put('/agent/voice-print', data, { - meta: { - ignoreAuth: false, - toast: true, - }, - }) -} diff --git a/main/manager-mobile/src/components/.gitkeep b/main/manager-mobile/src/components/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/main/manager-mobile/src/components/custom-tabs/index.vue b/main/manager-mobile/src/components/custom-tabs/index.vue deleted file mode 100644 index f5ef0705d..000000000 --- a/main/manager-mobile/src/components/custom-tabs/index.vue +++ /dev/null @@ -1,131 +0,0 @@ - - - - - diff --git a/main/manager-mobile/src/env.d.ts b/main/manager-mobile/src/env.d.ts deleted file mode 100644 index b4a2c97b2..000000000 --- a/main/manager-mobile/src/env.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -/// -/// - -declare module '*.vue' { - import type { DefineComponent } from 'vue' - - const component: DefineComponent<{}, {}, any> - export default component -} - -interface ImportMetaEnv { - /** 网站标题,应用名称 */ - readonly VITE_APP_TITLE: string - /** 服务端口号 */ - readonly VITE_SERVER_PORT: string - /** 后台接口地址 */ - readonly VITE_SERVER_BASEURL: string - /** H5是否需要代理 */ - readonly VITE_APP_PROXY: 'true' | 'false' - /** H5是否需要代理,需要的话有个前缀 */ - readonly VITE_APP_PROXY_PREFIX: string // 一般是/api - /** 上传图片地址 */ - readonly VITE_UPLOAD_BASEURL: string - /** 是否清除console */ - readonly VITE_DELETE_CONSOLE: string - // 更多环境变量... -} - -interface ImportMeta { - readonly env: ImportMetaEnv -} - -declare const __VITE_APP_PROXY__: 'true' | 'false' -declare const __UNI_PLATFORM__: 'app' | 'h5' | 'mp-alipay' | 'mp-baidu' | 'mp-kuaishou' | 'mp-lark' | 'mp-qq' | 'mp-tiktok' | 'mp-weixin' | 'mp-xiaochengxu' diff --git a/main/manager-mobile/src/hooks/.gitkeep b/main/manager-mobile/src/hooks/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/main/manager-mobile/src/hooks/usePageAuth.ts b/main/manager-mobile/src/hooks/usePageAuth.ts deleted file mode 100644 index fd006c812..000000000 --- a/main/manager-mobile/src/hooks/usePageAuth.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { onLoad } from '@dcloudio/uni-app' -import { useUserStore } from '@/store' -import { needLoginPages as _needLoginPages, getNeedLoginPages } from '@/utils' - -const loginRoute = import.meta.env.VITE_LOGIN_URL -const isDev = import.meta.env.DEV -function isLogined() { - const userStore = useUserStore() - return !!userStore.userInfo.username -} -// 检查当前页面是否需要登录 -export function usePageAuth() { - onLoad((options) => { - // 获取当前页面路径 - const pages = getCurrentPages() - const currentPage = pages[pages.length - 1] - const currentPath = `/${currentPage.route}` - - // 获取需要登录的页面列表 - let needLoginPages: string[] = [] - if (isDev) { - needLoginPages = getNeedLoginPages() - } - else { - needLoginPages = _needLoginPages - } - - // 检查当前页面是否需要登录 - const isNeedLogin = needLoginPages.includes(currentPath) - if (!isNeedLogin) { - return - } - - const hasLogin = isLogined() - if (hasLogin) { - return true - } - - // 构建重定向URL - const queryString = Object.entries(options || {}) - .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`) - .join('&') - - const currentFullPath = queryString ? `${currentPath}?${queryString}` : currentPath - const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(currentFullPath)}` - - // 重定向到登录页 - uni.redirectTo({ url: redirectRoute }) - }) -} diff --git a/main/manager-mobile/src/hooks/useRequest.ts b/main/manager-mobile/src/hooks/useRequest.ts deleted file mode 100644 index 017a710ad..000000000 --- a/main/manager-mobile/src/hooks/useRequest.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { Ref } from 'vue' - -interface IUseRequestOptions { - /** 是否立即执行 */ - immediate?: boolean - /** 初始化数据 */ - initialData?: T -} - -interface IUseRequestReturn { - loading: Ref - error: Ref - data: Ref - run: () => Promise -} - -/** - * useRequest是一个定制化的请求钩子,用于处理异步请求和响应。 - * @param func 一个执行异步请求的函数,返回一个包含响应数据的Promise。 - * @param options 包含请求选项的对象 {immediate, initialData}。 - * @param options.immediate 是否立即执行请求,默认为false。 - * @param options.initialData 初始化数据,默认为undefined。 - * @returns 返回一个对象{loading, error, data, run},包含请求的加载状态、错误信息、响应数据和手动触发请求的函数。 - */ -export default function useRequest( - func: () => Promise>, - options: IUseRequestOptions = { immediate: false }, -): IUseRequestReturn { - const loading = ref(false) - const error = ref(false) - const data = ref(options.initialData) as Ref - const run = async () => { - loading.value = true - return func() - .then((res) => { - data.value = res.data - error.value = false - return data.value - }) - .catch((err) => { - error.value = err - throw err - }) - .finally(() => { - loading.value = false - }) - } - - options.immediate && run() - return { loading, error, data, run } -} diff --git a/main/manager-mobile/src/hooks/useUpload.ts b/main/manager-mobile/src/hooks/useUpload.ts deleted file mode 100644 index 3080d5a79..000000000 --- a/main/manager-mobile/src/hooks/useUpload.ts +++ /dev/null @@ -1,160 +0,0 @@ -import { ref } from 'vue' -import { getEnvBaseUploadUrl } from '@/utils' - -const VITE_UPLOAD_BASEURL = `${getEnvBaseUploadUrl()}` - -type TfileType = 'image' | 'file' -type TImage = 'png' | 'jpg' | 'jpeg' | 'webp' | '*' -type TFile = 'doc' | 'docx' | 'ppt' | 'zip' | 'xls' | 'xlsx' | 'txt' | TImage - -interface TOptions { - formData?: Record - maxSize?: number - accept?: T extends 'image' ? TImage[] : TFile[] - fileType?: T - success?: (params: any) => void - error?: (err: any) => void -} - -export default function useUpload(options: TOptions = {} as TOptions) { - const { - formData = {}, - maxSize = 5 * 1024 * 1024, - accept = ['*'], - fileType = 'image', - success, - error: onError, - } = options - - const loading = ref(false) - const error = ref(null) - const data = ref(null) - - const handleFileChoose = ({ tempFilePath, size }: { tempFilePath: string, size: number }) => { - if (size > maxSize) { - uni.showToast({ - title: `文件大小不能超过 ${maxSize / 1024 / 1024}MB`, - icon: 'none', - }) - return - } - - // const fileExtension = file?.tempFiles?.name?.split('.').pop()?.toLowerCase() - // const isTypeValid = accept.some((type) => type === '*' || type.toLowerCase() === fileExtension) - - // if (!isTypeValid) { - // uni.showToast({ - // title: `仅支持 ${accept.join(', ')} 格式的文件`, - // icon: 'none', - // }) - // return - // } - - loading.value = true - uploadFile({ - tempFilePath, - formData, - onSuccess: (res) => { - const { data: _data } = JSON.parse(res) - data.value = _data - // console.log('上传成功', res) - success?.(_data) - }, - onError: (err) => { - error.value = err - onError?.(err) - }, - onComplete: () => { - loading.value = false - }, - }) - } - - const run = () => { - // 微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。 - // 微信小程序在2023年10月17日之后,使用本API需要配置隐私协议 - const chooseFileOptions = { - count: 1, - success: (res: any) => { - console.log('File selected successfully:', res) - // 小程序中res:{errMsg: "chooseImage:ok", tempFiles: [{fileType: "image", size: 48976, tempFilePath: "http://tmp/5iG1WpIxTaJf3ece38692a337dc06df7eb69ecb49c6b.jpeg"}]} - // h5中res:{errMsg: "chooseImage:ok", tempFilePaths: "blob:http://localhost:9000/f74ab6b8-a14d-4cb6-a10d-fcf4511a0de5", tempFiles: [File]} - // h5的File有以下字段:{name: "girl.jpeg", size: 48976, type: "image/jpeg"} - // App中res:{errMsg: "chooseImage:ok", tempFilePaths: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", tempFiles: [File]} - // App的File有以下字段:{path: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", size: 48976} - let tempFilePath = '' - let size = 0 - // #ifdef MP-WEIXIN - tempFilePath = res.tempFiles[0].tempFilePath - size = res.tempFiles[0].size - // #endif - // #ifndef MP-WEIXIN - tempFilePath = res.tempFilePaths[0] - size = res.tempFiles[0].size - // #endif - handleFileChoose({ tempFilePath, size }) - }, - fail: (err: any) => { - console.error('File selection failed:', err) - error.value = err - onError?.(err) - }, - } - - if (fileType === 'image') { - // #ifdef MP-WEIXIN - uni.chooseMedia({ - ...chooseFileOptions, - mediaType: ['image'], - }) - // #endif - - // #ifndef MP-WEIXIN - uni.chooseImage(chooseFileOptions) - // #endif - } - else { - uni.chooseFile({ - ...chooseFileOptions, - type: 'all', - }) - } - } - - return { loading, error, data, run } -} - -async function uploadFile({ - tempFilePath, - formData, - onSuccess, - onError, - onComplete, -}: { - tempFilePath: string - formData: Record - onSuccess: (data: any) => void - onError: (err: any) => void - onComplete: () => void -}) { - uni.uploadFile({ - url: VITE_UPLOAD_BASEURL, - filePath: tempFilePath, - name: 'file', - formData, - success: (uploadFileRes) => { - try { - const data = uploadFileRes.data - onSuccess(data) - } - catch (err) { - onError(err) - } - }, - fail: (err) => { - console.error('Upload failed:', err) - onError(err) - }, - complete: onComplete, - }) -} diff --git a/main/manager-mobile/src/http/README.md b/main/manager-mobile/src/http/README.md deleted file mode 100644 index fd34fd52b..000000000 --- a/main/manager-mobile/src/http/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# 请求库 - -当前项目使用 Alova 作为唯一的 HTTP 请求库: - -## 使用方式 - -- **Alova HTTP**:路径(src/http/request/alova.ts) -- **示例代码**:src/api/foo-alova.ts 和 src/api/foo.ts -- **API文档**:https://alova.js.org/ - -## 配置说明 - -Alova 实例已配置: -- 自动 Token 认证和刷新 -- 统一错误处理和提示 -- 支持动态域名切换 -- 内置请求/响应拦截器 - -## 使用示例 - -```typescript -import { http } from '@/http/request/alova' - -// GET 请求 -http.Get('/api/path', { - params: { id: 1 }, - headers: { 'Custom-Header': 'value' }, - meta: { toast: false } // 关闭错误提示 -}) - -// POST 请求 -http.Post('/api/path', data, { - params: { query: 'param' }, - headers: { 'Content-Type': 'application/json' } -}) -``` \ No newline at end of file diff --git a/main/manager-mobile/src/http/request/alova.ts b/main/manager-mobile/src/http/request/alova.ts deleted file mode 100644 index 288e2542c..000000000 --- a/main/manager-mobile/src/http/request/alova.ts +++ /dev/null @@ -1,120 +0,0 @@ -import type { uniappRequestAdapter } from '@alova/adapter-uniapp' -import type { IResponse } from './types' -import AdapterUniapp from '@alova/adapter-uniapp' -import { createAlova } from 'alova' -import { createServerTokenAuthentication } from 'alova/client' -import VueHook from 'alova/vue' -import { getEnvBaseUrl } from '@/utils' -import { toast } from '@/utils/toast' -import { ContentTypeEnum, ResultEnum, ShowMessage } from './enum' - -/** - * 创建请求实例 - */ -const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthentication< - typeof VueHook, - typeof uniappRequestAdapter ->({ - refreshTokenOnError: { - isExpired: (error) => { - return error.response?.status === ResultEnum.Unauthorized - }, - handler: async () => { - try { - // await authLogin(); - } - catch (error) { - // 切换到登录页 - await uni.reLaunch({ url: '/pages/login/index' }) - throw error - } - }, - }, -}) - -/** - * alova 请求实例 - */ -const alovaInstance = createAlova({ - baseURL: getEnvBaseUrl(), - ...AdapterUniapp(), - timeout: 5000, - statesHook: VueHook, - - beforeRequest: onAuthRequired((method) => { - // 设置默认 Content-Type - method.config.headers = { - 'Content-Type': ContentTypeEnum.JSON, - 'Accept': 'application/json, text/plain, */*', - ...method.config.headers, - } - - const { config } = method - const ignoreAuth = config.meta?.ignoreAuth - console.log('ignoreAuth===>', ignoreAuth) - - // 处理认证信息 - if (!ignoreAuth) { - const token = uni.getStorageSync('token') - if (!token) { - // 跳转到登录页 - uni.reLaunch({ url: '/pages/login/index' }) - throw new Error('[请求错误]:未登录') - } - // 添加 Authorization 头 - method.config.headers.Authorization = `Bearer ${token}` - } - - // 处理动态域名 - if (config.meta?.domain) { - method.baseURL = config.meta.domain - console.log('当前域名', method.baseURL) - } - }), - - responded: onResponseRefreshToken((response, method) => { - const { config } = method - const { requestType } = config - const { - statusCode, - data: rawData, - errMsg, - } = response as UniNamespace.RequestSuccessCallbackResult - - console.log(response) - - // 处理特殊请求类型(上传/下载) - if (requestType === 'upload' || requestType === 'download') { - return response - } - - // 处理 HTTP 状态码错误 - if (statusCode !== 200) { - const errorMessage = ShowMessage(statusCode) || `HTTP请求错误[${statusCode}]` - console.error('errorMessage===>', errorMessage) - toast.error(errorMessage) - throw new Error(`${errorMessage}:${errMsg}`) - } - - // 处理业务逻辑错误 - const { code, msg, data } = rawData as IResponse - if (code !== ResultEnum.Success) { - // 检查是否为token失效 - if (code === ResultEnum.Unauthorized) { - // 清除token并跳转到登录页 - uni.removeStorageSync('token') - uni.reLaunch({ url: '/pages/login/index' }) - throw new Error(`请求错误[${code}]:${msg}`) - } - - if (config.meta?.toast !== false) { - toast.warning(msg) - } - throw new Error(`请求错误[${code}]:${msg}`) - } - // 处理成功响应,返回业务数据 - return data - }), -}) - -export const http = alovaInstance diff --git a/main/manager-mobile/src/http/request/enum.ts b/main/manager-mobile/src/http/request/enum.ts deleted file mode 100644 index 1868fe085..000000000 --- a/main/manager-mobile/src/http/request/enum.ts +++ /dev/null @@ -1,66 +0,0 @@ -export enum ResultEnum { - Success = 0, // 成功 - Error = 400, // 错误 - Unauthorized = 401, // 未授权 - Forbidden = 403, // 禁止访问(原为forbidden) - NotFound = 404, // 未找到(原为notFound) - MethodNotAllowed = 405, // 方法不允许(原为methodNotAllowed) - RequestTimeout = 408, // 请求超时(原为requestTimeout) - InternalServerError = 500, // 服务器错误(原为internalServerError) - NotImplemented = 501, // 未实现(原为notImplemented) - BadGateway = 502, // 网关错误(原为badGateway) - ServiceUnavailable = 503, // 服务不可用(原为serviceUnavailable) - GatewayTimeout = 504, // 网关超时(原为gatewayTimeout) - HttpVersionNotSupported = 505, // HTTP版本不支持(原为httpVersionNotSupported) -} -export enum ContentTypeEnum { - JSON = 'application/json;charset=UTF-8', - FORM_URLENCODED = 'application/x-www-form-urlencoded;charset=UTF-8', - FORM_DATA = 'multipart/form-data;charset=UTF-8', -} -/** - * 根据状态码,生成对应的错误信息 - * @param {number|string} status 状态码 - * @returns {string} 错误信息 - */ -export function ShowMessage(status: number | string): string { - let message: string - switch (status) { - case 400: - message = '请求错误(400)' - break - case 401: - message = '未授权,请重新登录(401)' - break - case 403: - message = '拒绝访问(403)' - break - case 404: - message = '请求出错(404)' - break - case 408: - message = '请求超时(408)' - break - case 500: - message = '服务器错误(500)' - break - case 501: - message = '服务未实现(501)' - break - case 502: - message = '网络错误(502)' - break - case 503: - message = '服务不可用(503)' - break - case 504: - message = '网络超时(504)' - break - case 505: - message = 'HTTP版本不受支持(505)' - break - default: - message = `连接出错(${status})!` - } - return `${message},请检查网络或联系管理员!` -} diff --git a/main/manager-mobile/src/http/request/types.ts b/main/manager-mobile/src/http/request/types.ts deleted file mode 100644 index 824aa4f4e..000000000 --- a/main/manager-mobile/src/http/request/types.ts +++ /dev/null @@ -1,22 +0,0 @@ -// 通用响应格式 -export interface IResponse { - code: number | string - data: T - msg: string - status: string | number -} - -// 分页请求参数 -export interface PageParams { - page: number - pageSize: number - [key: string]: any -} - -// 分页响应数据 -export interface PageResult { - list: T[] - total: number - page: number - pageSize: number -} diff --git a/main/manager-mobile/src/i18n/en.ts b/main/manager-mobile/src/i18n/en.ts deleted file mode 100644 index 1d6e4beba..000000000 --- a/main/manager-mobile/src/i18n/en.ts +++ /dev/null @@ -1,440 +0,0 @@ -// English language pack -export default { - // TabBar - 'tabBar.home': 'Home', - 'tabBar.deviceConfig': 'Network Config', - 'tabBar.settings': 'System', - // Settings page title - 'settings.title': 'Settings', - // Login page - 'login.pageTitle': 'Login', - 'login.navigationTitle': 'Login', - 'login.fetchConfigError': 'Failed to fetch configuration:', - 'login.selectLanguage': 'Select Language', - 'login.selectLanguageTip': '中文', - 'login.welcomeBack': 'Welcome Back', - 'login.pleaseLogin': 'Please log in to your account', - 'login.enterUsername': 'Please enter username', - 'login.enterPassword': 'Please enter password', - 'login.enterCaptcha': 'Please enter verification code', - 'login.loginButton': 'Login', - 'login.loggingIn': 'Logging in...', - 'login.noAccount': 'Sign Up', - 'login.enterPhone': 'Please enter phone number', - 'login.selectCountry': 'Select Country/Region', - 'login.confirm': 'Confirm', - 'login.serverSetting': 'Server Settings', - 'login.requiredUsername': 'Username cannot be empty', - 'login.requiredPassword': 'Password cannot be empty', - 'login.requiredCaptcha': 'Verification code cannot be empty', - 'login.requiredMobile': 'Please enter a valid phone number', - 'login.captchaError': 'Graphic verification code error', - 'login.forgotPassword': 'Forgot Password', - - // Register page - 'register.pageTitle': 'Register', - 'register.createAccount': 'Create Account', - 'register.enterUsername': 'Please enter username', - 'register.enterPassword': 'Please enter password', - 'register.confirmPassword': 'Please confirm password', - 'register.enterPhone': 'Please enter phone number', - 'register.enterCode': 'Please enter verification code', - 'register.getCode': 'Get Code', - 'register.agreeTerms': 'I have read and agree to the', - 'register.terms': 'User Agreement', - 'register.privacy': 'Privacy Policy', - 'register.registerButton': 'Register', - 'register.registering': 'Registering...', - 'register.haveAccount': 'Already have an account?', - 'register.loginNow': 'Login Now', - 'register.selectCountry': 'Select Country/Region', - 'register.confirm': 'Confirm', - 'register.captchaSendSuccess': 'Verification code sent successfully', - - // Home page - 'home.pageTitle': 'Home', - 'home.createAgent': 'Create Agent', - 'home.agentName': 'Agent', - 'home.modelInfo': 'Model Info', - 'home.lastActive': 'Last Active', - 'home.greeting': 'Hi Jarvis', - 'home.subtitle': 'Let\'s have', - 'home.wonderfulDay': 'a wonderful day!', - 'home.emptyState': 'No agents available', - 'home.deviceManagement': 'Device Management', - 'home.lastConversation': 'Last Conversation:', - 'home.delete': 'Delete', - 'home.createFirstAgent': 'Click the + button in the lower right corner to create your first agent', - 'home.dialogTitle': 'Create Agent', - 'home.inputPlaceholder': 'e.g. Customer Service Assistant, Voice Assistant, Knowledge Q&A', - 'home.createError': 'Please input agent name', - 'home.createNow': 'Create Now', - 'home.justNow': 'Just now', - 'home.minutesAgo': 'minutes ago', - 'home.hoursAgo': 'hours ago', - 'home.daysAgo': 'days ago', - - // Agent page - 'agent.pageTitle': 'Agent', - 'agent.roleConfig': 'Role Configuration', - 'agent.deviceManagement': 'Device Management', - 'agent.chatHistory': 'Chat History', - 'agent.voiceprintManagement': 'Voiceprint Management', - 'agent.editTitle': 'Edit Agent', - 'agent.toolsTitle': 'Edit Features', - 'agent.voiceActivityDetection': 'Voice Activity Detection', - 'agent.speechRecognition': 'Speech Recognition', - 'agent.largeLanguageModel': 'Large Language Model', - 'agent.save': 'Save', - 'agent.cancel': 'Cancel', - // Agent Edit Page - 'agent.basicInfo': 'Basic Information', - 'agent.agentName': 'Agent Name', - 'agent.inputAgentName': 'Please input agent name', - 'agent.roleMode': 'Role Mode', - 'agent.roleDescription': 'Role Description', - 'agent.inputRoleDescription': 'Please input role description', - 'agent.modelConfig': 'Model Configuration', - 'agent.vad': 'Voice Activity Detection', - 'agent.asr': 'Speech Recognition', - 'agent.llm': 'Large Language Model', - 'agent.vllm': 'Vision Language Model', - 'agent.intent': 'Intent Recognition', - 'agent.memory': 'Memory', - 'agent.voiceSettings': 'Voice Settings', - 'agent.tts': 'Text-to-Speech', - 'agent.voiceprint': 'Agent Voice', - 'agent.plugins': 'Plugins', - 'agent.editFunctions': 'Edit Functions', - 'agent.historyMemory': 'History Memory', - 'agent.memoryContent': 'Memory content', - 'agent.saving': 'Saving...', - 'agent.saveSuccess': 'Save successful', - 'agent.saveFail': 'Save failed', - 'agent.loadFail': 'Load failed', - 'agent.pleaseInputAgentName': 'Please input agent name', - 'agent.pleaseInputRoleDescription': 'Please input role description', - 'agent.pleaseSelect': 'Please select', - - // Chat History Page - 'chatHistory.getChatSessions': 'Get chat session list', - 'chatHistory.noSelectedAgent': 'No agent selected', - 'chatHistory.getChatSessionsFailed': 'Failed to get chat session list:', - 'chatHistory.unknownTime': 'Unknown time', - 'chatHistory.justNow': 'Just now', - 'chatHistory.minutesAgo': '{minutes} minutes ago', - 'chatHistory.hoursAgo': '{hours} hours ago', - 'chatHistory.daysAgo': '{days} days ago', - 'chatHistory.conversationRecord': 'Conversation Record', - 'chatHistory.totalChats': '{count} chats in total', - 'chatHistory.loading': 'Loading...', - 'chatHistory.noMoreData': 'No more data', - 'chatHistory.noChatRecords': 'No chat records', - 'chatRecordsDescription': 'Conversation records with agents will be displayed here', - // Chat History Detail Page - 'chatHistory.pageTitle': 'Chat Detail', - 'chatHistory.assistantName': 'Intelligent Assistant', - 'chatHistory.userName': 'User', - 'chatHistory.aiAssistantName': 'AI Assistant', - 'chatHistory.loadFailed': 'Failed to load chat history', - 'chatHistory.parameterError': 'Page parameter error', - 'chatHistory.invalidAudioId': 'Invalid audio ID', - 'chatHistory.audioPlayFailed': 'Audio playback failed', - 'chatHistory.playAudioFailed': 'Failed to play audio', - - // Device management page - 'device.pageTitle': 'Device Management', - 'device.noDevices': 'No devices available', - 'device.macAddress': 'MAC Address', - 'device.firmwareVersion': 'Firmware Version', - 'device.lastConnected': 'Last Conversation', - 'device.otaUpdate': 'OTA Update', - 'device.unbind': 'Unbind', - 'device.confirmUnbind': 'Sure', - 'device.bindDevice': 'Bind New Device', - 'device.deviceType': 'Device Type', - 'device.loading': 'Loading...', - 'device.neverConnected': 'Never connected', - 'device.justNow': 'Just now', - 'device.minutesAgo': '{minutes} minutes ago', - 'device.hoursAgo': '{hours} hours ago', - 'device.daysAgo': '{days} days ago', - 'device.otaAutoUpdateEnabled': 'OTA auto update enabled', - 'device.otaAutoUpdateDisabled': 'OTA auto update disabled', - 'device.operationFailed': 'Operation failed, please retry', - 'device.deviceUnbound': 'Device unbound', - 'device.unbindFailed': 'Unbind failed, please retry', - 'device.unbindDevice': 'Unbind Device', - 'device.confirmUnbindDevice': 'Are you sure you want to unbind device "{macAddress}"?', - 'device.cancel': 'Cancel', - 'device.noDevice': 'No Device', - 'device.pleaseSelectAgent': 'Please select an agent first', - 'device.deviceBindSuccess': 'Device bound successfully!', - 'device.bindFailed': 'Bind failed, please check if the verification code is correct', - 'device.enterDeviceCode': 'Please enter device verification code', - 'device.bindNow': 'Bind Now', - 'device.lastConnection': 'Last Connection', - 'device.clickToBindFirstDevice': 'Click the + button in the lower right corner to bind your first device', - - // Common - 'common.success': 'Success', - 'common.fail': 'Failed', - 'common.loading': 'Loading...', - 'common.confirm': 'Confirm', - 'common.cancel': 'Cancel', - 'common.delete': 'Delete', - 'common.edit': 'Edit', - 'common.add': 'Add', - 'common.pleaseSelect': 'Please select', - 'common.unknownError': 'Unknown error', - 'common.networkError': 'Network error', - - // Retrieve Password page - 'retrievePassword.title': 'Reset Password', - 'retrievePassword.subtitle': 'Recover your account password via mobile number', - 'retrievePassword.mobileRequired': 'Please enter mobile number', - 'retrievePassword.inputCorrectMobile': 'Please enter a valid mobile number', - 'retrievePassword.captchaRequired': 'Please enter graphic verification code', - 'retrievePassword.mobileCaptchaRequired': 'Please enter SMS verification code', - 'retrievePassword.newPasswordRequired': 'Please enter new password', - 'retrievePassword.confirmNewPasswordRequired': 'Please confirm new password', - 'retrievePassword.passwordsNotMatch': 'Passwords do not match', - 'retrievePassword.mobilePlaceholder': 'Please enter mobile number', - 'retrievePassword.captchaPlaceholder': 'Please enter graphic verification code', - 'retrievePassword.mobileCaptchaPlaceholder': 'Please enter SMS verification code', - 'retrievePassword.newPasswordPlaceholder': 'Please enter new password', - 'retrievePassword.confirmNewPasswordPlaceholder': 'Please confirm new password', - 'retrievePassword.getMobileCaptcha': 'Get Code', - 'retrievePassword.captchaSendSuccess': 'Verification code sent successfully', - 'retrievePassword.passwordUpdateSuccess': 'Password reset successfully', - 'retrievePassword.resetButton': 'Reset Password', - 'retrievePassword.goToLogin': 'Back to Login', - - // SM2 encryption related error messages - 'sm2.publicKeyNotConfigured': 'SM2 public key not configured, please contact administrator', - 'sm2.encryptionFailed': 'Password encryption failed', - 'sm2.keyGenerationFailed': 'Key pair generation failed', - 'sm2.invalidPublicKey': 'Invalid public key format', - 'sm2.encryptionError': 'Error occurred during encryption', - 'sm2.publicKeyRetry': 'Retrying to get public key...', - 'sm2.publicKeyRetryFailed': 'Public key retrieval retry failed', - - // Voiceprint page - 'voiceprint.noSelectedAgent': 'No agent selected', - 'voiceprint.pleaseSelectAgent': 'Please select an agent first', - 'voiceprint.fetchHistoryFailed': 'Failed to fetch chat history', - 'voiceprint.clickToSelectVector': 'Click to select voiceprint vector', - 'voiceprint.pleaseInputName': 'Please input name', - 'voiceprint.pleaseSelectVector': 'Please select voiceprint vector', - 'voiceprint.addSuccess': 'Add success', - 'voiceprint.addFailed': 'Failed to add speaker', - 'voiceprint.editSuccess': 'Edit success', - 'voiceprint.editFailed': 'Failed to edit speaker', - 'voiceprint.deleteConfirmMsg': 'Are you sure to delete this speaker?', - 'voiceprint.deleteConfirmTitle': 'Confirm Delete', - 'voiceprint.deleteSuccess': 'Delete success', - 'voiceprint.loading': 'Loading...', - 'voiceprint.delete': 'Delete', - 'voiceprint.emptyTitle': 'No voiceprint data', - 'voiceprint.emptyDesc': 'Click the + button at the bottom right to add your first speaker', - 'voiceprint.addSpeaker': 'Add Speaker', - 'voiceprint.voiceVector': 'Voiceprint Vector', - 'voiceprint.name': 'Name', - 'voiceprint.description': 'Description', - 'voiceprint.pleaseInputDescription': 'Please input description', - 'voiceprint.cancel': 'Cancel', - 'voiceprint.save': 'Save', - 'voiceprint.editSpeaker': 'Edit Speaker', - 'voiceprint.selectVector': 'Select Voiceprint Vector', - 'voiceprint.voiceprintInterfaceNotConfigured': 'Voiceprint interface not configured', - - // Settings page - 'settings.pageTitle': 'Settings', - 'settings.navigationTitle': 'Settings', - 'settings.networkSettings': 'Network Settings', - 'settings.serverApiUrl': 'Server API URL', - 'settings.validServerUrl': 'Please enter a valid server address (starting with http or https and ending with /xiaozhi)', - 'settings.saveSettings': 'Save Settings', - 'settings.resetDefault': 'Reset Default', - 'settings.restartApp': 'Restart App', - 'settings.restartNow': 'Restart Now', - 'settings.restartLater': 'Later', - // About us - 'settings.aboutApp': 'About XiaoZhi Console', - 'settings.aboutContent': 'XiaoZhi Console\n\nA cross-platform mobile management app built with Vue.js 3 + uni-app, providing device management, agent configuration and other functions for xiaozhi ESP32 smart hardware.\n\n© 2025 xiaozhi-esp32-server {version}', - 'settings.restartSuccess': 'Saved, you can manually restart the app later', - 'settings.serverUrlSavedAndCacheCleared': 'Server URL saved and cache cleared', - 'settings.resetToDefaultAndCacheCleared': 'Reset to default and cache cleared', - 'settings.resetSuccess': 'Reset successful', - 'settings.enterServerUrl': 'Please enter server URL', - 'settings.clearCacheFailed': 'Failed to clear cache', - 'settings.cacheManagement': 'Cache Management', - 'settings.totalCacheSize': 'Total Cache Size', - 'settings.appDataSize': 'Total App Data Size', - 'settings.cacheClear': 'Cache Clear', - 'settings.clearAllCache': 'Clear all cache data', - 'settings.clearCache': 'Clear Cache', - 'settings.modifyWillClearCache': 'Modifications will clear cache', - 'settings.appInfo': 'App Info', - 'settings.aboutUs': 'About Us', - 'settings.appVersion': 'App Version & Team Info', - 'settings.confirmClear': 'Confirm Clear', - 'settings.confirmClearMessage': 'Are you sure you want to clear all cache? This will delete all data including login status and require re-login.', - 'settings.cacheCleared': 'Cache cleared successfully, redirecting to login page', - 'settings.languageSettings': 'Language Settings', - 'settings.language': 'Language', - 'settings.selectLanguage': 'Select Language', - 'settings.languageChanged': 'Language changed successfully', - - // Messages - 'message.loginSuccess': 'Login successful!', - 'message.loginFail': 'Login failed', - 'message.registerSuccess': 'Registration successful', - 'message.registerFail': 'Registration failed', - 'message.saveSuccess': 'Save successful', - 'message.saveFail': 'Save failed', - 'message.deleteSuccess': 'Delete successful', - 'message.deleteFail': 'Delete failed', - 'message.bindSuccess': 'Binding successful', - 'message.bindFail': 'Binding failed', - 'message.unbindSuccess': 'Unbinding successful', - 'message.unbindFail': 'Unbinding failed', - 'message.networkError': 'Network error, please check your connection', - 'message.serverError': 'Server error, please try again later', - 'message.invalidAddress': 'Invalid address, please check if the server is started or network connection is normal', - 'message.languageChanged': 'Language changed', - 'message.passwordError': 'Account or password error', - 'message.phoneRegistered': 'This phone number has been registered', - - // Agent Tools Page - 'agent.tools.pageTitle': 'Agent Tools', - 'agent.tools.unselected': 'Unselected', - 'agent.tools.selected': 'Selected', - 'agent.tools.noMorePlugins': 'No more plugins', - 'agent.tools.pleaseSelectPlugin': 'Please select plugin function', - 'agent.tools.builtInPlugins': 'Built-in Plugins', - 'agent.tools.mcpAccessPoint': 'MCP Access Point', - 'agent.tools.copy': 'Copy', - 'agent.tools.noTools': 'No tools available', - 'agent.tools.parameterConfig': 'Parameter Configuration', - 'agent.tools.noParamsNeeded': 'No parameters needed', - 'agent.tools.pleaseInput': 'Please input', - 'agent.tools.inputOneItemPerLine': 'Input one item per line', - 'agent.tools.pleaseInputValidJson': 'Please input valid JSON format', - 'agent.tools.enableFunction': 'Enable Function', - 'agent.tools.toggleFunction': 'Turn on or off this function', - 'agent.tools.jsonFormatError': 'JSON format error', - 'agent.tools.noMcpAddressToCopy': 'No MCP address to copy', - 'agent.tools.mcpAddressCopied': 'MCP address copied to clipboard', - 'agent.tools.copyFailed': 'Copy failed, please try again', - 'agent.tools.defaultValue': 'Default value', - 'agent.tools.notSelected': 'Unselected', - 'agent.tools.clickToConfigure': 'Click to configure', - 'agent.tools.mcpEndpoint': 'MCP Endpoint', - 'agent.tools.eachLineOneItem': 'Input one item per line', - - // Device Config page - 'deviceConfig.pageTitle': 'Device Configuration', - 'deviceConfig.wifiConfig': 'WiFi Configuration', - 'deviceConfig.ultrasonicConfig': 'Ultrasonic Configuration', - 'deviceConfig.selectConfigMethod': 'Select Configuration Method', - 'deviceConfig.networkConfig': 'Network Configuration', - 'deviceConfig.selectedNetwork': 'Selected Network', - 'deviceConfig.signal': 'Signal', - 'deviceConfig.openNetwork': 'Open Network', - 'deviceConfig.encryptedNetwork': 'Encrypted Network', - 'deviceConfig.password': 'Password', - 'deviceConfig.pleaseEnterPassword': 'Please enter WiFi password', - 'deviceConfig.startConfig': 'Start Configuration', - 'deviceConfig.connectToXiaozhiHotspot': 'Please connect to xiaozhi hotspot first', - 'deviceConfig.detecting': 'Detecting...', - 'deviceConfig.reDetect': 'Re-detect', - 'deviceConfig.alreadyConnected': 'Connected to xiaozhi hotspot', - 'deviceConfig.refreshStatus': 'Refresh Status', - 'deviceConfig.wifiNetworks': 'WiFi Networks', - 'deviceConfig.selectWifiNetwork': 'Select WiFi Network', - 'deviceConfig.refreshScan': 'Refresh Scan', - 'deviceConfig.noWifiNetworks': 'No WiFi networks available', - 'deviceConfig.clickToRefreshScan': 'Please click Refresh Scan', - 'deviceConfig.signalStrong': 'Strong Signal', - 'deviceConfig.signalGood': 'Good Signal', - 'deviceConfig.signalFair': 'Fair Signal', - 'deviceConfig.signalWeak': 'Weak Signal', - 'deviceConfig.channel': 'Channel', - 'deviceConfig.about': 'about', - 'deviceConfig.seconds': 'seconds', - 'deviceConfig.generating': 'Generating...', - 'deviceConfig.playing': 'Playing...', - 'deviceConfig.generateAndPlaySoundWave': 'Generate and Play Sound Wave', - 'deviceConfig.playSoundWave': 'Play Sound Wave', - 'deviceConfig.stopPlaying': 'Stop Playing', - 'deviceConfig.autoLoopPlaySoundWave': 'Auto Loop Play Sound Wave', - 'deviceConfig.configAudioFile': 'Configuration Audio File', - 'deviceConfig.duration': 'Duration', - 'deviceConfig.ultrasonicConfigInstructions': 'Ultrasonic Configuration Instructions', - 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': 'Ensure WiFi network is selected and password is entered', - 'deviceConfig.clickGenerateAndPlaySoundWave': 'Click Generate and Play Sound Wave, the system will encode configuration information into audio', - 'deviceConfig.bringPhoneCloseToXiaozhiDevice': 'Bring phone close to xiaozhi device (1-2 meters distance)', - 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': 'During audio playback, xiaozhi will receive and decode configuration information', - 'deviceConfig.afterConfigSuccessDeviceWillConnect': 'After successful configuration, the device will automatically connect to WiFi network', - 'deviceConfig.usesAfskModulation': 'Uses AFSK modulation technology, transmitting data through 1800Hz and 1500Hz frequencies', - 'deviceConfig.ensureModeratePhoneVolume': 'Please ensure phone volume is moderate to avoid environmental noise interference', - 'deviceConfig.generatingUltrasonicConfigAudio': 'Generating ultrasonic configuration audio', - 'deviceConfig.configData': 'Configuration data', - 'deviceConfig.dataBytesLength': 'Data bytes length', - 'deviceConfig.bitStreamLength': 'Bit stream length', - 'deviceConfig.base64Length': 'Base64 length', - 'deviceConfig.audioFileTooLarge': 'Audio file too large, please shorten SSID or password length', - 'deviceConfig.audioGenerationSuccess': 'Audio generation successful', - 'deviceConfig.samplePoints': 'Sample points', - 'deviceConfig.soundWaveGenerationSuccess': 'Sound wave generation successful', - 'deviceConfig.audioGenerationFailed': 'Audio generation failed', - 'deviceConfig.soundWaveGenerationFailed': 'Sound wave generation failed', - 'deviceConfig.pleaseGenerateAudioFirst': 'Please generate audio first', - 'deviceConfig.startPlayingUltrasonicConfigAudio': 'Starting to play ultrasonic configuration audio', - 'deviceConfig.ultrasonicAudioStartedPlaying': 'Ultrasonic audio started playing', - 'deviceConfig.startPlayingConfigSoundWave': 'Started playing configuration sound wave', - 'deviceConfig.ultrasonicAudioPlaybackEnded': 'Ultrasonic audio playback ended', - 'deviceConfig.audioPlaybackFailed': 'Audio playback failed', - 'deviceConfig.audioResourceBusy': 'Audio resource busy, please try again later', - 'deviceConfig.audioFormatNotSupported': 'Audio format not supported, may be a data URI issue', - 'deviceConfig.audioFileError': 'Audio file error', - 'deviceConfig.cleaningUpAudioContext': 'Cleaning up audio context', - 'deviceConfig.cleaningUpAudioContextFailed': 'Failed to clean up audio context', - 'deviceConfig.stoppedPlayingUltrasonicAudio': 'Stopped playing ultrasonic audio', - 'deviceConfig.stoppedPlaying': 'Stopped playing', - 'deviceConfig.configMethod': 'Configuration Method', - 'deviceConfig.enterWifiPassword': 'Please enter WiFi password', - 'deviceConfig.xiaozhi': 'xiaozhi', - 'deviceConfig.connectXiaozhiHotspot': 'Please connect to xiaozhi hotspot', - 'deviceConfig.wifiScanResponse': 'WiFi scan response', - 'deviceConfig.scanSuccess': 'Scan successful', - 'deviceConfig.networks': 'networks', - 'deviceConfig.wifiScanFailed': 'WiFi scan failed', - 'deviceConfig.scanFailedCheckConnection': 'Scan failed, please check connection', - 'deviceConfig.checking': 'Checking', - 'deviceConfig.reCheck': 'Re-check', - 'deviceConfig.connectedXiaozhiHotspot': 'Connected to xiaozhi hotspot', - 'deviceConfig.wifiNetwork': 'WiFi Network', - 'deviceConfig.scanning': 'Scanning', - 'deviceConfig.cancel': 'Cancel', - 'deviceConfig.clickRefreshScan': 'Please click Refresh Scan', - 'deviceConfig.esp32ConnectionCheckFailed': 'ESP32 connection check failed', - 'deviceConfig.startWifiConfig': 'Starting WiFi configuration', - 'deviceConfig.configSuccess': 'Configuration successful', - 'deviceConfig.deviceWillConnectTo': 'Device will connect to', - 'deviceConfig.deviceWillRestart': 'Device will restart', - 'deviceConfig.pleaseDisconnectXiaozhiHotspot': 'Please disconnect from xiaozhi hotspot', - 'deviceConfig.configFailed': 'Configuration failed', - 'deviceConfig.wifiConfigFailed': 'WiFi configuration failed', - 'deviceConfig.pleaseCheckNetworkConnection': 'Please check network connection', - 'deviceConfig.startWifiConfigButton': 'Start Configuration', - 'deviceConfig.wifiConfigInstructions': 'WiFi Configuration Instructions', - 'deviceConfig.phoneConnectXiaozhiHotspot': 'Phone connect to xiaozhi hotspot', - 'deviceConfig.selectTargetWifiNetwork': 'Select target WiFi network', - 'deviceConfig.enterWifiPasswordIfNeeded': 'Enter WiFi password if needed', - 'deviceConfig.clickStartConfigAndWait': 'Click Start Configuration and wait', - 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'After successful configuration, device will automatically restart', - 'deviceConfig.audioPlaybackError': 'Audio playback error', - 'deviceConfig.playbackFailed': 'Playback failed', -} diff --git a/main/manager-mobile/src/i18n/index.ts b/main/manager-mobile/src/i18n/index.ts deleted file mode 100644 index 8100e9a57..000000000 --- a/main/manager-mobile/src/i18n/index.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ref } from 'vue' -import { useLangStore } from '@/store/lang' -import type { Language } from '@/store/lang' - -// 导入各个语言的翻译文件 -import zhCN from './zh_CN' -import en from './en' -import zhTW from './zh_TW' - -// 语言包映射 -const messages = { - zh_CN: zhCN, - en, - zh_TW: zhTW, -} - -// 当前使用的语言 -const currentLang = ref('zh_CN') - -// 初始化语言 -export function initI18n() { - const langStore = useLangStore() - currentLang.value = langStore.currentLang -} - -// 切换语言 -export function changeLanguage(lang: Language) { - currentLang.value = lang - const langStore = useLangStore() - langStore.changeLang(lang) -} - -// 获取翻译文本 -export function t(key: string, params?: Record): string { - const langMessages = messages[currentLang.value] - - // 直接查找扁平键名 - if (langMessages && typeof langMessages === 'object' && key in langMessages) { - let value = langMessages[key] - if (typeof value === 'string') { - // 处理参数替换 - if (params) { - let result = value - Object.entries(params).forEach(([paramKey, paramValue]) => { - const regex = new RegExp(`\{${paramKey}\}`, 'g') - result = result.replace(regex, String(paramValue)) - }) - return result - } - return value - } - return key - } - - return key // 如果找不到对应的翻译,返回key本身 -} - -// 获取当前语言 -export function getCurrentLanguage(): Language { - return currentLang.value -} - -// 获取支持的语言列表 -export function getSupportedLanguages(): {code: Language, name: string}[] { - return [ - { code: 'zh_CN', name: '简体中文' }, - { code: 'en', name: 'English' }, - { code: 'zh_TW', name: '繁體中文' }, - ] -} \ No newline at end of file diff --git a/main/manager-mobile/src/i18n/zh_CN.ts b/main/manager-mobile/src/i18n/zh_CN.ts deleted file mode 100644 index c1e9b8560..000000000 --- a/main/manager-mobile/src/i18n/zh_CN.ts +++ /dev/null @@ -1,440 +0,0 @@ -// 简体中文语言包 -export default { - // TabBar - 'tabBar.home': '首页', - 'tabBar.deviceConfig': '配网', - 'tabBar.settings': '系统', - // 设置页面标题 - 'settings.title': '设置', - // 登录页面 - 'login.pageTitle': '登录', - 'login.navigationTitle': '登录', - 'login.fetchConfigError': '获取配置失败:', - 'login.selectLanguage': '选择语言', - 'login.selectLanguageTip': 'En', - 'login.welcomeBack': '欢迎回来', - 'login.pleaseLogin': '请登录您的账户', - 'login.enterUsername': '请输入用户名', - 'login.enterPassword': '请输入密码', - 'login.enterCaptcha': '请输入验证码', - 'login.loginButton': '登录', - 'login.loggingIn': '登录中...', - 'login.noAccount': '新用户注册', - 'login.enterPhone': '请输入手机号码', - 'login.selectCountry': '选择国家/地区', - 'login.confirm': '确认', - 'login.serverSetting': '服务端设置', - 'login.requiredUsername': '用户名不能为空', - 'login.requiredPassword': '密码不能为空', - 'login.requiredCaptcha': '验证码不能为空', - 'login.requiredMobile': '请输入正确的手机号码', - 'login.captchaError': '图形验证码错误', - 'login.forgotPassword': '忘记密码', - - // 注册页面 - 'register.pageTitle': '注册', - 'register.createAccount': '创建账户', - 'register.enterUsername': '请输入用户名', - 'register.enterPassword': '请输入密码', - 'register.confirmPassword': '请确认密码', - 'register.enterPhone': '请输入手机号码', - 'register.enterCode': '请输入验证码', - 'register.getCode': '获取验证码', - 'register.agreeTerms': '我已阅读并同意', - 'register.terms': '《用户协议》', - 'register.privacy': '《隐私政策》', - 'register.registerButton': '注册', - 'register.registering': '注册中...', - 'register.haveAccount': '已有账户?', - 'register.loginNow': '立即登录', - 'register.selectCountry': '选择国家/地区', - 'register.confirm': '确认', - 'register.captchaSendSuccess': '验证码发送成功', - - // 首页 - 'home.pageTitle': '首页', - 'home.createAgent': '创建智能体', - 'home.agentName': '智能体', - 'home.modelInfo': '模型信息', - 'home.lastActive': '最近活跃', - 'home.greeting': '你好,小智', - 'home.subtitle': '让我们度过', - 'home.wonderfulDay': '美好的一天!', - 'home.emptyState': '暂无智能体', - 'home.deviceManagement': '设备管理', - 'home.lastConversation': '最近对话:', - 'home.delete': '删除', - 'home.createFirstAgent': '点击右下角 + 号创建您的第一个智能体', - 'home.dialogTitle': '创建智能体', - 'home.inputPlaceholder': '例如:客服助手、语音助理、知识问答', - 'home.createError': '请输入智能体名称', - 'home.createNow': '立即创建', - 'home.justNow': '刚刚', - 'home.minutesAgo': '分钟前', - 'home.hoursAgo': '小时前', - 'home.daysAgo': '天前', - - // Agent页面 - 'agent.pageTitle': '智能体', - 'agent.roleConfig': '角色配置', - 'agent.deviceManagement': '设备管理', - 'agent.chatHistory': '聊天记录', - 'agent.voiceprintManagement': '声纹管理', - 'agent.editTitle': '编辑智能体', - 'agent.toolsTitle': '编辑功能', - 'agent.voiceActivityDetection': '语音活动检测', - 'agent.speechRecognition': '语音识别', - 'agent.largeLanguageModel': '大语言模型', - 'agent.save': '保存', - 'agent.cancel': '取消', - // Agent编辑页面 - 'agent.basicInfo': '基础信息', - 'agent.agentName': '助手昵称', - 'agent.inputAgentName': '请输入助手昵称', - 'agent.roleMode': '角色模式', - 'agent.roleDescription': '角色介绍', - 'agent.inputRoleDescription': '请输入角色介绍', - 'agent.modelConfig': '模型配置', - 'agent.vad': '语音活动检测', - 'agent.asr': '语音识别', - 'agent.llm': '大语言模型', - 'agent.vllm': '视觉大模型', - 'agent.intent': '意图识别', - 'agent.memory': '记忆', - 'agent.voiceSettings': '语音设置', - 'agent.tts': '语音合成', - 'agent.voiceprint': '角色音色', - 'agent.plugins': '插件', - 'agent.editFunctions': '编辑功能', - 'agent.historyMemory': '历史记忆', - 'agent.memoryContent': '记忆内容', - 'agent.saving': '保存中...', - 'agent.saveSuccess': '保存成功', - 'agent.saveFail': '保存失败', - 'agent.loadFail': '加载失败', - 'agent.pleaseInputAgentName': '请输入智能体名称', - 'agent.pleaseInputRoleDescription': '请输入角色介绍', - 'agent.pleaseSelect': '请选择', - - // 聊天历史页面 - 'chatHistory.getChatSessions': '获取聊天会话列表', - 'chatHistory.noSelectedAgent': '没有选中的智能体', - 'chatHistory.getChatSessionsFailed': '获取聊天会话列表失败:', - 'chatHistory.unknownTime': '未知时间', - 'chatHistory.justNow': '刚刚', - 'chatHistory.minutesAgo': '{minutes}分钟前', - 'chatHistory.hoursAgo': '{hours}小时前', - 'chatHistory.daysAgo': '{days}天前', - 'chatHistory.conversationRecord': '对话记录', - 'chatHistory.totalChats': '共 {count} 条对话', - 'chatHistory.loading': '加载中...', - 'chatHistory.noMoreData': '没有更多数据了', - 'chatHistory.noChatRecords': '暂无聊天记录', - 'chatHistory.chatRecordsDescription': '与智能体的对话记录会显示在这里', - // 聊天详情页面 - 'chatHistory.pageTitle': '聊天详情', - 'chatHistory.assistantName': '智能助手', - 'chatHistory.userName': '用户', - 'chatHistory.aiAssistantName': 'AI助手', - 'chatHistory.loadFailed': '获取聊天记录失败', - 'chatHistory.parameterError': '页面参数错误', - 'chatHistory.invalidAudioId': '音频ID无效', - 'chatHistory.audioPlayFailed': '音频播放失败', - 'chatHistory.playAudioFailed': '播放音频失败', - - // 设备管理页面 - 'device.pageTitle': '设备管理', - 'device.noDevices': '暂无设备', - 'device.macAddress': 'MAC地址', - 'device.firmwareVersion': '固件版本', - 'device.lastConnected': '最近对话', - 'device.otaUpdate': 'OTA升级', - 'device.unbind': '解绑', - 'device.confirmUnbind': '确定要解绑设备', - 'device.bindDevice': '绑定新设备', - 'device.deviceType': '设备类型', - 'device.loading': '加载中...', - 'device.neverConnected': '从未连接', - 'device.justNow': '刚刚', - 'device.minutesAgo': '{minutes}分钟前', - 'device.hoursAgo': '{hours}小时前', - 'device.daysAgo': '{days}天前', - 'device.otaAutoUpdateEnabled': 'OTA自动升级已开启', - 'device.otaAutoUpdateDisabled': 'OTA自动升级已关闭', - 'device.operationFailed': '操作失败,请重试', - 'device.deviceUnbound': '设备已解绑', - 'device.unbindFailed': '解绑失败,请重试', - 'device.unbindDevice': '解绑设备', - 'device.confirmUnbindDevice': '确定要解绑设备 "{macAddress}" 吗?', - 'device.cancel': '取消', - 'device.noDevice': '暂无设备', - 'device.pleaseSelectAgent': '请先选择智能体', - 'device.deviceBindSuccess': '设备绑定成功!', - 'device.bindFailed': '绑定失败,请检查验证码是否正确', - 'device.enterDeviceCode': '请输入设备验证码', - 'device.bindNow': '立即绑定', - 'device.lastConnection': '最近对话', - 'device.clickToBindFirstDevice': '点击右下角 + 号绑定您的第一个设备', - - // 通用 - 'common.success': '成功', - 'common.fail': '失败', - 'common.loading': '加载中...', - 'common.confirm': '确认', - 'common.cancel': '取消', - 'common.delete': '删除', - 'common.edit': '编辑', - 'common.add': '添加', - 'common.pleaseSelect': '请选择', - 'common.unknownError': '未知错误', - 'common.networkError': '网络错误', - - // SM2加密相关错误消息 - 'sm2.publicKeyNotConfigured': 'SM2公钥未配置,请联系管理员', - 'sm2.encryptionFailed': '密码加密失败', - 'sm2.keyGenerationFailed': '密钥对生成失败', - 'sm2.invalidPublicKey': '无效的公钥格式', - 'sm2.encryptionError': '加密过程中发生错误', - 'sm2.publicKeyRetry': '正在重试获取公钥...', - 'sm2.publicKeyRetryFailed': '公钥获取重试失败', - - // Voiceprint page - 'voiceprint.noSelectedAgent': '没有选中的智能体', - 'voiceprint.pleaseSelectAgent': '请先选择智能体', - 'voiceprint.fetchHistoryFailed': '获取对话记录失败', - 'voiceprint.clickToSelectVector': '点击选择声纹向量', - 'voiceprint.pleaseInputName': '请输入姓名', - 'voiceprint.pleaseSelectVector': '请选择声纹向量', - 'voiceprint.addSuccess': '添加成功', - 'voiceprint.addFailed': '添加说话人失败', - 'voiceprint.editSuccess': '编辑成功', - 'voiceprint.editFailed': '编辑说话人失败', - 'voiceprint.deleteConfirmMsg': '确定要删除这个说话人吗?', - 'voiceprint.deleteConfirmTitle': '确认删除', - 'voiceprint.deleteSuccess': '删除成功', - 'voiceprint.loading': '加载中...', - 'voiceprint.delete': '删除', - 'voiceprint.emptyTitle': '暂无声纹数据', - 'voiceprint.emptyDesc': '点击右下角 + 号添加您的第一个说话人', - 'voiceprint.addSpeaker': '添加说话人', - 'voiceprint.voiceVector': '声纹向量', - 'voiceprint.name': '姓名', - 'voiceprint.description': '描述', - 'voiceprint.pleaseInputDescription': '请输入描述', - 'voiceprint.cancel': '取消', - 'voiceprint.save': '保存', - 'voiceprint.editSpeaker': '编辑说话人', - 'voiceprint.selectVector': '选择声纹向量', - 'voiceprint.voiceprintInterfaceNotConfigured': '声纹接口未配置', - - // 设置页面 - 'settings.pageTitle': '设置', - 'settings.navigationTitle': '设置', - 'settings.networkSettings': '网络设置', - 'settings.serverApiUrl': '服务端接口地址', - 'settings.validServerUrl': '请输入有效的服务端地址(以 http 或 https 开头,并以 /xiaozhi 结尾)', - 'settings.saveSettings': '保存设置', - 'settings.resetDefault': '恢复默认', - 'settings.restartApp': '重启应用', - 'settings.restartNow': '立即重启', - 'settings.restartLater': '稍后', - // 关于我们 - 'settings.aboutApp': '关于小智智控台', - 'settings.aboutContent': '小智智控台\n\n基于 Vue.js 3 + uni-app 构建的跨平台移动端管理应用,为小智ESP32智能硬件提供设备管理、智能体配置等功能。\n\n© 2025 xiaozhi-esp32-server {version}', - 'settings.restartSuccess': '已保存,可稍后手动重启应用', - 'settings.serverUrlSavedAndCacheCleared': '服务端地址已保存,缓存已清除', - 'settings.resetToDefaultAndCacheCleared': '已恢复默认设置,缓存已清除', - 'settings.resetSuccess': '重置成功', - 'settings.enterServerUrl': '请输入服务端地址', - 'settings.clearCacheFailed': '清除缓存失败', - 'settings.cacheManagement': '缓存管理', - 'settings.totalCacheSize': '总缓存大小', - 'settings.appDataSize': '应用数据总大小', - 'settings.cacheClear': '缓存清理', - 'settings.clearAllCache': '清空所有缓存数据', - 'settings.clearCache': '清除缓存', - 'settings.modifyWillClearCache': '修改将清除缓存', - 'settings.appInfo': '应用信息', - 'settings.aboutUs': '关于我们', - 'settings.appVersion': '应用版本与团队信息', - 'settings.confirmClear': '确认清除', - 'settings.confirmClearMessage': '确定要清除所有缓存吗?这将删除所有数据包括登录状态,需要重新登录。', - 'settings.cacheCleared': '缓存清除成功,即将跳转到登录页', - 'settings.languageSettings': '语言设置', - 'settings.language': '语言', - 'settings.selectLanguage': '选择语言', - 'settings.languageChanged': '语言切换成功', - - // 重置密码页面 - 'retrievePassword.title': '重置密码', - 'retrievePassword.subtitle': '通过手机号找回您的账户密码', - 'retrievePassword.mobileRequired': '请输入手机号码', - 'retrievePassword.inputCorrectMobile': '请输入正确的手机号码', - 'retrievePassword.captchaRequired': '请输入图形验证码', - 'retrievePassword.mobileCaptchaRequired': '请输入短信验证码', - 'retrievePassword.newPasswordRequired': '请输入新密码', - 'retrievePassword.confirmNewPasswordRequired': '请确认新密码', - 'retrievePassword.passwordsNotMatch': '两次输入的密码不一致', - 'retrievePassword.mobilePlaceholder': '请输入手机号码', - 'retrievePassword.captchaPlaceholder': '请输入图形验证码', - 'retrievePassword.mobileCaptchaPlaceholder': '请输入短信验证码', - 'retrievePassword.newPasswordPlaceholder': '请输入新密码', - 'retrievePassword.confirmNewPasswordPlaceholder': '请确认新密码', - 'retrievePassword.getMobileCaptcha': '获取验证码', - 'retrievePassword.captchaSendSuccess': '验证码发送成功', - 'retrievePassword.passwordUpdateSuccess': '密码重置成功', - 'retrievePassword.resetButton': '重置密码', - 'retrievePassword.goToLogin': '返回登录', - - // 消息提示 - 'message.loginSuccess': '登录成功!', - 'message.loginFail': '登录失败', - 'message.registerSuccess': '注册成功', - 'message.registerFail': '注册失败', - 'message.saveSuccess': '保存成功', - 'message.saveFail': '保存失败', - 'message.deleteSuccess': '删除成功', - 'message.deleteFail': '删除失败', - 'message.bindSuccess': '绑定成功', - 'message.bindFail': '绑定失败', - 'message.unbindSuccess': '解绑成功', - 'message.unbindFail': '解绑失败', - 'message.networkError': '网络错误,请检查网络连接', - 'message.serverError': '服务器错误,请稍后再试', - 'message.invalidAddress': '无效地址,请检查服务端是否启动或网络连接是否正常', - 'message.languageChanged': '语言已切换', - 'message.passwordError': '账号或密码错误', - 'message.phoneRegistered': '此手机号码已经注册过', - - // Agent工具页面 - 'agent.tools.pageTitle': 'Agent工具', - 'agent.tools.unselected': '未选', - 'agent.tools.selected': '已选', - 'agent.tools.noMorePlugins': '暂无更多插件', - 'agent.tools.pleaseSelectPlugin': '请选择插件功能', - 'agent.tools.builtInPlugins': '内置插件', - 'agent.tools.mcpAccessPoint': 'mcp接入点', - 'agent.tools.copy': '复制', - 'agent.tools.noTools': '暂无工具', - 'agent.tools.parameterConfig': '参数配置', - 'agent.tools.noParamsNeeded': '无需配置参数', - 'agent.tools.pleaseInput': '请输入', - 'agent.tools.inputOneItemPerLine': '每行输入一个项目', - 'agent.tools.pleaseInputValidJson': '请输入有效的JSON格式', - 'agent.tools.enableFunction': '启用功能', - 'agent.tools.toggleFunction': '开启或关闭此功能', - 'agent.tools.jsonFormatError': 'JSON格式错误', - 'agent.tools.noMcpAddressToCopy': '暂无MCP地址可复制', - 'agent.tools.mcpAddressCopied': 'MCP地址已复制到剪贴板', - 'agent.tools.copyFailed': '复制失败,请重试', - 'agent.tools.defaultValue': '默认值', - 'agent.tools.notSelected': '未选', - 'agent.tools.clickToConfigure': '点击配置', - 'agent.tools.mcpEndpoint': 'MCP接入点', - 'agent.tools.eachLineOneItem': '每行输入一个项目', - - // 设备配置页面 - 'deviceConfig.pageTitle': '设备配置', - 'deviceConfig.wifiConfig': 'WiFi配网', - 'deviceConfig.ultrasonicConfig': '超声波配网', - 'deviceConfig.selectConfigMethod': '选择配网方式', - 'deviceConfig.networkConfig': '网络配置', - 'deviceConfig.selectedNetwork': '选中网络', - 'deviceConfig.signal': '信号', - 'deviceConfig.openNetwork': '开放网络', - 'deviceConfig.encryptedNetwork': '加密网络', - 'deviceConfig.password': '密码', - 'deviceConfig.pleaseEnterPassword': '请输入WiFi密码', - 'deviceConfig.startConfig': '开始配网', - 'deviceConfig.connectToXiaozhiHotspot': '请先连接xiaozhi热点 (xiaozhi-XXXXXX)', - 'deviceConfig.detecting': '检测中...', - 'deviceConfig.reDetect': '重新检测', - 'deviceConfig.alreadyConnected': '已连接xiaozhi热点', - 'deviceConfig.refreshStatus': '刷新状态', - 'deviceConfig.wifiNetworks': 'WiFi网络', - 'deviceConfig.selectWifiNetwork': '选择WiFi网络', - 'deviceConfig.refreshScan': '刷新扫描', - 'deviceConfig.noWifiNetworks': '暂无WiFi网络', - 'deviceConfig.clickToRefreshScan': '请点击刷新扫描', - 'deviceConfig.signalStrong': '信号强', - 'deviceConfig.signalGood': '信号良好', - 'deviceConfig.signalFair': '信号一般', - 'deviceConfig.signalWeak': '信号弱', - 'deviceConfig.channel': '频道', - 'deviceConfig.about': '约', - 'deviceConfig.seconds': '秒', - 'deviceConfig.generating': '生成中...', - 'deviceConfig.playing': '播放中...', - 'deviceConfig.generateAndPlaySoundWave': '生成并播放声波', - 'deviceConfig.playSoundWave': '播放声波', - 'deviceConfig.stopPlaying': '停止播放', - 'deviceConfig.autoLoopPlaySoundWave': '自动循环播放声波', - 'deviceConfig.configAudioFile': '配网音频文件', - 'deviceConfig.duration': '时长', - 'deviceConfig.ultrasonicConfigInstructions': '超声波配网说明', - 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': '确保已选择WiFi网络并输入密码', - 'deviceConfig.clickGenerateAndPlaySoundWave': '点击生成并播放声波,系统会将配网信息编码为音频', - 'deviceConfig.bringPhoneCloseToXiaozhiDevice': '将手机靠近xiaozhi设备(距离1-2米)', - 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': '音频播放时,xiaozhi会接收并解码配网信息', - 'deviceConfig.afterConfigSuccessDeviceWillConnect': '配网成功后设备会自动连接WiFi网络', - 'deviceConfig.usesAfskModulation': '使用AFSK调制技术,通过1800Hz和1500Hz频率传输数据', - 'deviceConfig.ensureModeratePhoneVolume': '请确保手机音量适中,避免环境噪音干扰', - 'deviceConfig.generatingUltrasonicConfigAudio': '生成超声波配网音频', - 'deviceConfig.configData': '配网数据', - 'deviceConfig.dataBytesLength': '数据字节长度', - 'deviceConfig.bitStreamLength': '比特流长度', - 'deviceConfig.base64Length': 'base64长度', - 'deviceConfig.audioFileTooLarge': '音频文件过大,请缩短SSID或密码长度', - 'deviceConfig.audioGenerationSuccess': '音频生成成功', - 'deviceConfig.samplePoints': '采样点数', - 'deviceConfig.soundWaveGenerationSuccess': '声波生成成功', - 'deviceConfig.audioGenerationFailed': '音频生成失败', - 'deviceConfig.soundWaveGenerationFailed': '声波生成失败', - 'deviceConfig.pleaseGenerateAudioFirst': '请先生成音频', - 'deviceConfig.startPlayingUltrasonicConfigAudio': '开始播放超声波配网音频', - 'deviceConfig.ultrasonicAudioStartedPlaying': '超声波音频开始播放', - 'deviceConfig.startPlayingConfigSoundWave': '开始播放配网声波', - 'deviceConfig.ultrasonicAudioPlaybackEnded': '超声波音频播放结束', - 'deviceConfig.audioPlaybackFailed': '音频播放失败', - 'deviceConfig.audioResourceBusy': '音频资源繁忙,请稍后重试', - 'deviceConfig.audioFormatNotSupported': '音频格式不支持,可能是data URI问题', - 'deviceConfig.audioFileError': '音频文件错误', - 'deviceConfig.cleaningUpAudioContext': '清理音频上下文', - 'deviceConfig.cleaningUpAudioContextFailed': '清理音频上下文失败', - 'deviceConfig.stoppedPlayingUltrasonicAudio': '停止播放超声波音频', - 'deviceConfig.stoppedPlaying': '已停止播放', - 'deviceConfig.configMethod': '配网方式', - 'deviceConfig.enterWifiPassword': '请输入WiFi密码', - 'deviceConfig.xiaozhi': 'xiaozhi', - 'deviceConfig.connectXiaozhiHotspot': '请连接xiaozhi热点', - 'deviceConfig.wifiScanResponse': 'WiFi扫描响应', - 'deviceConfig.scanSuccess': '扫描成功', - 'deviceConfig.networks': '个网络', - 'deviceConfig.wifiScanFailed': 'WiFi扫描失败', - 'deviceConfig.scanFailedCheckConnection': '扫描失败,请检查连接', - 'deviceConfig.checking': '检查中', - 'deviceConfig.reCheck': '重新检查', - 'deviceConfig.connectedXiaozhiHotspot': '已连接xiaozhi热点', - 'deviceConfig.wifiNetwork': 'WiFi网络', - 'deviceConfig.scanning': '扫描中', - 'deviceConfig.cancel': '取消', - 'deviceConfig.clickRefreshScan': '请点击刷新扫描', - 'deviceConfig.esp32ConnectionCheckFailed': 'ESP32连接检查失败', - 'deviceConfig.startWifiConfig': '开始WiFi配网', - 'deviceConfig.configSuccess': '配网成功', - 'deviceConfig.deviceWillConnectTo': '设备将连接到', - 'deviceConfig.deviceWillRestart': '设备将重启', - 'deviceConfig.pleaseDisconnectXiaozhiHotspot': '请断开xiaozhi热点连接', - 'deviceConfig.configFailed': '配网失败', - 'deviceConfig.wifiConfigFailed': 'WiFi配网失败', - 'deviceConfig.pleaseCheckNetworkConnection': '请检查网络连接', - 'deviceConfig.startWifiConfigButton': '开始配网', - 'deviceConfig.wifiConfigInstructions': 'WiFi配网说明', - 'deviceConfig.phoneConnectXiaozhiHotspot': '手机连接xiaozhi热点', - 'deviceConfig.selectTargetWifiNetwork': '选择目标WiFi网络', - 'deviceConfig.enterWifiPasswordIfNeeded': '如有需要请输入WiFi密码', - 'deviceConfig.clickStartConfigAndWait': '点击开始配网并等待', - 'deviceConfig.afterConfigSuccessDeviceWillRestart': '配网成功后设备将自动重启', - 'deviceConfig.audioPlaybackError': '音频播放错误', - 'deviceConfig.playbackFailed': '播放失败', -} diff --git a/main/manager-mobile/src/i18n/zh_TW.ts b/main/manager-mobile/src/i18n/zh_TW.ts deleted file mode 100644 index 4873f5362..000000000 --- a/main/manager-mobile/src/i18n/zh_TW.ts +++ /dev/null @@ -1,444 +0,0 @@ -// 繁體中文語言包 -export default { - // TabBar - 'tabBar.home': '首頁', - 'tabBar.deviceConfig': '配網', - 'tabBar.settings': '系統', - // 設置頁面標題 - 'settings.title': '設置', - // 登錄頁面 - 'login.pageTitle': '登錄', - 'login.navigationTitle': '登錄', - 'login.fetchConfigError': '獲取配置失敗:', - 'login.selectLanguage': '選擇語言', - 'login.selectLanguageTip': '简体', - 'login.welcomeBack': '歡迎回來', - 'login.pleaseLogin': '請登錄您的賬戶', - 'login.enterUsername': '請輸入用戶名', - 'login.enterPassword': '請輸入密碼', - 'login.enterCaptcha': '請輸入驗證碼', - 'login.loginButton': '登錄', - 'login.loggingIn': '登錄中...', - 'login.noAccount': '新用戶註冊', - 'login.enterPhone': '請輸入手機號碼', - 'login.selectCountry': '選擇國家/地區', - 'login.confirm': '確認', - 'login.serverSetting': '服務端設置', - 'login.requiredUsername': '用戶名不能為空', - 'login.requiredPassword': '密碼不能為空', - 'login.requiredCaptcha': '驗證碼不能為空', - 'login.requiredMobile': '請輸入正確的手機號碼', - 'login.captchaError': '圖形驗證碼錯誤', - 'login.forgotPassword': '忘記密碼', - - // 忘記密碼頁面 - 'retrievePassword.title': '重置密碼', - 'retrievePassword.subtitle': '請輸入您的手機號碼以重置密碼', - 'retrievePassword.mobileRequired': '請輸入手機號碼', - 'retrievePassword.inputCorrectMobile': '請輸入正確的手機號碼', - 'retrievePassword.captchaRequired': '請輸入圖形驗證碼', - 'retrievePassword.mobileCaptchaRequired': '請輸入手機驗證碼', - 'retrievePassword.newPasswordRequired': '請輸入新密碼', - 'retrievePassword.confirmNewPasswordRequired': '請確認新密碼', - 'retrievePassword.passwordsNotMatch': '兩次輸入的密碼不一致', - 'retrievePassword.mobilePlaceholder': '請輸入手機號碼', - 'retrievePassword.captchaPlaceholder': '請輸入圖形驗證碼', - 'retrievePassword.mobileCaptchaPlaceholder': '請輸入手機驗證碼', - 'retrievePassword.newPasswordPlaceholder': '請輸入新密碼', - 'retrievePassword.confirmNewPasswordPlaceholder': '請確認新密碼', - 'retrievePassword.confirmPasswordPlaceholder': '請確認新密碼', - 'retrievePassword.captchaSendSuccess': '驗證碼發送成功', - 'retrievePassword.passwordUpdateSuccess': '密碼更新成功', - 'retrievePassword.getCaptcha': '獲取驗證碼', - 'retrievePassword.getMobileCaptcha': '獲取驗證碼', - 'retrievePassword.resend': '重新發送', - 'retrievePassword.resetPasswordButton': '重置密碼', - 'retrievePassword.resetButton': '重置密碼', - 'retrievePassword.goToLogin': '返回登錄', - - // 註冊頁面 - 'register.pageTitle': '註冊', - 'register.createAccount': '創建賬戶', - 'register.enterUsername': '請輸入用戶名', - 'register.enterPassword': '請輸入密碼', - 'register.confirmPassword': '請確認密碼', - 'register.enterPhone': '請輸入手機號碼', - 'register.enterCode': '請輸入驗證碼', - 'register.getCode': '獲取驗證碼', - 'register.agreeTerms': '我已閱讀並同意', - 'register.terms': '《用戶協議》', - 'register.privacy': '《隱私政策》', - 'register.registerButton': '註冊', - 'register.registering': '註冊中...', - 'register.haveAccount': '已有賬戶?', - 'register.loginNow': '立即登錄', - 'register.selectCountry': '選擇國家/地區', - 'register.confirm': '確認', - 'register.captchaSendSuccess': '驗證碼發送成功', - - // 首頁 - 'home.pageTitle': '首頁', - 'home.createAgent': '創建智能體', - 'home.agentName': '智能體', - 'home.modelInfo': '模型信息', - 'home.lastActive': '最近活躍', - 'home.greeting': '你好,小智', - 'home.subtitle': '讓我們度過', - 'home.wonderfulDay': '美好的一天!', - 'home.emptyState': '暫無智能體', - 'home.deviceManagement': '設備管理', - 'home.lastConversation': '最近對話:', - 'home.delete': '刪除', - 'home.createFirstAgent': '點擊右下角 + 號創建您的第一個智能體', - 'home.dialogTitle': '創建智能體', - 'home.inputPlaceholder': '例如:客服助手、語音助理、知識問答', - 'home.createError': '請輸入智能體暱稱', - 'home.createNow': '立即創建', - 'home.justNow': '剛剛', - 'home.minutesAgo': '分鐘前', - 'home.hoursAgo': '小時前', - 'home.daysAgo': '天前', - - // Agent頁面 - 'agent.pageTitle': '智能體', - 'agent.roleConfig': '角色配置', - 'agent.deviceManagement': '設備管理', - 'agent.chatHistory': '聊天記錄', - 'agent.voiceprintManagement': '聲紋管理', - 'agent.editTitle': '編輯智能體', - 'agent.toolsTitle': '編輯功能', - 'agent.voiceActivityDetection': '語音活動檢測', - 'agent.speechRecognition': '語音識別', - 'agent.largeLanguageModel': '大語言模型', - 'agent.save': '保存', - 'agent.cancel': '取消', - // Agent編輯頁面 - 'agent.basicInfo': '基礎資訊', - 'agent.agentName': '助手暱稱', - 'agent.inputAgentName': '請輸入助手暱稱', - 'agent.roleMode': '角色模式', - 'agent.roleDescription': '角色介紹', - 'agent.inputRoleDescription': '請輸入角色介紹', - 'agent.modelConfig': '模型配置', - 'agent.vad': '語音活動檢測', - 'agent.asr': '語音識別', - 'agent.llm': '大語言模型', - 'agent.vllm': '視覺大模型', - 'agent.intent': '意圖識別', - 'agent.memory': '記憶', - 'agent.voiceSettings': '語音設置', - 'agent.tts': '語音合成', - 'agent.voiceprint': '角色音色', - 'agent.plugins': '外掛', - 'agent.editFunctions': '編輯功能', - 'agent.historyMemory': '歷史記憶', - 'agent.memoryContent': '記憶內容', - 'agent.saving': '儲存中...', - 'agent.saveSuccess': '儲存成功', - 'agent.saveFail': '儲存失敗', - 'agent.loadFail': '加載失敗', - 'agent.pleaseInputAgentName': '請輸入助手暱稱', - 'agent.pleaseInputRoleDescription': '請輸入角色介紹', - 'agent.pleaseSelect': '請選擇', - - // 聊天歷史頁面 - 'chatHistory.getChatSessions': '獲取聊天會話列表', - 'chatHistory.noSelectedAgent': '沒有選中的智能體', - 'chatHistory.getChatSessionsFailed': '獲取聊天會話列表失敗:', - 'chatHistory.unknownTime': '未知時間', - 'chatHistory.justNow': '剛剛', - 'chatHistory.minutesAgo': '{minutes}分鐘前', - 'chatHistory.hoursAgo': '{hours}小時前', - 'chatHistory.daysAgo': '{days}天前', - 'chatHistory.conversationRecord': '對話記錄', - 'chatHistory.totalChats': '共 {count} 條對話', - 'chatHistory.loading': '加載中...', - 'chatHistory.noMoreData': '沒有更多數據了', - 'chatHistory.noChatRecords': '暫無聊天記錄', - 'chatHistory.chatRecordsDescription': '與智能體的對話記錄會顯示在這裡', - // 聊天詳情頁面 - 'chatHistory.pageTitle': '聊天詳情', - 'chatHistory.assistantName': '智能助手', - 'chatHistory.userName': '用戶', - 'chatHistory.aiAssistantName': 'AI助手', - 'chatHistory.loadFailed': '獲取聊天記錄失敗', - 'chatHistory.parameterError': '頁面參數錯誤', - 'chatHistory.invalidAudioId': '音頻ID無效', - 'chatHistory.audioPlayFailed': '音頻播放失敗', - 'chatHistory.playAudioFailed': '播放音頻失敗', - - // 設備管理頁面 - 'device.pageTitle': '設備管理', - 'device.noDevices': '暫無設備', - 'device.macAddress': 'MAC地址', - 'device.firmwareVersion': '固件版本', - 'device.lastConnected': '最近對話', - 'device.otaUpdate': 'OTA升級', - 'device.unbind': '解除綁定', - 'device.confirmUnbind': '確定要解綁設備', - 'device.bindDevice': '綁定新設備', - 'device.deviceType': '設備類型', - 'device.loading': '加載中...', - 'device.neverConnected': '從未連接', - 'device.justNow': '剛剛', - 'device.minutesAgo': '{minutes}分鐘前', - 'device.hoursAgo': '{hours}小時前', - 'device.daysAgo': '{days}天前', - 'device.otaAutoUpdateEnabled': 'OTA自動升級已開啟', - 'device.otaAutoUpdateDisabled': 'OTA自動升級已關閉', - 'device.operationFailed': '操作失敗,請重試', - 'device.deviceUnbound': '設備已解除綁定', - 'device.unbindFailed': '解除綁定失敗,請重試', - 'device.unbindDevice': '解除綁定設備', - 'device.confirmUnbindDevice': '確定要解除綁定設備 "{macAddress}" 嗎?', - 'device.cancel': '取消', - 'device.noDevice': '暫無設備', - 'device.pleaseSelectAgent': '請先選擇智能體', - 'device.deviceBindSuccess': '設備綁定成功!', - 'device.bindFailed': '綁定失敗,請檢查驗證碼是否正確', - 'device.enterDeviceCode': '請輸入設備驗證碼', - 'device.bindNow': '立即綁定', - 'device.lastConnection': '最近對話', - 'device.clickToBindFirstDevice': '點擊右下角 + 號綁定您的第一個設備', - - // 通用 - 'common.success': '成功', - 'common.fail': '失敗', - 'common.loading': '加載中...', - 'common.confirm': '確認', - 'common.cancel': '取消', - 'common.delete': '刪除', - 'common.edit': '編輯', - 'common.add': '添加', - 'common.pleaseSelect': '請選擇', - 'common.unknownError': '未知錯誤', - 'common.networkError': '網路錯誤', - - // SM2加密相關錯誤消息 - 'sm2.publicKeyNotConfigured': 'SM2公鑰未配置,請聯繫管理員', - 'sm2.encryptionFailed': '密碼加密失敗', - 'sm2.keyGenerationFailed': '金鑰對生成失敗', - 'sm2.invalidPublicKey': '無效的公鑰格式', - 'sm2.encryptionError': '加密過程中發生錯誤', - 'sm2.publicKeyRetry': '正在重試獲取公鑰...', - 'sm2.publicKeyRetryFailed': '公鑰獲取重試失敗', - - // Voiceprint page - 'voiceprint.noSelectedAgent': '沒有選中的智能體', - 'voiceprint.pleaseSelectAgent': '請先選擇智能體', - 'voiceprint.fetchHistoryFailed': '獲取對話記錄失敗', - 'voiceprint.clickToSelectVector': '點擊選擇聲紋向量', - 'voiceprint.pleaseInputName': '請輸入姓名', - 'voiceprint.pleaseSelectVector': '請選擇聲紋向量', - 'voiceprint.addSuccess': '添加成功', - 'voiceprint.addFailed': '添加說話人失敗', - 'voiceprint.editSuccess': '編輯成功', - 'voiceprint.editFailed': '編輯說話人失敗', - 'voiceprint.deleteConfirmMsg': '確定要刪除這個說話人嗎?', - 'voiceprint.deleteConfirmTitle': '確認刪除', - 'voiceprint.deleteSuccess': '刪除成功', - 'voiceprint.loading': '加載中...', - 'voiceprint.delete': '刪除', - 'voiceprint.emptyTitle': '暫無聲紋數據', - 'voiceprint.emptyDesc': '點擊右下角 + 號添加您的第一個說話人', - 'voiceprint.addSpeaker': '添加說話人', - 'voiceprint.voiceVector': '聲紋向量', - 'voiceprint.name': '姓名', - 'voiceprint.description': '描述', - 'voiceprint.pleaseInputDescription': '請輸入描述', - 'voiceprint.cancel': '取消', - 'voiceprint.save': '保存', - 'voiceprint.editSpeaker': '編輯說話人', - 'voiceprint.selectVector': '選擇聲紋向量', - 'voiceprint.voiceprintInterfaceNotConfigured': '聲紋接口未配置', - - // 設置頁面 - 'settings.pageTitle': '設置', - 'settings.navigationTitle': '設置', - 'settings.networkSettings': '網絡設置', - 'settings.serverApiUrl': '服務端接口地址', - 'settings.validServerUrl': '請輸入有效的服務端地址(以 http 或 https 開頭,並以 /xiaozhi 結尾)', - 'settings.saveSettings': '保存設置', - 'settings.resetDefault': '恢復默認', - 'settings.restartApp': '重啟應用', - 'settings.restartNow': '立即重啟', - 'settings.restartLater': '稍後', - // 關於我們 - 'settings.aboutApp': '關於小智智控台', - 'settings.aboutContent': '小智智控台\n\n基於 Vue.js 3 + uni-app 構建的跨平台移動端管理應用,為小智ESP32智能硬體提供設備管理、智能體配置等功能。\n\n© 2025 xiaozhi-esp32-server {version}', - 'settings.restartSuccess': '已保存,可稍後手動重啟應用', - 'settings.serverUrlSavedAndCacheCleared': '服務端地址已保存,緩存已清除', - 'settings.resetToDefaultAndCacheCleared': '已恢復默認設置,緩存已清除', - 'settings.resetSuccess': '重置成功', - 'settings.enterServerUrl': '請輸入服務端地址', - 'settings.clearCacheFailed': '清除緩存失敗', - 'settings.cacheManagement': '緩存管理', - 'settings.totalCacheSize': '總緩存大小', - 'settings.appDataSize': '應用數據總大小', - 'settings.cacheClear': '緩存清理', - 'settings.clearAllCache': '清空所有緩存數據', - 'settings.clearCache': '清除緩存', - 'settings.modifyWillClearCache': '修改將清除緩存', - 'settings.appInfo': '應用信息', - 'settings.aboutUs': '關於我們', - 'settings.appVersion': '應用版本與團隊信息', - 'settings.confirmClear': '確認清除', - 'settings.confirmClearMessage': '確定要清除所有緩存嗎?這將刪除所有數據包括登錄狀態,需要重新登錄。', - 'settings.cacheCleared': '緩存清除成功,即將跳轉到登錄頁', - 'settings.languageSettings': '語言設置', - 'settings.language': '語言', - 'settings.selectLanguage': '選擇語言', - 'settings.languageChanged': '語言切換成功', - - // 消息提示 - 'message.loginSuccess': '登錄成功!', - 'message.loginFail': '登錄失敗', - 'message.registerSuccess': '註冊成功', - 'message.registerFail': '註冊失敗', - 'message.saveSuccess': '保存成功', - 'message.saveFail': '保存失敗', - 'message.deleteSuccess': '刪除成功', - 'message.deleteFail': '刪除失敗', - 'message.bindSuccess': '綁定成功', - 'message.bindFail': '綁定失敗', - 'message.unbindSuccess': '解除綁定成功', - 'message.unbindFail': '解除綁定失敗', - 'message.networkError': '網絡錯誤,請檢查網絡連接', - 'message.serverError': '服務器錯誤,請稍後再試', - 'message.invalidAddress': '無效地址,請檢查服務端是否啟動或網絡連接是否正常', - 'message.languageChanged': '語言已切換', - 'message.passwordError': '帳號或密碼錯誤', - 'message.phoneRegistered': '此手機號已經註冊過', - - // Agent工具頁面 - 'agent.tools.pageTitle': 'Agent工具', - 'agent.tools.unselected': '未選', - 'agent.tools.selected': '已選', - 'agent.tools.noMorePlugins': '暫無更多插件', - 'agent.tools.pleaseSelectPlugin': '請選擇插件功能', - 'agent.tools.builtInPlugins': '內置插件', - 'agent.tools.mcpAccessPoint': 'mcp接入點', - 'agent.tools.copy': '複製', - 'agent.tools.noTools': '暫無工具', - 'agent.tools.parameterConfig': '參數配置', - 'agent.tools.noParamsNeeded': '無需配置參數', - 'agent.tools.pleaseInput': '請輸入', - 'agent.tools.inputOneItemPerLine': '每行輸入一個項目', - 'agent.tools.pleaseInputValidJson': '請輸入有效的JSON格式', - 'agent.tools.enableFunction': '啟用功能', - 'agent.tools.toggleFunction': '開啟或關閉此功能', - 'agent.tools.jsonFormatError': 'JSON格式錯誤', - 'agent.tools.noMcpAddressToCopy': '暫無MCP地址可複製', - 'agent.tools.mcpAddressCopied': 'MCP地址已複製到剪貼簿', - 'agent.tools.copyFailed': '複製失敗,請重試', - 'agent.tools.defaultValue': '默認值', - 'agent.tools.notSelected': '未選', - 'agent.tools.clickToConfigure': '點擊配置', - 'agent.tools.mcpEndpoint': 'MCP接入點', - 'agent.tools.eachLineOneItem': '每行輸入一個項目', - - // 設備配置頁面 - 'deviceConfig.pageTitle': '設備配置', - 'deviceConfig.wifiConfig': 'WiFi配網', - 'deviceConfig.ultrasonicConfig': '超聲波配網', - 'deviceConfig.selectConfigMethod': '選擇配網方式', - 'deviceConfig.networkConfig': '網絡配置', - 'deviceConfig.selectedNetwork': '選中網絡', - 'deviceConfig.signal': '信號', - 'deviceConfig.openNetwork': '開放網絡', - 'deviceConfig.encryptedNetwork': '加密網絡', - 'deviceConfig.password': '密碼', - 'deviceConfig.pleaseEnterPassword': '請輸入WiFi密碼', - 'deviceConfig.startConfig': '開始配網', - 'deviceConfig.connectToXiaozhiHotspot': '請先連接xiaozhi熱點 (xiaozhi-XXXXXX)', - 'deviceConfig.detecting': '檢測中...', - 'deviceConfig.reDetect': '重新檢測', - 'deviceConfig.alreadyConnected': '已連接xiaozhi熱點', - 'deviceConfig.refreshStatus': '刷新狀態', - 'deviceConfig.wifiNetworks': 'WiFi網絡', - 'deviceConfig.selectWifiNetwork': '選擇WiFi網絡', - 'deviceConfig.refreshScan': '刷新掃描', - 'deviceConfig.noWifiNetworks': '暫無WiFi網絡', - 'deviceConfig.clickToRefreshScan': '請點擊刷新掃描', - 'deviceConfig.signalStrong': '信號強', - 'deviceConfig.signalGood': '信號良好', - 'deviceConfig.signalFair': '信號一般', - 'deviceConfig.signalWeak': '信號弱', - 'deviceConfig.channel': '頻道', - 'deviceConfig.about': '約', - 'deviceConfig.seconds': '秒', - 'deviceConfig.generating': '生成中...', - 'deviceConfig.playing': '播放中...', - 'deviceConfig.generateAndPlaySoundWave': '生成並播放聲波', - 'deviceConfig.playSoundWave': '播放聲波', - 'deviceConfig.stopPlaying': '停止播放', - 'deviceConfig.autoLoopPlaySoundWave': '自動循環播放聲波', - 'deviceConfig.configAudioFile': '配網音頻文件', - 'deviceConfig.duration': '時長', - 'deviceConfig.ultrasonicConfigInstructions': '超聲波配網說明', - 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': '確保已選擇WiFi網絡並輸入密碼', - 'deviceConfig.clickGenerateAndPlaySoundWave': '點擊生成並播放聲波,系統會將配網信息編碼為音頻', - 'deviceConfig.bringPhoneCloseToXiaozhiDevice': '將手機靠近xiaozhi設備(距離1-2米)', - 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': '音頻播放時,xiaozhi會接收並解碼配網信息', - 'deviceConfig.afterConfigSuccessDeviceWillConnect': '配網成功後設備會自動連接WiFi網絡', - 'deviceConfig.usesAfskModulation': '使用AFSK調制技術,通過1800Hz和1500Hz頻率傳輸數據', - 'deviceConfig.ensureModeratePhoneVolume': '請確保手機音量適中,避免環境噪音干擾', - 'deviceConfig.generatingUltrasonicConfigAudio': '生成超聲波配網音頻', - 'deviceConfig.configData': '配網數據', - 'deviceConfig.dataBytesLength': '數據字節長度', - 'deviceConfig.bitStreamLength': '比特流長度', - 'deviceConfig.base64Length': 'base64長度', - 'deviceConfig.audioFileTooLarge': '音頻文件過大,請縮短SSID或密碼長度', - 'deviceConfig.audioGenerationSuccess': '音頻生成成功', - 'deviceConfig.samplePoints': '採樣點數', - 'deviceConfig.soundWaveGenerationSuccess': '聲波生成成功', - 'deviceConfig.audioGenerationFailed': '音頻生成失敗', - 'deviceConfig.soundWaveGenerationFailed': '聲波生成失敗', - 'deviceConfig.pleaseGenerateAudioFirst': '請先生成音頻', - 'deviceConfig.startPlayingUltrasonicConfigAudio': '開始播放超聲波配網音頻', - 'deviceConfig.ultrasonicAudioStartedPlaying': '超聲波音頻開始播放', - 'deviceConfig.startPlayingConfigSoundWave': '開始播放配網聲波', - 'deviceConfig.ultrasonicAudioPlaybackEnded': '超聲波音頻播放結束', - 'deviceConfig.audioPlaybackFailed': '音頻播放失敗', - 'deviceConfig.audioResourceBusy': '音頻資源繁忙,請稍後重試', - 'deviceConfig.audioFormatNotSupported': '音頻格式不支援,可能是data URI問題', - 'deviceConfig.audioFileError': '音頻文件錯誤', - 'deviceConfig.cleaningUpAudioContext': '清理音頻上下文', - 'deviceConfig.cleaningUpAudioContextFailed': '清理音頻上下文失敗', - 'deviceConfig.stoppedPlayingUltrasonicAudio': '停止播放超聲波音頻', - 'deviceConfig.stoppedPlaying': '已停止播放', - 'deviceConfig.configMethod': '配網方式', - 'deviceConfig.enterWifiPassword': '請輸入WiFi密碼', - 'deviceConfig.xiaozhi': 'xiaozhi', - 'deviceConfig.connectXiaozhiHotspot': '請連接xiaozhi熱點', - 'deviceConfig.wifiScanResponse': 'WiFi掃描響應', - 'deviceConfig.scanSuccess': '掃描成功', - 'deviceConfig.networks': '個網絡', - 'deviceConfig.wifiScanFailed': 'WiFi掃描失敗', - 'deviceConfig.scanFailedCheckConnection': '掃描失敗,請檢查連接', - 'deviceConfig.checking': '檢查中', - 'deviceConfig.reCheck': '重新檢查', - 'deviceConfig.connectedXiaozhiHotspot': '已連接xiaozhi熱點', - 'deviceConfig.wifiNetwork': 'WiFi網絡', - 'deviceConfig.scanning': '掃描中', - 'deviceConfig.cancel': '取消', - 'deviceConfig.clickRefreshScan': '請點擊刷新掃描', - 'deviceConfig.esp32ConnectionCheckFailed': 'ESP32連接檢查失敗', - 'deviceConfig.startWifiConfig': '開始WiFi配網', - 'deviceConfig.configSuccess': '配網成功', - 'deviceConfig.deviceWillConnectTo': '設備將連接到', - 'deviceConfig.deviceWillRestart': '設備將重啟', - 'deviceConfig.pleaseDisconnectXiaozhiHotspot': '請斷開xiaozhi熱點連接', - 'deviceConfig.configFailed': '配網失敗', - 'deviceConfig.wifiConfigFailed': 'WiFi配網失敗', - 'deviceConfig.pleaseCheckNetworkConnection': '請檢查網絡連接', - 'deviceConfig.startWifiConfigButton': '開始配網', - 'deviceConfig.wifiConfigInstructions': 'WiFi配網說明', - 'deviceConfig.phoneConnectXiaozhiHotspot': '手機連接xiaozhi熱點', - 'deviceConfig.selectTargetWifiNetwork': '選擇目標WiFi網絡', - 'deviceConfig.enterWifiPasswordIfNeeded': '如有需要請輸入WiFi密碼', - 'deviceConfig.clickStartConfigAndWait': '點擊開始配網並等待', - 'deviceConfig.afterConfigSuccessDeviceWillRestart': '配網成功後設備將自動重啟', - 'deviceConfig.audioPlaybackError': '音頻播放錯誤', - 'deviceConfig.playbackFailed': '播放失敗', -} diff --git a/main/manager-mobile/src/layouts/default.vue b/main/manager-mobile/src/layouts/default.vue deleted file mode 100644 index 360c6b216..000000000 --- a/main/manager-mobile/src/layouts/default.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/main/manager-mobile/src/layouts/fg-tabbar/fg-tabbar.vue b/main/manager-mobile/src/layouts/fg-tabbar/fg-tabbar.vue deleted file mode 100644 index 819aa6fb0..000000000 --- a/main/manager-mobile/src/layouts/fg-tabbar/fg-tabbar.vue +++ /dev/null @@ -1,68 +0,0 @@ - - - diff --git a/main/manager-mobile/src/layouts/fg-tabbar/tabbar.md b/main/manager-mobile/src/layouts/fg-tabbar/tabbar.md deleted file mode 100644 index 2485b06db..000000000 --- a/main/manager-mobile/src/layouts/fg-tabbar/tabbar.md +++ /dev/null @@ -1,17 +0,0 @@ -# tabbar 说明 - -`tabbar` 分为 `4 种` 情况: - -- 0 `无 tabbar`,只有一个页面入口,底部无 `tabbar` 显示;常用语临时活动页。 -- 1 `原生 tabbar`,使用 `switchTab` 切换 tabbar,`tabbar` 页面有缓存。 - - 优势:原生自带的 tabbar,最先渲染,有缓存。 - - 劣势:只能使用 2 组图片来切换选中和非选中状态,修改颜色只能重新换图片(或者用 iconfont)。 -- 2 `有缓存自定义 tabbar`,使用 `switchTab` 切换 tabbar,`tabbar` 页面有缓存。使用了第三方 UI 库的 `tabbar` 组件,并隐藏了原生 `tabbar` 的显示。 - - 优势:可以随意配置自己想要的 `svg icon`,切换字体颜色方便。有缓存。可以实现各种花里胡哨的动效等。 - - 劣势:首次点击 tababr 会闪烁。 -- 3 `无缓存自定义 tabbar`,使用 `navigateTo` 切换 `tabbar`,`tabbar` 页面无缓存。使用了第三方 UI 库的 `tabbar` 组件。 - - 优势:可以随意配置自己想要的 svg icon,切换字体颜色方便。可以实现各种花里胡哨的动效等。 - - 劣势:首次点击 `tababr` 会闪烁,无缓存。 - - -> 注意:花里胡哨的效果需要自己实现,本模版不提供。 diff --git a/main/manager-mobile/src/layouts/fg-tabbar/tabbar.ts b/main/manager-mobile/src/layouts/fg-tabbar/tabbar.ts deleted file mode 100644 index 03be03fb2..000000000 --- a/main/manager-mobile/src/layouts/fg-tabbar/tabbar.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * tabbar 状态,增加 storageSync 保证刷新浏览器时在正确的 tabbar 页面 - * 使用reactive简单状态,而不是 pinia 全局状态 - */ -export const tabbarStore = reactive({ - curIdx: uni.getStorageSync('app-tabbar-index') || 0, - setCurIdx(idx: number) { - this.curIdx = idx - uni.setStorageSync('app-tabbar-index', idx) - }, -}) diff --git a/main/manager-mobile/src/layouts/fg-tabbar/tabbarList.ts b/main/manager-mobile/src/layouts/fg-tabbar/tabbarList.ts deleted file mode 100644 index 5273136c7..000000000 --- a/main/manager-mobile/src/layouts/fg-tabbar/tabbarList.ts +++ /dev/null @@ -1,76 +0,0 @@ -import type { TabBar } from '@uni-helper/vite-plugin-uni-pages' - -type FgTabBarItem = TabBar['list'][0] & { - icon: string - iconType: 'uiLib' | 'unocss' | 'iconfont' -} - -/** - * tabbar 选择的策略,更详细的介绍见 tabbar.md 文件 - * 0: 'NO_TABBAR' `无 tabbar` - * 1: 'NATIVE_TABBAR' `完全原生 tabbar` - * 2: 'CUSTOM_TABBAR_WITH_CACHE' `有缓存自定义 tabbar` - * 3: 'CUSTOM_TABBAR_WITHOUT_CACHE' `无缓存自定义 tabbar` - * - * 温馨提示:本文件的任何代码更改了之后,都需要重新运行,否则 pages.json 不会更新导致错误 - */ -export const TABBAR_MAP = { - NO_TABBAR: 0, - NATIVE_TABBAR: 1, - CUSTOM_TABBAR_WITH_CACHE: 2, - CUSTOM_TABBAR_WITHOUT_CACHE: 3, -} -// TODO:通过这里切换使用tabbar的策略 -export const selectedTabbarStrategy = TABBAR_MAP.NATIVE_TABBAR - -// selectedTabbarStrategy==NATIVE_TABBAR(1) 时,需要填 iconPath 和 selectedIconPath -// selectedTabbarStrategy==CUSTOM_TABBAR(2,3) 时,需要填 icon 和 iconType -// selectedTabbarStrategy==NO_TABBAR(0) 时,tabbarList 不生效 -export const tabbarList: FgTabBarItem[] = [ - { - iconPath: 'static/tabbar/robot.png', - selectedIconPath: 'static/tabbar/robot_activate.png', - pagePath: 'pages/index/index', - text: '首页', - icon: 'home', - // 选用 UI 框架自带的 icon 时,iconType 为 uiLib - iconType: 'uiLib', - }, - { - iconPath: 'static/tabbar/network.png', - selectedIconPath: 'static/tabbar/network_activate.png', - pagePath: 'pages/device-config/index', - text: '配网', - icon: 'i-carbon-network-3', - iconType: 'uiLib', - }, - { - iconPath: 'static/tabbar/system.png', - selectedIconPath: 'static/tabbar/system_activate.png', - pagePath: 'pages/settings/index', - text: '系统', - icon: 'i-carbon-settings', - iconType: 'uiLib', - }, -] - -// NATIVE_TABBAR(1) 和 CUSTOM_TABBAR_WITH_CACHE(2) 时,需要tabbar缓存 -export const cacheTabbarEnable = selectedTabbarStrategy === TABBAR_MAP.NATIVE_TABBAR - || selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE - -const _tabbar: TabBar = { - // 只有微信小程序支持 custom。App 和 H5 不生效 - custom: selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE, - color: '#e6e6e6', - selectedColor: '#667dea', - backgroundColor: '#fff', - borderStyle: 'black', - height: '50px', - fontSize: '10px', - iconWidth: '24px', - spacing: '3px', - list: tabbarList as unknown as TabBar['list'], -} - -// 0和1 需要显示底部的tabbar的各种配置,以利用缓存 -export const tabBar = cacheTabbarEnable ? _tabbar : undefined diff --git a/main/manager-mobile/src/layouts/tabbar.vue b/main/manager-mobile/src/layouts/tabbar.vue deleted file mode 100644 index 0c1bb1c6e..000000000 --- a/main/manager-mobile/src/layouts/tabbar.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - diff --git a/main/manager-mobile/src/main.ts b/main/manager-mobile/src/main.ts deleted file mode 100644 index 4b3ad83e4..000000000 --- a/main/manager-mobile/src/main.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { VueQueryPlugin } from '@tanstack/vue-query' -import { createSSRApp } from 'vue' -import App from './App.vue' -import { routeInterceptor } from './router/interceptor' - -import store from './store' -import '@/style/index.scss' -import 'virtual:uno.css' - -// 导入国际化相关功能 -import { initI18n } from './i18n' -import { useLangStore } from './store/lang' - -export function createApp() { - const app = createSSRApp(App) - app.use(store) - app.use(routeInterceptor) - app.use(VueQueryPlugin) - - // 初始化国际化 - initI18n() - - return { - app, - } -} diff --git a/main/manager-mobile/src/manifest.json b/main/manager-mobile/src/manifest.json deleted file mode 100644 index 67225dc8e..000000000 --- a/main/manager-mobile/src/manifest.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "name": "小智", - "appid": "__UNI__36A515E", - "description": "", - "versionName": "1.0.0", - "versionCode": "100", - "transformPx": false, - "app-plus": { - "usingComponents": true, - "nvueStyleCompiler": "uni-app", - "compilerVersion": 3, - "splashscreen": { - "alwaysShowBeforeRender": true, - "waiting": true, - "autoclose": true, - "delay": 0 - }, - "modules": {}, - "distribute": { - "android": { - "permissions": [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ], - "minSdkVersion": 30, - "targetSdkVersion": 30, - "abiFilters": [ - "armeabi-v7a", - "arm64-v8a" - ] - }, - "ios": {}, - "sdkConfigs": {}, - "icons": { - "android": { - "hdpi": "unpackage/res/icons/72x72.png", - "xhdpi": "unpackage/res/icons/96x96.png", - "xxhdpi": "unpackage/res/icons/144x144.png", - "xxxhdpi": "unpackage/res/icons/192x192.png" - }, - "ios": { - "appstore": "unpackage/res/icons/1024x1024.png", - "ipad": { - "app": "unpackage/res/icons/76x76.png", - "app@2x": "unpackage/res/icons/152x152.png", - "notification": "unpackage/res/icons/20x20.png", - "notification@2x": "unpackage/res/icons/40x40.png", - "proapp@2x": "unpackage/res/icons/167x167.png", - "settings": "unpackage/res/icons/29x29.png", - "settings@2x": "unpackage/res/icons/58x58.png", - "spotlight": "unpackage/res/icons/40x40.png", - "spotlight@2x": "unpackage/res/icons/80x80.png" - }, - "iphone": { - "app@2x": "unpackage/res/icons/120x120.png", - "app@3x": "unpackage/res/icons/180x180.png", - "notification@2x": "unpackage/res/icons/40x40.png", - "notification@3x": "unpackage/res/icons/60x60.png", - "settings@2x": "unpackage/res/icons/58x58.png", - "settings@3x": "unpackage/res/icons/87x87.png", - "spotlight@2x": "unpackage/res/icons/80x80.png", - "spotlight@3x": "unpackage/res/icons/120x120.png" - } - } - } - }, - "compatible": { - "ignoreVersion": true - } - }, - "quickapp": {}, - "mp-weixin": { - "appid": "wxa2abb91f64032a2b", - "setting": { - "urlCheck": false, - "es6": true, - "minified": true - }, - "usingComponents": true, - "optimization": { - "subPackages": true - }, - "permission": { - "scope.userLocation": { - "desc": "WiFi配网功能需要获取位置权限" - } - }, - "requiredPrivateInfos": [ - "getLocation" - ] - }, - "mp-alipay": { - "usingComponents": true, - "styleIsolation": "shared" - }, - "mp-baidu": { - "usingComponents": true - }, - "mp-toutiao": { - "usingComponents": true - }, - "uniStatistics": { - "enable": false - }, - "vueVersion": "3", - "h5": { - "router": {} - } -} \ No newline at end of file diff --git a/main/manager-mobile/src/pages-sub/demo/index.vue b/main/manager-mobile/src/pages-sub/demo/index.vue deleted file mode 100644 index 4231cff4e..000000000 --- a/main/manager-mobile/src/pages-sub/demo/index.vue +++ /dev/null @@ -1,27 +0,0 @@ - -{ - "layout": "default", - "style": { - "navigationBarTitleText": "分包页面" - } -} - - - - - - - diff --git a/main/manager-mobile/src/pages.json b/main/manager-mobile/src/pages.json deleted file mode 100644 index 554a0a20b..000000000 --- a/main/manager-mobile/src/pages.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "globalStyle": { - "navigationStyle": "default", - "navigationBarTitleText": "智控台", - "navigationBarBackgroundColor": "#f8f8f8", - "navigationBarTextStyle": "black", - "backgroundColor": "#FFFFFF" - }, - "easycom": { - "autoscan": true, - "custom": { - "^fg-(.*)": "@/components/fg-$1/fg-$1.vue", - "^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue", - "^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue" - } - }, - "tabBar": { - "custom": false, - "color": "#e6e6e6", - "selectedColor": "#667dea", - "backgroundColor": "#fff", - "borderStyle": "black", - "height": "50px", - "fontSize": "10px", - "iconWidth": "24px", - "spacing": "3px", - "list": [ - { - "iconPath": "static/tabbar/robot.png", - "selectedIconPath": "static/tabbar/robot_activate.png", - "pagePath": "pages/index/index", - "text": "首页", - "icon": "home", - "iconType": "uiLib" - }, - { - "iconPath": "static/tabbar/network.png", - "selectedIconPath": "static/tabbar/network_activate.png", - "pagePath": "pages/device-config/index", - "text": "配网", - "icon": "i-carbon-network-3", - "iconType": "uiLib" - }, - { - "iconPath": "static/tabbar/system.png", - "selectedIconPath": "static/tabbar/system_activate.png", - "pagePath": "pages/settings/index", - "text": "系统", - "icon": "i-carbon-settings", - "iconType": "uiLib" - } - ] - }, - "pages": [ - { - "path": "pages/index/index", - "type": "home", - "layout": "tabbar", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "首页" - } - }, - { - "path": "pages/agent/edit", - "type": "page" - }, - { - "path": "pages/agent/index", - "type": "page", - "layout": "default", - "style": { - "navigationBarTitleText": "智能体", - "navigationStyle": "custom" - } - }, - { - "path": "pages/agent/tools", - "type": "page", - "layout": "default", - "style": { - "navigationBarTitleText": "编辑功能", - "navigationStyle": "custom" - } - }, - { - "path": "pages/chat-history/detail", - "type": "page", - "layout": "default", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "聊天详情" - } - }, - { - "path": "pages/chat-history/index", - "type": "page" - }, - { - "path": "pages/device/index", - "type": "page" - }, - { - "path": "pages/device-config/index", - "type": "page", - "style": { - "navigationBarTitleText": "设备配置", - "navigationStyle": "custom" - } - }, - { - "path": "pages/forgot-password/index", - "type": "page", - "layout": "default", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "ForgotPassword" - } - }, - { - "path": "pages/login/index", - "type": "page", - "layout": "default", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "Login" - } - }, - { - "path": "pages/register/index", - "type": "page", - "layout": "default", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "注册" - } - }, - { - "path": "pages/settings/index", - "type": "page", - "layout": "default", - "style": { - "navigationBarTitleText": "设置", - "navigationStyle": "custom" - } - }, - { - "path": "pages/voiceprint/index", - "type": "page" - } - ], - "subPackages": [ - { - "root": "pages-sub", - "pages": [ - { - "path": "demo/index", - "type": "page", - "layout": "default", - "style": { - "navigationBarTitleText": "分包页面" - } - } - ] - } - ] -} \ No newline at end of file diff --git a/main/manager-mobile/src/pages/agent/edit.vue b/main/manager-mobile/src/pages/agent/edit.vue deleted file mode 100644 index 0fb6a46ce..000000000 --- a/main/manager-mobile/src/pages/agent/edit.vue +++ /dev/null @@ -1,703 +0,0 @@ - - -