### RabbitMQ Configuration Constants Source: https://context7.com/gitgg021/ai-chart/llms.txt Defines constants for RabbitMQ exchange, queue, and routing key used for asynchronous task processing. Ensure these constants match your RabbitMQ setup. ```java public class MqConstant { public static final String BI_EXCHANGE = "bi_exchange"; public static final String BI_QUEUE = "bi_queue"; public static final String BI_ROUTING_KEY = "bi_routingKey"; } ``` -------------------------------- ### Get Current Logged-in User API Source: https://context7.com/gitgg021/ai-chart/llms.txt Retrieves the details of the currently logged-in user, requiring a valid session cookie. ```APIDOC ## GET /api/user/get/login ### Description Retrieves the detailed information of the currently logged-in user. Requires a valid session cookie. ### Method GET ### Endpoint /api/user/get/login ### Parameters #### Cookie Parameters - **cookies.txt** - Required - Session cookie for authentication. ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **data** (object) - User information. - **id** (long) - User ID. - **userName** (string) - User's name. - **userAvatar** (string) - URL of the user's avatar. - **userProfile** (string) - User's profile description. - **userRole** (string) - User's role. - **createTime** (string) - User creation timestamp. - **message** (string) - "ok" for success. #### Response Example ```json { "code": 0, "data": { "id": 1234567890123456789, "userName": "testuser", "userAvatar": "https://www.codefather.cn/logo.png", "userProfile": "数据分析师", "userRole": "user", "createTime": "2024-01-01T10:00:00.000+00:00" }, "message": "ok" } ``` ``` -------------------------------- ### Get Chart Details API Source: https://context7.com/gitgg021/ai-chart/llms.txt Retrieves detailed information for a specific chart using its ID, including raw data, analysis goals, generated chart configurations, and conclusions. ```APIDOC ## GET /api/chart/get ### Description Retrieves the detailed information for a specific chart based on its ID. This includes the original data, analysis goal, generated chart configuration, and analysis conclusions. ### Method GET ### Endpoint /api/chart/get ### Parameters #### Query Parameters - **id** (long) - Required - The unique identifier of the chart. #### Cookie Parameters - **cookies.txt** - Required - Session cookie for authentication. ### Request Example ```bash curl -X GET "http://localhost:8080/api/chart/get?id=1234567890123456790" \ -b cookies.txt ``` ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **data** (object) - Chart details. - **id** (long) - Chart ID. - **name** (string) - Name of the chart. - **goal** (string) - Analysis goal. - **chartType** (string) - Type of the chart. - **status** (string) - Current status of the analysis (e.g., "succeed", "running", "failed"). - **genChart** (string) - JSON string of the generated chart configuration (null if not generated). - **genResult** (string) - Textual analysis result (null if not generated). - **message** (string) - "ok" for success. #### Response Example (Completed) ```json { "code": 0, "data": { "id": 1234567890123456791, "name": "网站流量分析", "goal": "分析网站各页面的访问量分布", "chartType": "饼图", "status": "succeed", "genChart": "{\"title\":{\"text\":\"页面访问量分布\"},\"series\":[{\"type\":\"pie\",\"data\":[{\"value\":1048,\"name\":\"首页\"},{\"value\":735,\"name\":\"产品页\"},{\"value\":580,\"name\":\"关于我们\"}]}]}", "genResult": "首页访问量最高,占总访问量的44%,建议优化首页内容展示。" }, "message": "ok" } ``` ``` -------------------------------- ### User Registration API Source: https://context7.com/gitgg021/ai-chart/llms.txt Allows new users to create an account. Requires account, password, and password confirmation. The system encrypts passwords and assigns a default avatar. ```APIDOC ## POST /api/user/register ### Description Registers a new user with the provided account credentials. ### Method POST ### Endpoint /api/user/register ### Parameters #### Request Body - **userAccount** (string) - Required - The user's account name. - **userPassword** (string) - Required - The user's password. - **checkPassword** (string) - Required - The confirmation of the user's password. ### Request Example ```json { "userAccount": "testuser", "userPassword": "password123", "checkPassword": "password123" } ``` ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **data** (long) - The ID of the newly created user. - **message** (string) - "ok" for success. #### Response Example ```json { "code": 0, "data": 1234567890123456789, "message": "ok" } ``` #### Error Response (40000) - **code** (integer) - 40000 for password mismatch. - **message** (string) - "两次输入的密码不一致" #### Error Response Example ```json { "code": 40000, "message": "两次输入的密码不一致" } ``` ``` -------------------------------- ### 异步智能分析(消息队列)API Source: https://context7.com/gitgg021/ai-chart/llms.txt 基于RabbitMQ的异步分析接口,任务持久化到消息队列,由消费者处理。生产环境推荐使用。任务状态包括 wait, running, succeed, failed。 ```bash # 异步智能分析请求(MQ模式) curl -X POST "http://localhost:8080/api/chart/gen/async/mq" \ -b cookies.txt \ -F "file=@user_behavior.xlsx" \ -F "name=用户行为分析" \ -F "goal=分析用户在不同时段的活跃度" \ -F "chartType=柱状图" ``` ```json # 立即返回响应(任务已入队) { "code": 0, "data": { "chartId": 1234567890123456792, "chartData": null, "onAnalysis": null }, "message": "ok" } ``` ```text # 图表状态流转:wait -> running -> succeed/failed # wait: 排队中 # running: 执行中 # succeed: 已完成 # failed: 失败 ``` -------------------------------- ### Paginate My Chart List Success Response Source: https://context7.com/gitgg021/ai-chart/llms.txt Sample successful response for paginating the user's chart list, including records, total count, and pagination details. ```json { "code": 0, "data": { "records": [ { "id": 1234567890123456790, "name": "月度销售分析", "goal": "分析各月份的销售趋势", "chartType": "折线图", "status": "succeed", "createTime": "2024-01-15T14:30:00.000+00:00" }, { "id": 1234567890123456780, "name": "季度销售对比", "goal": "对比各季度销售业绩", "chartType": "柱状图", "status": "succeed", "createTime": "2024-01-10T10:00:00.000+00:00" } ], "total": 15, "size": 10, "current": 1, "pages": 2 }, "message": "ok" } ``` -------------------------------- ### 用户注册 API Source: https://context7.com/gitgg021/ai-chart/llms.txt 用于创建新用户账户。需要提供账号、密码和确认密码。成功后返回用户ID,失败时根据错误原因返回相应消息。 ```bash # 用户注册请求 curl -X POST "http://localhost:8080/api/user/register" \ -H "Content-Type: application/json" \ -d '{ "userAccount": "testuser", "userPassword": "password123", "checkPassword": "password123" }' ``` ```json # 成功响应 { "code": 0, "data": 1234567890123456789, "message": "ok" } ``` ```json # 错误响应 - 密码不一致 { "code": 40000, "message": "两次输入的密码不一致" } ``` -------------------------------- ### 获取当前登录用户 API Source: https://context7.com/gitgg021/ai-chart/llms.txt 获取当前登录用户的详细信息。需要携带有效的Session Cookie(通过 `-b cookies.txt` 发送)。 ```bash # 获取当前登录用户 curl -X GET "http://localhost:8080/api/user/get/login" \ -b cookies.txt ``` ```json # 成功响应 { "code": 0, "data": { "id": 1234567890123456789, "userName": "testuser", "userAvatar": "https://www.codefather.cn/logo.png", "userProfile": "数据分析师", "userRole": "user", "createTime": "2024-01-01T10:00:00.000+00:00" }, "message": "ok" } ``` -------------------------------- ### 获取图表详情 API Source: https://context7.com/gitgg021/ai-chart/llms.txt 根据图表ID获取图表的详细信息,包括原始数据、分析目标、生成的图表配置和分析结论。 ```bash # 获取图表详情 curl -X GET "http://localhost:8080/api/chart/get?id=1234567890123456790" \ -b cookies.txt ``` -------------------------------- ### Admin: Paginate User List Request Source: https://context7.com/gitgg021/ai-chart/llms.txt Admin-only endpoint to paginate and retrieve complete information for all users in the system. Requires administrator privileges. ```bash # 分页获取用户列表(仅管理员) curl -X POST "http://localhost:8080/api/user/list/page" \ -H "Content-Type: application/json" \ -b cookies.txt \ -d '{ "current": 1, "pageSize": 10, "userName": "测试" }' ``` -------------------------------- ### 用户登录 API Source: https://context7.com/gitgg021/ai-chart/llms.txt 用于验证用户身份并创建会话。登录成功后返回用户基本信息(脱敏),并将登录状态保存在Session中。请使用 `-c cookies.txt` 保存和发送Cookies。 ```bash # 用户登录请求 curl -X POST "http://localhost:8080/api/user/login" \ -H "Content-Type: application/json" \ -c cookies.txt \ -d '{ "userAccount": "testuser", "userPassword": "password123" }' ``` ```json # 成功响应 { "code": 0, "data": { "id": 1234567890123456789, "userName": "testuser", "userAvatar": "https://www.codefather.cn/logo.png", "userProfile": null, "userRole": "user", "createTime": "2024-01-01T10:00:00.000+00:00" }, "message": "ok" } ``` -------------------------------- ### Paginate My Chart List Request Source: https://context7.com/gitgg021/ai-chart/llms.txt Use this endpoint to paginate and retrieve a list of charts created by the current user. Supports filtering by name, goal, and chart type. ```bash # 分页获取我的图表列表 curl -X POST "http://localhost:8080/api/chart/my/list/page/vo" \ -H "Content-Type: application/json" \ -b cookies.txt \ -d '{ "current": 1, "pageSize": 10, "name": "销售", "sortField": "createTime", "sortOrder": "desc" }' ``` -------------------------------- ### User Login API Source: https://context7.com/gitgg021/ai-chart/llms.txt Authenticates a user and establishes a session. Returns sanitized user information upon successful login. ```APIDOC ## POST /api/user/login ### Description Logs in a user and creates a session. Returns basic user information (sanitized) and saves login status in the session. ### Method POST ### Endpoint /api/user/login ### Parameters #### Request Body - **userAccount** (string) - Required - The user's account name. - **userPassword** (string) - Required - The user's password. ### Request Example ```json { "userAccount": "testuser", "userPassword": "password123" } ``` ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **data** (object) - User information. - **id** (long) - User ID. - **userName** (string) - User's name. - **userAvatar** (string) - URL of the user's avatar. - **userProfile** (string) - User's profile description (can be null). - **userRole** (string) - User's role. - **createTime** (string) - User creation timestamp. - **message** (string) - "ok" for success. #### Response Example ```json { "code": 0, "data": { "id": 1234567890123456789, "userName": "testuser", "userAvatar": "https://www.codefather.cn/logo.png", "userProfile": null, "userRole": "user", "createTime": "2024-01-01T10:00:00.000+00:00" }, "message": "ok" } ``` ``` -------------------------------- ### Successful Chart Creation Response Source: https://context7.com/gitgg021/ai-chart/llms.txt This is a sample successful response for chart creation, indicating the code, data, and message. ```json { "code": 0, "data": { "id": 1234567890123456790, "name": "月度销售分析", "goal": "分析各月份的销售趋势", "chartData": "月份,销售额(万),订单数\n1月,820,1200\n2月,932,1350\n...", "chartType": "折线图", "genChart": "{\"title\":{\"text\":\"月度销售趋势\"},\"xAxis\":{...},\"series\":[...]}", "genResult": "销售额呈现稳步上升趋势...", "status": "succeed", "userId": 1234567890123456789, "createTime": "2024-01-15T14:30:00.000+00:00", "updateTime": "2024-01-15T14:31:00.000+00:00" }, "message": "ok" } ``` -------------------------------- ### Admin: Paginate User List Success Response Source: https://context7.com/gitgg021/ai-chart/llms.txt Successful response for paginating the user list, including user records and pagination details. ```json { "code": 0, "data": { "records": [ { "id": 1234567890123456789, "userAccount": "testuser", "userName": "测试用户", "userRole": "user", "createTime": "2024-01-01T10:00:00.000+00:00" } ], "total": 100, "size": 10, "current": 1 }, "message": "ok" } ``` -------------------------------- ### 同步智能分析 API Source: https://context7.com/gitgg021/ai-chart/llms.txt 接收Excel文件、分析需求和图表类型,同步调用AI生成可视化图表配置和分析结论。适用于数据量较小的场景。成功响应包含图表ID、配置和分析结果。 ```bash # 同步智能分析请求 curl -X POST "http://localhost:8080/api/chart/gen" \ -b cookies.txt \ -F "file=@sales_data.xlsx" \ -F "name=月度销售分析" \ -F "goal=分析各月份的销售趋势,找出销售高峰期" \ -F "chartType=折线图" ``` ```json # 成功响应 { "code": 0, "data": { "chartId": 1234567890123456790, "chartData": "{\"title\":{\"text\":\"月度销售趋势分析\"},\"xAxis\":{\"type\":\"category\",\"data\":[\"1月\",\"2月\",\"3月\",\"4月\",\"5月\",\"6月\"]},\"yAxis\":{\"type\":\"value\"},\"series\":[{\"data\":[820,932,901,1234,1290,1530],\"type\":\"line\"}]}", "onAnalysis": "根据数据分析,销售额呈现稳步上升趋势。1-3月销售相对平稳,4月开始明显增长,6月达到峰值1530万。建议在4-6月加大营销投入。" }, "message": "ok" } ``` ```text # Excel文件格式示例 (sales_data.xlsx): # | 月份 | 销售额(万) | 订单数 | # |------|-----------|--------| # | 1月 | 820 | 1200 | # | 2月 | 932 | 1350 | # | 3月 | 901 | 1280 | # | 4月 | 1234 | 1680 | # | 5月 | 1290 | 1720 | # | 6月 | 1530 | 2100 | ``` -------------------------------- ### Intelligent Analysis (Asynchronous - Message Queue) Source: https://context7.com/gitgg021/ai-chart/llms.txt Utilizes RabbitMQ for asynchronous analysis. Tasks are persisted in a message queue, ensuring durability even through service restarts. Recommended for production environments. ```APIDOC ## POST /api/chart/gen/async/mq ### Description Performs asynchronous AI analysis using RabbitMQ. Tasks are persisted in a message queue and processed by independent consumers, ensuring task durability even if the service restarts. This method is recommended for production environments. ### Method POST ### Endpoint /api/chart/gen/async/mq ### Parameters #### Cookie Parameters - **cookies.txt** - Required - Session cookie for authentication. #### Form Data - **file** (file) - Required - The Excel file containing the data (e.g., user_behavior.xlsx). - **name** (string) - Required - The name or title for the analysis (e.g., "用户行为分析"). - **goal** (string) - Required - The user's analysis objective (e.g., "分析用户在不同时段的活跃度"). - **chartType** (string) - Required - The desired type of chart (e.g., "柱状图"). ### Request Example ```bash curl -X POST "http://localhost:8080/api/chart/gen/async/mq" \ -b cookies.txt \ -F "file=@user_behavior.xlsx" \ -F "name=用户行为分析" \ -F "goal=分析用户在不同时段的活跃度" \ -F "chartType=柱状图" ``` ### Response #### Immediate Response (Task Queued) - **code** (integer) - 0 for success. - **data** (object) - Contains the chart ID. - **chartId** (long) - The ID of the queued analysis task. - **chartData** (null) - Initially null. - **onAnalysis** (null) - Initially null. - **message** (string) - "ok" for success. #### Response Example ```json { "code": 0, "data": { "chartId": 1234567890123456792, "chartData": null, "onAnalysis": null }, "message": "ok" } ``` ### Chart Status Flow - **wait**: Queued - **running**: Processing - **succeed**: Completed - **failed**: Failed ``` -------------------------------- ### POST /api/user/list/page Source: https://context7.com/gitgg021/ai-chart/llms.txt Admin-only endpoint to paginate and retrieve full information for all users in the system. ```APIDOC ## POST /api/user/list/page ### Description Admin-only endpoint to paginate and retrieve full information for all users in the system. ### Method POST ### Endpoint /api/user/list/page ### Parameters #### Request Body - **current** (integer) - Required - The current page number. - **pageSize** (integer) - Required - The number of items per page. - **userName** (string) - Optional - Filter by user name. ### Request Example ```json { "current": 1, "pageSize": 10, "userName": "测试" } ``` ### Response #### Success Response (200) - **records** (array) - List of user objects. - **id** (long) - The unique identifier of the user. - **userAccount** (string) - The user's account name. - **userName** (string) - The user's display name. - **userRole** (string) - The role of the user (e.g., 'user', 'admin'). - **createTime** (string) - The timestamp when the user was created. - **total** (integer) - The total number of users. - **size** (integer) - The number of items per page. - **current** (integer) - The current page number. #### Response Example ```json { "code": 0, "data": { "records": [ { "id": 1234567890123456789, "userAccount": "testuser", "userName": "测试用户", "userRole": "user", "createTime": "2024-01-01T10:00:00.000+00:00" } ], "total": 100, "size": 10, "current": 1 }, "message": "ok" } ``` #### Error Response (401) - **message** (string) - Error message indicating lack of administrator privileges. #### Error Response Example ```json { "code": 40101, "message": "无权限" } ``` ``` -------------------------------- ### 异步智能分析(线程池)API Source: https://context7.com/gitgg021/ai-chart/llms.txt 使用线程池异步处理AI分析任务,立即返回图表ID。适用于数据量大或需提升用户体验的场景。可通过查询接口获取结果。 ```bash # 异步智能分析请求(线程池模式) curl -X POST "http://localhost:8080/api/chart/gen/async" \ -b cookies.txt \ -F "file=@website_traffic.xlsx" \ -F "name=网站流量分析" \ -F "goal=分析网站各页面的访问量分布" \ -F "chartType=饼图" ``` ```json # 立即返回响应(任务已提交) { "code": 0, "data": { "chartId": 1234567890123456791, "chartData": null, "onAnalysis": null }, "message": "ok" } ``` ```bash # 轮询查询分析结果 curl -X GET "http://localhost:8080/api/chart/get?id=1234567890123456791" \ -b cookies.txt ``` ```json # 处理中响应 { "code": 0, "data": { "id": 1234567890123456791, "name": "网站流量分析", "goal": "分析网站各页面的访问量分布", "chartType": "饼图", "status": "running", "genChart": null, "genResult": null }, "message": "ok" } ``` ```json # 处理完成响应 { "code": 0, "data": { "id": 1234567890123456791, "name": "网站流量分析", "status": "succeed", "genChart": "{\"title\":{\"text\":\"页面访问量分布\"},\"series\":[{\"type\":\"pie\",\"data\":[{\"value\":1048,\"name\":\"首页\"},{\"value\":735,\"name\":\"产品页\"},{\"value\":580,\"name\":\"关于我们\"}]}]}", "genResult": "首页访问量最高,占总访问量的44%,建议优化首页内容展示。" }, "message": "ok" } ``` -------------------------------- ### Distributed Rate Limiting Configuration Source: https://context7.com/gitgg021/ai-chart/llms.txt The system uses Redisson for Redis-based distributed rate limiting to prevent excessive requests. Each user is limited to 2 AI analysis requests per second. ```java // RedisLimiterManager 限流服务 // 每个用户每秒最多允许2次AI分析请求 // 限流规则配置示例 @Service public class RedisLimiterManager { @Resource private RedissonClient redissonClient; public void doRateLimit(String key) { // 创建限流器,每秒最多2个请求 RRateLimiter rateLimiter = redissonClient.getRateLimiter(key); rateLimiter.trySetRate(RateType.OVERALL, 2, 1, RateIntervalUnit.SECONDS); // 尝试获取令牌 boolean canOp = rateLimiter.tryAcquire(1); if (!canOp) { throw new BusinessException(ErrorCode.TOO_MANY_REQUEST); } } } ``` -------------------------------- ### 用户注销 API Source: https://context7.com/gitgg021/ai-chart/llms.txt 用于用户退出登录,清除Session中的登录状态。需要携带有效的Session Cookie。 ```bash # 用户注销请求 curl -X POST "http://localhost:8080/api/user/logout" \ -b cookies.txt ``` ```json # 成功响应 { "code": 0, "data": true, "message": "ok" } ``` -------------------------------- ### User Table Schema Source: https://context7.com/gitgg021/ai-chart/llms.txt Defines the SQL structure for the user table, including fields for authentication, profile information, and roles. An index is created on userAccount for efficient lookups. ```sql CREATE TABLE user ( id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'id', userAccount VARCHAR(256) NOT NULL COMMENT '账号', userPassword VARCHAR(512) NOT NULL COMMENT '密码', userName VARCHAR(256) COMMENT '用户昵称', userAvatar VARCHAR(1024) COMMENT '用户头像', userProfile VARCHAR(512) COMMENT '用户简介', userRole VARCHAR(256) DEFAULT 'user' NOT NULL COMMENT '用户角色:user/admin/ban', createTime DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间', updateTime DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL COMMENT '更新时间', isDelete TINYINT DEFAULT 0 NOT NULL COMMENT '是否删除', INDEX idx_unionAccount (userAccount) ) COMMENT '用户' COLLATE = utf8mb4_unicode_ci; ``` -------------------------------- ### POST /api/chart/my/list/page/vo Source: https://context7.com/gitgg021/ai-chart/llms.txt Paginate and retrieve a list of charts created by the current user. Supports filtering by name, analysis goal, and chart type. ```APIDOC ## POST /api/chart/my/list/page/vo ### Description Paginate and retrieve a list of charts created by the current user. Supports filtering by name, analysis goal, and chart type. ### Method POST ### Endpoint /api/chart/my/list/page/vo ### Parameters #### Request Body - **current** (integer) - Required - The current page number. - **pageSize** (integer) - Required - The number of items per page. - **name** (string) - Optional - Filter by chart name. - **sortField** (string) - Optional - The field to sort by (e.g., 'createTime'). - **sortOrder** (string) - Optional - The sort order ('asc' or 'desc'). ### Request Example ```json { "current": 1, "pageSize": 10, "name": "销售", "sortField": "createTime", "sortOrder": "desc" } ``` ### Response #### Success Response (200) - **records** (array) - List of chart objects. - **id** (long) - The unique identifier of the chart. - **name** (string) - The name of the chart. - **goal** (string) - The analysis goal of the chart. - **chartType** (string) - The type of the chart. - **status** (string) - The status of the chart generation. - **createTime** (string) - The timestamp when the chart was created. - **total** (integer) - The total number of charts. - **size** (integer) - The number of items per page. - **current** (integer) - The current page number. - **pages** (integer) - The total number of pages. #### Response Example ```json { "code": 0, "data": { "records": [ { "id": 1234567890123456790, "name": "月度销售分析", "goal": "分析各月份的销售趋势", "chartType": "折线图", "status": "succeed", "createTime": "2024-01-15T14:30:00.000+00:00" }, { "id": 1234567890123456780, "name": "季度销售对比", "goal": "对比各季度销售业绩", "chartType": "柱状图", "status": "succeed", "createTime": "2024-01-10T10:00:00.000+00:00" } ], "total": 15, "size": 10, "current": 1, "pages": 2 }, "message": "ok" } ``` ``` -------------------------------- ### Intelligent Analysis (Synchronous) Source: https://context7.com/gitgg021/ai-chart/llms.txt Performs synchronous AI analysis on uploaded Excel data to generate visualization configurations and analysis conclusions. Suitable for smaller datasets. ```APIDOC ## POST /api/chart/gen ### Description Performs synchronous AI analysis on an uploaded Excel file and analysis requirements. Generates visualization chart configurations and analysis conclusions. Waits for AI processing to complete before returning results. Suitable for smaller data volumes. ### Method POST ### Endpoint /api/chart/gen ### Parameters #### Cookie Parameters - **cookies.txt** - Required - Session cookie for authentication. #### Form Data - **file** (file) - Required - The Excel file containing the data (e.g., sales_data.xlsx). - **name** (string) - Required - The name or title for the analysis (e.g., "月度销售分析"). - **goal** (string) - Required - The user's analysis objective (e.g., "分析各月份的销售趋势,找出销售高峰期"). - **chartType** (string) - Required - The desired type of chart (e.g., "折线图"). ### Request Example ```bash curl -X POST "http://localhost:8080/api/chart/gen" \ -b cookies.txt \ -F "file=@sales_data.xlsx" \ -F "name=月度销售分析" \ -F "goal=分析各月份的销售趋势,找出销售高峰期" \ -F "chartType=折线图" ``` ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **data** (object) - Analysis results. - **chartId** (long) - The ID of the generated chart. - **chartData** (string) - JSON string representing the ECharts configuration. - **onAnalysis** (string) - Textual analysis conclusion. - **message** (string) - "ok" for success. #### Response Example ```json { "code": 0, "data": { "chartId": 1234567890123456790, "chartData": "{\"title\":{\"text\":\"月度销售趋势分析\"},\"xAxis\":{\"type\":\"category\",\"data\":[\"1月\",\"2月\",\"3月\",\"4月\",\"5月\",\"6月\"]},\"yAxis\":{\"type\":\"value\"},\"series\":[{\"data\":[820,932,901,1234,1290,1530],\"type\":\"line\"}]}", "onAnalysis": "根据数据分析,销售额呈现稳步上升趋势。1-3月销售相对平稳,4月开始明显增长,6月达到峰值1530万。建议在4-6月加大营销投入。" }, "message": "ok" } ``` ### Excel File Format Example ``` | 月份 | 销售额(万) | 订单数 | |------|-----------|--------| | 1月 | 820 | 1200 | | 2月 | 932 | 1350 | | 3月 | 901 | 1280 | | 4月 | 1234 | 1680 | | 5月 | 1290 | 1720 | | 6月 | 1530 | 2100 | ``` ``` -------------------------------- ### File Upload Success Response (OCR) Source: https://context7.com/gitgg021/ai-chart/llms.txt Successful response after uploading a file, returning OCR recognition results if applicable. ```json { "code": 0, "data": "识别的文字内容...", "message": "ok" } ``` -------------------------------- ### POST /api/user/update/my Source: https://context7.com/gitgg021/ai-chart/llms.txt Update the current user's personal information, including nickname, avatar, and profile description. ```APIDOC ## POST /api/user/update/my ### Description Update the current user's personal information, including nickname, avatar, and profile description. ### Method POST ### Endpoint /api/user/update/my ### Parameters #### Request Body - **userName** (string) - Optional - The user's nickname. - **userAvatar** (string) - Optional - The URL of the user's avatar. - **userProfile** (string) - Optional - A brief profile description for the user. ### Request Example ```json { "userName": "数据分析师小王", "userAvatar": "https://example.com/avatar.png", "userProfile": "专注于数据分析和可视化" } ``` ### Response #### Success Response (200) - **data** (boolean) - True if the update was successful, false otherwise. #### Response Example ```json { "code": 0, "data": true, "message": "ok" } ``` ``` -------------------------------- ### File Upload Request Source: https://context7.com/gitgg021/ai-chart/llms.txt General file upload endpoint that supports image uploads and OCR character recognition. File size limit is 1MB, and supported formats include jpeg, jpg, svg, png, webp. ```bash # 文件上传 curl -X POST "http://localhost:8080/api/file/upload" \ -b cookies.txt \ -F "file=@document.png" \ -F "biz=file_ai" ``` -------------------------------- ### Update User Profile Request Source: https://context7.com/gitgg021/ai-chart/llms.txt Endpoint for users to update their personal information, including nickname, avatar, and profile description. ```bash # 更新个人信息 curl -X POST "http://localhost:8080/api/user/update/my" \ -H "Content-Type: application/json" \ -b cookies.txt \ -d '{ "userName": "数据分析师小王", "userAvatar": "https://example.com/avatar.png", "userProfile": "专注于数据分析和可视化" }' ``` -------------------------------- ### Distributed Rate Limiting Configuration Source: https://context7.com/gitgg021/ai-chart/llms.txt Details on the distributed rate limiting mechanism implemented using Redisson and Redis to prevent excessive requests. ```APIDOC ## Distributed Rate Limiting Configuration ### Description The system utilizes Redisson for Redis-based distributed rate limiting to protect system resources from excessive user requests. Each user is limited to a maximum of 2 AI analysis requests per second. ### Implementation Details - **Rate Limiter**: Implemented using `RedissonClient` and `RRateLimiter`. - **Configuration**: Each user is allowed a maximum of 2 requests per second. ### Code Example (Java) ```java @Service public class RedisLimiterManager { @Resource private RedissonClient redissonClient; public void doRateLimit(String key) { // Create a rate limiter: max 2 requests per second RRateLimiter rateLimiter = redissonClient.getRateLimiter(key); rateLimiter.trySetRate(RateType.OVERALL, 2, 1, RateIntervalUnit.SECONDS); // Attempt to acquire a token boolean canOp = rateLimiter.tryAcquire(1); if (!canOp) { throw new BusinessException(ErrorCode.TOO_MANY_REQUEST); } } } ``` ### Response Example (When Rate Limit is Exceeded) ```json { "code": 42900, "message": "请求过于频繁,请稍后再试" } ``` ``` -------------------------------- ### POST /api/file/upload Source: https://context7.com/gitgg021/ai-chart/llms.txt General file upload interface, supporting uploads of images and other files, along with OCR character recognition. ```APIDOC ## POST /api/file/upload ### Description General file upload interface, supporting uploads of images and other files, along with OCR character recognition. ### Method POST ### Endpoint /api/file/upload ### Parameters #### Form Data - **file** (file) - Required - The file to upload (e.g., document.png). - **biz** (string) - Optional - Business context for the upload (e.g., 'file_ai'). ### Request Example ```bash curl -X POST "http://localhost:8080/api/file/upload" \ -b cookies.txt \ -F "file=@document.png" \ -F "biz=file_ai" ``` ### Response #### Success Response (200) - **data** (string) - The OCR recognition result if applicable. #### Response Example ```json { "code": 0, "data": "识别的文字内容...", "message": "ok" } ``` ### Notes - File size limit: 1MB - Supported image formats: jpeg, jpg, svg, png, webp ``` -------------------------------- ### Intelligent Analysis (Asynchronous - Thread Pool) Source: https://context7.com/gitgg021/ai-chart/llms.txt Uses a thread pool for asynchronous AI analysis. Returns a chart ID immediately, allowing users to poll for results. Ideal for improving user experience with larger datasets. ```APIDOC ## POST /api/chart/gen/async ### Description Performs asynchronous AI analysis using a thread pool. The API returns a chart ID immediately, and the user can poll for the analysis results using the `/api/chart/get` endpoint. This is suitable for scenarios requiring improved user experience or handling larger datasets. ### Method POST ### Endpoint /api/chart/gen/async ### Parameters #### Cookie Parameters - **cookies.txt** - Required - Session cookie for authentication. #### Form Data - **file** (file) - Required - The Excel file containing the data (e.g., website_traffic.xlsx). - **name** (string) - Required - The name or title for the analysis (e.g., "网站流量分析"). - **goal** (string) - Required - The user's analysis objective (e.g., "分析网站各页面的访问量分布"). - **chartType** (string) - Required - The desired type of chart (e.g., "饼图"). ### Request Example ```bash curl -X POST "http://localhost:8080/api/chart/gen/async" \ -b cookies.txt \ -F "file=@website_traffic.xlsx" \ -F "name=网站流量分析" \ -F "goal=分析网站各页面的访问量分布" \ -F "chartType=饼图" ``` ### Response #### Immediate Response (Task Submitted) - **code** (integer) - 0 for success. - **data** (object) - Contains the chart ID. - **chartId** (long) - The ID of the submitted analysis task. - **chartData** (null) - Initially null. - **onAnalysis** (null) - Initially null. - **message** (string) - "ok" for success. #### Response Example (Immediate) ```json { "code": 0, "data": { "chartId": 1234567890123456791, "chartData": null, "onAnalysis": null }, "message": "ok" } ``` ### Polling for Results Use the `GET /api/chart/get` endpoint with the `id` parameter. #### Polling Request Example ```bash curl -X GET "http://localhost:8080/api/chart/get?id=1234567890123456791" \ -b cookies.txt ``` #### Processing Response Example ```json { "code": 0, "data": { "id": 1234567890123456791, "name": "网站流量分析", "goal": "分析网站各页面的访问量分布", "chartType": "饼图", "status": "running", "genChart": null, "genResult": null }, "message": "ok" } ``` #### Completion Response Example ```json { "code": 0, "data": { "id": 1234567890123456791, "name": "网站流量分析", "status": "succeed", "genChart": "{\"title\":{\"text\":\"页面访问量分布\"},\"series\":[{\"type\":\"pie\",\"data\":[{\"value\":1048,\"name\":\"首页\"},{\"value\":735,\"name\":\"产品页\"},{\"value\":580,\"name\":\"关于我们\"}]}]}", "genResult": "首页访问量最高,占总访问量的44%,建议优化首页内容展示。" }, "message": "ok" } ``` ``` -------------------------------- ### Admin: Paginate User List Forbidden Response Source: https://context7.com/gitgg021/ai-chart/llms.txt Error response indicating insufficient administrator privileges to access the user list. ```json { "code": 40101, "message": "无权限" } ```