后台管理功能实现
This commit is contained in:
+74
-7
@@ -1,10 +1,77 @@
|
|||||||
---
|
---
|
||||||
inclusion: always
|
inclusion: always
|
||||||
---
|
---
|
||||||
1.所有问答使用中文;
|
## 基础设置
|
||||||
2.所有Controller层接口定义要完整,入参使用request封装,出参使用response封装;
|
1. 保持对话语言为中文/英文
|
||||||
3.除了特殊情况,不允许使用try-catch,交由全局异常处理机制处理异常;
|
2. 根据当前的操作系统环境确定要使用的是什么类型的操作命令,Mac或者Windows系统的操作命令是不一样的
|
||||||
4.未经允许不允许删除任何文件;
|
3. 执行终端命令时要关注执行情况,避免无效等待
|
||||||
6.所有的新增代码要遵循当前的项目规范;
|
|
||||||
7.禁止使用批量脚本创建代码文件;
|
## 代码规范
|
||||||
8.需要修改明显有问题的代码时直接自动操作修改代码,不要询问;
|
4. 生成代码时必须添加类级和函数级注释
|
||||||
|
5. 使用import导包,禁止使用全限定名称引用类
|
||||||
|
6. 禁止使用枚举类型作为entity、request、response、dto对象的字段类型
|
||||||
|
7. 新增数据的id使用已存在的雪花算法生成器生成
|
||||||
|
|
||||||
|
## 架构规范
|
||||||
|
8. 所有开发必须遵循当前项目规范
|
||||||
|
9. Controller层禁止添加业务逻辑
|
||||||
|
10. 使用全局异常处理,禁止使用try-catch
|
||||||
|
11. 前端接口访问尽可能走网关调用
|
||||||
|
|
||||||
|
## 接口设计规范
|
||||||
|
12. Controller层接口定义要完整:
|
||||||
|
- 入参使用request封装传递到service层
|
||||||
|
- service层的方法命名与controller层定义的接口的方法名称保持一致
|
||||||
|
- 出参使用response封装由service层传递到controller层
|
||||||
|
- 禁止在controller层做entity/domain对象与request/response的转换
|
||||||
|
- 使用项目已有的Result做接口返回
|
||||||
|
13. 接口和方法参数不允许超过两个,超过时使用request或DTO对象封装
|
||||||
|
14. Controller层路由禁止添加/api前缀
|
||||||
|
15. Controller层接口的Mapping注解value属性值不允许重复且不允许为空
|
||||||
|
16. 用户相关接口禁止直接传递用户id,需要后端根据token获取当前登录用户信息
|
||||||
|
17. Controller层接口的Mapping注解(PostMapping、GetMapping、PutMapping、DeleteMapping等)的value属性值要简洁明了,与接口作用相关,名称不宜过长,使用驼峰结构命名
|
||||||
|
18. 禁止使用/{param}格式的路径参数,避免网关路由冲突和分发错误
|
||||||
|
19. 所有接口注解必须明确指定value属性,不允许使用空注解
|
||||||
|
20. 路径参数统一使用@RequestParam而非@PathVariable,确保网关分发准确性
|
||||||
|
21. 接口路径命名应具有明确的语义,避免使用通用词汇如/get、/list等
|
||||||
|
22. 批量操作接口应使用专门的Request对象封装参数,而非直接传递List
|
||||||
|
23. 接口路径应避免层级过深,建议不超过3级路径结构
|
||||||
|
24. 更新操作应直接使用封装了ID和其他数据的Request对象,而不是单独传递ID参数。Service层方法应保持参数简洁,业务逻辑所需数据应全部包含在Request对象中
|
||||||
|
|
||||||
|
## 环境配置
|
||||||
|
|
||||||
|
25. 为不同环境(local、dev、prod)创建单独配置文件,部署时通过参数选择
|
||||||
|
26. 启动服务时禁止擅自修改端口号,使用配置文件中的端口设置
|
||||||
|
|
||||||
|
## 数据库规范
|
||||||
|
|
||||||
|
27. 所有数据表必须包含创建时间(create_time)和更新时间(update_time)字段
|
||||||
|
28. 删除操作优先使用逻辑删除,添加deleted字段标识
|
||||||
|
29. 数据库字段命名使用下划线分隔,Java实体类使用驼峰命名
|
||||||
|
30. 优先使用LambdaQueryWrapper构造条件查询,避免硬编码字段名
|
||||||
|
31. 使用Lambda表达式引用实体类属性,提高代码可维护性和类型安全
|
||||||
|
32. 复杂查询条件应使用LambdaQueryWrapper的链式调用,保持代码清晰
|
||||||
|
33. 避免在查询条件中使用字符串字段名,防止字段名变更导致的运行时错误
|
||||||
|
|
||||||
|
## 安全规范
|
||||||
|
|
||||||
|
34. 所有外部输入必须进行参数校验
|
||||||
|
35. 敏感信息不得在日志中输出
|
||||||
|
36. 数据库操作必须使用参数化查询,防止SQL注入
|
||||||
|
|
||||||
|
## 性能规范
|
||||||
|
|
||||||
|
37. 避免N+1查询问题,合理使用批量查询
|
||||||
|
38. 大数据量查询必须分页处理
|
||||||
|
39. 缓存策略要考虑数据一致性问题
|
||||||
|
|
||||||
|
## 日志规范
|
||||||
|
|
||||||
|
40. 关键业务操作必须记录操作日志
|
||||||
|
41. 异常信息要包含足够的上下文信息
|
||||||
|
42. 生产环境禁止输出debug级别日志
|
||||||
|
|
||||||
|
## 修改规范
|
||||||
|
|
||||||
|
43. 代码修改时,只修改用户指定的业务逻辑和代码,解决用户指定的问题,不得随意修改其他无关代码
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.emotion.config;
|
package com.emotion.config;
|
||||||
|
|
||||||
import com.emotion.interceptor.AuthInterceptor;
|
import com.emotion.interceptor.AuthInterceptor;
|
||||||
|
import com.emotion.interceptor.AdminAuthInterceptor;
|
||||||
import com.emotion.interceptor.UserContextInterceptor;
|
import com.emotion.interceptor.UserContextInterceptor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -21,6 +22,9 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AuthInterceptor authInterceptor;
|
private AuthInterceptor authInterceptor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AdminAuthInterceptor adminAuthInterceptor;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserContextInterceptor userContextInterceptor;
|
private UserContextInterceptor userContextInterceptor;
|
||||||
|
|
||||||
@@ -29,11 +33,17 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
// 认证拦截器
|
// 管理员认证拦截器 - 优先级最高
|
||||||
|
registry.addInterceptor(adminAuthInterceptor)
|
||||||
|
.addPathPatterns("/admin/**")
|
||||||
|
.order(1);
|
||||||
|
|
||||||
|
// 用户认证拦截器
|
||||||
registry.addInterceptor(authInterceptor)
|
registry.addInterceptor(authInterceptor)
|
||||||
.addPathPatterns("/**")
|
.addPathPatterns("/**")
|
||||||
.excludePathPatterns(
|
.excludePathPatterns(
|
||||||
"/auth/**",
|
"/auth/**",
|
||||||
|
"/admin/**", // 排除管理员接口,由AdminAuthInterceptor处理
|
||||||
"/error",
|
"/error",
|
||||||
"/favicon.ico",
|
"/favicon.ico",
|
||||||
"/actuator/**",
|
"/actuator/**",
|
||||||
@@ -45,7 +55,8 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
"/doc.html",
|
"/doc.html",
|
||||||
"/static/**",
|
"/static/**",
|
||||||
"/public/**"
|
"/public/**"
|
||||||
);
|
)
|
||||||
|
.order(2);
|
||||||
|
|
||||||
// 用户上下文拦截器
|
// 用户上下文拦截器
|
||||||
registry.addInterceptor(userContextInterceptor)
|
registry.addInterceptor(userContextInterceptor)
|
||||||
@@ -62,7 +73,8 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
"/doc.html",
|
"/doc.html",
|
||||||
"/static/**",
|
"/static/**",
|
||||||
"/public/**"
|
"/public/**"
|
||||||
);
|
)
|
||||||
|
.order(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -98,11 +98,13 @@ public class AdminAuthInterceptor implements HandlerInterceptor {
|
|||||||
private boolean isPublicAdminEndpoint(String requestURI) {
|
private boolean isPublicAdminEndpoint(String requestURI) {
|
||||||
String[] publicEndpoints = {
|
String[] publicEndpoints = {
|
||||||
"/admin/auth/login",
|
"/admin/auth/login",
|
||||||
"/admin/auth/refreshToken"
|
"/admin/auth/refreshToken",
|
||||||
|
"/api/admin/auth/login", // 包含context-path的路径
|
||||||
|
"/api/admin/auth/refreshToken" // 包含context-path的路径
|
||||||
};
|
};
|
||||||
|
|
||||||
for (String endpoint : publicEndpoints) {
|
for (String endpoint : publicEndpoints) {
|
||||||
if (requestURI.equals(endpoint)) {
|
if (requestURI.equals(endpoint) || requestURI.endsWith(endpoint)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private JwtUtil jwtUtil;
|
private JwtUtil jwtUtil;
|
||||||
|
|
||||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
@Autowired
|
||||||
|
private org.springframework.security.crypto.password.PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
private static final String ADMIN_TOKEN_PREFIX = "admin_token:";
|
private static final String ADMIN_TOKEN_PREFIX = "admin_token:";
|
||||||
private static final String ADMIN_REFRESH_TOKEN_PREFIX = "admin_refresh_token:";
|
private static final String ADMIN_REFRESH_TOKEN_PREFIX = "admin_refresh_token:";
|
||||||
|
|||||||
@@ -92,13 +92,13 @@ public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements
|
|||||||
.map(this::convertToResponse)
|
.map(this::convertToResponse)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return PageResult.<AdminResponse>builder()
|
PageResult<AdminResponse> result = new PageResult<>();
|
||||||
.records(responseList)
|
result.setRecords(responseList);
|
||||||
.total(adminPage.getTotal())
|
result.setTotal(adminPage.getTotal());
|
||||||
.current(adminPage.getCurrent())
|
result.setCurrent(adminPage.getCurrent());
|
||||||
.size(adminPage.getSize())
|
result.setSize(adminPage.getSize());
|
||||||
.pages(adminPage.getPages())
|
result.setPages(adminPage.getPages());
|
||||||
.build();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -936,5 +936,265 @@ WHERE
|
|||||||
ORDER BY
|
ORDER BY
|
||||||
TABLE_NAME;
|
TABLE_NAME;
|
||||||
|
|
||||||
|
-- ============================================================================
|
||||||
|
-- 19. AI接口配置表 (t_ai_config)
|
||||||
|
-- 用于存储各种AI接口的调用配置,支持从配置文件迁移到数据库管理
|
||||||
|
-- ============================================================================
|
||||||
|
CREATE TABLE t_ai_config (
|
||||||
|
id VARCHAR(64) PRIMARY KEY COMMENT 'UUID主键',
|
||||||
|
config_name VARCHAR(100) NOT NULL COMMENT '配置名称',
|
||||||
|
config_key VARCHAR(100) NOT NULL UNIQUE COMMENT '配置键值 (唯一标识)',
|
||||||
|
config_type VARCHAR(50) NOT NULL DEFAULT 'coze' COMMENT '配置类型: coze-扣子, openai-OpenAI, claude-Claude, gemini-Gemini等',
|
||||||
|
provider VARCHAR(50) NOT NULL COMMENT '服务提供商: coze, openai, anthropic, google等',
|
||||||
|
|
||||||
|
-- API基础配置
|
||||||
|
api_base_url VARCHAR(500) NOT NULL COMMENT 'API基础URL',
|
||||||
|
api_token VARCHAR(1000) NOT NULL COMMENT 'API访问令牌 (加密存储)',
|
||||||
|
api_version VARCHAR(20) COMMENT 'API版本',
|
||||||
|
|
||||||
|
-- 模型配置
|
||||||
|
model_name VARCHAR(100) COMMENT '模型名称',
|
||||||
|
bot_id VARCHAR(100) COMMENT 'Bot ID (Coze专用)',
|
||||||
|
workflow_id VARCHAR(100) COMMENT 'Workflow ID (Coze专用)',
|
||||||
|
|
||||||
|
-- 请求配置
|
||||||
|
timeout_ms INT DEFAULT 30000 COMMENT '超时时间(毫秒)',
|
||||||
|
retry_count INT DEFAULT 3 COMMENT '重试次数',
|
||||||
|
retry_delay_ms INT DEFAULT 1000 COMMENT '重试延迟(毫秒)',
|
||||||
|
max_tokens INT DEFAULT 4000 COMMENT '最大Token数',
|
||||||
|
temperature DECIMAL(3,2) DEFAULT 0.7 COMMENT '温度参数 (0.0-2.0)',
|
||||||
|
top_p DECIMAL(3,2) DEFAULT 1.0 COMMENT 'Top-p参数 (0.0-1.0)',
|
||||||
|
|
||||||
|
-- 功能配置
|
||||||
|
support_stream TINYINT DEFAULT 1 COMMENT '是否支持流式输出: 0-不支持, 1-支持',
|
||||||
|
support_function_call TINYINT DEFAULT 0 COMMENT '是否支持函数调用: 0-不支持, 1-支持',
|
||||||
|
support_vision TINYINT DEFAULT 0 COMMENT '是否支持视觉理解: 0-不支持, 1-支持',
|
||||||
|
support_file_upload TINYINT DEFAULT 0 COMMENT '是否支持文件上传: 0-不支持, 1-支持',
|
||||||
|
|
||||||
|
-- 使用场景配置
|
||||||
|
usage_scenario VARCHAR(100) NOT NULL COMMENT '使用场景: chat-聊天, summary-总结, emotion_analysis-情绪分析, content_generation-内容生成等',
|
||||||
|
priority INT DEFAULT 0 COMMENT '优先级 (数值越大优先级越高)',
|
||||||
|
|
||||||
|
-- 费用配置
|
||||||
|
input_price_per_1k DECIMAL(10,6) DEFAULT 0.000000 COMMENT '输入Token价格(每1K)',
|
||||||
|
output_price_per_1k DECIMAL(10,6) DEFAULT 0.000000 COMMENT '输出Token价格(每1K)',
|
||||||
|
currency VARCHAR(10) DEFAULT 'USD' COMMENT '货币单位',
|
||||||
|
|
||||||
|
-- 限制配置
|
||||||
|
rate_limit_per_minute INT DEFAULT 60 COMMENT '每分钟请求限制',
|
||||||
|
rate_limit_per_hour INT DEFAULT 3600 COMMENT '每小时请求限制',
|
||||||
|
rate_limit_per_day INT DEFAULT 86400 COMMENT '每日请求限制',
|
||||||
|
|
||||||
|
-- 状态配置
|
||||||
|
is_enabled TINYINT DEFAULT 1 COMMENT '是否启用: 0-禁用, 1-启用',
|
||||||
|
is_default TINYINT DEFAULT 0 COMMENT '是否为默认配置: 0-否, 1-是',
|
||||||
|
environment VARCHAR(20) DEFAULT 'production' COMMENT '环境: development-开发, testing-测试, production-生产',
|
||||||
|
|
||||||
|
-- 扩展配置
|
||||||
|
custom_headers JSON COMMENT '自定义请求头',
|
||||||
|
custom_params JSON COMMENT '自定义参数',
|
||||||
|
webhook_url VARCHAR(500) COMMENT 'Webhook回调地址',
|
||||||
|
|
||||||
|
-- 监控配置
|
||||||
|
health_check_url VARCHAR(500) COMMENT '健康检查URL',
|
||||||
|
health_check_interval_minutes INT DEFAULT 5 COMMENT '健康检查间隔(分钟)',
|
||||||
|
|
||||||
|
-- 描述信息
|
||||||
|
description TEXT COMMENT '配置描述',
|
||||||
|
usage_notes TEXT COMMENT '使用说明',
|
||||||
|
|
||||||
|
-- 公共字段
|
||||||
|
create_by VARCHAR(64) COMMENT '创建人ID',
|
||||||
|
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
update_by VARCHAR(64) COMMENT '更新人ID',
|
||||||
|
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
is_deleted TINYINT DEFAULT 0 COMMENT '是否删除: 0-未删除, 1-已删除',
|
||||||
|
remarks VARCHAR(500) COMMENT '备注'
|
||||||
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'AI接口配置表 (t_ai_config)';
|
||||||
|
|
||||||
|
-- AI配置表索引
|
||||||
|
CREATE INDEX idx_ai_config_config_key ON t_ai_config (config_key);
|
||||||
|
CREATE INDEX idx_ai_config_config_type ON t_ai_config (config_type);
|
||||||
|
CREATE INDEX idx_ai_config_provider ON t_ai_config (provider);
|
||||||
|
CREATE INDEX idx_ai_config_usage_scenario ON t_ai_config (usage_scenario);
|
||||||
|
CREATE INDEX idx_ai_config_is_enabled ON t_ai_config (is_enabled);
|
||||||
|
CREATE INDEX idx_ai_config_is_default ON t_ai_config (is_default);
|
||||||
|
CREATE INDEX idx_ai_config_environment ON t_ai_config (environment);
|
||||||
|
CREATE INDEX idx_ai_config_priority ON t_ai_config (priority);
|
||||||
|
CREATE INDEX idx_ai_config_create_time ON t_ai_config (create_time);
|
||||||
|
CREATE INDEX idx_ai_config_update_time ON t_ai_config (update_time);
|
||||||
|
CREATE INDEX idx_ai_config_is_deleted ON t_ai_config (is_deleted);
|
||||||
|
CREATE INDEX idx_ai_config_scenario_enabled ON t_ai_config (usage_scenario, is_enabled);
|
||||||
|
CREATE INDEX idx_ai_config_type_enabled ON t_ai_config (config_type, is_enabled);
|
||||||
|
|
||||||
|
-- ============================================================================
|
||||||
|
-- AI配置初始化数据
|
||||||
|
-- 基于AiChatServiceImpl.java中的配置参数创建默认配置
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
-- 1. Coze聊天配置 (默认聊天场景)
|
||||||
|
INSERT INTO t_ai_config (
|
||||||
|
id, config_name, config_key, config_type, provider,
|
||||||
|
api_base_url, api_token, api_version,
|
||||||
|
bot_id, workflow_id,
|
||||||
|
timeout_ms, retry_count, retry_delay_ms, max_tokens, temperature,
|
||||||
|
support_stream, support_function_call, support_vision, support_file_upload,
|
||||||
|
usage_scenario, priority, is_enabled, is_default, environment,
|
||||||
|
input_price_per_1k, output_price_per_1k, currency,
|
||||||
|
rate_limit_per_minute, rate_limit_per_hour, rate_limit_per_day,
|
||||||
|
description, usage_notes,
|
||||||
|
create_time, update_time, is_deleted
|
||||||
|
) VALUES (
|
||||||
|
REPLACE(UUID(), '-', ''),
|
||||||
|
'Coze聊天机器人配置',
|
||||||
|
'coze.chat.default',
|
||||||
|
'coze',
|
||||||
|
'coze',
|
||||||
|
'https://api.coze.cn',
|
||||||
|
'sat_WgqusMh5gTfgRhsEFycGA5n9NailrJYV1rHeruJCHNB1gAvJz4laprLsvK8i2jEL',
|
||||||
|
'v3',
|
||||||
|
'7523042446285439016',
|
||||||
|
'7523047462895796287',
|
||||||
|
30000, 3, 1000, 4000, 0.7,
|
||||||
|
1, 1, 0, 0,
|
||||||
|
'chat', 100, 1, 1, 'production',
|
||||||
|
0.001000, 0.002000, 'USD',
|
||||||
|
60, 3600, 86400,
|
||||||
|
'Coze平台的默认聊天机器人配置,用于日常情绪对话',
|
||||||
|
'1. 需要配置有效的API Token\n2. 需要配置Bot ID和Workflow ID\n3. 支持流式输出和函数调用',
|
||||||
|
NOW(), NOW(), 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 2. Coze总结配置 (专用于对话总结)
|
||||||
|
INSERT INTO t_ai_config (
|
||||||
|
id, config_name, config_key, config_type, provider,
|
||||||
|
api_base_url, api_token, api_version,
|
||||||
|
bot_id, workflow_id,
|
||||||
|
timeout_ms, retry_count, retry_delay_ms, max_tokens, temperature,
|
||||||
|
support_stream, support_function_call, support_vision, support_file_upload,
|
||||||
|
usage_scenario, priority, is_enabled, is_default, environment,
|
||||||
|
input_price_per_1k, output_price_per_1k, currency,
|
||||||
|
rate_limit_per_minute, rate_limit_per_hour, rate_limit_per_day,
|
||||||
|
description, usage_notes,
|
||||||
|
create_time, update_time, is_deleted
|
||||||
|
) VALUES (
|
||||||
|
REPLACE(UUID(), '-', ''),
|
||||||
|
'Coze对话总结配置',
|
||||||
|
'coze.summary.default',
|
||||||
|
'coze',
|
||||||
|
'coze',
|
||||||
|
'https://api.coze.cn',
|
||||||
|
'sat_WgqusMh5gTfgRhsEFycGA5n9NailrJYV1rHeruJCHNB1gAvJz4laprLsvK8i2jEL',
|
||||||
|
'v3',
|
||||||
|
'7529062814150295595',
|
||||||
|
'7523047462895796287',
|
||||||
|
30000, 3, 1000, 8000, 0.3,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
'summary', 90, 1, 1, 'production',
|
||||||
|
0.001000, 0.002000, 'USD',
|
||||||
|
30, 1800, 43200,
|
||||||
|
'Coze平台的对话总结配置,专门用于生成对话摘要和情绪分析',
|
||||||
|
'1. 使用较低的temperature以获得更稳定的总结结果\n2. 增加max_tokens以支持长文本总结\n3. 不支持流式输出',
|
||||||
|
NOW(), NOW(), 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 3. Coze情绪分析配置 (专用于情绪分析)
|
||||||
|
INSERT INTO t_ai_config (
|
||||||
|
id, config_name, config_key, config_type, provider,
|
||||||
|
api_base_url, api_token, api_version,
|
||||||
|
bot_id, workflow_id,
|
||||||
|
timeout_ms, retry_count, retry_delay_ms, max_tokens, temperature,
|
||||||
|
support_stream, support_function_call, support_vision, support_file_upload,
|
||||||
|
usage_scenario, priority, is_enabled, is_default, environment,
|
||||||
|
input_price_per_1k, output_price_per_1k, currency,
|
||||||
|
rate_limit_per_minute, rate_limit_per_hour, rate_limit_per_day,
|
||||||
|
description, usage_notes,
|
||||||
|
create_time, update_time, is_deleted
|
||||||
|
) VALUES (
|
||||||
|
REPLACE(UUID(), '-', ''),
|
||||||
|
'Coze情绪分析配置',
|
||||||
|
'coze.emotion_analysis.default',
|
||||||
|
'coze',
|
||||||
|
'coze',
|
||||||
|
'https://api.coze.cn',
|
||||||
|
'sat_WgqusMh5gTfgRhsEFycGA5n9NailrJYV1rHeruJCHNB1gAvJz4laprLsvK8i2jEL',
|
||||||
|
'v3',
|
||||||
|
'7529062814150295595', -- 复用总结bot,或配置专门的情绪分析bot
|
||||||
|
'7523047462895796287', -- 复用总结workflow,或配置专门的情绪分析workflow
|
||||||
|
45000, 3, 1500, 6000, 0.2,
|
||||||
|
0, 1, 0, 0,
|
||||||
|
'emotion_analysis', 95, 1, 1, 'production',
|
||||||
|
0.001000, 0.002000, 'USD',
|
||||||
|
20, 1200, 28800,
|
||||||
|
'Coze平台的情绪分析配置,用于分析用户聊天记录的情绪状态',
|
||||||
|
'1. 使用最低的temperature以获得准确的情绪分析\n2. 支持函数调用以获取结构化的分析结果\n3. 增加超时时间以处理复杂的情绪分析',
|
||||||
|
NOW(), NOW(), 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 4. 备用OpenAI配置 (作为备选方案)
|
||||||
|
INSERT INTO t_ai_config (
|
||||||
|
id, config_name, config_key, config_type, provider,
|
||||||
|
api_base_url, api_token, api_version,
|
||||||
|
model_name,
|
||||||
|
timeout_ms, retry_count, retry_delay_ms, max_tokens, temperature, top_p,
|
||||||
|
support_stream, support_function_call, support_vision, support_file_upload,
|
||||||
|
usage_scenario, priority, is_enabled, is_default, environment,
|
||||||
|
input_price_per_1k, output_price_per_1k, currency,
|
||||||
|
rate_limit_per_minute, rate_limit_per_hour, rate_limit_per_day,
|
||||||
|
description, usage_notes,
|
||||||
|
create_time, update_time, is_deleted
|
||||||
|
) VALUES (
|
||||||
|
REPLACE(UUID(), '-', ''),
|
||||||
|
'OpenAI GPT-4备用配置',
|
||||||
|
'openai.gpt4.backup',
|
||||||
|
'openai',
|
||||||
|
'openai',
|
||||||
|
'https://api.openai.com/v1',
|
||||||
|
'sk-placeholder-openai-api-key-here', -- 需要配置实际的OpenAI API Key
|
||||||
|
'v1',
|
||||||
|
'gpt-4-turbo-preview',
|
||||||
|
30000, 3, 2000, 4000, 0.7, 1.0,
|
||||||
|
1, 1, 1, 1,
|
||||||
|
'chat', 50, 0, 0, 'production', -- 默认禁用,作为备用
|
||||||
|
0.010000, 0.030000, 'USD',
|
||||||
|
60, 3600, 86400,
|
||||||
|
'OpenAI GPT-4备用配置,当Coze服务不可用时的备选方案',
|
||||||
|
'1. 需要配置有效的OpenAI API Key\n2. 支持视觉理解和文件上传\n3. 成本较高,建议作为备用方案',
|
||||||
|
NOW(), NOW(), 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 5. 开发环境测试配置
|
||||||
|
INSERT INTO t_ai_config (
|
||||||
|
id, config_name, config_key, config_type, provider,
|
||||||
|
api_base_url, api_token, api_version,
|
||||||
|
bot_id, workflow_id,
|
||||||
|
timeout_ms, retry_count, retry_delay_ms, max_tokens, temperature,
|
||||||
|
support_stream, support_function_call, support_vision, support_file_upload,
|
||||||
|
usage_scenario, priority, is_enabled, is_default, environment,
|
||||||
|
input_price_per_1k, output_price_per_1k, currency,
|
||||||
|
rate_limit_per_minute, rate_limit_per_hour, rate_limit_per_day,
|
||||||
|
description, usage_notes,
|
||||||
|
create_time, update_time, is_deleted
|
||||||
|
) VALUES (
|
||||||
|
REPLACE(UUID(), '-', ''),
|
||||||
|
'Coze开发环境测试配置',
|
||||||
|
'coze.chat.development',
|
||||||
|
'coze',
|
||||||
|
'coze',
|
||||||
|
'https://api.coze.cn',
|
||||||
|
'sat_WgqusMh5gTfgRhsEFycGA5n9NailrJYV1rHeruJCHNB1gAvJz4laprLsvK8i2jEL', -- 开发环境可使用相同token或配置专门的开发token
|
||||||
|
'v3',
|
||||||
|
'7523042446285439016', -- 开发环境可使用相同bot-id或配置专门的开发bot-id
|
||||||
|
'7523047462895796287', -- 开发环境可使用相同workflow-id或配置专门的开发workflow-id
|
||||||
|
10000, 2, 500, 2000, 0.8,
|
||||||
|
1, 1, 0, 0,
|
||||||
|
'chat', 80, 1, 0, 'development',
|
||||||
|
0.000500, 0.001000, 'USD',
|
||||||
|
120, 7200, 172800,
|
||||||
|
'Coze平台开发环境测试配置,用于开发和调试',
|
||||||
|
'1. 开发环境专用配置\n2. 较短的超时时间和更高的请求限制\n3. 用于功能测试和调试',
|
||||||
|
NOW(), NOW(), 0
|
||||||
|
);
|
||||||
|
|
||||||
-- 提交事务
|
-- 提交事务
|
||||||
COMMIT;
|
COMMIT;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
VITE_APP_TITLE=情绪博物馆管理后台
|
VITE_APP_TITLE=情绪博物馆管理后台
|
||||||
VITE_APP_BASE_API=/api
|
VITE_APP_BASE_API=http://localhost:19089/api
|
||||||
VITE_APP_PORT=5174
|
VITE_APP_PORT=5174
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
# 生产环境配置
|
# 生产环境配置
|
||||||
VITE_APP_TITLE=情绪博物馆管理后台
|
VITE_APP_TITLE=情绪博物馆管理后台
|
||||||
VITE_APP_BASE_API=/api
|
# 生产环境需要配置实际的后端服务器地址
|
||||||
|
VITE_APP_BASE_API=http://localhost:19089/api
|
||||||
|
|||||||
Generated
+4194
File diff suppressed because it is too large
Load Diff
@@ -13,8 +13,9 @@ export default defineConfig({
|
|||||||
port: 5174,
|
port: 5174,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://localhost:8080',
|
target: 'http://localhost:19089',
|
||||||
changeOrigin: true
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user