diff --git a/docs/SQL建表语句.sql b/docs/SQL建表语句.sql deleted file mode 100644 index e214d5f23c..0000000000 --- a/docs/SQL建表语句.sql +++ /dev/null @@ -1,285 +0,0 @@ --- Yudao 风格建表语句 --- 包含多租户概念,使用 TenantBaseDO --- 命名规范:业务模块_功能模块_功能,如 muye_point_(幕业积分)、muye_member_(幕业会员)、muye_ai_(幕业AI) - --- =============================================== --- 1. 积分管理模块 (muye_point_) --- =============================================== - --- 积分兑换配置表 -CREATE TABLE `muye_point_exchange_config` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `exchange_rate` int NOT NULL DEFAULT 1 COMMENT '兑换比例(1元兑换多少积分)', - `adjust_reason` varchar(200) NOT NULL DEFAULT '' COMMENT '调整原因', - `operator_id` bigint NOT NULL DEFAULT 0 COMMENT '操作人用户编号', - `operator_name` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人账号', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用 1-启用)', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - `updater` varchar(64) NOT NULL DEFAULT '' COMMENT '更新者', - `deleted` bit NOT NULL DEFAULT b'0' COMMENT '是否删除', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_tenant_id` (`tenant_id`) USING BTREE, - KEY `idx_create_time` (`create_time`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='积分兑换配置表'; - --- 积分签到配置表 -CREATE TABLE `muye_point_signin_config` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `daily_points` int NOT NULL DEFAULT 0 COMMENT '每日签到赠送积分', - `continuous_days` int NOT NULL DEFAULT 0 COMMENT '连续签到天数', - `bonus_points` int NOT NULL DEFAULT 0 COMMENT '连续签到奖励积分', - `reset_days` int NOT NULL DEFAULT 0 COMMENT '重置签到天数(0表示不重置)', - `adjust_reason` varchar(200) NOT NULL DEFAULT '' COMMENT '调整原因', - `operator_id` bigint NOT NULL DEFAULT 0 COMMENT '操作人用户编号', - `operator_name` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人账号', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用 1-启用)', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - `updater` varchar(64) NOT NULL DEFAULT '' COMMENT '更新者', - `deleted` bit NOT NULL DEFAULT b'0' COMMENT '是否删除', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_tenant_id` (`tenant_id`) USING BTREE, - KEY `idx_continuous_days` (`continuous_days`) USING BTREE, - KEY `idx_create_time` (`create_time`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='积分签到配置表'; - --- 积分充值配置表 -CREATE TABLE `muye_point_recharge_config` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `recharge_amount` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '充值金额', - `bonus_points` int NOT NULL DEFAULT 0 COMMENT '赠送积分数', - `adjust_reason` varchar(200) NOT NULL DEFAULT '' COMMENT '调整原因', - `operator_id` bigint NOT NULL DEFAULT 0 COMMENT '操作人用户编号', - `operator_name` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人账号', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用 1-启用)', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - `updater` varchar(64) NOT NULL DEFAULT '' COMMENT '更新者', - `deleted` bit NOT NULL DEFAULT b'0' COMMENT '是否删除', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_tenant_id` (`tenant_id`) USING BTREE, - KEY `idx_recharge_amount` (`recharge_amount`) USING BTREE, - KEY `idx_create_time` (`create_time`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='积分充值配置表'; - --- 积分记录表 -CREATE TABLE `muye_point_record` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `user_id` bigint NOT NULL DEFAULT 0 COMMENT '用户编号', - `mobile` varchar(20) NOT NULL DEFAULT '' COMMENT '手机号', - `type` varchar(20) NOT NULL DEFAULT '' COMMENT '变动类型(increase-增加 decrease-减少)', - `point_amount` int NOT NULL DEFAULT 0 COMMENT '变动积分数量(正数为增加,负数为减少)', - `balance` int NOT NULL DEFAULT 0 COMMENT '变动后余额', - `reason` varchar(100) NOT NULL DEFAULT '' COMMENT '变动原因', - `biz_type` varchar(50) NOT NULL DEFAULT '' COMMENT '业务类型(signin-签到 recharge-充值 exchange-兑换 admin-后台调整 gift-礼包赠送)', - `biz_id` varchar(64) NOT NULL DEFAULT '' COMMENT '业务关联ID', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_tenant_id_user_id` (`tenant_id`, `user_id`) USING BTREE, - KEY `idx_user_id_create_time` (`user_id`, `create_time`) USING BTREE, - KEY `idx_type` (`type`) USING BTREE, - KEY `idx_biz_type` (`biz_type`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='积分记录表'; - --- =============================================== --- 2. 会员管理模块 (muye_member_) --- =============================================== - --- 会员用户档案表 -CREATE TABLE `muye_member_user_profile` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `user_id` varchar(32) NOT NULL COMMENT '用户ID', - `mobile` varchar(20) NOT NULL COMMENT '手机号', - `register_time` datetime NOT NULL COMMENT '注册时间', - `last_login_time` datetime NOT NULL COMMENT '最后登录时间', - `total_points` int NOT NULL DEFAULT 0 COMMENT '账户总积分', - `used_points` int NOT NULL DEFAULT 0 COMMENT '账户消耗积分', - `remaining_points` int NOT NULL DEFAULT 0 COMMENT '账户剩余积分', - `total_storage` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '云空间总容量(GB)', - `used_storage` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '云空间已用容量(GB)', - `remaining_storage` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '云空间剩余容量(GB)', - `total_recharge` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '总充值金额', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用 1-启用)', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - `updater` varchar(64) NOT NULL DEFAULT '' COMMENT '更新者', - `deleted` bit NOT NULL DEFAULT b'0' COMMENT '是否删除', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_user_id` (`user_id`) USING BTREE, - UNIQUE KEY `uk_mobile` (`mobile`) USING BTREE, - KEY `idx_tenant_id` (`tenant_id`) USING BTREE, - KEY `idx_register_time` (`register_time`) USING BTREE, - KEY `idx_last_login_time` (`last_login_time`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='会员用户档案表'; - --- 充值记录表 -CREATE TABLE `muye_member_recharge_record` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `user_id` bigint NOT NULL DEFAULT 0 COMMENT '用户编号', - `mobile` varchar(20) NOT NULL COMMENT '手机号', - `recharge_amount` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '充值金额', - `recharge_type` varchar(20) NOT NULL DEFAULT '' COMMENT '充值方式(alipay-支付宝 wechat-微信 admin-人工)', - `order_type` varchar(50) NOT NULL DEFAULT '' COMMENT '订单类型(purchase-权限购买 exchange-积分兑换)', - `permission_type` varchar(100) NOT NULL DEFAULT '' COMMENT '购买权限类型', - `bonus_points` int NOT NULL DEFAULT 0 COMMENT '获得积分', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-失败 1-成功)', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_tenant_id_user_id` (`tenant_id`, `user_id`) USING BTREE, - KEY `idx_user_id_create_time` (`user_id`, `create_time`) USING BTREE, - KEY `idx_recharge_type` (`recharge_type`) USING BTREE, - KEY `idx_order_type` (`order_type`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='充值记录表'; - --- 礼包表 -CREATE TABLE `muye_member_gift_package` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `package_id` varchar(32) NOT NULL COMMENT '礼包ID', - `package_name` varchar(100) NOT NULL COMMENT '礼包名称', - `sort_order` int NOT NULL DEFAULT 0 COMMENT 'C端展示排序', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用 1-启用)', - `price` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '购买价格', - `validity_days` int NOT NULL DEFAULT 0 COMMENT '有效期(天)', - `bonus_points` int NOT NULL DEFAULT 0 COMMENT '赠送积分', - `applications` text NOT NULL COMMENT '关联应用(JSON格式)', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `operator_id` bigint NOT NULL DEFAULT 0 COMMENT '操作人用户编号', - `operator_name` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人账号', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - `updater` varchar(64) NOT NULL DEFAULT '' COMMENT '更新者', - `deleted` bit NOT NULL DEFAULT b'0' COMMENT '是否删除', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_package_id` (`package_id`) USING BTREE, - KEY `idx_tenant_id` (`tenant_id`) USING BTREE, - KEY `idx_sort_order` (`sort_order`) USING BTREE, - KEY `idx_status` (`status`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='礼包表'; - --- =============================================== --- 3. AI 模块 (muye_ai_) --- =============================================== - --- AI模型配置表 -CREATE TABLE `muye_ai_model_config` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `model_name` varchar(100) NOT NULL COMMENT '模型名称', - `model_code` varchar(100) NOT NULL COMMENT '模型标识/编码', - `platform` varchar(50) NOT NULL COMMENT '所属平台', - `api_key` varchar(200) NOT NULL COMMENT 'API秘钥', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用 1-启用)', - `temperature` decimal(3,2) NOT NULL DEFAULT 0.70 COMMENT '温度参数', - `max_tokens` int NOT NULL DEFAULT 0 COMMENT '回复数Token数', - `daily_limit` int NOT NULL DEFAULT 0 COMMENT '每日请求次数', - `model_type` varchar(50) NOT NULL COMMENT '模型类型(image-图像 text-文本 video-视频 audio-音频)', - `consume_points` int NOT NULL DEFAULT 0 COMMENT '消耗积分', - `max_text_length` int NOT NULL DEFAULT 0 COMMENT '最大文本数量', - `max_image_size` varchar(50) NOT NULL DEFAULT '' COMMENT '图片最大像素', - `max_video_duration` int NOT NULL DEFAULT 0 COMMENT '视频最大时长(秒)', - `max_video_quality` varchar(20) NOT NULL DEFAULT '' COMMENT '视频最大质量', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - `updater` varchar(64) NOT NULL DEFAULT '' COMMENT '更新者', - `deleted` bit NOT NULL DEFAULT b'0' COMMENT '是否删除', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_tenant_id` (`tenant_id`) USING BTREE, - KEY `idx_platform` (`platform`) USING BTREE, - KEY `idx_model_type` (`model_type`) USING BTREE, - KEY `idx_status` (`status`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='AI模型配置表'; - --- AI应用功能表 -CREATE TABLE `muye_ai_application` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `app_id` varchar(32) NOT NULL COMMENT '应用ID', - `app_name` varchar(100) NOT NULL COMMENT '应用名称', - `api_key` varchar(200) NOT NULL COMMENT '第三方API秘钥', - `consume_points` int NOT NULL DEFAULT 0 COMMENT '单位消耗积分', - `unit_type` varchar(20) NOT NULL COMMENT '消耗单位(time-时长 count-次数)', - `unit_value` varchar(50) NOT NULL COMMENT '单位值(如:1min、20次)', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用 1-启用)', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - `updater` varchar(64) NOT NULL DEFAULT '' COMMENT '更新者', - `deleted` bit NOT NULL DEFAULT b'0' COMMENT '是否删除', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_app_id` (`app_id`) USING BTREE, - KEY `idx_tenant_id` (`tenant_id`) USING BTREE, - KEY `idx_app_name` (`app_name`) USING BTREE, - KEY `idx_status` (`status`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='AI应用功能表'; - --- AI智能体表 -CREATE TABLE `muye_ai_agent` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `agent_id` varchar(32) NOT NULL COMMENT '智能体ID', - `agent_name` varchar(100) NOT NULL COMMENT '智能体名称', - `icon` varchar(200) NOT NULL DEFAULT '' COMMENT '图标URL', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用 1-启用)', - `description` text NOT NULL COMMENT '设定描述', - `system_prompt` text NOT NULL COMMENT '预置提示词', - `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', - `operator_id` bigint NOT NULL DEFAULT 0 COMMENT '操作人用户编号', - `operator_name` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人账号', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - `updater` varchar(64) NOT NULL DEFAULT '' COMMENT '更新者', - `deleted` bit NOT NULL DEFAULT b'0' COMMENT '是否删除', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `uk_agent_id` (`agent_id`) USING BTREE, - KEY `idx_tenant_id` (`tenant_id`) USING BTREE, - KEY `idx_agent_name` (`agent_name`) USING BTREE, - KEY `idx_status` (`status`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='AI智能体表'; - --- =============================================== --- 4. 权限管理模块 --- =============================================== - --- 用户权限表 -CREATE TABLE `muye_member_user_permission` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `user_id` bigint NOT NULL DEFAULT 0 COMMENT '用户编号', - `permission_type` varchar(100) NOT NULL COMMENT '权限类型', - `package_id` bigint NOT NULL DEFAULT 0 COMMENT '礼包ID', - `validity_start` datetime NOT NULL COMMENT '有效期开始时间', - `validity_end` datetime NOT NULL COMMENT '有效期结束时间', - `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-过期 1-有效)', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '创建者', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_tenant_id_user_id` (`tenant_id`, `user_id`) USING BTREE, - KEY `idx_user_id` (`user_id`) USING BTREE, - KEY `idx_package_id` (`package_id`) USING BTREE, - KEY `idx_validity_end` (`validity_end`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户权限表'; diff --git a/frontend/app/web-gold/src/api/modelConfig.js b/frontend/app/web-gold/src/api/modelConfig.js index fa33b121ad..d5a385bc80 100644 --- a/frontend/app/web-gold/src/api/modelConfig.js +++ b/frontend/app/web-gold/src/api/modelConfig.js @@ -1,61 +1,64 @@ /** - * AI模型配置 API 服务 - * 用于获取模型积分消耗配置 + * AI第三方服务配置 API 服务 + * 用于获取服务积分消耗配置 */ import http from './http' -const BASE_URL = '/webApi/api/tik/ai-model-config' +const BASE_URL = '/webApi/api/tik/ai-service-config' /** - * 模型配置 API 服务 + * 服务配置 API 服务 */ -export const ModelConfigService = { +export const ServiceConfigService = { /** - * 获取所有启用的模型配置列表(按平台分组) - * @returns {Promise} 按平台分组的模型配置 - * 格式: { platform: [{ modelCode, modelName, consumePoints }] } + * 获取所有启用的服务配置列表(按平台分组) + * @returns {Promise} 按平台分组的服务配置 + * 格式: { platform: [{ serviceCode, serviceName, consumePoints }] } */ - async getEnabledModelConfigList() { + async getEnabledServiceConfigList() { const { data } = await http.get(`${BASE_URL}/list-enabled`) return data || {} }, /** - * 根据模型代码获取积分消耗 - * @param {Object} configMap - 配置映射(从 getEnabledModelConfigList 获取) - * @param {string} modelCode - 模型代码 + * 根据服务代码获取积分消耗 + * @param {Object} configMap - 配置映射(从 getEnabledServiceConfigList 获取) + * @param {string} serviceCode - 服务代码 * @returns {number|null} 积分消耗,未找到返回 null */ - getConsumePoints(configMap, modelCode) { - if (!configMap || !modelCode) return null + getConsumePoints(configMap, serviceCode) { + if (!configMap || !serviceCode) return null for (const platform of Object.values(configMap)) { - const model = platform?.find(m => m.modelCode === modelCode) - if (model) { - return model.consumePoints + const service = platform?.find(s => s.serviceCode === serviceCode) + if (service) { + return service.consumePoints } } return null }, /** - * 根据模型代码获取模型名称 + * 根据服务代码获取服务名称 * @param {Object} configMap - 配置映射 - * @param {string} modelCode - 模型代码 - * @returns {string|null} 模型名称,未找到返回 null + * @param {string} serviceCode - 服务代码 + * @returns {string|null} 服务名称,未找到返回 null */ - getModelName(configMap, modelCode) { - if (!configMap || !modelCode) return null + getServiceName(configMap, serviceCode) { + if (!configMap || !serviceCode) return null for (const platform of Object.values(configMap)) { - const model = platform?.find(m => m.modelCode === modelCode) - if (model) { - return model.modelName + const service = platform?.find(s => s.serviceCode === serviceCode) + if (service) { + return service.serviceName } } return null } } -export default ModelConfigService +// 兼容旧名称(逐步废弃) +export const ModelConfigService = ServiceConfigService + +export default ServiceConfigService diff --git a/frontend/app/web-gold/src/stores/pointsConfig.js b/frontend/app/web-gold/src/stores/pointsConfig.js index 0012330777..12ae3df7e1 100644 --- a/frontend/app/web-gold/src/stores/pointsConfig.js +++ b/frontend/app/web-gold/src/stores/pointsConfig.js @@ -1,18 +1,18 @@ /** * 积分配置 Store - * 管理AI模型积分消耗配置 + * 管理AI服务积分消耗配置 */ import { ref, computed } from 'vue' import { defineStore } from 'pinia' import { getJSON, setJSON } from '@/utils/storage' -import ModelConfigService from '@/api/modelConfig' +import ServiceConfigService from '@/api/modelConfig' const STORAGE_KEY = 'points_config_v1' const CACHE_DURATION = 30 * 60 * 1000 // 30分钟缓存 export const usePointsConfigStore = defineStore('pointsConfig', () => { - // 模型配置映射(按平台分组) + // 服务配置映射(按平台分组) const configMap = ref({}) // 是否已加载 const isLoaded = ref(false) @@ -24,57 +24,66 @@ export const usePointsConfigStore = defineStore('pointsConfig', () => { // 所有平台列表 const platforms = computed(() => Object.keys(configMap.value)) - // 获取所有模型列表(扁平化) - const allModels = computed(() => { - const models = [] + // 获取所有服务列表(扁平化) + const allServices = computed(() => { + const services = [] for (const [platform, list] of Object.entries(configMap.value)) { if (Array.isArray(list)) { - list.forEach(model => { - models.push({ ...model, platform }) + list.forEach(service => { + services.push({ ...service, platform }) }) } } - return models + return services }) + // 兼容:allModels 别名 + const allModels = allServices + /** - * 根据模型代码获取积分消耗 - * @param {string} modelCode - 模型代码 + * 根据服务代码获取积分消耗 + * @param {string} serviceCode - 服务代码 * @returns {number|null} 积分消耗 */ - const getConsumePoints = (modelCode) => { - if (!modelCode) return null - return ModelConfigService.getConsumePoints(configMap.value, modelCode) + const getConsumePoints = (serviceCode) => { + if (!serviceCode) return null + return ServiceConfigService.getConsumePoints(configMap.value, serviceCode) } /** - * 根据模型代码获取模型名称 - * @param {string} modelCode - 模型代码 - * @returns {string|null} 模型名称 + * 根据服务代码获取服务名称 + * @param {string} serviceCode - 服务代码 + * @returns {string|null} 服务名称 */ - const getModelName = (modelCode) => { - if (!modelCode) return null - return ModelConfigService.getModelName(configMap.value, modelCode) + const getServiceName = (serviceCode) => { + if (!serviceCode) return null + return ServiceConfigService.getServiceName(configMap.value, serviceCode) } + // 兼容:getModelName 别名 + const getModelName = getServiceName + /** - * 获取模型完整信息 - * @param {string} modelCode - 模型代码 - * @returns {Object|null} 模型信息 { modelCode, modelName, consumePoints, platform } + * 获取服务完整信息 + * @param {string} serviceCode - 服务代码 + * @returns {Object|null} 服务信息 { serviceCode, serviceName, consumePoints, platform } */ - const getModelInfo = (modelCode) => { - if (!modelCode) return null + const getServiceInfo = (serviceCode) => { + if (!serviceCode) return null for (const [platform, list] of Object.entries(configMap.value)) { if (Array.isArray(list)) { - const model = list.find(m => m.modelCode === modelCode) - if (model) { - return { ...model, platform } + const service = list.find(s => s.serviceCode === serviceCode) + if (service) { + return { ...service, platform } } } } return null } + // 兼容:getModelInfo 别名 + const getModelInfo = getServiceInfo + /** * 从本地存储恢复 */ @@ -98,7 +107,7 @@ export const usePointsConfigStore = defineStore('pointsConfig', () => { } /** - * 加载模型配置(从服务器) + * 加载服务配置(从服务器) * @param {boolean} force - 是否强制刷新 */ const loadConfig = async (force = false) => { @@ -115,14 +124,14 @@ export const usePointsConfigStore = defineStore('pointsConfig', () => { isLoading.value = true try { - const data = await ModelConfigService.getEnabledModelConfigList() + const data = await ServiceConfigService.getEnabledServiceConfigList() configMap.value = data || {} lastLoadTime.value = now isLoaded.value = true await persistToStorage() return configMap.value } catch (error) { - console.error('[pointsConfig] 加载模型配置失败:', error) + console.error('[pointsConfig] 加载服务配置失败:', error) throw error } finally { isLoading.value = false @@ -149,11 +158,14 @@ export const usePointsConfigStore = defineStore('pointsConfig', () => { isLoaded, isLoading, platforms, - allModels, + allServices, + allModels, // 兼容 // 方法 getConsumePoints, - getModelName, - getModelInfo, + getServiceName, + getModelName, // 兼容 + getServiceInfo, + getModelInfo, // 兼容 loadConfig, formatPoints, } diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/dify/service/DifyServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/dify/service/DifyServiceImpl.java index 8b76085e3b..d0a2fddac4 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/dify/service/DifyServiceImpl.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/dify/service/DifyServiceImpl.java @@ -10,7 +10,7 @@ import cn.iocoder.yudao.module.tik.enums.AiModelTypeEnum; import cn.iocoder.yudao.module.tik.enums.AiPlatformEnum; import cn.iocoder.yudao.module.tik.muye.aiagent.dal.AiAgentDO; import cn.iocoder.yudao.module.tik.muye.aiagent.service.AiAgentService; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; import cn.iocoder.yudao.module.tik.muye.points.service.PointsService; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -63,7 +63,7 @@ public class DifyServiceImpl implements DifyService { AiModelTypeEnum modelTypeEnum = "standard".equals(reqVO.getModelMode()) ? AiModelTypeEnum.DIFY_WRITING_STANDARD : AiModelTypeEnum.DIFY_WRITING_PRO; - AiModelConfigDO config = pointsService.getConfig( + AiServiceConfigDO config = pointsService.getConfig( AiPlatformEnum.DIFY.getPlatform(), modelTypeEnum.getModelCode()); @@ -161,7 +161,7 @@ public class DifyServiceImpl implements DifyService { AiModelTypeEnum modelTypeEnum = "forecast_pro".equals(reqVO.getModelType()) ? AiModelTypeEnum.FORECAST_PRO : AiModelTypeEnum.FORECAST_STANDARD; - AiModelConfigDO config = pointsService.getConfig( + AiServiceConfigDO config = pointsService.getConfig( AiPlatformEnum.DIFY.getPlatform(), modelTypeEnum.getModelCode()); @@ -277,7 +277,7 @@ public class DifyServiceImpl implements DifyService { } // 获取积分配置(使用标准模式的 API Key) - AiModelConfigDO config = pointsService.getConfig( + AiServiceConfigDO config = pointsService.getConfig( AiPlatformEnum.DIFY.getPlatform(), AiModelTypeEnum.DIFY_WRITING_STANDARD.getModelCode()); @@ -296,7 +296,7 @@ public class DifyServiceImpl implements DifyService { } // 获取积分配置(使用标准模式的 API Key) - AiModelConfigDO config = pointsService.getConfig( + AiServiceConfigDO config = pointsService.getConfig( AiPlatformEnum.DIFY.getPlatform(), AiModelTypeEnum.DIFY_WRITING_STANDARD.getModelCode()); diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/AiApplicationController.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/AiApplicationController.java deleted file mode 100644 index 792628d2b1..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/AiApplicationController.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aiapplication; - -import cn.iocoder.yudao.module.tik.muye.aiapplication.dal.AiApplicationDO; -import cn.iocoder.yudao.module.tik.muye.aiapplication.service.AiApplicationService; -import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationPageReqVO; -import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationRespVO; -import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationSaveReqVO; -import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import jakarta.validation.constraints.*; -import jakarta.validation.*; -import jakarta.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; - - -@Tag(name = "管理后台 - AI应用功能") -@RestController -@RequestMapping("/admin-api/muye/ai-application") -@Validated -public class AiApplicationController { - - @Resource - private AiApplicationService aiApplicationService; - - @PostMapping("/create") - @Operation(summary = "创建AI应用功能") - @PreAuthorize("@ss.hasPermission('muye:ai-application:create')") - public CommonResult createAiApplication(@Valid @RequestBody AiApplicationSaveReqVO createReqVO) { - return success(aiApplicationService.createAiApplication(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新AI应用功能") - @PreAuthorize("@ss.hasPermission('muye:ai-application:update')") - public CommonResult updateAiApplication(@Valid @RequestBody AiApplicationSaveReqVO updateReqVO) { - aiApplicationService.updateAiApplication(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除AI应用功能") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('muye:ai-application:delete')") - public CommonResult deleteAiApplication(@RequestParam("id") Long id) { - aiApplicationService.deleteAiApplication(id); - return success(true); - } - - @DeleteMapping("/delete-list") - @Parameter(name = "ids", description = "编号", required = true) - @Operation(summary = "批量删除AI应用功能") - @PreAuthorize("@ss.hasPermission('muye:ai-application:delete')") - public CommonResult deleteAiApplicationList(@RequestParam("ids") List ids) { - aiApplicationService.deleteAiApplicationListByIds(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得AI应用功能") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('muye:ai-application:query')") - public CommonResult getAiApplication(@RequestParam("id") Long id) { - AiApplicationDO aiApplication = aiApplicationService.getAiApplication(id); - return success(BeanUtils.toBean(aiApplication, AiApplicationRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得AI应用功能分页") - @PreAuthorize("@ss.hasPermission('muye:ai-application:query')") - public CommonResult> getAiApplicationPage(@Valid AiApplicationPageReqVO pageReqVO) { - PageResult pageResult = aiApplicationService.getAiApplicationPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, AiApplicationRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出AI应用功能 Excel") - @PreAuthorize("@ss.hasPermission('muye:ai-application:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportAiApplicationExcel(@Valid AiApplicationPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = aiApplicationService.getAiApplicationPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "AI应用功能.xls", "数据", AiApplicationRespVO.class, - BeanUtils.toBean(list, AiApplicationRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/dal/AiApplicationDO.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/dal/AiApplicationDO.java deleted file mode 100644 index 6675d11f08..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/dal/AiApplicationDO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aiapplication.dal; - -import lombok.*; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * AI应用功能 DO - * - * @author 芋道源码 - */ -@TableName("muye_ai_application") -@KeySequence("muye_ai_application_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class AiApplicationDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 应用ID - */ - private String appId; - /** - * 应用名称 - */ - private String appName; - /** - * 第三方API秘钥 - */ - private String apiKey; - /** - * 单位消耗积分 - */ - private Integer consumePoints; - /** - * 消耗单位(time-时长 count-次数) - */ - private String unitType; - /** - * 单位值(如:1min、20次) - */ - private String unitValue; - /** - * 状态(0-禁用 1-启用) - */ - private Integer status; - /** - * 备注 - */ - private String remark; - - -} diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/mapper/AiApplicationMapper.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/mapper/AiApplicationMapper.java deleted file mode 100644 index 1f4cc3bde3..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/mapper/AiApplicationMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aiapplication.mapper; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.tik.muye.aiapplication.dal.AiApplicationDO; -import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationPageReqVO; -import org.apache.ibatis.annotations.Mapper; - - -/** - * AI应用功能 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface AiApplicationMapper extends BaseMapperX { - - default PageResult selectPage(AiApplicationPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(AiApplicationDO::getAppId, reqVO.getAppId()) - .likeIfPresent(AiApplicationDO::getAppName, reqVO.getAppName()) - .eqIfPresent(AiApplicationDO::getApiKey, reqVO.getApiKey()) - .eqIfPresent(AiApplicationDO::getConsumePoints, reqVO.getConsumePoints()) - .eqIfPresent(AiApplicationDO::getUnitType, reqVO.getUnitType()) - .eqIfPresent(AiApplicationDO::getUnitValue, reqVO.getUnitValue()) - .eqIfPresent(AiApplicationDO::getStatus, reqVO.getStatus()) - .eqIfPresent(AiApplicationDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(AiApplicationDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(AiApplicationDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/service/AiApplicationService.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/service/AiApplicationService.java deleted file mode 100644 index 3e935cb16a..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/service/AiApplicationService.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aiapplication.service; - -import java.util.*; - -import cn.iocoder.yudao.module.tik.muye.aiapplication.dal.AiApplicationDO; -import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationPageReqVO; -import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationSaveReqVO; -import jakarta.validation.*; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -/** - * AI应用功能 Service 接口 - * - * @author 芋道源码 - */ -public interface AiApplicationService { - - /** - * 创建AI应用功能 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAiApplication(@Valid AiApplicationSaveReqVO createReqVO); - - /** - * 更新AI应用功能 - * - * @param updateReqVO 更新信息 - */ - void updateAiApplication(@Valid AiApplicationSaveReqVO updateReqVO); - - /** - * 删除AI应用功能 - * - * @param id 编号 - */ - void deleteAiApplication(Long id); - - /** - * 批量删除AI应用功能 - * - * @param ids 编号 - */ - void deleteAiApplicationListByIds(List ids); - - /** - * 获得AI应用功能 - * - * @param id 编号 - * @return AI应用功能 - */ - AiApplicationDO getAiApplication(Long id); - - /** - * 获得AI应用功能分页 - * - * @param pageReqVO 分页查询 - * @return AI应用功能分页 - */ - PageResult getAiApplicationPage(AiApplicationPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/service/AiApplicationServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/service/AiApplicationServiceImpl.java deleted file mode 100644 index 30ef3c331b..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/service/AiApplicationServiceImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aiapplication.service; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.module.tik.muye.aiapplication.dal.AiApplicationDO; -import cn.iocoder.yudao.module.tik.muye.aiapplication.mapper.AiApplicationMapper; -import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationPageReqVO; -import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationSaveReqVO; -import org.springframework.stereotype.Service; -import jakarta.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; - -/** - * AI应用功能 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class AiApplicationServiceImpl implements AiApplicationService { - - @Resource - private AiApplicationMapper aiApplicationMapper; - - @Override - public Long createAiApplication(AiApplicationSaveReqVO createReqVO) { - // 插入 - AiApplicationDO aiApplication = BeanUtils.toBean(createReqVO, AiApplicationDO.class); - aiApplicationMapper.insert(aiApplication); - - // 返回 - return aiApplication.getId(); - } - - @Override - public void updateAiApplication(AiApplicationSaveReqVO updateReqVO) { - // 校验存在 - validateAiApplicationExists(updateReqVO.getId()); - // 更新 - AiApplicationDO updateObj = BeanUtils.toBean(updateReqVO, AiApplicationDO.class); - aiApplicationMapper.updateById(updateObj); - } - - @Override - public void deleteAiApplication(Long id) { - // 校验存在 - validateAiApplicationExists(id); - // 删除 - aiApplicationMapper.deleteById(id); - } - - @Override - public void deleteAiApplicationListByIds(List ids) { - // 删除 - aiApplicationMapper.deleteByIds(ids); - } - - - private void validateAiApplicationExists(Long id) { - if (aiApplicationMapper.selectById(id) == null) { - throw exception(new ErrorCode(1004, "AI应用功能不存在")); - } - } - - @Override - public AiApplicationDO getAiApplication(Long id) { - return aiApplicationMapper.selectById(id); - } - - @Override - public PageResult getAiApplicationPage(AiApplicationPageReqVO pageReqVO) { - return aiApplicationMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationPageReqVO.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationPageReqVO.java deleted file mode 100644 index b782cbc2be..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationPageReqVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aiapplication.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - AI应用功能分页 Request VO") -@Data -public class AiApplicationPageReqVO extends PageParam { - - @Schema(description = "应用ID", example = "6241") - private String appId; - - @Schema(description = "应用名称", example = "芋艿") - private String appName; - - @Schema(description = "第三方API秘钥") - private String apiKey; - - @Schema(description = "单位消耗积分") - private Integer consumePoints; - - @Schema(description = "消耗单位(time-时长 count-次数)", example = "1") - private String unitType; - - @Schema(description = "单位值(如:1min、20次)") - private String unitValue; - - @Schema(description = "状态(0-禁用 1-启用)", example = "1") - private Integer status; - - @Schema(description = "备注", example = "你说的对") - private String remark; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationRespVO.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationRespVO.java deleted file mode 100644 index e8084d4375..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationRespVO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aiapplication.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.idev.excel.annotation.*; - -@Schema(description = "管理后台 - AI应用功能 Response VO") -@Data -@ExcelIgnoreUnannotated -public class AiApplicationRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "5521") - @ExcelProperty("主键") - private Long id; - - @Schema(description = "应用ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6241") - @ExcelProperty("应用ID") - private String appId; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @ExcelProperty("应用名称") - private String appName; - - @Schema(description = "第三方API秘钥", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("第三方API秘钥") - private String apiKey; - - @Schema(description = "单位消耗积分", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("单位消耗积分") - private Integer consumePoints; - - @Schema(description = "消耗单位(time-时长 count-次数)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("消耗单位(time-时长 count-次数)") - private String unitType; - - @Schema(description = "单位值(如:1min、20次)", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("单位值(如:1min、20次)") - private String unitValue; - - @Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("状态(0-禁用 1-启用)") - private Integer status; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationSaveReqVO.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationSaveReqVO.java deleted file mode 100644 index ef3af8a908..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiapplication/vo/AiApplicationSaveReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aiapplication.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - AI应用功能新增/修改 Request VO") -@Data -public class AiApplicationSaveReqVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "5521") - private Long id; - - @Schema(description = "应用ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6241") - @NotEmpty(message = "应用ID不能为空") - private String appId; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @NotEmpty(message = "应用名称不能为空") - private String appName; - - @Schema(description = "第三方API秘钥", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "第三方API秘钥不能为空") - private String apiKey; - - @Schema(description = "单位消耗积分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "单位消耗积分不能为空") - private Integer consumePoints; - - @Schema(description = "消耗单位(time-时长 count-次数)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "消耗单位(time-时长 count-次数)不能为空") - private String unitType; - - @Schema(description = "单位值(如:1min、20次)", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "单位值(如:1min、20次)不能为空") - private String unitValue; - - @Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态(0-禁用 1-启用)不能为空") - private Integer status; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") - @NotEmpty(message = "备注不能为空") - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/AiModelConfigController.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/AiModelConfigController.java deleted file mode 100644 index f00244e78e..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/AiModelConfigController.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig; - -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigPageReqVO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigRespVO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigSaveReqVO; -import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import jakarta.validation.constraints.*; -import jakarta.validation.*; -import jakarta.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.service.AiModelConfigService; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; - -@Tag(name = "管理后台 - AI模型配置") -@RestController -@RequestMapping("/admin-api/muye/ai-model-config") -@Validated -public class AiModelConfigController { - - @Resource - private AiModelConfigService aiModelConfigService; - - @PostMapping("/create") - @Operation(summary = "创建AI模型配置") - @PreAuthorize("@ss.hasPermission('muye:ai-model-config:create')") - public CommonResult createAiModelConfig(@Valid @RequestBody AiModelConfigSaveReqVO createReqVO) { - return success(aiModelConfigService.createAiModelConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新AI模型配置") - @PreAuthorize("@ss.hasPermission('muye:ai-model-config:update')") - public CommonResult updateAiModelConfig(@Valid @RequestBody AiModelConfigSaveReqVO updateReqVO) { - aiModelConfigService.updateAiModelConfig(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除AI模型配置") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('muye:ai-model-config:delete')") - public CommonResult deleteAiModelConfig(@RequestParam("id") Long id) { - aiModelConfigService.deleteAiModelConfig(id); - return success(true); - } - - @DeleteMapping("/delete-list") - @Parameter(name = "ids", description = "编号", required = true) - @Operation(summary = "批量删除AI模型配置") - @PreAuthorize("@ss.hasPermission('muye:ai-model-config:delete')") - public CommonResult deleteAiModelConfigList(@RequestParam("ids") List ids) { - aiModelConfigService.deleteAiModelConfigListByIds(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得AI模型配置") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('muye:ai-model-config:query')") - public CommonResult getAiModelConfig(@RequestParam("id") Long id) { - AiModelConfigDO aiModelConfig = aiModelConfigService.getAiModelConfig(id); - return success(BeanUtils.toBean(aiModelConfig, AiModelConfigRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得AI模型配置分页") - @PreAuthorize("@ss.hasPermission('muye:ai-model-config:query')") - public CommonResult> getAiModelConfigPage(@Valid AiModelConfigPageReqVO pageReqVO) { - PageResult pageResult = aiModelConfigService.getAiModelConfigPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, AiModelConfigRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出AI模型配置 Excel") - @PreAuthorize("@ss.hasPermission('muye:ai-model-config:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportAiModelConfigExcel(@Valid AiModelConfigPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = aiModelConfigService.getAiModelConfigPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "AI模型配置.xls", "数据", AiModelConfigRespVO.class, - BeanUtils.toBean(list, AiModelConfigRespVO.class)); - } - - @GetMapping("/list-enabled") - @Operation(summary = "获取所有启用的模型配置列表(前端积分显示用)") - @PreAuthorize("@ss.hasPermission('muye:ai-model-config:query')") - public CommonResult>> getEnabledModelConfigList() { - return success(aiModelConfigService.getEnabledModelConfigList()); - } - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/mapper/AiModelConfigMapper.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/mapper/AiModelConfigMapper.java deleted file mode 100644 index 4f77f752fa..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/mapper/AiModelConfigMapper.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig.mapper; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigPageReqVO; -import org.apache.ibatis.annotations.Mapper; - - -/** - * AI模型配置 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface AiModelConfigMapper extends BaseMapperX { - - default PageResult selectPage(AiModelConfigPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(AiModelConfigDO::getModelName, reqVO.getModelName()) - .eqIfPresent(AiModelConfigDO::getModelCode, reqVO.getModelCode()) - .eqIfPresent(AiModelConfigDO::getPlatform, reqVO.getPlatform()) - .eqIfPresent(AiModelConfigDO::getApiKey, reqVO.getApiKey()) - .eqIfPresent(AiModelConfigDO::getStatus, reqVO.getStatus()) - .eqIfPresent(AiModelConfigDO::getModelType, reqVO.getModelType()) - .eqIfPresent(AiModelConfigDO::getConsumePoints, reqVO.getConsumePoints()) - .eqIfPresent(AiModelConfigDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(AiModelConfigDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(AiModelConfigDO::getId)); - } - - /** - * 根据平台和模型标识查询配置 - */ - default AiModelConfigDO selectByPlatformAndModelCode(String platform, String modelCode) { - return selectOne(new LambdaQueryWrapperX() - .eq(AiModelConfigDO::getPlatform, platform) - .eq(AiModelConfigDO::getModelCode, modelCode) - .eq(AiModelConfigDO::getStatus, 1)); - } - - /** - * 查询所有启用的模型配置 - */ - default List selectEnabledList() { - return selectList(new LambdaQueryWrapperX() - .eq(AiModelConfigDO::getStatus, 1) - .orderByAsc(AiModelConfigDO::getPlatform, AiModelConfigDO::getModelCode)); - } - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/service/AiModelConfigService.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/service/AiModelConfigService.java deleted file mode 100644 index 24e437ea50..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/service/AiModelConfigService.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig.service; - -import java.util.*; -import lombok.Data; - -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigPageReqVO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigSaveReqVO; -import jakarta.validation.*; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -/** - * AI模型配置 Service 接口 - * - * @author 芋道源码 - */ -public interface AiModelConfigService { - - /** - * 创建AI模型配置 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAiModelConfig(@Valid AiModelConfigSaveReqVO createReqVO); - - /** - * 更新AI模型配置 - * - * @param updateReqVO 更新信息 - */ - void updateAiModelConfig(@Valid AiModelConfigSaveReqVO updateReqVO); - - /** - * 删除AI模型配置 - * - * @param id 编号 - */ - void deleteAiModelConfig(Long id); - - /** - * 批量删除AI模型配置 - * - * @param ids 编号 - */ - void deleteAiModelConfigListByIds(List ids); - - /** - * 获得AI模型配置 - * - * @param id 编号 - * @return AI模型配置 - */ - AiModelConfigDO getAiModelConfig(Long id); - - /** - * 获得AI模型配置分页 - * - * @param pageReqVO 分页查询 - * @return AI模型配置分页 - */ - PageResult getAiModelConfigPage(AiModelConfigPageReqVO pageReqVO); - - /** - * 获取所有启用的模型配置列表(前端积分显示用) - * - * @return 模型配置列表(按平台分组) - */ - Map> getEnabledModelConfigList(); - - /** - * 启用的模型配置简单VO(用于前端显示) - */ - @Data - class ModelConfigSimpleVO { - private String modelCode; - private String modelName; - private Integer consumePoints; - } - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/service/AiModelConfigServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/service/AiModelConfigServiceImpl.java deleted file mode 100644 index 9e15faca65..0000000000 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/service/AiModelConfigServiceImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig.service; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.mapper.AiModelConfigMapper; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigPageReqVO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigSaveReqVO; -import org.springframework.stereotype.Service; -import jakarta.annotation.Resource; -import org.springframework.validation.annotation.Validated; - - -import java.util.*; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; - -/** - * AI模型配置 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class AiModelConfigServiceImpl implements AiModelConfigService { - - @Resource - private AiModelConfigMapper aiModelConfigMapper; - - @Override - public Long createAiModelConfig(AiModelConfigSaveReqVO createReqVO) { - // 插入 - AiModelConfigDO aiModelConfig = BeanUtils.toBean(createReqVO, AiModelConfigDO.class); - aiModelConfigMapper.insert(aiModelConfig); - - // 返回 - return aiModelConfig.getId(); - } - - @Override - public void updateAiModelConfig(AiModelConfigSaveReqVO updateReqVO) { - // 校验存在 - validateAiModelConfigExists(updateReqVO.getId()); - // 更新 - AiModelConfigDO updateObj = BeanUtils.toBean(updateReqVO, AiModelConfigDO.class); - aiModelConfigMapper.updateById(updateObj); - } - - @Override - public void deleteAiModelConfig(Long id) { - // 校验存在 - validateAiModelConfigExists(id); - // 删除 - aiModelConfigMapper.deleteById(id); - } - - @Override - public void deleteAiModelConfigListByIds(List ids) { - // 删除 - aiModelConfigMapper.deleteByIds(ids); - } - - - private void validateAiModelConfigExists(Long id) { - if (aiModelConfigMapper.selectById(id) == null) { - throw exception(new ErrorCode(1004, "AI模型配置不存在")); - } - } - - @Override - public AiModelConfigDO getAiModelConfig(Long id) { - return aiModelConfigMapper.selectById(id); - } - - @Override - public PageResult getAiModelConfigPage(AiModelConfigPageReqVO pageReqVO) { - return aiModelConfigMapper.selectPage(pageReqVO); - } - - @Override - public Map> getEnabledModelConfigList() { - List configList = aiModelConfigMapper.selectEnabledList(); - Map> result = new HashMap<>(); - for (AiModelConfigDO config : configList) { - ModelConfigSimpleVO simpleVO = new ModelConfigSimpleVO(); - simpleVO.setModelCode(config.getModelCode()); - simpleVO.setModelName(config.getModelName()); - simpleVO.setConsumePoints(config.getConsumePoints()); - result.computeIfAbsent(config.getPlatform(), k -> new ArrayList<>()).add(simpleVO); - } - return result; - } - -} \ No newline at end of file diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/AiServiceConfigController.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/AiServiceConfigController.java new file mode 100644 index 0000000000..4310f05df0 --- /dev/null +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/AiServiceConfigController.java @@ -0,0 +1,111 @@ +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig; + +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigPageReqVO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigRespVO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigSaveReqVO; +import org.springframework.web.bind.annotation.*; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import jakarta.validation.constraints.*; +import jakarta.validation.*; +import jakarta.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.service.AiServiceConfigService; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +@Tag(name = "管理后台 - AI第三方服务配置") +@RestController +@RequestMapping("/admin-api/muye/ai-service-config") +@Validated +public class AiServiceConfigController { + + @Resource + private AiServiceConfigService aiServiceConfigService; + + @PostMapping("/create") + @Operation(summary = "创建AI服务配置") + @PreAuthorize("@ss.hasPermission('muye:ai-service-config:create')") + public CommonResult createAiServiceConfig(@Valid @RequestBody AiServiceConfigSaveReqVO createReqVO) { + return success(aiServiceConfigService.createAiServiceConfig(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新AI服务配置") + @PreAuthorize("@ss.hasPermission('muye:ai-service-config:update')") + public CommonResult updateAiServiceConfig(@Valid @RequestBody AiServiceConfigSaveReqVO updateReqVO) { + aiServiceConfigService.updateAiServiceConfig(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除AI服务配置") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('muye:ai-service-config:delete')") + public CommonResult deleteAiServiceConfig(@RequestParam("id") Long id) { + aiServiceConfigService.deleteAiServiceConfig(id); + return success(true); + } + + @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除AI服务配置") + @PreAuthorize("@ss.hasPermission('muye:ai-service-config:delete')") + public CommonResult deleteAiServiceConfigList(@RequestParam("ids") List ids) { + aiServiceConfigService.deleteAiServiceConfigListByIds(ids); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得AI服务配置") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('muye:ai-service-config:query')") + public CommonResult getAiServiceConfig(@RequestParam("id") Long id) { + AiServiceConfigDO aiServiceConfig = aiServiceConfigService.getAiServiceConfig(id); + return success(BeanUtils.toBean(aiServiceConfig, AiServiceConfigRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得AI服务配置分页") + @PreAuthorize("@ss.hasPermission('muye:ai-service-config:query')") + public CommonResult> getAiServiceConfigPage(@Valid AiServiceConfigPageReqVO pageReqVO) { + PageResult pageResult = aiServiceConfigService.getAiServiceConfigPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, AiServiceConfigRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出AI服务配置 Excel") + @PreAuthorize("@ss.hasPermission('muye:ai-service-config:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportAiServiceConfigExcel(@Valid AiServiceConfigPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = aiServiceConfigService.getAiServiceConfigPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "AI服务配置.xls", "数据", AiServiceConfigRespVO.class, + BeanUtils.toBean(list, AiServiceConfigRespVO.class)); + } + + @GetMapping("/list-enabled") + @Operation(summary = "获取所有启用的服务配置列表(前端积分显示用)") + @PreAuthorize("@ss.hasPermission('muye:ai-service-config:query')") + public CommonResult>> getEnabledServiceConfigList() { + return success(aiServiceConfigService.getEnabledServiceConfigList()); + } + +} diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/AppAiModelConfigController.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/AppAiServiceConfigController.java similarity index 51% rename from yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/AppAiModelConfigController.java rename to yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/AppAiServiceConfigController.java index e73c06fa8b..2606a64784 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/AppAiModelConfigController.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/AppAiServiceConfigController.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig; +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.service.AiModelConfigService; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.service.AiServiceConfigService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -16,21 +16,21 @@ import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** - * 用户 App - AI模型配置 + * 用户 App - AI第三方服务配置 */ -@Tag(name = "用户 App - AI模型配置") +@Tag(name = "用户 App - AI第三方服务配置") @RestController -@RequestMapping("/api/tik/ai-model-config") +@RequestMapping("/api/tik/ai-service-config") @Validated -public class AppAiModelConfigController { +public class AppAiServiceConfigController { @Resource - private AiModelConfigService aiModelConfigService; + private AiServiceConfigService aiServiceConfigService; @GetMapping("/list-enabled") - @Operation(summary = "获取所有启用的模型配置列表(前端积分显示用)") - public CommonResult>> getEnabledModelConfigList() { - return success(aiModelConfigService.getEnabledModelConfigList()); + @Operation(summary = "获取所有启用的服务配置列表(前端积分显示用)") + public CommonResult>> getEnabledServiceConfigList() { + return success(aiServiceConfigService.getEnabledServiceConfigList()); } } diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/dal/AiModelConfigDO.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/dal/AiServiceConfigDO.java similarity index 60% rename from yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/dal/AiModelConfigDO.java rename to yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/dal/AiServiceConfigDO.java index 86569771c1..bed9b41b93 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/dal/AiModelConfigDO.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/dal/AiServiceConfigDO.java @@ -1,23 +1,23 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal; +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal; import lombok.*; import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; /** - * AI模型配置 DO + * AI第三方服务配置 DO * * @author 芋道源码 */ -@TableName("muye_ai_model_config") -@KeySequence("muye_ai_model_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@TableName("muye_ai_service_config") +@KeySequence("muye_ai_service_config_seq") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @Builder @NoArgsConstructor @AllArgsConstructor -public class AiModelConfigDO extends BaseDO { +public class AiServiceConfigDO extends BaseDO { /** * 主键 @@ -25,13 +25,13 @@ public class AiModelConfigDO extends BaseDO { @TableId private Long id; /** - * 模型名称 + * 服务名称 */ - private String modelName; + private String serviceName; /** - * 模型标识/编码 + * 服务标识 */ - private String modelCode; + private String serviceCode; /** * 所属平台 */ @@ -45,7 +45,7 @@ public class AiModelConfigDO extends BaseDO { */ private Integer status; /** - * 模型类型(image-图像 text-文本 video-视频 audio-音频) + * 服务类型(image-图像 text-文本 video-视频 audio-音频) */ private String modelType; /** @@ -57,5 +57,4 @@ public class AiModelConfigDO extends BaseDO { */ private String remark; - } diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/mapper/AiServiceConfigMapper.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/mapper/AiServiceConfigMapper.java new file mode 100644 index 0000000000..f33bfc917b --- /dev/null +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/mapper/AiServiceConfigMapper.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.mapper; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigPageReqVO; +import org.apache.ibatis.annotations.Mapper; + + +/** + * AI第三方服务配置 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface AiServiceConfigMapper extends BaseMapperX { + + default PageResult selectPage(AiServiceConfigPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(AiServiceConfigDO::getServiceName, reqVO.getServiceName()) + .eqIfPresent(AiServiceConfigDO::getServiceCode, reqVO.getServiceCode()) + .eqIfPresent(AiServiceConfigDO::getPlatform, reqVO.getPlatform()) + .eqIfPresent(AiServiceConfigDO::getApiKey, reqVO.getApiKey()) + .eqIfPresent(AiServiceConfigDO::getStatus, reqVO.getStatus()) + .eqIfPresent(AiServiceConfigDO::getModelType, reqVO.getModelType()) + .eqIfPresent(AiServiceConfigDO::getConsumePoints, reqVO.getConsumePoints()) + .eqIfPresent(AiServiceConfigDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(AiServiceConfigDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(AiServiceConfigDO::getId)); + } + + /** + * 根据平台和服务标识查询配置 + */ + default AiServiceConfigDO selectByPlatformAndServiceCode(String platform, String serviceCode) { + return selectOne(new LambdaQueryWrapperX() + .eq(AiServiceConfigDO::getPlatform, platform) + .eq(AiServiceConfigDO::getServiceCode, serviceCode) + .eq(AiServiceConfigDO::getStatus, 1)); + } + + /** + * 查询所有启用的服务配置 + */ + default List selectEnabledList() { + return selectList(new LambdaQueryWrapperX() + .eq(AiServiceConfigDO::getStatus, 1) + .orderByAsc(AiServiceConfigDO::getPlatform, AiServiceConfigDO::getServiceCode)); + } + +} diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/service/AiServiceConfigService.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/service/AiServiceConfigService.java new file mode 100644 index 0000000000..aacff48604 --- /dev/null +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/service/AiServiceConfigService.java @@ -0,0 +1,81 @@ +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.service; + +import java.util.*; +import lombok.Data; + +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigPageReqVO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigSaveReqVO; +import jakarta.validation.*; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * AI第三方服务配置 Service 接口 + * + * @author 芋道源码 + */ +public interface AiServiceConfigService { + + /** + * 创建AI服务配置 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createAiServiceConfig(@Valid AiServiceConfigSaveReqVO createReqVO); + + /** + * 更新AI服务配置 + * + * @param updateReqVO 更新信息 + */ + void updateAiServiceConfig(@Valid AiServiceConfigSaveReqVO updateReqVO); + + /** + * 删除AI服务配置 + * + * @param id 编号 + */ + void deleteAiServiceConfig(Long id); + + /** + * 批量删除AI服务配置 + * + * @param ids 编号 + */ + void deleteAiServiceConfigListByIds(List ids); + + /** + * 获得AI服务配置 + * + * @param id 编号 + * @return AI服务配置 + */ + AiServiceConfigDO getAiServiceConfig(Long id); + + /** + * 获得AI服务配置分页 + * + * @param pageReqVO 分页查询 + * @return AI服务配置分页 + */ + PageResult getAiServiceConfigPage(AiServiceConfigPageReqVO pageReqVO); + + /** + * 获取所有启用的服务配置列表(前端积分显示用) + * + * @return 服务配置列表(按平台分组) + */ + Map> getEnabledServiceConfigList(); + + /** + * 启用的服务配置简单VO(用于前端显示) + */ + @Data + class ServiceConfigSimpleVO { + private String serviceCode; + private String serviceName; + private Integer consumePoints; + } + +} diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/service/AiServiceConfigServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/service/AiServiceConfigServiceImpl.java new file mode 100644 index 0000000000..92e7702a03 --- /dev/null +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/service/AiServiceConfigServiceImpl.java @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.service; + +import cn.iocoder.yudao.framework.common.exception.ErrorCode; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.mapper.AiServiceConfigMapper; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigPageReqVO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigSaveReqVO; +import org.springframework.stereotype.Service; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; + + +import java.util.*; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; + +/** + * AI第三方服务配置 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class AiServiceConfigServiceImpl implements AiServiceConfigService { + + @Resource + private AiServiceConfigMapper aiServiceConfigMapper; + + @Override + public Long createAiServiceConfig(AiServiceConfigSaveReqVO createReqVO) { + // 插入 + AiServiceConfigDO aiServiceConfig = BeanUtils.toBean(createReqVO, AiServiceConfigDO.class); + aiServiceConfigMapper.insert(aiServiceConfig); + + // 返回 + return aiServiceConfig.getId(); + } + + @Override + public void updateAiServiceConfig(AiServiceConfigSaveReqVO updateReqVO) { + // 校验存在 + validateAiServiceConfigExists(updateReqVO.getId()); + // 更新 + AiServiceConfigDO updateObj = BeanUtils.toBean(updateReqVO, AiServiceConfigDO.class); + aiServiceConfigMapper.updateById(updateObj); + } + + @Override + public void deleteAiServiceConfig(Long id) { + // 校验存在 + validateAiServiceConfigExists(id); + // 删除 + aiServiceConfigMapper.deleteById(id); + } + + @Override + public void deleteAiServiceConfigListByIds(List ids) { + // 删除 + aiServiceConfigMapper.deleteByIds(ids); + } + + + private void validateAiServiceConfigExists(Long id) { + if (aiServiceConfigMapper.selectById(id) == null) { + throw exception(new ErrorCode(1004, "AI服务配置不存在")); + } + } + + @Override + public AiServiceConfigDO getAiServiceConfig(Long id) { + return aiServiceConfigMapper.selectById(id); + } + + @Override + public PageResult getAiServiceConfigPage(AiServiceConfigPageReqVO pageReqVO) { + return aiServiceConfigMapper.selectPage(pageReqVO); + } + + @Override + public Map> getEnabledServiceConfigList() { + List configList = aiServiceConfigMapper.selectEnabledList(); + Map> result = new HashMap<>(); + for (AiServiceConfigDO config : configList) { + ServiceConfigSimpleVO simpleVO = new ServiceConfigSimpleVO(); + simpleVO.setServiceCode(config.getServiceCode()); + simpleVO.setServiceName(config.getServiceName()); + simpleVO.setConsumePoints(config.getConsumePoints()); + result.computeIfAbsent(config.getPlatform(), k -> new ArrayList<>()).add(simpleVO); + } + return result; + } + +} diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigPageReqVO.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigPageReqVO.java similarity index 61% rename from yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigPageReqVO.java rename to yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigPageReqVO.java index d0018130d0..3be2e08e79 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigPageReqVO.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigPageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo; +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo; import lombok.*; import io.swagger.v3.oas.annotations.media.Schema; @@ -8,16 +8,16 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - AI模型配置分页 Request VO") +@Schema(description = "管理后台 - AI第三方服务配置分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) -public class AiModelConfigPageReqVO extends SortablePageParam { +public class AiServiceConfigPageReqVO extends SortablePageParam { - @Schema(description = "模型名称", example = "李四") - private String modelName; + @Schema(description = "服务名称", example = "AI文案-Pro版") + private String serviceName; - @Schema(description = "模型标识/编码") - private String modelCode; + @Schema(description = "服务标识") + private String serviceCode; @Schema(description = "所属平台") private String platform; @@ -25,20 +25,20 @@ public class AiModelConfigPageReqVO extends SortablePageParam { @Schema(description = "API秘钥") private String apiKey; - @Schema(description = "状态(0-禁用 1-启用)", example = "2") + @Schema(description = "状态(0-禁用 1-启用)", example = "1") private Integer status; - @Schema(description = "模型类型(image-图像 text-文本 video-视频 audio-音频)", example = "2") + @Schema(description = "服务类型(image-图像 text-文本 video-视频 audio-音频)", example = "text") private String modelType; @Schema(description = "消耗积分") private Integer consumePoints; - @Schema(description = "备注", example = "随便") + @Schema(description = "备注", example = "备注信息") private String remark; @Schema(description = "创建时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; -} \ No newline at end of file +} diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigRespVO.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigRespVO.java similarity index 59% rename from yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigRespVO.java rename to yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigRespVO.java index 4a47237c56..1936515912 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigRespVO.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigRespVO.java @@ -1,26 +1,26 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo; +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.time.LocalDateTime; import cn.idev.excel.annotation.*; -@Schema(description = "管理后台 - AI模型配置 Response VO") +@Schema(description = "管理后台 - AI第三方服务配置 Response VO") @Data @ExcelIgnoreUnannotated -public class AiModelConfigRespVO { +public class AiServiceConfigRespVO { @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29327") @ExcelProperty("主键") private Long id; - @Schema(description = "模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("模型名称") - private String modelName; + @Schema(description = "服务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "AI文案-Pro版") + @ExcelProperty("服务名称") + private String serviceName; - @Schema(description = "模型标识/编码", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("模型标识/编码") - private String modelCode; + @Schema(description = "服务标识", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("服务标识") + private String serviceCode; @Schema(description = "所属平台", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("所属平台") @@ -30,19 +30,19 @@ public class AiModelConfigRespVO { @ExcelProperty("API秘钥") private String apiKey; - @Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @ExcelProperty("状态(0-禁用 1-启用)") private Integer status; - @Schema(description = "模型类型(image-图像 text-文本 video-视频 audio-音频)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("模型类型(image-图像 text-文本 video-视频 audio-音频)") + @Schema(description = "服务类型(image-图像 text-文本 video-视频 audio-音频)", requiredMode = Schema.RequiredMode.REQUIRED, example = "text") + @ExcelProperty("服务类型") private String modelType; @Schema(description = "消耗积分", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("消耗积分") private Integer consumePoints; - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") + @Schema(description = "备注", example = "备注信息") @ExcelProperty("备注") private String remark; diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigSaveReqVO.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigSaveReqVO.java similarity index 52% rename from yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigSaveReqVO.java rename to yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigSaveReqVO.java index 158d57edeb..3b42b3f16d 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aimodelconfig/vo/AiModelConfigSaveReqVO.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiserviceconfig/vo/AiServiceConfigSaveReqVO.java @@ -1,23 +1,23 @@ -package cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo; +package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import jakarta.validation.constraints.*; -@Schema(description = "管理后台 - AI模型配置新增/修改 Request VO") +@Schema(description = "管理后台 - AI第三方服务配置新增/修改 Request VO") @Data -public class AiModelConfigSaveReqVO { +public class AiServiceConfigSaveReqVO { @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29327") private Long id; - @Schema(description = "模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "模型名称不能为空") - private String modelName; + @Schema(description = "服务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "AI文案-Pro版") + @NotEmpty(message = "服务名称不能为空") + private String serviceName; - @Schema(description = "模型标识/编码", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "模型标识/编码不能为空") - private String modelCode; + @Schema(description = "服务标识", requiredMode = Schema.RequiredMode.REQUIRED) + @NotEmpty(message = "服务标识不能为空") + private String serviceCode; @Schema(description = "所属平台", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "所属平台不能为空") @@ -26,19 +26,19 @@ public class AiModelConfigSaveReqVO { @Schema(description = "API秘钥") private String apiKey; - @Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @NotNull(message = "状态不能为空") private Integer status; - @Schema(description = "模型类型(image-图像 text-文本 video-视频 audio-音频)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotEmpty(message = "模型类型不能为空") + @Schema(description = "服务类型(image-图像 text-文本 video-视频 audio-音频)", requiredMode = Schema.RequiredMode.REQUIRED, example = "text") + @NotEmpty(message = "服务类型不能为空") private String modelType; @Schema(description = "消耗积分", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "消耗积分不能为空") private Integer consumePoints; - @Schema(description = "备注", example = "随便") + @Schema(description = "备注", example = "备注信息") private String remark; -} \ No newline at end of file +} diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/points/service/PointsService.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/points/service/PointsService.java index e57ee7b898..a2bb6b3957 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/points/service/PointsService.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/points/service/PointsService.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.tik.muye.points.service; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; /** * 积分扣减公共服务 @@ -12,11 +12,11 @@ public interface PointsService { /** * 获取积分配置 * - * @param platform 平台标识(dify/tikhub/voice/digital_human) - * @param modelCode 模型标识 + * @param platform 平台标识(dify/tikhub/voice/digital_human) + * @param serviceCode 服务标识 * @return 积分配置 */ - AiModelConfigDO getConfig(String platform, String modelCode); + AiServiceConfigDO getConfig(String platform, String serviceCode); /** * 预检积分(余额不足抛异常) diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/points/service/PointsServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/points/service/PointsServiceImpl.java index fff2414924..0ea48539ac 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/points/service/PointsServiceImpl.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/points/service/PointsServiceImpl.java @@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.tik.muye.points.service; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.mapper.AiModelConfigMapper; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.mapper.AiServiceConfigMapper; import cn.iocoder.yudao.module.tik.muye.memberuserprofile.dal.MemberUserProfileDO; import cn.iocoder.yudao.module.tik.muye.memberuserprofile.mapper.MemberUserProfileMapper; import cn.iocoder.yudao.module.tik.muye.pointrecord.dal.PointRecordDO; @@ -37,7 +37,7 @@ public class PointsServiceImpl implements PointsService { private static final String STATUS_CANCELED = "canceled"; @Resource - private AiModelConfigMapper aiModelConfigMapper; + private AiServiceConfigMapper aiServiceConfigMapper; @Resource private MemberUserProfileMapper memberUserProfileMapper; @@ -49,8 +49,8 @@ public class PointsServiceImpl implements PointsService { private MemberUserService memberUserService; @Override - public AiModelConfigDO getConfig(String platform, String modelCode) { - AiModelConfigDO config = aiModelConfigMapper.selectByPlatformAndModelCode(platform, modelCode); + public AiServiceConfigDO getConfig(String platform, String serviceCode) { + AiServiceConfigDO config = aiServiceConfigMapper.selectByPlatformAndServiceCode(platform, serviceCode); if (config == null) { throw exception(POINTS_CONFIG_NOT_FOUND); } diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/tikhup/service/TikHupServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/tikhup/service/TikHupServiceImpl.java index 6eafbca82c..513c8c1711 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/tikhup/service/TikHupServiceImpl.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/tikhup/service/TikHupServiceImpl.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.tik.tikhup.service; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; import cn.iocoder.yudao.module.tik.muye.points.service.PointsService; import cn.iocoder.yudao.module.tik.tikhup.mapper.TikPromptMapper; import cn.iocoder.yudao.module.tik.tikhup.mapper.TikTokenMapper; @@ -94,7 +94,7 @@ public class TikHupServiceImpl implements TikHupService { // 2. 获取当前用户ID并预检积分 Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); String userId = loginUserId != null ? loginUserId.toString() : "1"; - AiModelConfigDO config; + AiServiceConfigDO config; try { config = pointsService.getConfig(PLATFORM_TIKHUB, MODEL_CODE_CRAWLER); pointsService.checkPoints(userId, config.getConsumePoints()); diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/voice/service/DigitalHumanTaskServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/voice/service/DigitalHumanTaskServiceImpl.java index 42a20f7f8c..0398424f69 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/voice/service/DigitalHumanTaskServiceImpl.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/voice/service/DigitalHumanTaskServiceImpl.java @@ -17,7 +17,7 @@ import cn.iocoder.yudao.module.tik.file.dal.dataobject.TikUserFileDO; import cn.iocoder.yudao.module.tik.file.dal.mysql.TikUserFileMapper; import cn.iocoder.yudao.module.tik.file.service.TikOssInitService; import cn.iocoder.yudao.module.tik.kling.dto.KlingLipSyncCreateResponse; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; import cn.iocoder.yudao.module.tik.muye.points.service.PointsService; import cn.iocoder.yudao.module.tik.voice.dal.dataobject.TikDigitalHumanTaskDO; import cn.iocoder.yudao.module.tik.voice.dal.dataobject.TikUserVoiceDO; @@ -98,7 +98,7 @@ public class DigitalHumanTaskServiceImpl implements DigitalHumanTaskService { // 2. 积分预检和预扣 String aiProvider = StrUtil.blankToDefault(reqVO.getAiProvider(), "302ai"); String modelCode = "kling".equalsIgnoreCase(aiProvider) ? MODEL_CODE_KLING : MODEL_CODE_LATENTSYNC; - AiModelConfigDO config = pointsService.getConfig(PLATFORM_DIGITAL_HUMAN, modelCode); + AiServiceConfigDO config = pointsService.getConfig(PLATFORM_DIGITAL_HUMAN, modelCode); pointsService.checkPoints(userId.toString(), config.getConsumePoints()); Long pendingRecordId = pointsService.createPendingDeduct( userId.toString(), diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/voice/service/TikUserVoiceServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/voice/service/TikUserVoiceServiceImpl.java index baead9f423..76f2f6e1e2 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/voice/service/TikUserVoiceServiceImpl.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/voice/service/TikUserVoiceServiceImpl.java @@ -25,7 +25,7 @@ import cn.iocoder.yudao.module.tik.voice.client.VoiceCloneProvider; import cn.iocoder.yudao.module.tik.voice.client.VoiceCloneProviderFactory; import cn.iocoder.yudao.module.tik.voice.client.dto.VoiceTtsRequest; import cn.iocoder.yudao.module.tik.voice.client.dto.VoiceTtsResult; -import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO; +import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO; import cn.iocoder.yudao.module.tik.muye.points.service.PointsService; import cn.iocoder.yudao.module.tik.voice.dal.dataobject.TikUserVoiceDO; import cn.iocoder.yudao.module.tik.voice.dal.mysql.TikUserVoiceMapper; @@ -414,7 +414,7 @@ public class TikUserVoiceServiceImpl implements TikUserVoiceService { } // 获取积分配置并预检(缓存未命中,需要实际调用 TTS) - AiModelConfigDO ttsConfig = pointsService.getConfig(PLATFORM_VOICE, MODEL_CODE_TTS); + AiServiceConfigDO ttsConfig = pointsService.getConfig(PLATFORM_VOICE, MODEL_CODE_TTS); pointsService.checkPoints(userId.toString(), ttsConfig.getConsumePoints()); // 使用 Provider 接口进行 TTS 合成(支持前端选择供应商,不传则使用默认) diff --git a/yudao-module-tik/src/main/resources/mapper/muye/aimodelconfig/AiModelConfigMapper.xml b/yudao-module-tik/src/main/resources/mapper/muye/aiserviceconfig/AiServiceConfigMapper.xml similarity index 84% rename from yudao-module-tik/src/main/resources/mapper/muye/aimodelconfig/AiModelConfigMapper.xml rename to yudao-module-tik/src/main/resources/mapper/muye/aiserviceconfig/AiServiceConfigMapper.xml index 268268424e..ad7de1580f 100644 --- a/yudao-module-tik/src/main/resources/mapper/muye/aimodelconfig/AiModelConfigMapper.xml +++ b/yudao-module-tik/src/main/resources/mapper/muye/aiserviceconfig/AiServiceConfigMapper.xml @@ -1,6 +1,6 @@ - + - + \ No newline at end of file + diff --git a/yudao-ui-admin-vue3/src/views/muye/memberuserprofile/index.vue b/yudao-ui-admin-vue3/src/views/muye/memberuserprofile/index.vue index 09fd405984..7a017a0278 100644 --- a/yudao-ui-admin-vue3/src/views/muye/memberuserprofile/index.vue +++ b/yudao-ui-admin-vue3/src/views/muye/memberuserprofile/index.vue @@ -92,9 +92,9 @@ :formatter="dateFormatter" width="180px" /> - - - + + +