### Install Server Dependencies Source: https://github.com/didi/xiaoju-survey/blob/main/README_EN.md Navigate to the server directory and install project dependencies using npm. This is a prerequisite for starting the server. ```shell cd server npm install ``` -------------------------------- ### Start Server and Web Applications Source: https://github.com/didi/xiaoju-survey/blob/main/README.md Commands to start the server and web applications for local development. Ensure you are in the respective directories ('server' or 'web') and have installed dependencies. ```bash cd server npm install npm run local ``` ```bash cd web npm install npm run serve ``` -------------------------------- ### Start Server Locally Source: https://github.com/didi/xiaoju-survey/blob/main/README_EN.md Start the server using the 'npm run local' command. This option is suitable for quick previews and utilizes mongodb-memory-server for in-memory data storage. ```shell npm run local ``` -------------------------------- ### Get Workspace Details Source: https://context7.com/didi/xiaoju-survey/llms.txt Fetches detailed information about a specific workspace, including its member list. ```bash curl -X GET "http://localhost:8080/api/workspace/workspace_65abc123" \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Workspace List Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieves a list of workspaces, supporting filtering by name and pagination. ```bash curl -X GET "http://localhost:8080/api/workspace?curPage=1&pageSize=10&name=市场" \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Role List Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieves a list of available roles within workspaces. ```bash curl -X GET "http://localhost:8080/api/workspace/getRoleList" \ -H "Authorization: Bearer " ``` -------------------------------- ### Local Development and Docker Deployment Source: https://context7.com/didi/xiaoju-survey/llms.txt Commands for starting the backend and frontend services locally, and deploying the full stack using Docker Compose. ```bash cd server npm install npm run local cd web npm install npm run serve export MONGO_INITDB_ROOT_USERNAME=admin export MONGO_INITDB_ROOT_PASSWORD=your_secure_password export XIAOJU_SURVEY_MONGO_AUTH_SOURCE=admin docker-compose up -d ``` -------------------------------- ### Get Download Task List Source: https://context7.com/didi/xiaoju-survey/llms.txt Fetches a list of available survey data download tasks, supporting pagination. ```bash curl -X GET "http://localhost:8080/api/downloadTask/getDownloadTaskList?pageIndex=1&pageSize=10" \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Channel List Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieves a list of distribution channels for a specific survey, supporting pagination. ```bash curl -X GET "http://localhost:8080/api/channel/getList?surveyId=survey_65abc123&curPage=1&pageSize=10" \ -H "Authorization: Bearer " ``` -------------------------------- ### Get User Workspace Members Source: https://context7.com/didi/xiaoju-survey/llms.txt Fetches a list of workspaces a user is part of, along with their members. ```bash curl -X GET "http://localhost:8080/api/workspace/member/list" \ -H "Authorization: Bearer " ``` -------------------------------- ### Get File URL Source: https://context7.com/didi/xiaoju-survey/llms.txt Obtain a URL for accessing survey materials. ```APIDOC ## POST /api/file/getUrl ### Description Retrieves a URL for a specified file key within the SURVEY_MATERIAL channel. ### Method POST ### Endpoint /api/file/getUrl ### Request Body - **channel** (string) - Required - The channel for the file, e.g., "SURVEY_MATERIAL". - **key** (string) - Required - The key of the file, e.g., "survey/image_abc123.jpg". ### Request Example ```json { "channel": "SURVEY_MATERIAL", "key": "survey/image_abc123.jpg" } ``` ### Response #### Success Response (200) - **url** (string) - The URL to access the file. - **key** (string) - The key of the file. #### Response Example ```json { "code": 200, "message": "成功", "data": { "url": "http://your-storage-url/survey/image_abc123.jpg", "key": "survey/image_abc123.jpg" } } ``` ``` -------------------------------- ### Get Survey Preview Schema Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieve the schema for a survey's preview, used for client-side rendering. Requires the surveyPath. ```bash curl -X GET "http://localhost:8080/api/survey/getPreviewSchema?surveyPath=abc123xyz" ``` -------------------------------- ### Clone Xiaoju Survey Project Source: https://github.com/didi/xiaoju-survey/blob/main/README_EN.md Clone the project repository using Git. Ensure Node.js version 18.x or higher is installed. ```shell git clone git@github.com:didi/xiaoju-survey.git ``` -------------------------------- ### GET /api/survey/getList Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieves a list of surveys with support for filtering, sorting, and recycle bin access. ```APIDOC ## GET /api/survey/getList ### Description Retrieves a paginated list of surveys based on provided filters or status. ### Method GET ### Endpoint /api/survey/getList ### Parameters #### Query Parameters - **curPage** (number) - Required - Current page number - **pageSize** (number) - Required - Number of items per page - **filter** (string) - Optional - JSON string for filtering (e.g., {"surveyType": "normal"}) - **order** (string) - Optional - JSON string for sorting (e.g., {"createdAt": -1}) - **isRecycleBin** (boolean) - Optional - Whether to fetch from recycle bin ### Response #### Success Response (200) - **code** (number) - Status code - **data** (object) - Survey data object containing count and list ``` -------------------------------- ### Get Aggregated Statistics Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieve aggregated statistics for survey questions, such as option distributions. Requires surveyId. ```bash curl -X GET "http://localhost:8080/api/survey/dataStatistic/aggregationStatis?surveyId=survey_65abc123" \ -H "Authorization: Bearer " ``` -------------------------------- ### GET /api/survey/dataStatistic/dataTable Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieves the survey response data table with support for pagination and data masking. ```APIDOC ## GET /api/survey/dataStatistic/dataTable ### Description Fetches the raw response data table for a survey. ### Method GET ### Endpoint /api/survey/dataStatistic/dataTable ### Parameters #### Query Parameters - **surveyId** (string) - Required - ID of the survey - **page** (number) - Required - Page number - **pageSize** (number) - Required - Items per page - **isMasked** (boolean) - Optional - Whether to mask sensitive data ``` -------------------------------- ### Get Survey Response Data Table Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieve survey response data in a table format, supporting pagination and data masking. Requires surveyId. ```bash curl -X GET "http://localhost:8080/api/survey/dataStatistic/dataTable?surveyId=survey_65abc123&page=1&pageSize=10&isMasked=true" \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Single Download Task Status Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieves the status and details of a specific survey data download task using its task ID. ```bash curl -X GET "http://localhost:8080/api/downloadTask/getDownloadTask?taskId=task_65abc123" \ -H "Authorization: Bearer " ``` -------------------------------- ### Local Development and Docker Deployment Source: https://context7.com/didi/xiaoju-survey/llms.txt Instructions for setting up the development environment and deploying the application using Docker. ```APIDOC ## Local Development ### Backend Service ```bash cd server npm install npm run local # Starts the development server ``` ### Frontend ```bash cd web npm install npm run serve # Starts the frontend development server # B-end Management: http://localhost:8080/management # C-end Answering: http://localhost:8080/render/:surveyPath ``` ## Docker Compose Deployment (Recommended) ### 1. Set Environment Variables ```bash export MONGO_INITDB_ROOT_USERNAME=admin export MONGO_INITDB_ROOT_PASSWORD=your_secure_password export XIAOJU_SURVEY_MONGO_AUTH_SOURCE=admin ``` ### 2. Start Services ```bash docker-compose up -d ``` ### `docker-compose.yaml` Configuration Example ```yaml version: "3.6" services: mongo: image: mongo:4 container_name: xiaoju-survey-mongo environment: MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME} MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD} ports: - "27017:27017" xiaoju-survey: image: "xiaojusurvey/xiaoju-survey:1.3.4-slim" container_name: xiaoju-survey ports: - "8080:8080" environment: XIAOJU_SURVEY_MONGO_URL: mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@xiaoju-survey-mongo:27017 ``` ## AI Questionnaire Generation Configuration (Optional) ```bash export AImodel_API_URL=https://api.openai.com/v1/chat/completions export AImodel_API_KEY=your_api_key export AImodel_MODEL=gpt-3.5-turbo ``` ``` -------------------------------- ### Environment Configuration Source: https://context7.com/didi/xiaoju-survey/llms.txt Required environment variables for database connectivity, JWT security, AI integration, and file storage services. ```bash XIAOJU_SURVEY_MONGO_URL=mongodb://username:password@localhost:27017 XIAOJU_SURVEY_MONGO_AUTH_SOURCE=admin XIAOJU_SURVEY_MONGO_DB_NAME=xiaojuSurvey XIAOJU_SURVEY_JWT_SECRET=your_jwt_secret_key XIAOJU_SURVEY_JWT_EXPIRES_IN=8h AImodel_API_URL=https://api.openai.com/v1/chat/completions AImodel_API_KEY=your_api_key AImodel_MODEL=gpt-3.5-turbo SURVEY_MATERIAL=ALIOSS_CONFIG ALIOSS_CONFIG.NEED_AUTH=true ALIOSS_CONFIG.FILE_KEY_PREFIX=survey/ ALIOSS_CONFIG.ACCESS_KEY_ID=your_access_key ALIOSS_CONFIG.ACCESS_KEY_SECRET=your_secret_key ALIOSS_CONFIG.BUCKET=your_bucket ALIOSS_CONFIG.REGION=oss-cn-hangzhou ``` -------------------------------- ### Create Workspace Source: https://context7.com/didi/xiaoju-survey/llms.txt Creates a new workspace for team collaboration, including initial members and roles. Requires name, description, and a list of members with their user IDs and roles. ```bash curl -X POST http://localhost:8080/api/workspace \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "市场调研团队", "description": "负责市场调研相关问卷", "members": [ { "userId": "user_001", "role": "admin" }, { "userId": "user_002", "role": "user" } ] }' ``` -------------------------------- ### Query Channel Details Source: https://context7.com/didi/xiaoju-survey/llms.txt Fetches the details of a specific distribution channel using its channel ID. This is an open interface. ```bash curl -X GET "http://localhost:8080/api/channel/find?channelId=channel_65abc123" ``` -------------------------------- ### Import Questions via Excel Source: https://context7.com/didi/xiaoju-survey/llms.txt Upload an Excel file to batch import survey questions. The file must contain columns for title, type, and options. ```bash curl -X POST http://localhost:8080/api/survey/getExcelQuestions \ -H "Authorization: Bearer " \ -F "files=@/path/to/questions.xlsx" ``` -------------------------------- ### POST /api/workspace Source: https://context7.com/didi/xiaoju-survey/llms.txt Creates a new workspace for team collaboration. ```APIDOC ## POST /api/workspace ### Description Creates a new workspace for team collaboration, including initial member assignments. ### Method POST ### Endpoint /api/workspace ### Request Body - **name** (string) - Required - Name of the workspace. - **description** (string) - Optional - Description of the workspace. - **members** (array) - Optional - List of members with userId and role. ### Response #### Success Response (200) - **workspaceId** (string) - The ID of the created workspace. ### Response Example { "code": 200, "data": { "workspaceId": "workspace_65abc123" } } ``` -------------------------------- ### Create Survey Download Task Source: https://context7.com/didi/xiaoju-survey/llms.txt Initiates a data export task for a specified survey. Requires survey ID and a boolean to indicate if data should be masked. ```bash curl -X POST http://localhost:8080/api/downloadTask/createTask \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "surveyId": "survey_65abc123", "isMasked": false }' ``` -------------------------------- ### Create Distribution Channel Source: https://context7.com/didi/xiaoju-survey/llms.txt Creates a new distribution channel for a survey, used for tracking data sources. Requires channel name, type, and survey ID. ```bash curl -X POST http://localhost:8080/api/channel/create \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "微信公众号", "type": "wechat", "surveyId": "survey_65abc123" }' ``` -------------------------------- ### Upload File Source: https://context7.com/didi/xiaoju-survey/llms.txt Uploads a file (e.g., image, attachment) to be used in surveys. Supports various storage backends. Requires the file and a channel identifier. ```bash curl -X POST http://localhost:8080/api/file/upload \ -H "Authorization: Bearer " \ -F "file=@/path/to/image.jpg" \ -F "channel=SURVEY_MATERIAL" ``` -------------------------------- ### POST /api/file/upload Source: https://context7.com/didi/xiaoju-survey/llms.txt Uploads a file to the configured storage backend. ```APIDOC ## POST /api/file/upload ### Description Uploads a file (image or attachment) to the system. ### Method POST ### Endpoint /api/file/upload ### Request Body - **file** (file) - Required - The file to upload. - **channel** (string) - Required - The storage channel identifier. ### Response #### Success Response (200) - **url** (string) - Public URL of the uploaded file. - **key** (string) - Storage key of the file. ### Response Example { "code": 200, "data": { "url": "https://storage.example.com/survey/image_abc123.jpg", "key": "survey/image_abc123.jpg" } } ``` -------------------------------- ### List Surveys with Sorting Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieve a list of surveys with sorting applied. The 'order' parameter must be URL-encoded, with -1 for descending and 1 for ascending. ```bash curl -X GET "http://localhost:8080/api/survey/getList?curPage=1&pageSize=10&order=%7B%22createdAt%22%3A-1%7D" \ -H "Authorization: Bearer " ``` -------------------------------- ### Retrieve File Access URL Source: https://context7.com/didi/xiaoju-survey/llms.txt Use this endpoint to obtain a temporary access URL for survey materials stored in the system. ```bash curl -X POST http://localhost:8080/api/file/getUrl \ -H "Content-Type: application/json" \ -d '{ "channel": "SURVEY_MATERIAL", "key": "survey/image_abc123.jpg" }' ``` -------------------------------- ### Submit Survey Response with Whitelist Source: https://context7.com/didi/xiaoju-survey/llms.txt Submit survey answers with whitelist verification (e.g., email, phone number, team member). Requires the 'whitelist' field. ```bash curl -X POST http://localhost:8080/api/surveyResponse/createResponse \ -H "Content-Type: application/json" \ -d '{ "surveyPath": "abc123xyz", "data": { "q1": "opt1" }, "clientTime": 1705312800000, "whitelist": "user@example.com" }' ``` -------------------------------- ### Submit Survey Response (Standard) Source: https://context7.com/didi/xiaoju-survey/llms.txt Submit survey answers using the standard method. Includes surveyPath, response data, client time, and optional diffTime. ```bash curl -X POST http://localhost:8080/api/surveyResponse/createResponse \ -H "Content-Type: application/json" \ -d '{ "surveyPath": "abc123xyz", "data": { "q1": "opt1", "q2": ["opt2", "opt3"], "q3": "这是一段文本回答" }, "clientTime": 1705312800000, "diffTime": 120000 }' ``` -------------------------------- ### Environment Variable Configuration Source: https://context7.com/didi/xiaoju-survey/llms.txt Details on environment variables for configuring the Xiaoju Survey application. ```APIDOC ## Environment Variables ### MongoDB Configuration - **XIAOJU_SURVEY_MONGO_URL**: MongoDB connection URL (e.g., `mongodb://username:password@localhost:27017`). - **XIAOJU_SURVEY_MONGO_AUTH_SOURCE**: The authentication source for MongoDB (e.g., `admin`). - **XIAOJU_SURVEY_MONGO_DB_NAME**: The name of the MongoDB database (e.g., `xiaojuSurvey`). ### JWT Configuration - **XIAOJU_SURVEY_JWT_SECRET**: Secret key for JWT signing. - **XIAOJU_SURVEY_JWT_EXPIRES_IN**: JWT expiration time (e.g., `8h`). ### AI Model Configuration (Optional) - **AImodel_API_URL**: API endpoint for the AI model (e.g., `https://api.openai.com/v1/chat/completions`). - **AImodel_API_KEY**: API key for the AI model. - **AImodel_MODEL**: The specific AI model to use (e.g., `gpt-3.5-turbo`). ### File Storage Configuration (Example: Alibaba Cloud OSS) - **SURVEY_MATERIAL**: Specifies the storage type, e.g., `ALIOSS_CONFIG`. - **ALIOSS_CONFIG.NEED_AUTH**: Boolean indicating if authentication is required (`true`/`false`). - **ALIOSS_CONFIG.FILE_KEY_PREFIX**: Prefix for file keys in storage (e.g., `survey/`). - **ALIOSS_CONFIG.ACCESS_KEY_ID**: Your Alibaba Cloud Access Key ID. - **ALIOSS_CONFIG.ACCESS_KEY_SECRET**: Your Alibaba Cloud Access Key Secret. - **ALIOSS_CONFIG.BUCKET**: Your Alibaba Cloud OSS bucket name. - **ALIOSS_CONFIG.REGION**: Your Alibaba Cloud OSS bucket region (e.g., `oss-cn-hangzhou`). ``` -------------------------------- ### User Authentication API Source: https://context7.com/didi/xiaoju-survey/llms.txt Endpoints for managing user sessions, including registration, login, captcha verification, and token validation. ```bash # 获取图形验证码 curl -X POST http://localhost:8080/api/auth/captcha \ -H "Content-Type: application/json" # 响应示例: # { # "code": 200, # "data": { # "id": "65abc123def456789", # "img": "..." # } # } # 用户注册(密码需6-16位,支持字母、数字、特殊字符) curl -X POST http://localhost:8080/api/auth/register \ -H "Content-Type: application/json" \ -d '{ "username": "testuser", "password": "SecurePass123!", "captchaId": "65abc123def456789", "captcha": "a1b2" }' # 响应示例: # { # "code": 200, # "data": { # "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", # "username": "testuser" # } # } # 用户登录 curl -X POST http://localhost:8080/api/auth/login \ -H "Content-Type: application/json" \ -d '{ "username": "testuser", "password": "SecurePass123!", "captchaId": "65abc123def456789", "captcha": "a1b2" }' # 检查密码强度 curl -X GET "http://localhost:8080/api/auth/password/strength?password=Test123!" \ -H "Content-Type: application/json" # 响应: { "code": 200, "data": "Strong" } // Strong/Medium/Weak # 验证 Token 是否有效 curl -X GET http://localhost:8080/api/auth/verifyToken \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." ``` -------------------------------- ### List Surveys with Filters Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieve a list of surveys, optionally filtering by type and status. Ensure filters are URL-encoded. ```bash curl -X GET "http://localhost:8080/api/survey/getList?curPage=1&pageSize=10&filter=%7B%22surveyType%22%3A%22normal%22%7D" \ -H "Authorization: Bearer " ``` -------------------------------- ### List Surveys from Recycle Bin Source: https://context7.com/didi/xiaoju-survey/llms.txt Retrieve surveys that have been moved to the recycle bin. ```bash curl -X GET "http://localhost:8080/api/survey/getList?curPage=1&pageSize=10&isRecycleBin=true" \ -H "Authorization: Bearer " ``` -------------------------------- ### POST /api/downloadTask/createTask Source: https://context7.com/didi/xiaoju-survey/llms.txt Creates a new data export task for a specific survey. ```APIDOC ## POST /api/downloadTask/createTask ### Description Creates a new data export task for a specific survey. ### Method POST ### Endpoint /api/downloadTask/createTask ### Request Body - **surveyId** (string) - Required - The ID of the survey to export. - **isMasked** (boolean) - Required - Whether to mask sensitive data. ### Response #### Success Response (200) - **taskId** (string) - The ID of the created task. ### Response Example { "code": 200, "data": { "taskId": "task_65abc123" } } ``` -------------------------------- ### User Authentication API Source: https://context7.com/didi/xiaoju-survey/llms.txt Provides endpoints for user registration, login, captcha generation, and token verification. Includes password strength checking and CAPTCHA anti-brushing mechanisms. ```APIDOC ## GET /api/auth/captcha ### Description Retrieves a graphical CAPTCHA image for verification. ### Method POST ### Endpoint /api/auth/captcha ### Request Body None ### Response #### Success Response (200) - **code** (integer) - Response status code. - **data** (object) - Contains CAPTCHA details. - **id** (string) - Unique identifier for the CAPTCHA. - **img** (string) - SVG representation of the CAPTCHA image. ### Response Example ```json { "code": 200, "data": { "id": "65abc123def456789", "img": "..." } } ``` ## POST /api/auth/register ### Description Registers a new user. Password must be 6-16 characters long and include letters, numbers, and special characters. ### Method POST ### Endpoint /api/auth/register ### Parameters #### Request Body - **username** (string) - Required - The desired username. - **password** (string) - Required - The user's password. - **captchaId** (string) - Required - The ID of the CAPTCHA. - **captcha** (string) - Required - The user-provided CAPTCHA string. ### Request Example ```json { "username": "testuser", "password": "SecurePass123!", "captchaId": "65abc123def456789", "captcha": "a1b2" } ``` ### Response #### Success Response (200) - **code** (integer) - Response status code. - **data** (object) - Contains user and token information. - **token** (string) - JWT token for authentication. - **username** (string) - The registered username. ### Response Example ```json { "code": 200, "data": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "username": "testuser" } } ``` ## POST /api/auth/login ### Description Logs in an existing user. ### Method POST ### Endpoint /api/auth/login ### Parameters #### Request Body - **username** (string) - Required - The user's username. - **password** (string) - Required - The user's password. - **captchaId** (string) - Required - The ID of the CAPTCHA. - **captcha** (string) - Required - The user-provided CAPTCHA string. ### Request Example ```json { "username": "testuser", "password": "SecurePass123!", "captchaId": "65abc123def456789", "captcha": "a1b2" } ``` ## GET /api/auth/password/strength ### Description Checks the strength of a given password. ### Method GET ### Endpoint /api/auth/password/strength ### Parameters #### Query Parameters - **password** (string) - Required - The password to check. ### Response #### Success Response (200) - **code** (integer) - Response status code. - **data** (string) - The strength of the password (e.g., "Strong", "Medium", "Weak"). ### Response Example ```json { "code": 200, "data": "Strong" } ``` ## GET /api/auth/verifyToken ### Description Verifies if the provided JWT token is valid. ### Method GET ### Endpoint /api/auth/verifyToken ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., "Bearer "). ### Response #### Success Response (200) Indicates the token is valid. The response body might be empty or contain a success message. ``` -------------------------------- ### Query Option Count for Quota Control Source: https://context7.com/didi/xiaoju-survey/llms.txt Query the count of specific options for a survey, useful for quota control. Requires surveyPath and a list of fields. ```bash curl -X GET "http://localhost:8080/api/counter/queryOptionCountInfo?surveyPath=abc123xyz&fieldList=q1,q2" \ -H "Content-Type: application/json" ``` -------------------------------- ### Update Workspace Source: https://context7.com/didi/xiaoju-survey/llms.txt Modifies an existing workspace's name, description, and member list. Existing members can be updated by their ID, and new members can be added. ```bash curl -X POST "http://localhost:8080/api/workspace/workspace_65abc123" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "name": "新名称", "description": "新描述", "members": [ { "_id": "member_id_1", "userId": "user_001", "role": "admin" }, { "userId": "user_003", "role": "user" } ] }' ``` -------------------------------- ### Excel Import Survey Questions API Source: https://context7.com/didi/xiaoju-survey/llms.txt API to import survey questions from an Excel file. ```APIDOC ## POST /api/survey/getExcelQuestions ### Description Supports batch import of questions via an Excel file. The Excel file must contain columns for question title, question type, and option content. ### Method POST ### Endpoint /api/survey/getExcelQuestions ### Parameters #### Request Body - **files** (file) - Required - The Excel file containing the survey questions. ### Request Example ```bash curl -X POST http://localhost:8080/api/survey/getExcelQuestions \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer " \ -F "files=@/path/to/questions.xlsx" ``` ### Excel Format Requirements | 题目标题 | 题型 | 选项内容 | |---|---|---| | 您的性别 | 单选 | 男;女 | | 您的爱好 | 多选 | 阅读;运动;音乐;旅行 | | 您的建议 | 文本 | | ### Response #### Success Response (200) - **questions** (array) - An array of question objects. - **title** (string) - The title of the question. - **type** (string) - The type of the question (e.g., "单选", "多选", "文本"). - **options** (string) - The options for the question, separated by semicolons. #### Response Example ```json { "code": 200, "message": "上传成功", "data": { "questions": [ { "title": "您的性别", "type": "单选", "options": "男;女" }, { "title": "您的爱好", "type": "多选", "options": "阅读;运动;音乐;旅行" } ] } } ``` #### Error Response Examples - **HEADER_FORMAT**: Indicates an error in the header format of the Excel file. - **MERGED_CELLS**: Indicates that the Excel file contains merged cells. - **SIZE_LIMIT**: Indicates that the file size exceeds the limit. ```json { "code": 400, "message": "文件不通过校验", "error": "HEADER_FORMAT" } ``` ``` -------------------------------- ### Submit Survey Response via Open API Source: https://context7.com/didi/xiaoju-survey/llms.txt Submit survey answers through an open API endpoint, requiring a channel ID and API token for authentication. ```bash curl -X POST http://localhost:8080/api/surveyResponse/createResponseWithOpen \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "surveyPath": "abc123xyz", "channelId": "channel_65abc123", "data": { "q1": "opt1" }, "clientTime": 1705312800000 }' ``` -------------------------------- ### Submit Survey Response with RSA Encryption Source: https://context7.com/didi/xiaoju-survey/llms.txt Submit survey answers securely using RSA encryption. Requires 'encryptType', 'sessionId', and encrypted 'data' chunks. ```bash curl -X POST http://localhost:8080/api/surveyResponse/createResponse \ -H "Content-Type: application/json" \ -d '{ "surveyPath": "abc123xyz", "encryptType": "rsa", "sessionId": "encrypt_session_id", "data": ["base64_encrypted_chunk1", "base64_encrypted_chunk2"], "clientTime": 1705312800000 }' ``` -------------------------------- ### Survey List Query API Source: https://context7.com/didi/xiaoju-survey/llms.txt Endpoint for retrieving a paginated list of surveys with support for filtering and sorting. ```bash # 获取问卷列表(支持分页、筛选、排序) curl -X GET "http://localhost:8080/api/survey/getList?curPage=1&pageSize=10&workspaceId=workspace_id" \ -H "Authorization: Bearer " # 带筛选条件查询(filter 需 URL 编码) ``` -------------------------------- ### Survey Management API Source: https://context7.com/didi/xiaoju-survey/llms.txt Endpoints for creating, updating, publishing, and managing the lifecycle of surveys. ```bash # 创建问卷(支持从模板复制或 AI 生成) curl -X POST http://localhost:8080/api/survey/createSurvey \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "title": "用户满意度调研", "remark": "2024年第一季度满意度调研", "surveyType": "normal", "createMethod": "create", "workspaceId": "workspace_id_here", "questionList": [ { "type": "radio", "title": "您对我们的服务满意吗?", "options": [ { "text": "非常满意", "hash": "opt1" }, { "text": "满意", "hash": "opt2" }, { "text": "一般", "hash": "opt3" }, { "text": "不满意", "hash": "opt4" } ] } ] }' # 响应示例: # { "code": 200, "data": { "id": "survey_65abc123" } } # 从已有问卷复制创建 curl -X POST http://localhost:8080/api/survey/createSurvey \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "title": "用户满意度调研-副本", "remark": "从模板复制", "createMethod": "copy", "createFrom": "source_survey_id" }' # 获取问卷详情 curl -X GET "http://localhost:8080/api/survey/getSurvey?surveyId=survey_65abc123" \ -H "Authorization: Bearer " # 响应示例: # { # "code": 200, # "data": { # "surveyMetaRes": { # "_id": "survey_65abc123", # "title": "用户满意度调研", # "surveyType": "normal", # "surveyPath": "abc123xyz", # "currentUserId": "user_id", # "isCollaborated": false # }, # "surveyConfRes": { # "code": { "dataConf": {...}, "skinConf": {...}, "baseConf": {...} } # } # } # } # 更新问卷配置 curl -X POST http://localhost:8080/api/survey/updateConf \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "surveyId": "survey_65abc123", "sessionId": "session_id_here", "configData": { "dataConf": { "dataList": [ { "field": "q1", "type": "radio", "title": "您的性别是?", "options": [...] } ] }, "skinConf": { "backgroundConf": { "color": "#ffffff" } }, "baseConf": { "begTime": "", "endTime": "" } } }' # 发布问卷(发布后可通过 surveyPath 访问) curl -X POST http://localhost:8080/api/survey/publishSurvey \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "surveyId": "survey_65abc123" }' # 暂停问卷回收 curl -X POST http://localhost:8080/api/survey/pausingSurvey \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "surveyId": "survey_65abc123" }' # 删除问卷(移入回收站) curl -X POST http://localhost:8080/api/survey/deleteSurvey \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "surveyId": "survey_65abc123" }' # 恢复已删除问卷 curl -X POST http://localhost:8080/api/survey/recoverSurvey \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "surveyId": "survey_65abc123" }' # 彻底删除问卷 curl -X POST http://localhost:8080/api/survey/completeDeleteSurvey \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "surveyId": "survey_65abc123" }' ``` -------------------------------- ### POST /api/surveyResponse/createResponse Source: https://context7.com/didi/xiaoju-survey/llms.txt Submits a survey response, supporting standard, password-protected, whitelisted, and encrypted submissions. ```APIDOC ## POST /api/surveyResponse/createResponse ### Description Submits survey answers. Supports various security modes including RSA encryption, password, and whitelist validation. ### Method POST ### Endpoint /api/surveyResponse/createResponse ### Parameters #### Request Body - **surveyPath** (string) - Required - Unique survey path - **data** (object/array) - Required - Survey answers - **clientTime** (number) - Required - Timestamp of submission - **password** (string) - Optional - Password for protected surveys - **whitelist** (string) - Optional - Whitelist identifier - **encryptType** (string) - Optional - Encryption type (e.g., 'rsa') ``` -------------------------------- ### Survey List Query API Source: https://context7.com/didi/xiaoju-survey/llms.txt Provides endpoints for querying lists of surveys with support for pagination, filtering, sorting, and workspace/group filtering. Includes functionality for collaborative surveys and trash. ```APIDOC ## GET /api/survey/getList ### Description Retrieves a list of surveys with support for pagination, filtering, and sorting. ### Method GET ### Endpoint /api/survey/getList ### Parameters #### Query Parameters - **curPage** (integer) - Optional - The current page number for pagination. - **pageSize** (integer) - Optional - The number of items per page. - **workspaceId** (string) - Optional - Filter surveys by workspace ID. - **filter** (string) - Optional - Filter criteria for the list (URL encoded). #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Response #### Success Response (200) - **code** (integer) - Response status code. - **data** (array) - A list of survey objects. - Each survey object may contain details like ID, title, status, etc. ### Response Example ```json { "code": 200, "data": [ { "id": "survey_abc", "title": "Customer Satisfaction Survey", "status": "published", "createdAt": "2024-01-01T10:00:00Z" }, { "id": "survey_xyz", "title": "Employee Feedback Form", "status": "draft", "createdAt": "2024-01-02T11:00:00Z" } ] } ``` ``` -------------------------------- ### Submit Survey Response with Password Source: https://context7.com/didi/xiaoju-survey/llms.txt Submit survey answers with password verification. Requires the 'password' field in the JSON payload. ```bash curl -X POST http://localhost:8080/api/surveyResponse/createResponse \ -H "Content-Type: application/json" \ -d '{ "surveyPath": "abc123xyz", "data": { "q1": "opt1" }, "clientTime": 1705312800000, "password": "survey_password" }' ```