diff --git a/README.md b/README.md index 0517aff..faf84ee 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ ### 背景介绍 -AI Code 是一个企业级智能代码生成与协作平台,旨在利用人工智能技术提升软件开发效率。随着大语言模型(LLM)技术的快速发展,我们看到了将 AI 能力与软件开发流程深度结合的巨大潜力。本项目提供了一个完整的解决方案,涵盖从代码生成、团队协作到积分管理的全流程功能。 +AI Code 是一个企业级智能代码生成与协作平台,旨在利用人工智能技术提升软件开发效率。随着大语言模型(LLM)技术的快速发展,我们看到了将 AI 能力与软件开发流程深度结合的巨大潜力。本项目提供了一个完整的解决方案,涵盖从代码生成、多模型支持、团队协作到积分管理的全流程功能。 传统的代码生成工具往往只关注单一场景,缺乏企业级的权限管理、团队协作和成本控制能力。AI Code 正是为解决这些痛点而设计,我们希望构建一个既能满足个人开发者需求,又适合企业团队使用的综合性平台。 @@ -56,7 +56,7 @@ AI Code 适用于多种实际应用场景。对于个人开发者而言,它可 ### 智能代码生成 -平台采用模块化的代码生成架构。核心代码生成引擎基于 LangChain4j 框架构建,能够灵活调用 AI 大模型。用户可以通过自然语言描述需求,系统自动生成完整的代码实现。生成结果支持多文件输出,满足复杂项目的需求。同时,平台集成了代码片段搜索功能,可以在生成过程中参考已有代码库,提高代码质量和一致性。 +平台采用模块化的代码生成架构,支持多种代码生成策略。核心代码生成引擎基于 LangChain4j 框架构建,能够灵活适配不同的大模型提供商。用户可以通过自然语言描述需求,系统自动生成完整的代码实现。生成结果支持多文件输出,满足复杂项目的需求。同时,平台集成了代码片段搜索功能,可以在生成过程中参考已有代码库,提高代码质量和一致性。 ### 多人协作可视化编辑 @@ -101,9 +101,6 @@ sequenceDiagram B-->>A: 11. 释放编辑锁 ``` -示例: -![img.png](img.png) - **核心代码实现:** ```java @@ -753,47 +750,43 @@ public class RedisCacheManagerConfig { } ``` -**AI 模型服务实现:** +**模型工厂缓存实现(Caffeine + Redis):** ```java -// AI 代码生成服务工厂 +// 动态 AI 模型工厂(双层缓存) @Service @Slf4j -public class AiCodeGeneratorServiceFactory { - - @Resource(name = "streamingChatModelPrototype") - private StreamingChatModel streamingChatModel; - - @Resource - private AppService appService; - - @Resource - private UserPointService userPointService; +public class DynamicAiModelFactory { + + // 本地缓存(Caffeine)- 一级缓存 + private final Cache modelCache = Caffeine.newBuilder() + .maximumSize(100) + .expireAfterWrite(Duration.ofMinutes(30)) // 写入 30 分钟后过期 + .expireAfterAccess(Duration.ofMinutes(10)) // 访问 10 分钟后过期 + .removalListener((key, value, cause) -> { + log.debug("StreamingChatModel 被移除,modelKey: {}, 原因: {}", key, cause); + }) + .build(); - @Resource - private CodeSnippetService codeSnippetService; + // 获取模型(带缓存) + public StreamingChatModel getStreamingChatModel(String modelKey) { + if (modelKey == null || modelKey.isBlank()) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "模型key不能为空"); + } - @Resource - private AiCodeGeneratorLogService aiCodeGeneratorLogService; + // 先查本地缓存,未命中则创建新实例 + return modelCache.get(modelKey, key -> createStreamingChatModel(key)); + } - @Resource - private ToolExecutor toolExecutor; + // 清除缓存 + public void invalidateCache(String modelKey) { + modelCache.invalidate(modelKey); + log.info("已清除模型缓存: {}", modelKey); + } - /** - * 创建 AI 代码生成服务 - */ - public AiCodeGeneratorService createAiCodeGeneratorService(Long appId, Long userId, String inviteCode) { - return new AiCodeGeneratorServiceImpl( - streamingChatModel, - appService, - userPointService, - codeSnippetService, - aiCodeGeneratorLogService, - toolExecutor, - appId, - userId, - inviteCode - ); + public void invalidateAllCache() { + modelCache.invalidateAll(); + log.info("已清除所有模型缓存"); } } ``` @@ -826,13 +819,17 @@ public class IpRateLimiter { } ``` +### 多模型支持 + +AI Code 集成了业界主流的大语言模型,包括 OpenAI GPT 系列、阿里通义千问(DashScope)、OpenRouter 等。平台采用工厂模式设计,新增模型提供商只需实现统一接口,无需修改核心逻辑。每种模型都支持独立的配置,包括 API 地址、积分消耗比例、模型参数等。系统会自动进行模型路由,根据任务类型和成本策略选择最优模型。 + ### 空间协作系统 空间是平台的组织核心单元,支持多种协作模式。空间管理员可以邀请成员加入,分配不同的角色权限(所有者、管理员、普通成员)。空间内的应用默认对所有成员可见,成员可以查看对话历史、修改配置、部署应用。这种设计既保证了协作的便利性,又通过角色划分维护了权限的安全边界。 ### 积分消费体系 -为了控制 AI 接口调用成本,平台实现了完整的积分管理体系。用户通过注册、签到、邀请等方式获取积分,调用 AI 接口时按固定费率扣减积分。系统自动计算每次请求的积分消耗。积分记录详细记录了每笔消费的来源和用途,用户可以清晰了解自己的积分流向。 +为了控制 AI 接口调用成本,平台实现了完整的积分管理体系。用户通过注册、签到、邀请等方式获取积分,调用 AI 接口时按消耗扣减积分。管理员可以在后台配置不同模型的积分单价,系统自动计算每次请求的积分消耗。积分记录详细记录了每笔消费的来源和用途,用户可以清晰了解自己的积分流向。 ### 应用部署能力 @@ -1060,7 +1057,7 @@ public class AiCodeGeneratorFacade { */ public Flux generateAndSaveCodeStream(String userMessage, CodeGenTypeEnum codeGenTypeEnum, Long appId, Consumer sseCallback, - Long userId, User user) { + Long userId, User user, String modelKey) { // 1. 参数校验 if (codeGenTypeEnum == null) { throw new BusinessException(ErrorCode.SYSTEM_ERROR, "生成类型为空"); @@ -1782,28 +1779,49 @@ flowchart TB Req["前端请求 /points/estimate"] Ctrl["PointsController.estimateGenerationCost()"] - subgraph Base["积分计算"] - BaseFn["使用固定配置计算积分"] + subgraph Base["基础积分计算"] + BaseFn["PointsConstants.getPointsByGenType()"] - subgraph Mapping["生成类型与积分映射"] + subgraph Mapping["生成类型与基础积分映射"] HTML["HTML → 5 分"] MF["MULTI_FILE → 8 分"] Vue["VUE_PROJECT → 15 分"] React["REACT_PROJECT → 15 分"] end + end + + ModelQ{"有指定模型?"} + NoModel["使用基础积分"] + YesModel["获取模型配置"] + + subgraph ModelConfig["AiModelConfigService"] + GetCfg["aiModelConfigService.getByModelKey()"] - subgraph Fixed["固定参数"] - Token["预估Token: 5000"] - KToken["1K Token 消耗 1 分"] - Quality["质量系数: 1.0"] + subgraph Fields["模型配置字段"] + Key["modelKey - 模型唯一标识"] + Name["modelName - 模型名称"] + Token["avgTokenUsage - 平均Token使用量"] + Points["pointsPerKToken - 每1K Token消耗积分"] + Quality["qualityScore - 质量系数(可选)"] end end + subgraph Calc["AiModelConfigService.calculatePoints()"] + Formula1["基础积分 = ceil(tokenCount / 1000.0) × pointsPerKToken"] + Formula2["最终积分 = 基础积分 × qualityScore"] + end + subgraph Response["返回预估结果"] - Res["{genType, basePoints, estimatedPoints, qualityScore, estimatedTokenUsage}"] + Res["{genType, basePoints, modelKey, estimatedPoints, ...}"] end - Req --> Ctrl --> Base --> Response + Req --> Ctrl + Ctrl --> Base + Base --> ModelQ + ModelQ -- NO --> NoModel + ModelQ -- YES --> YesModel + YesModel --> GetCfg + GetCfg --> Formula1 --> Formula2 --> Response end subgraph Deduct["积分扣减流程"] @@ -1855,26 +1873,42 @@ flowchart TB -**积分计算服务实现** + + +**积分计算服务:AiModelConfigService** ```java -public Integer calculatePoints(Integer tokenCount) { +@Override +public Integer calculatePoints(String modelKey, Integer tokenCount) { + AiModelConfig config = getByModelKey(modelKey); + if (config == null) { + throw new IllegalArgumentException("模型配置不存在: " + modelKey); + } + // 1. 计算K Token数量(向上取整) int kTokens = (int) Math.ceil(tokenCount / 1000.0); - // 2. 基础积分 = K Tokens × 每K Token积分(固定费率:1分/1K Token) - int basePoints = kTokens * PointsConstants.DEFAULT_POINTS_PER_KTOKEN; + // 2. 基础积分 = K Tokens × 每K Token积分 + int basePoints = kTokens * config.getPointsPerKToken(); + + // 3. 应用质量系数 + BigDecimal qualityScore = config.getQualityScore(); + if (qualityScore != null && qualityScore.compareTo(BigDecimal.ONE) != 0) { + BigDecimal finalPoints = BigDecimal.valueOf(basePoints) + .multiply(qualityScore) + .setScale(0, RoundingMode.HALF_UP); - // 3. 应用质量系数(固定1.0) - BigDecimal qualityScore = BigDecimal.valueOf(PointsConstants.DEFAULT_QUALITY_SCORE); - BigDecimal finalPoints = BigDecimal.valueOf(basePoints) - .multiply(qualityScore) - .setScale(0, RoundingMode.HALF_UP); + log.debug("模型 {} Token消耗: {}tokens → {}K tokens, 基础: {}×{}={}, 质量系数: {}, 最终: {}", + modelKey, tokenCount, kTokens, kTokens, config.getPointsPerKToken(), + basePoints, qualityScore, finalPoints.intValue()); - log.debug("Token消耗: {}tokens → {}K tokens, 积分: {}×{}={}", - tokenCount, kTokens, kTokens, PointsConstants.DEFAULT_POINTS_PER_KTOKEN, finalPoints.intValue()); + return finalPoints.intValue(); + } - return finalPoints.intValue(); + log.debug("模型 {} Token消耗: {}tokens → {}K tokens, 积分: {}×{}={} (无质量系数)", + modelKey, tokenCount, kTokens, kTokens, config.getPointsPerKToken(), basePoints); + + return basePoints; } ``` @@ -1882,7 +1916,7 @@ public Integer calculatePoints(Integer tokenCount) { ```java private void deductPointsFIFO(Long userId, Integer points, String type, String reason, - Long relatedId, Integer tokenCount, Integer currentBalance) { + Long relatedId, String modelKey, Integer tokenCount, Integer currentBalance) { // 1. 查询所有有效的积分记录(按创建时间正序) QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("userId", userId) @@ -1930,13 +1964,14 @@ private void deductPointsFIFO(Long userId, Integer points, String type, String r .type(type) .status(PointsStatusEnum.CONSUMED.getValue()) .reason(reason + String.format("(FIFO策略,消耗%d笔记录)", consumedRecordCount)) + .modelKey(modelKey) .tokenCount(tokenCount) .build(); pointsRecordService.save(deductRecord); - log.info("用户 {} FIFO扣减 {} 积分(token:{}),消耗 {} 笔记录,原余额:{} → 新余额:{}", - userId, points, tokenCount, consumedRecordCount, + log.info("用户 {} FIFO扣减 {} 积分(模型:{},token:{}),消耗 {} 笔记录,原余额:{} → 新余额:{}", + userId, points, modelKey, tokenCount, consumedRecordCount, originalBalance, currentBalance - points); } ``` @@ -1947,6 +1982,7 @@ private void deductPointsFIFO(Long userId, Integer points, String type, String r @GetMapping("/estimate") public BaseResponse> estimateGenerationCost( @RequestParam(required = false, defaultValue = "html") String genType, + @RequestParam(required = false) String modelKey, HttpServletRequest request) { Map result = new HashMap<>(); @@ -1957,16 +1993,40 @@ public BaseResponse> estimateGenerationCost( int basePoints = PointsConstants.getPointsByGenType(genType); result.put("basePoints", basePoints); - // 2. 使用固定配置计算预估积分 - Integer estimatedTokenUsage = PointsConstants.DEFAULT_ESTIMATED_TOKEN_USAGE; - result.put("estimatedTokenUsage", estimatedTokenUsage); + // 2. 如果指定了模型,使用模型配置计算 + if (modelKey != null && !modelKey.isEmpty()) { + AiModelConfig modelConfig = aiModelConfigService.getByModelKey(modelKey); + if (modelConfig != null) { + result.put("modelKey", modelKey); + result.put("modelName", modelConfig.getModelName()); + result.put("pointsPerKToken", modelConfig.getPointsPerKToken()); + result.put("qualityScore", modelConfig.getQualityScore()); + + Integer estimatedTokenUsage = modelConfig.getAvgTokenUsage(); + result.put("estimatedTokenUsage", estimatedTokenUsage); + + // 3. 计算预估积分 + if (estimatedTokenUsage != null && estimatedTokenUsage > 0) { + Integer estimatedPoints = aiModelConfigService.calculatePoints( + modelKey, estimatedTokenUsage); + result.put("estimatedPoints", estimatedPoints); + } else { + result.put("estimatedPoints", basePoints); + result.put("warning", "模型未配置平均Token使用量,使用基础积分"); + } - // 3. 计算预估积分 - Integer estimatedPoints = calculatePoints(estimatedTokenUsage); - result.put("estimatedPoints", estimatedPoints); - result.put("qualityScore", PointsConstants.DEFAULT_QUALITY_SCORE); - result.put("qualityScoreDescription", getQualityScoreDescription( - BigDecimal.valueOf(PointsConstants.DEFAULT_QUALITY_SCORE))); + // 4. 质量系数说明 + BigDecimal qualityScore = modelConfig.getQualityScore(); + if (qualityScore != null) { + result.put("qualityScoreDescription", getQualityScoreDescription(qualityScore)); + } + } else { + result.put("estimatedPoints", basePoints); + result.put("warning", "模型配置不存在,使用基础积分"); + } + } else { + result.put("estimatedPoints", basePoints); + } return ResultUtils.success(result); } @@ -2782,13 +2842,14 @@ ai-code/ │ │ │ ├── ErrorCode.java │ │ │ └── GlobalExceptionHandler.java │ │ │ -│ │ └── ai/ # AI 能力模块 -│ │ ├── core/ # 核心引擎 -│ │ │ ├── AiCodeGeneratorFacade.java -│ │ │ └── StreamHandlerExecutor.java -│ │ ├── factory/ # 工厂模式 -│ │ │ └── AiCodeGeneratorServiceFactory.java -│ │ ├── service/ # AI 服务 +│ │ └── ai/ # AI 能力模块 +│ │ ├── core/ # 核心引擎 +│ │ │ ├── AiCodeGeneratorFacade.java +│ │ │ └── StreamHandlerExecutor.java +│ │ ├── factory/ # 工厂模式 +│ │ │ ├── AiCodeGeneratorServiceFactory.java +│ │ │ └── DynamicAiModelFactory.java +│ │ ├── service/ # AI 服务 │ │ │ ├── AiCodeGeneratorService.java │ │ │ └── AppNameService.java │ │ ├── tool/ # 工具集 @@ -2869,6 +2930,7 @@ ai-code-frontend/ │ │ ├── Account/ │ │ │ └── Center/ # 个人中心 │ │ ├── Admin/ # 管理后台 +│ │ │ ├── AiModelConfig/ # AI模型配置 │ │ │ ├── App/ # 应用管理 │ │ │ ├── ChatHistory/ # 对话历史管理 │ │ │ ├── CodeSnippet/ # 代码片段管理 @@ -2897,6 +2959,7 @@ ai-code-frontend/ │ │ │ ├── services/ # API 服务 │ │ └── backend/ # 后端 API +│ │ ├── aiModelConfigController.ts │ │ ├── appController.ts │ │ ├── chatHistoryController.ts │ │ ├── inviteController.ts @@ -3015,7 +3078,8 @@ Content-Type: application/json { "appId": 123, - "message": "帮我写一个排序算法" + "message": "帮我写一个排序算法", + "modelKey": "gpt-4" } ``` @@ -3044,7 +3108,7 @@ GET /api/userPoint/user/points #### 获取预估消耗 ```http -GET /api/points/estimate?genType=html +GET /api/points/estimate?modelKey=gpt-4 ``` Response: @@ -3053,12 +3117,13 @@ Response: { "code": 0, "data": { - "genType": "html", - "basePoints": 5, + "basePoints": 10, + "modelKey": "gpt-4", + "modelName": "GPT-4", "qualityScore": 1.0, "qualityScoreDescription": "标准质量", - "estimatedTokenUsage": 5000, - "estimatedPoints": 5 + "estimatedTokenUsage": 1000, + "estimatedPoints": 10 } } ``` @@ -3132,7 +3197,7 @@ GET /api/deploy/{deployKey} 项目提供了预设的 Grafana 面板,包括: 1. **应用概览**:请求量、响应时间、错误率 -2. **AI 调用统计**:Token 消耗、积分消耗、响应时间 +2. **AI 模型使用**:各模型调用量、Token 消耗、积分消耗 3. **系统资源**:CPU、内存、磁盘、网络 4. **数据库查询**:慢查询统计、连接池状态 5. **业务指标**:用户活跃度、应用创建量、部署量 @@ -3321,11 +3386,20 @@ rm -rf node_modules package-lock.json npm install ``` -### Q4: 积分不足怎么办? +### Q4: 如何配置新的 AI 模型? + +在管理后台的「AI 模型配置」页面添加新模型,或直接插入数据库: + +```sql +INSERT INTO ai_model_config (modelKey, modelName, provider, baseUrl, pointsPerKToken, isEnabled) +VALUES ('new-model', '新模型', 'openai', 'https://api.openai.com/v1', 10, 1); +``` + +### Q5: 积分不足怎么办? 管理员可以在后台手动发放积分,或检查是否正确配置了积分获取规则。 -### Q5: 部署后无法访问? +### Q6: 部署后无法访问? 1. 检查 Nginx 配置是否正确 2. 检查防火墙是否开放端口 diff --git a/ai-code-frontend/package.json b/ai-code-frontend/package.json index b6306a1..1c0143d 100644 --- a/ai-code-frontend/package.json +++ b/ai-code-frontend/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vite build", + "build": "tsc -b && vite build", "lint": "eslint .", "preview": "vite preview" }, diff --git a/ai-code-frontend/src/api/params/appParams.ts b/ai-code-frontend/src/api/params/appParams.ts deleted file mode 100644 index 36fd94b..0000000 --- a/ai-code-frontend/src/api/params/appParams.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * 应用添加参数 - */ -export type AppAddParams = { - appName: string; - appDesc?: string; - appIcon?: string; - appCover?: string; - initPrompt: string; - codeGenType: string; -}; - -/** - * 应用部署参数 - */ -export type AppDeployParams = { - appId: number; -}; - -/** - * 应用查询参数 - */ -export type AppQueryParams = { - pageNum: number; - pageSize: number; - sortField?: string; - sortOrder?: string; - id?: string; - appName?: string; - appDesc?: string; - codeGenType?: string; - userId?: string; - isFeatured?: number; - searchKey?: string; - appType?: string; - spaceId?: string; -}; - -/** - * 应用更新参数 - */ -export type AppUpdateParams = { - id: string; - appName?: string; - appDesc?: string; - appIcon?: string; - appCover?: string; - priority?: number; -}; - -/** - * 对话生成代码参数 - */ -export type ChatToGenCodeParams = { - appId: number; - message: string; -}; - -/** - * 取消代码生成参数 - */ -export type CancelCodeGenerationParams = { - appId: number; -}; - -/** - * 下载应用代码参数 - */ -export type DownloadAppCodeParams = { - appId: number; -}; - -/** - * 获取应用参数 - */ -export type GetAppParams = { - id: number; -}; - -/** - * 获取应用VO参数 - */ -export type GetAppVOParams = { - id: number; -}; diff --git a/ai-code-frontend/src/api/params/chatParams.ts b/ai-code-frontend/src/api/params/chatParams.ts deleted file mode 100644 index cfba543..0000000 --- a/ai-code-frontend/src/api/params/chatParams.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 聊天历史查询参数 - */ -export type ChatHistoryQueryParams = { - pageNum: number; - pageSize: number; - sortField?: string; - sortOrder?: string; - id?: number; - message?: string; - messageType?: string; - appId?: number; - userId?: number; - lastCreateTime?: string; -}; - -/** - * 获取聊天历史参数 - */ -export type GetChatHistoryParams = { - id: number; -}; - -/** - * 列出应用聊天历史参数 - */ -export type ListAppChatHistoryParams = { - appId: number; - pageSize?: number; - lastCreateTime?: string; -}; - -/** - * 列出最新聊天历史VO参数 - */ -export type ListLatestChatHistoryVOParams = { - appId: number; -}; - -/** - * 添加聊天历史参数 - */ -export type AddChatHistoryParams = { - appId: number; - messageType: string; - messageContent: string; - errorInfo?: string; -}; - -/** - * 对话请求参数 - */ -export type DialogueRequestParams = { - appId: number; - message: string; -}; diff --git a/ai-code-frontend/src/api/params/codeSnippetParams.ts b/ai-code-frontend/src/api/params/codeSnippetParams.ts deleted file mode 100644 index de812e6..0000000 --- a/ai-code-frontend/src/api/params/codeSnippetParams.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 代码片段添加参数 - */ -export type CodeSnippetAddParams = { - snippetName: string; - snippetType: string; - snippetCategory: string; - snippetDesc?: string; - snippetCode: string; - usageScenario?: string; - tags?: string; - priority?: number; -}; - -/** - * 代码片段更新参数 - */ -export type CodeSnippetUpdateParams = { - id: string; - snippetName?: string; - snippetType?: string; - snippetCategory?: string; - snippetDesc?: string; - snippetCode?: string; - usageScenario?: string; - tags?: string; - isActive?: number; - priority?: number; -}; - -/** - * 代码片段查询参数 - */ -export type CodeSnippetQueryParams = { - pageNum: number; - pageSize: number; - sortField?: string; - sortOrder?: string; - id?: string; - snippetName?: string; - snippetType?: string; - snippetCategory?: string; - searchKey?: string; - isActive?: number; -}; - -/** - * 获取代码片段参数 - */ -export type GetCodeSnippetParams = { - id: number; -}; - -/** - * 删除代码片段参数 - */ -export type DeleteCodeSnippetParams = { - id: number; -}; - -/** - * 代码片段搜索参数 - */ -export type CodeSnippetSearchParams = { - keyword: string; - snippetType?: string; - limit?: number; -}; diff --git a/ai-code-frontend/src/api/params/commentParams.ts b/ai-code-frontend/src/api/params/commentParams.ts deleted file mode 100644 index e7a9ad1..0000000 --- a/ai-code-frontend/src/api/params/commentParams.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 评论添加参数 - */ -export type CommentAddParams = { - appId: string; - content: string; -}; - -/** - * 评论回复参数 - */ -export type CommentReplyParams = { - parentId: string; - content: string; - replyUserId: string; -}; - -/** - * 评论查询参数 - */ -export type CommentQueryParams = { - pageNum: number; - pageSize: number; - sortField?: string; - sortOrder?: string; - id?: string; - appId?: string; - parentId?: string; - userId?: string; - content?: string; - relatedId?: string; - commentType?: number; -}; - -/** - * 获取评论参数 - */ -export type GetCommentParams = { - id: string; -}; - -/** - * 删除评论参数 - */ -export type DeleteCommentParams = { - id: string; -}; - -/** - * 评论点赞参数 - */ -export type CommentLikeParams = { - id: string; -}; diff --git a/ai-code-frontend/src/api/params/forumParams.ts b/ai-code-frontend/src/api/params/forumParams.ts deleted file mode 100644 index 3a46594..0000000 --- a/ai-code-frontend/src/api/params/forumParams.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * 论坛帖子添加参数 - */ -export type ForumPostAddParams = { - title: string; - content: string; - appId?: number; -}; - -/** - * 论坛帖子更新参数 - */ -export type ForumPostUpdateParams = { - id: string; - title?: string; - content?: string; - appId?: string; - isPinned?: number; -}; - -/** - * 论坛帖子查询参数 - */ -export type ForumPostQueryParams = { - pageNum: number; - pageSize: number; - sortField?: string; - sortOrder?: string; - id?: string; - title?: string; - searchKey?: string; - appId?: string; - userId?: string; - isPinned?: number; -}; - -/** - * 获取论坛帖子参数 - */ -export type GetForumPostParams = { - id: number; -}; - -/** - * 论坛帖子点赞参数 - */ -export type ForumPostLikeParams = { - id: number; -}; diff --git a/ai-code-frontend/src/api/params/inviteParams.ts b/ai-code-frontend/src/api/params/inviteParams.ts deleted file mode 100644 index d46b8f1..0000000 --- a/ai-code-frontend/src/api/params/inviteParams.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * 邀请记录查询参数 - */ -export type InviteRecordQueryParams = { - pageNum: number; - pageSize: number; - status?: string; -}; - -/** - * 使用邀请码参数 - */ -export type UseInviteCodeParams = { - inviteCode: string; -}; - -/** - * 生成邀请码参数 - */ -export type GenerateInviteCodeParams = { - expireDays?: number; -}; - -/** - * 获取我的邀请码参数 - */ -export type GetMyInviteCodeParams = { - userId: number; -}; - -/** - * 邀请成员参数 - */ -export type InviteMemberParams = { - spaceId: number; - invitedUserId: number; - role?: string; -}; diff --git a/ai-code-frontend/src/api/params/pointsParams.ts b/ai-code-frontend/src/api/params/pointsParams.ts deleted file mode 100644 index c9a3166..0000000 --- a/ai-code-frontend/src/api/params/pointsParams.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 积分预估参数 - */ -export type EstimateCostParams = { - genType?: string; -}; - -/** - * 积分记录查询参数 - */ -export type PointsRecordsParams = { - type?: string; - pageNum?: number; - pageSize?: number; -}; - -/** - * 用户积分查询参数 - */ -export type UserPointParams = { - userId: number; -}; - -/** - * 积分操作参数 - */ -export type PointsOperationParams = { - userId: number; - points: number; - type: string; - reason?: string; - relatedId?: number; -}; diff --git a/ai-code-frontend/src/api/params/spaceParams.ts b/ai-code-frontend/src/api/params/spaceParams.ts deleted file mode 100644 index bb2cc8e..0000000 --- a/ai-code-frontend/src/api/params/spaceParams.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 空间添加参数 - */ -export type SpaceAddParams = { - spaceName: string; - spaceType: number; - spaceDesc?: string; -}; - -/** - * 空间更新参数 - */ -export type SpaceUpdateParams = { - id: string; - spaceName?: string; - description?: string; -}; - -/** - * 空间查询参数 - */ -export type SpaceQueryParams = { - pageNum: number; - pageSize: number; - id?: string; - spaceName?: string; - spaceType?: number; - ownerId?: string; - sortField?: string; - sortOrder?: string; -}; - -/** - * 空间成员操作参数 - */ -export type SpaceMemberParams = { - spaceId: string; - userId: string; -}; - -/** - * 空间应用操作参数 - */ -export type SpaceAppParams = { - spaceId: string; - appId: string; -}; - -/** - * 空间邀请参数 - */ -export type SpaceInviteParams = { - spaceId: string; - invitedUserId: number; - role: string; -}; - -/** - * 获取空间参数 - */ -export type GetSpaceParams = { - id: number; -}; - -/** - * 获取空间成员参数 - */ -export type GetSpaceMembersParams = { - spaceId: number; -}; diff --git a/ai-code-frontend/src/api/params/userParams.ts b/ai-code-frontend/src/api/params/userParams.ts deleted file mode 100644 index 86a5163..0000000 --- a/ai-code-frontend/src/api/params/userParams.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * 用户登录参数 - */ -export type UserLoginParams = { - userAccount: string; - userPassword: string; -}; - -/** - * 用户注册参数 - */ -export type UserRegisterParams = { - userAccount: string; - userPassword: string; - checkPassword: string; - email?: string; - emailCode?: string; - inviteCode?: string; -}; - -/** - * 用户更新参数 - */ -export type UserUpdateParams = { - id: number; - userName?: string; - userAvatar?: string; - userProfile?: string; - userRole?: string; -}; - -/** - * 用户更新个人信息参数 - */ -export type UserUpdateInfoParams = { - userName?: string; - userProfile?: string; -}; - -/** - * 用户更新密码参数 - */ -export type UserUpdatePasswordParams = { - oldPassword: string; - newPassword: string; - checkPassword: string; -}; - -/** - * 用户更新头像参数 - */ -export type UserUpdateAvatarParams = { - userAvatar: string; -}; - -/** - * 发送邮箱验证码参数 - */ -export type SendEmailCodeParams = { - email: string; - type: string; -}; - -/** - * 用户查询参数 - */ -export type UserQueryParams = { - pageNum: number; - pageSize: number; - sortField?: string; - sortOrder?: string; - id?: number; - userName?: string; - userAccount?: string; - userProfile?: string; - userRole?: string; -}; diff --git a/ai-code-frontend/src/api/vo/appVO.ts b/ai-code-frontend/src/api/vo/appVO.ts deleted file mode 100644 index 12063db..0000000 --- a/ai-code-frontend/src/api/vo/appVO.ts +++ /dev/null @@ -1,138 +0,0 @@ -/** - * 应用视图对象类型定义 - */ - -/** - * 应用基本信息视图对象 - */ -export type AppVO = { - id: number; - appName: string; - appDesc?: string; - appIcon?: string; - appCover?: string; - initPrompt: string; - codeGenType: string; - appType: number; - reviewStatus: number; - reviewerId?: number; - reviewTime?: string; - reviewMessage?: string; - createUserId: number; - createTime: string; - updateTime?: string; -}; - -/** - * 应用详情信息视图对象 - */ -export type AppDetailVO = AppVO & { - createUser?: import('./userVO').UserSimpleVO; - useCount: number; - favorCount: number; - shareCount: number; - tags?: string[]; - isFavorite: boolean; - isPublic: boolean; -}; - -/** - * 应用简要信息视图对象(用于列表展示) - */ -export type AppSimpleVO = { - id: number; - appName: string; - appDesc?: string; - appIcon?: string; - codeGenType: string; - appType: number; - createUserId: number; - createTime: string; -}; - -/** - * 应用分类视图对象 - */ -export type AppCategoryVO = { - id: number; - categoryName: string; - parentId?: number; - sortOrder: number; - appCount: number; -}; - -/** - * 应用标签视图对象 - */ -export type AppTagVO = { - id: number; - tagName: string; - tagColor?: string; - appCount: number; -}; - -/** - * 应用统计信息视图对象 - */ -export type AppStatisticsVO = { - totalApps: number; - publicApps: number; - privateApps: number; - underReviewApps: number; - rejectedApps: number; -}; - -/** - * 应用创建响应视图对象 - */ -export type AppCreateVO = { - id: number; - appName: string; - appKey?: string; - appSecret?: string; - createTime: string; -}; - -/** - * 应用配置视图对象 - */ -export type AppConfigVO = { - appId: number; - maxTokens: number; - temperature: number; - topP: number; - presencePenalty: number; - frequencyPenalty: number; - streamEnable: boolean; - systemPrompt?: string; -}; - -/** - * 应用使用记录视图对象 - */ -export type AppUsageRecordVO = { - id: number; - appId: number; - appName: string; - userId: number; - messageCount: number; - tokenCount: number; - pointsCost: number; - createTime: string; -}; - -/** - * 我的应用视图对象 - */ -export type MyAppVO = { - id: number; - appName: string; - appDesc?: string; - appIcon?: string; - codeGenType: string; - appType: number; - reviewStatus: number; - useCount: number; - createTime: string; - updateTime?: string; -}; diff --git a/ai-code-frontend/src/api/vo/chatVO.ts b/ai-code-frontend/src/api/vo/chatVO.ts deleted file mode 100644 index 085299b..0000000 --- a/ai-code-frontend/src/api/vo/chatVO.ts +++ /dev/null @@ -1,160 +0,0 @@ -/** - * 聊天视图对象类型定义 - */ - -/** - * 聊天记录视图对象 - */ -export type ChatRecordVO = { - id: number; - appId: number; - message: string; - messageType: string; - responseMessage?: string; - codeContent?: string; - codeLanguage?: string; - tokenCount: number; - pointsCost: number; - createTime: string; - updateTime?: string; -}; - -/** - * 聊天消息视图对象 - */ -export type ChatMessageVO = { - id: number; - conversationId: string; - role: string; - content: string; - codeContent?: string; - codeLanguage?: string; - tokens: number; - points: number; - createTime: string; -}; - -/** - * 对话历史视图对象 - */ -export type ChatHistoryVO = { - id: number; - appId: number; - appName: string; - appIcon?: string; - messageCount: number; - lastMessage?: string; - lastMessageTime?: string; - createTime: string; - updateTime?: string; -}; - -/** - * 对话详情视图对象 - */ -export type ChatDetailVO = { - id: number; - conversationId: string; - appId: number; - appName: string; - appIcon?: string; - messageCount: number; - totalTokens: number; - totalPoints: number; - createTime: string; - updateTime?: string; - messages: ChatMessageVO[]; -}; - -/** - * 代码生成结果视图对象 - */ -export type CodeGenResultVO = { - id: number; - conversationId: string; - appId: number; - userMessage: string; - codeContent: string; - codeLanguage: string; - codeExplanation?: string; - tokens: number; - pointsCost: number; - createTime: string; -}; - -/** - * 代码执行结果视图对象 - */ -export type CodeExecuteResultVO = { - id: number; - codeGenId: number; - output: string; - error?: string; - executionTime: number; - memoryUsage: number; - createTime: string; -}; - -/** - * 对话模板视图对象 - */ -export type ChatTemplateVO = { - id: number; - templateName: string; - templateDesc?: string; - initPrompt: string; - appId?: number; - isDefault: boolean; - createUserId: number; - createTime: string; -}; - -/** - * 对话统计信息视图对象 - */ -export type ChatStatisticsVO = { - totalConversations: number; - totalMessages: number; - totalTokens: number; - totalPoints: number; - avgResponseTime: number; - todayConversations: number; - todayMessages: number; -}; - -/** - * 对话分享视图对象 - */ -export type ChatShareVO = { - id: number; - conversationId: string; - shareCode: string; - shareUrl: string; - viewCount: number; - expiresTime?: string; - createTime: string; -}; - -/** - * 对话反馈视图对象 - */ -export type ChatFeedbackVO = { - id: number; - conversationId: string; - messageId: number; - feedbackType: string; - feedbackContent?: string; - createTime: string; -}; - -/** - * 对话收藏视图对象 - */ -export type ChatFavoriteVO = { - id: number; - userId: number; - conversationId: string; - name?: string; - description?: string; - createTime: string; -}; diff --git a/ai-code-frontend/src/api/vo/codeSnippetVO.ts b/ai-code-frontend/src/api/vo/codeSnippetVO.ts deleted file mode 100644 index 93bd6b1..0000000 --- a/ai-code-frontend/src/api/vo/codeSnippetVO.ts +++ /dev/null @@ -1,165 +0,0 @@ -/** - * 代码片段视图对象类型定义 - */ - -/** - * 代码片段基本信息视图对象 - */ -export type CodeSnippetVO = { - id: number; - snippetName: string; - snippetDesc?: string; - codeContent: string; - codeLanguage: string; - tags?: string[]; - isPublic: boolean; - viewCount: number; - likeCount: number; - collectCount: number; - createUserId: number; - createTime: string; - updateTime?: string; -}; - -/** - * 代码片段详情视图对象 - */ -export type CodeSnippetDetailVO = CodeSnippetVO & { - createUser?: import('./userVO').UserSimpleVO; - likeStatus: boolean; - collectStatus: boolean; - comments: CommentVO[]; - relatedSnippets?: CodeSnippetVO[]; -}; - -/** - * 代码片段简要视图对象(用于列表展示) - */ -export type CodeSnippetSimpleVO = { - id: number; - snippetName: string; - snippetDesc?: string; - codeLanguage: string; - tags?: string[]; - createUserId: number; - createUserName?: string; - createTime: string; -}; - -/** - * 代码片段分类视图对象 - */ -export type CodeSnippetCategoryVO = { - id: number; - categoryName: string; - parentId?: number; - snippetCount: number; - sortOrder: number; -}; - -/** - * 代码片段标签视图对象 - */ -export type CodeSnippetTagVO = { - id: number; - tagName: string; - tagColor?: string; - snippetCount: number; -}; - -/** - * 代码片段搜索结果视图对象 - */ -export type CodeSnippetSearchVO = { - total: number; - pageNum: number; - pageSize: number; - list: CodeSnippetSimpleVO[]; -}; - -/** - * 代码片段统计视图对象 - */ -export type CodeSnippetStatisticsVO = { - totalSnippets: number; - publicSnippets: number; - mySnippets: number; - totalViews: number; - totalLikes: number; - totalCollects: number; -}; - -/** - * 我的代码片段视图对象 - */ -export type MyCodeSnippetVO = { - id: number; - snippetName: string; - snippetDesc?: string; - codeLanguage: string; - isPublic: boolean; - viewCount: number; - likeCount: number; - createTime: string; - updateTime?: string; -}; - -/** - * 代码片段版本视图对象 - */ -export type CodeSnippetVersionVO = { - id: number; - snippetId: number; - version: string; - codeContent: string; - changeDesc?: string; - createUserId: number; - createTime: string; -}; - -/** - * 代码片段收藏视图对象 - */ -export type CodeSnippetCollectVO = { - id: number; - userId: number; - snippetId: number; - snippet?: CodeSnippetSimpleVO; - createTime: string; -}; - -/** - * 代码片段点赞视图对象 - */ -export type CodeSnippetLikeVO = { - id: number; - userId: number; - snippetId: number; - createTime: string; -}; - -/** - * 代码片段分享视图对象 - */ -export type CodeSnippetShareVO = { - id: number; - snippetId: number; - shareCode: string; - shareUrl: string; - expiresTime?: string; - viewCount: number; - createTime: string; -}; - -/** - * 代码片段导入视图对象 - */ -export type CodeSnippetImportVO = { - id: number; - originalUrl?: string; - originalId?: number; - importStatus: number; - createTime: string; -}; - -import { CommentVO } from './commentVO'; diff --git a/ai-code-frontend/src/api/vo/commentVO.ts b/ai-code-frontend/src/api/vo/commentVO.ts deleted file mode 100644 index fdb9a3e..0000000 --- a/ai-code-frontend/src/api/vo/commentVO.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * 评论视图对象类型定义 - */ - -/** - * 评论基本信息视图对象 - */ -export type CommentVO = { - id: number; - targetType: string; - targetId: number; - content: string; - likeCount: number; - replyCount: number; - status: number; - createUserId: number; - createTime: string; - updateTime?: string; -}; - -/** - * 评论详情视图对象 - */ -export type CommentDetailVO = CommentVO & { - createUser?: import('./userVO').UserSimpleVO; - replies?: CommentReplyVO[]; - likeStatus: boolean; -}; - -/** - * 评论回复视图对象 - */ -export type CommentReplyVO = { - id: number; - commentId: number; - parentReplyId?: number; - content: string; - likeCount: number; - status: number; - createUserId: number; - createUser?: import('./userVO').UserSimpleVO; - replyToUserId?: number; - replyToUser?: import('./userVO').UserSimpleVO; - createTime: string; - updateTime?: string; -}; - -/** - * 评论简要视图对象(用于列表展示) - */ -export type CommentSimpleVO = { - id: number; - targetType: string; - targetId: number; - contentPreview: string; - likeCount: number; - createUserId: number; - createUserName?: string; - createUserAvatar?: string; - createTime: string; -}; - -/** - * 我的评论视图对象 - */ -export type MyCommentVO = { - id: number; - targetType: string; - targetId: number; - targetTitle?: string; - content: string; - likeCount: number; - status: number; - createTime: string; -}; - -/** - * 评论统计视图对象 - */ -export type CommentStatisticsVO = { - totalComments: number; - myComments: number; - receivedLikes: number; - todayComments: number; -}; - -/** - * 评论点赞视图对象 - */ -export type CommentLikeVO = { - id: number; - commentId: number; - userId: number; - createTime: string; -}; - -/** - * 评论举报视图对象 - */ -export type CommentReportVO = { - id: number; - commentId: number; - reportType: string; - reportContent?: string; - status: number; - createUserId: number; - createTime: string; -}; - -/** - * 消息通知视图对象 - */ -export type NotificationVO = { - id: number; - type: string; - title: string; - content: string; - sourceType?: string; - sourceId?: string; - readStatus: number; - createTime: string; -}; - -/** - * 通知统计视图对象 - */ -export type NotificationStatisticsVO = { - totalNotifications: number; - unreadCount: number; - likeNotifications: number; - commentNotifications: number; - systemNotifications: number; -}; - -/** - * @Mention 通知视图对象 - */ -export type MentionNotificationVO = { - id: number; - targetType: string; - targetId: number; - targetTitle?: string; - mentionUserId: number; - mentionUser?: import('./userVO').UserSimpleVO; - content: string; - readStatus: number; - createTime: string; -}; - -/** - * 点赞通知视图对象 - */ -export type LikeNotificationVO = { - id: number; - targetType: string; - targetId: number; - targetTitle?: string; - likeUserId: number; - likeUser?: import('./userVO').UserSimpleVO; - readStatus: number; - createTime: string; -}; - -/** - * 评论通知视图对象 - */ -export type CommentNotificationVO = { - id: number; - targetType: string; - targetId: number; - targetTitle?: string; - commentId: number; - commentContent: string; - commentUserId: number; - commentUser?: import('./userVO').UserSimpleVO; - readStatus: number; - createTime: string; -}; diff --git a/ai-code-frontend/src/api/vo/forumVO.ts b/ai-code-frontend/src/api/vo/forumVO.ts deleted file mode 100644 index 1b7efc6..0000000 --- a/ai-code-frontend/src/api/vo/forumVO.ts +++ /dev/null @@ -1,192 +0,0 @@ -/** - * 社区论坛视图对象类型定义 - */ - -/** - * 论坛帖子视图对象 - */ -export type ForumPostVO = { - id: number; - title: string; - content: string; - contentType: string; - tags?: string[]; - viewCount: number; - likeCount: number; - commentCount: number; - collectCount: number; - isTop: boolean; - isEssence: boolean; - status: number; - createUserId: number; - createTime: string; - updateTime?: string; -}; - -/** - * 论坛帖子详情视图对象 - */ -export type ForumPostDetailVO = ForumPostVO & { - createUser?: import('./userVO').UserSimpleVO; - likeStatus: boolean; - collectStatus: boolean; - comments: CommentVO[]; - previousPost?: ForumPostVO; - nextPost?: ForumPostVO; -}; - -/** - * 论坛帖子简要视图对象(用于列表展示) - */ -export type ForumPostSimpleVO = { - id: number; - title: string; - contentPreview: string; - tags?: string[]; - viewCount: number; - likeCount: number; - commentCount: number; - isTop: boolean; - isEssence: boolean; - createUserId: number; - createUserName?: string; - createUserAvatar?: string; - createTime: string; -}; - -/** - * 论坛板块视图对象 - */ -export type ForumBoardVO = { - id: number; - boardName: string; - boardDesc?: string; - parentId?: number; - icon?: string; - postCount: number; - todayPostCount: number; - sortOrder: number; -}; - -/** - * 论坛板块详情视图对象 - */ -export type ForumBoardDetailVO = ForumBoardVO & { - children?: ForumBoardVO[]; - posts: ForumPostSimpleVO[]; -}; - -/** - * 论坛评论视图对象 - */ -export type ForumCommentVO = { - id: number; - postId: number; - content: string; - likeCount: number; - replyCount: number; - status: number; - createUserId: number; - createTime: string; - updateTime?: string; -}; - -/** - * 论坛评论详情视图对象 - */ -export type ForumCommentDetailVO = ForumCommentVO & { - createUser?: import('./userVO').UserSimpleVO; - replies?: ForumCommentVO[]; - likeStatus: boolean; -}; - -/** - * 论坛搜索结果视图对象 - */ -export type ForumSearchVO = { - total: number; - pageNum: number; - pageSize: number; - list: ForumPostSimpleVO[]; -}; - -/** - * 论坛统计信息视图对象 - */ -export type ForumStatisticsVO = { - totalPosts: number; - totalComments: number; - totalUsers: number; - todayPosts: number; - totalBoards: number; - hotPosts: ForumPostSimpleVO[]; -}; - -/** - * 热门帖子视图对象 - */ -export type HotPostVO = { - id: number; - title: string; - viewCount: number; - likeCount: number; - commentCount: number; - score: number; - createTime: string; -}; - -/** - * 最新帖子视图对象 - */ -export type LatestPostVO = { - id: number; - title: string; - boardName: string; - createUserName: string; - createUserAvatar?: string; - createTime: string; -}; - -/** - * 我的帖子视图对象 - */ -export type MyForumPostVO = { - id: number; - title: string; - contentType: string; - viewCount: number; - likeCount: number; - commentCount: number; - status: number; - isTop: boolean; - isEssence: boolean; - createTime: string; - updateTime?: string; -}; - -/** - * 帖子分享视图对象 - */ -export type ForumPostShareVO = { - id: number; - postId: number; - shareCode: string; - shareUrl: string; - expiresTime?: string; - viewCount: number; - createTime: string; -}; - -/** - * 帖子举报视图对象 - */ -export type ForumReportVO = { - id: number; - targetType: string; - targetId: number; - reportType: string; - reportContent?: string; - status: number; - createUserId: number; - createTime: string; -}; diff --git a/ai-code-frontend/src/api/vo/index.ts b/ai-code-frontend/src/api/vo/index.ts deleted file mode 100644 index d756ae0..0000000 --- a/ai-code-frontend/src/api/vo/index.ts +++ /dev/null @@ -1,234 +0,0 @@ -/** - * API 通用响应视图对象类型定义 - */ - -/** - * 通用分页响应视图对象 - */ -export type PageResponseVO = { - total: number; - pageNum: number; - pageSize: number; - totalPages: number; - list: T[]; -}; - -/** - * 通用响应视图对象 - */ -export type BaseResponseVO = { - code: number; - data: T; - message?: string; - description?: string; -}; - -/** - * 登录响应视图对象 - */ -export type LoginResponseVO = { - accessToken: string; - refreshToken?: string; - expiresIn?: number; - tokenType?: string; -}; - -/** - * 分页查询参数视图对象 - */ -export type PageQueryVO = { - pageNum: number; - pageSize: number; - total?: number; - pages?: number; -}; - -/** - * 排序参数视图对象 - */ -export type SortVO = { - field: string; - order: 'asc' | 'desc'; -}; - -/** - * 筛选参数视图对象 - */ -export type FilterVO = { - field: string; - value: unknown; - operator?: 'eq' | 'ne' | 'gt' | 'lt' | 'ge' | 'le' | 'like' | 'in' | 'between'; -}; - -/** - * 上传文件响应视图对象 - */ -export type UploadFileVO = { - fileName: string; - filePath: string; - fileUrl: string; - fileSize: number; - fileType: string; -}; - -/** - * 文件信息视图对象 - */ -export type FileInfoVO = { - id: string; - fileName: string; - filePath: string; - fileUrl: string; - fileSize: number; - fileType: string; - uploadUserId: number; - createTime: string; -}; - -/** - * 地区信息视图对象 - */ -export type RegionVO = { - id: number; - name: string; - code: string; - parentId?: number; - level: number; -}; - -/** - * 字典数据视图对象 - */ -export type DictDataVO = { - dictType: string; - dictCode: string; - dictLabel: string; - dictValue: string; - sortOrder: number; - status: number; -}; - -/** - * 字典类型视图对象 - */ -export type DictTypeVO = { - dictType: string; - dictName: string; - status: number; - remark?: string; - createTime?: string; -}; - -/** - * 验证码响应视图对象 - */ -export type CaptchaVO = { - captchaKey: string; - captchaImage: string; - captchaExpiresIn: number; -}; - -/** - * 配置信息视图对象 - */ -export type ConfigVO = { - configKey: string; - configValue: string; - configType: string; - remark?: string; -}; - -/** - * 通用列表响应视图对象 - */ -export type ListResponseVO = { - list: T[]; - total: number; -}; - -/** - * 树形结构视图对象 - */ -export type TreeNodeVO = { - id: string | number; - label: string; - children?: TreeNodeVO[]; - [key: string]: unknown; -}; - -/** - * 级联选择器视图对象 - */ -export type CascaderVO = { - value: string | number; - label: string; - children?: CascaderVO[]; -}; - -/** - * 选择器选项视图对象 - */ -export type SelectOptionVO = { - value: string | number; - label: string; - disabled?: boolean; - children?: SelectOptionVO[]; -}; - -/** - * 键值对视图对象 - */ -export type KeyValueVO = { - key: string; - value: unknown; -}; - -/** - * 结果消息视图对象 - */ -export type ResultMessageVO = { - type: 'success' | 'error' | 'warning' | 'info'; - content: string; -}; - -/** - * 批量操作结果视图对象 - */ -export type BatchResultVO = { - successCount: number; - failCount: number; - totalCount: number; - errors?: Array<{ - id: string | number; - message: string; - }>; -}; - -/** - * 导出数据响应视图对象 - */ -export type ExportResultVO = { - exportId: string; - fileName: string; - fileUrl: string; - status: number; - progress: number; - createTime: string; - completeTime?: string; -}; - -/** - * 导入数据响应视图对象 - */ -export type ImportResultVO = { - importId: string; - totalCount: number; - successCount: number; - failCount: number; - errors?: Array<{ - row: number; - message: string; - }>; - fileUrl?: string; - createTime: string; -}; diff --git a/ai-code-frontend/src/api/vo/inviteVO.ts b/ai-code-frontend/src/api/vo/inviteVO.ts deleted file mode 100644 index ce6dd2d..0000000 --- a/ai-code-frontend/src/api/vo/inviteVO.ts +++ /dev/null @@ -1,137 +0,0 @@ -/** - * 邀请视图对象类型定义 - */ - -/** - * 邀请记录视图对象 - */ -export type InviteRecordVO = { - id: number; - inviterId: number; - inviter?: import('./userVO').UserSimpleVO; - inviteeId: number; - invitee?: import('./userVO').UserSimpleVO; - inviteCode: string; - status: number; - rewardPoints: number; - registerTime: string; - rewardTime?: string; - createTime: string; -}; - -/** - * 邀请统计视图对象 - */ -export type InviteStatisticsVO = { - totalInvites: number; - successfulInvites: number; - pendingInvites: number; - totalRewardPoints: number; - pendingRewardPoints: number; - rank: number; -}; - -/** - * 我的邀请视图对象 - */ -export type MyInviteVO = { - id: number; - inviteeId: number; - invitee?: import('./userVO').UserSimpleVO; - status: number; - rewardPoints: number; - registerTime: string; - rewardTime?: string; -}; - -/** - * 邀请链接视图对象 - */ -export type InviteLinkVO = { - id: number; - inviteCode: string; - inviteUrl: string; - qrCodeUrl?: string; - validDays: number; - useCount: number; - maxUseCount?: number; - status: number; - createTime: string; - expiresTime?: string; -}; - -/** - * 邀请奖励规则视图对象 - */ -export type InviteRewardRuleVO = { - id: number; - ruleName: string; - registerRewardPoints: number; - firstRechargeRewardPoints: number; - firstRechargeThreshold: number; - validDays: number; - status: number; - createTime: string; -}; - -/** - * 邀请排行榜视图对象 - */ -export type InviteLeaderboardVO = { - rank: number; - userId: number; - user?: import('./userVO').UserSimpleVO; - successfulInvites: number; - totalRewardPoints: number; -}; - -/** - * 被邀请人视图对象 - */ -export type InviteeVO = { - id: number; - userId: number; - user?: import('./userVO').UserSimpleVO; - inviteCode: string; - registerTime: string; - firstRechargeTime?: string; - firstRechargeAmount?: number; - status: number; -}; - -/** - * 邀请通知视图对象 - */ -export type InviteNotificationVO = { - id: number; - type: string; - inviterId: number; - inviter?: import('./userVO').UserSimpleVO; - rewardPoints: number; - message: string; - readStatus: number; - createTime: string; -}; - -/** - * 邀请海报视图对象 - */ -export type InvitePosterVO = { - id: number; - posterUrl: string; - posterName: string; - description?: string; - isDefault: boolean; - sortOrder: number; -}; - -/** - * 邀请分享视图对象 - */ -export type InviteShareVO = { - shareTitle: string; - shareDesc: string; - shareUrl: string; - shareIcon?: string; - sharePoster?: string; -}; diff --git a/ai-code-frontend/src/api/vo/pointsVO.ts b/ai-code-frontend/src/api/vo/pointsVO.ts deleted file mode 100644 index 4588186..0000000 --- a/ai-code-frontend/src/api/vo/pointsVO.ts +++ /dev/null @@ -1,164 +0,0 @@ -/** - * 积分视图对象类型定义 - */ - -/** - * 积分账户信息视图对象 - */ -export type PointsAccountVO = { - id: number; - userId: number; - totalPoints: number; - usedPoints: number; - remainingPoints: number; - frozenPoints: number; - createTime: string; - updateTime?: string; -}; - -/** - * 积分记录视图对象 - */ -export type PointsRecordVO = { - id: number; - userId: number; - points: number; - type: string; - sourceType: string; - sourceId?: string; - description: string; - balance: number; - createTime: string; -}; - -/** - * 积分流水视图对象 - */ -export type PointsFlowVO = { - id: number; - userId: number; - points: number; - flowType: string; - businessType: string; - orderNo?: string; - description: string; - beforeBalance: number; - afterBalance: number; - createTime: string; -}; - -/** - * 积分预估结果视图对象 - */ -export type PointsEstimateVO = { - genType: string; - estimatedTokens: number; - estimatedPoints: number; - modelName?: string; - unitPrice: number; -}; - -/** - * 积分充值记录视图对象 - */ -export type PointsRechargeVO = { - id: number; - userId: number; - orderNo: string; - rechargePoints: number; - payAmount: number; - payType: string; - payStatus: number; - createTime: string; - payTime?: string; -}; - -/** - * 积分消费记录视图对象 - */ -export type PointsConsumeVO = { - id: number; - userId: number; - consumePoints: number; - businessType: string; - businessId?: string; - description: string; - createTime: string; -}; - -/** - * 积分套餐视图对象 - */ -export type PointsPackageVO = { - id: number; - packageName: string; - points: number; - originalPrice: number; - currentPrice: number; - description?: string; - sortOrder: number; - status: number; -}; - -/** - * 积分统计信息视图对象 - */ -export type PointsStatisticsVO = { - totalPoints: number; - usedPoints: number; - remainingPoints: number; - todayConsumed: number; - monthConsumed: number; - totalRecharge: number; - rank: number; -}; - -/** - * 积分变动通知视图对象 - */ -export type PointsNotificationVO = { - id: number; - userId: number; - title: string; - message: string; - pointsChange: number; - readStatus: number; - createTime: string; -}; - -/** - * 签到视图对象 - */ -export type SignInVO = { - id: number; - userId: number; - signInDate: string; - rewardPoints: number; - consecutiveDays: number; - isExtraReward: boolean; - createTime: string; -}; - -/** - * 签到记录视图对象 - */ -export type SignInRecordVO = { - id: number; - userId: number; - signInDate: string; - rewardPoints: number; - consecutiveDays: number; - createTime: string; -}; - -/** - * 邀请奖励视图对象 - */ -export type InviteRewardVO = { - id: number; - inviterId: number; - inviteeId: number; - rewardPoints: number; - inviteeFirstRecharge: boolean; - createTime: string; -}; diff --git a/ai-code-frontend/src/api/vo/spaceVO.ts b/ai-code-frontend/src/api/vo/spaceVO.ts deleted file mode 100644 index b4fb361..0000000 --- a/ai-code-frontend/src/api/vo/spaceVO.ts +++ /dev/null @@ -1,147 +0,0 @@ -/** - * 空间视图对象类型定义 - */ - -/** - * 空间基本信息视图对象 - */ -export type SpaceVO = { - id: string; - spaceName: string; - spaceType: number; - spaceDesc?: string; - spaceIcon?: string; - ownerId: number; - memberCount: number; - maxMembers: number; - isPublic: boolean; - createTime: string; - updateTime?: string; -}; - -/** - * 空间详情视图对象 - */ -export type SpaceDetailVO = SpaceVO & { - owner?: import('./userVO').UserSimpleVO; - members: SpaceMemberVO[]; - admins: SpaceMemberVO[]; - files: SpaceFileVO[]; - totalStorage: number; - usedStorage: number; -}; - -/** - * 空间成员视图对象 - */ -export type SpaceMemberVO = { - id: number; - spaceId: string; - userId: number; - user?: import('./userVO').UserSimpleVO; - role: string; - joinTime: string; - lastActiveTime?: string; -}; - -/** - * 空间文件视图对象 - */ -export type SpaceFileVO = { - id: string; - spaceId: string; - fileName: string; - filePath: string; - fileType: string; - fileSize: number; - uploadUserId: number; - uploadUser?: import('./userVO').UserSimpleVO; - createTime: string; - updateTime?: string; -}; - -/** - * 空间邀请视图对象 - */ -export type SpaceInviteVO = { - id: string; - spaceId: string; - inviteCode: string; - inviteUrl: string; - inviterId: number; - inviter?: import('./userVO').UserSimpleVO; - inviteeId?: number; - role: string; - status: number; - expiresTime?: string; - createTime: string; -}; - -/** - * 空间申请视图对象 - */ -export type SpaceApplyVO = { - id: string; - spaceId: string; - applicantId: number; - applicant?: import('./userVO').UserSimpleVO; - applyMessage?: string; - status: number; - reviewMessage?: string; - reviewTime?: string; - createTime: string; -}; - -/** - * 空间统计信息视图对象 - */ -export type SpaceStatisticsVO = { - totalSpaces: number; - ownedSpaces: number; - joinedSpaces: number; - totalMembers: number; - totalFiles: number; - totalStorage: number; -}; - -/** - * 我的空间视图对象 - */ -export type MySpaceVO = { - id: string; - spaceName: string; - spaceType: number; - spaceIcon?: string; - role: string; - memberCount: number; - isPublic: boolean; - lastActiveTime?: string; - createTime: string; -}; - -/** - * 空间操作日志视图对象 - */ -export type SpaceLogVO = { - id: string; - spaceId: string; - operatorId: number; - operator?: import('./userVO').UserSimpleVO; - operationType: string; - operationDesc: string; - createTime: string; -}; - -/** - * 空间权限视图对象 - */ -export type SpacePermissionVO = { - spaceId: string; - canManage: boolean; - canInvite: boolean; - canKick: boolean; - canEdit: boolean; - canDelete: boolean; - canUpload: boolean; - canDownload: boolean; -}; diff --git a/ai-code-frontend/src/api/vo/userVO.ts b/ai-code-frontend/src/api/vo/userVO.ts deleted file mode 100644 index c093064..0000000 --- a/ai-code-frontend/src/api/vo/userVO.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * 用户视图对象类型定义 - */ - -/** - * 用户基本信息视图对象 - */ -export type UserVO = { - id: number; - userAccount: string; - userName?: string; - userAvatar?: string; - userProfile?: string; - email?: string; - userRole: string; - userStatus: number; - createTime: string; - updateTime?: string; -}; - -/** - * 用户详情信息视图对象 - */ -export type UserDetailVO = UserVO & { - lastLoginTime?: string; - totalPoints?: number; - usedPoints?: number; - remainingPoints?: number; - invitationCode?: string; - invitedCount?: number; -}; - -/** - * 用户登录响应视图对象 - */ -export type UserLoginVO = { - id: number; - userAccount: string; - userName?: string; - userAvatar?: string; - email?: string; - accessToken: string; - refreshToken?: string; - expiresIn?: number; -}; - -/** - * 用户注册响应视图对象 - */ -export type UserRegisterVO = { - id: number; - userAccount: string; - userName?: string; - userAvatar?: string; - accessToken: string; -}; - -/** - * 用户积分信息视图对象 - */ -export type UserPointsVO = { - userId: number; - totalPoints: number; - usedPoints: number; - remainingPoints: number; - pointsBalance: number; -}; - -/** - * 用户邀请信息视图对象 - */ -export type UserInviteVO = { - inviterId: number; - inviterAccount: string; - inviteCode: string; - invitedCount: number; - rewardPoints: number; -}; - -/** - * 用户统计信息视图对象 - */ -export type UserStatisticsVO = { - totalApps: number; - totalConversations: number; - totalCodeSnippets: number; - totalPointsSpent: number; - joinDays: number; -}; - -/** - * 用户简要信息视图对象(用于列表展示) - */ -export type UserSimpleVO = { - id: number; - userAccount: string; - userName?: string; - userAvatar?: string; -}; diff --git a/ai-code-frontend/src/constants/index.ts b/ai-code-frontend/src/constants/index.ts index ad7af18..74ec2b3 100644 --- a/ai-code-frontend/src/constants/index.ts +++ b/ai-code-frontend/src/constants/index.ts @@ -7,10 +7,7 @@ export const APP_NAME = 'AI Code Generator'; // API基础路径 -export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || '/api'; - -// WebSocket基础路径 -export const WS_BASE_URL = import.meta.env.VITE_WS_BASE_URL || ''; +export const API_BASE_URL = '/api'; // 生产环境后端主机 export const BACKEND_HOST_PROD = "https://xxx"; @@ -65,4 +62,4 @@ export const PAGINATION = { export const CHAT_CONFIG = { MAX_MESSAGES: 100, // 最大消息数量 STREAM_TIMEOUT: 30000 // 流式传输超时时间(毫秒) -} as const; +} as const; \ No newline at end of file diff --git a/ai-code-frontend/src/global.tsx b/ai-code-frontend/src/global.tsx index 28ec2f1..d1e94a8 100644 --- a/ai-code-frontend/src/global.tsx +++ b/ai-code-frontend/src/global.tsx @@ -9,7 +9,7 @@ const clearCache = () => { caches.delete(key); }); }) - .catch(() => undefined); + .catch((e) => console.log(e)); } }; @@ -34,4 +34,4 @@ window.addEventListener('offline', () => { window.addEventListener('online', () => { message.success('网络已恢复'); -}); +}); \ No newline at end of file diff --git a/ai-code-frontend/src/layouts/BasicLayout/index.tsx b/ai-code-frontend/src/layouts/BasicLayout/index.tsx index 57911a3..322415b 100644 --- a/ai-code-frontend/src/layouts/BasicLayout/index.tsx +++ b/ai-code-frontend/src/layouts/BasicLayout/index.tsx @@ -84,6 +84,11 @@ const BasicLayout = () => { name: '积分记录管理', icon: , }, + { + path: '/admin/aiModelConfig', + name: 'AI模型配置', + icon: , + }, { path: '/admin/dataRepair', name: '数据修复工具', @@ -97,6 +102,7 @@ const BasicLayout = () => { return ( } title={defaultSettings.title} layout={defaultSettings.layout} navTheme={defaultSettings.navTheme} @@ -124,7 +130,6 @@ const BasicLayout = () => { }} footerRender={() =>