### Build JimuReport Example Project Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Clone the example project and build it using Maven. The resulting JAR file will be located in the target directory. ```bash cd jimureport-example mvn clean package ``` -------------------------------- ### Example Tenant ID Retrieval Implementation (Java) Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/authentication-service.md Provides an example implementation for retrieving the tenant ID from request headers ('X-Tenant-Key', 'X-Tenant-ID') or a URL parameter ('tenantId'). ```java @Override public String getTenantId() { HttpServletRequest request = JimuSpringContextUtils.getHttpServletRequest(); if (request == null) { return null; } // Check custom header first String tenantId = request.getHeader("X-Tenant-Key"); if (OkConvertUtils.isEmpty(tenantId)) { tenantId = request.getHeader("X-Tenant-ID"); } // Fallback to parameter if (OkConvertUtils.isEmpty(tenantId)) { tenantId = request.getParameter("tenantId"); } return tenantId; } ``` -------------------------------- ### JimuReport Engine Settings Example Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Example configuration for JimuReport's core engine properties, including display limits and security secrets. ```yaml jeecg: jmreport: col: 100 row: 200 max-data-rows: 100000 signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a apiBasePath: http://192.168.1.11:8085 ``` -------------------------------- ### TokenInfoDTO Example Implementation Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/types.md Provides an example implementation of a TokenInfoDTO class, used for holding extended token information such as username, roles, permissions, and expiration. ```java public class TokenInfoDTO { private String token; // Token value private String username; // Logged-in username private String[] roles; // User roles private String[] permissions; // User permissions private Long expiresIn; // Expiration time (ms) private String tenantId; // Tenant ID (if multi-tenant) public TokenInfoDTO(String token, String username, String[] roles, String[] permissions, Long expiresIn, String tenantId) { this.token = token; this.username = username; this.roles = roles; this.permissions = permissions; this.expiresIn = expiresIn; this.tenantId = tenantId; } } ``` -------------------------------- ### Example: System Dictionaries Only Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/drag-external-service.md Demonstrates retrieving dictionary items using only system dictionary codes. ```java // System dictionaries only List codes = Arrays.asList("STATUS", "PRIORITY"); Map> results = service.getManyDictItems(codes, null); ``` -------------------------------- ### Implementation Example of addLog Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/drag-external-service.md Provides a sample implementation of the addLog method, showing how to extract context and log messages using a logger. ```java @Override public void addLog(String logMsg, int logType, int operateType) { try { String operator = getCurrentUsername(); String logLevel = getLogLevelName(logType); String operationType = getOperationTypeName(operateType); logger.info("[{}] [{}] [{}] - {}", logLevel, operationType, operator, logMsg); } catch (Exception e) { log.error("Failed to create audit log", e); } } private String getCurrentUsername() { return StpUtil.getLoginIdAsString(); } private String getLogLevelName(int logType) { switch (logType) { case 0: return "INFO"; case 1: return "WARN"; case 2: return "ERROR"; default: return "UNKNOWN"; } } private String getOperationTypeName(int operateType) { switch (operateType) { case 0: return "CREATE"; case 1: return "UPDATE"; case 2: return "DELETE"; case 3: return "VIEW"; default: return "UNKNOWN"; } } ``` -------------------------------- ### JimuReport Configuration Example Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/overview.md Provides an example of JimuReport's configuration using Spring Boot's standard YAML format. Adjust these settings to customize server limits, database connections, security, file storage, and report-specific options. ```yaml spring: # Server and multipart upload limits servlet: multipart: max-file-size: 10MB # Database connection datasource: url: jdbc:mysql://... # Redis (for distributed caching/sessions) data: redis: host: 127.0.0.1 port: 6379 # Security and authentication security: enable: true user: name: admin password: 123456 jeecg: # File storage backend uploadType: local # or minio, alioss # JimuReport specific settings jmreport: # Mail configuration for report distribution mail: enabled: false # Automated report export automate: export: enable-auto-export: true # Firewall and security firewall: dataSourceSafe: false lowCodeMode: dev # or prod sqlInjectionLevel: basic # Amap/Gaode map API keys gao-de-api: api-key: ??? # Display/pagination limits col: 100 row: 200 max-data-rows: 100000 ``` -------------------------------- ### Example: Both System and Table Dictionaries Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/drag-external-service.md Demonstrates retrieving dictionary items using both system dictionary codes and table-based dictionary specifications. ```java // Both types Map> results = service.getManyDictItems(codes, tableDicts); ``` -------------------------------- ### Build Docker Image Source: https://github.com/jeecgboot/jimureport/blob/master/jimureport-example/README.en-US.md Commands to clone the project, navigate to the example directory, package the project, and build the Docker image using docker-compose. ```bash git clone https://gitee.com/jeecg/JimuReport.git cd JimuReport/jimureport-example mvn clean package docker-compose up -d ``` -------------------------------- ### Install JimuReport Skills Only Source: https://github.com/jeecgboot/jimureport/blob/master/README.en-US.md If you already have Claude Code installed, use this command to clone the JimuReport Skills repository. Run `git pull` within the directory to update the skills. After installation, launch `claude` in a new terminal to start generating reports. ```bash git clone https://github.com/jeecgboot/skills.git ~/.claude/skills # Update: cd ~/.claude/skills && git pull ``` -------------------------------- ### Complete Custom JimuReport Token Service Example (Java) Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/authentication-service.md A comprehensive example of a custom token service implementation for JimuReport, handling token retrieval, username extraction, role and permission assignment, token verification, and tenant ID retrieval. ```java package com.example.jmreport.security; import cn.dev33.satoken.context.SaHolder; import cn.dev33.satoken.exception.NotLoginException; import cn.dev33.satoken.stp.StpUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; import org.jeecg.modules.jmreport.common.expetion.JimuReportException; import org.springframework.stereotype.Component; import jakarta.servlet.http.HttpServletRequest; @Slf4j @Component public class CustomJimuReportTokenService implements JmReportTokenServiceI { private final UserService userService; private final AuthTokenProvider authTokenProvider; public CustomJimuReportTokenService(UserService userService, AuthTokenProvider authTokenProvider) { this.userService = userService; this.authTokenProvider = authTokenProvider; } @Override public String getToken(HttpServletRequest request) { try { return StpUtil.getTokenValue(); } catch (Exception e) { if (request != null) { return request.getParameter("token"); } return null; } } @Override public String getUsername(String token) { return StpUtil.getLoginIdAsString(); } @Override public String[] getRoles(String token) { String username = getUsername(token); User user = userService.findByUsername(username); if (user.isAdmin()) { return new String[]{"admin"}; } else if (user.isDesigner()) { return new String[]{"lowdeveloper"}; } else if (user.isDatabaseAdmin()) { return new String[]{"dbadeveloper"}; } return new String[]{}; } @Override public String[] getPermissions(String token) { String username = getUsername(token); User user = userService.findByUsername(username); if (!user.isAdmin()) { return new String[]{}; } return new String[]{ "drag:datasource:testConnection", "drag:dataset:save", "drag:dataset:delete", "drag:datasource:saveOrUpate", "drag:datasource:delete", "drag:design:getTotalData", "drag:analysis:sql" }; } @Override public Boolean verifyToken(String token) { try { StpUtil.checkLogin(); String username = getUsername(token); User user = userService.findByUsername(username); return user != null && user.isActive(); } catch (NotLoginException e) { log.warn("Authentication failed: {}", e.getMessage()); return false; } catch (Exception e) { log.error("Token verification error", e); throw new JimuReportException(e); } } @Override public String getTenantId() { HttpServletRequest request = getRequest(); if (request == null) { return null; } String tenantId = request.getHeader("X-Tenant-ID"); if (StringUtils.isEmpty(tenantId)) { tenantId = request.getParameter("tenantId"); } return tenantId; } private HttpServletRequest getRequest() { try { return SaHolder.getRequest().getSource(); } catch (Exception e) { return null; } } } ``` -------------------------------- ### Example MySQL Database Configuration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Configure your MySQL database connection using these properties. Ensure the driver class name is correct for your MySQL version. ```yaml spring: datasource: url: jdbc:mysql://127.0.0.1:3306/jimureport?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver ``` -------------------------------- ### Timestamp Handling Examples Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/types.md Shows how to create a new timestamp, parse a timestamp from an ISO-8601 formatted string, and format a timestamp into a string. ```java // Create timestamp Timestamp now = new Timestamp(System.currentTimeMillis()); // Parse from string (ISO-8601) Timestamp ts = Timestamp.valueOf("2026-06-25 10:30:00"); // Format to string String iso = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(ts); ``` -------------------------------- ### Install Jimu Skills Only Source: https://github.com/jeecgboot/jimureport/blob/master/README.md If Claude Code is already installed, use this command to clone the JimuReport Skills repository into your local Claude configuration directory. Run 'git pull' in the skills directory to update. ```bash git clone https://github.com/jeecgboot/skills.git ~/.claude/skills ``` ```bash # 更新: cd ~/.claude/skills && git pull ``` -------------------------------- ### Docker Compose Command Source: https://github.com/jeecgboot/jimureport/blob/master/jimureport-example/README.md Command to build and start Docker containers for the project. ```bash docker-compose up -d ``` -------------------------------- ### Example: Table Dictionaries Only Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/drag-external-service.md Demonstrates retrieving dictionary items using only table-based dictionary specifications. ```java // Table dictionaries only List tableDicts = Arrays.asList( JSONObject.of("dictField", "id", "dictTable", "employees", "dictText", "name") ); Map> results = service.getManyDictItems(null, tableDicts); ``` -------------------------------- ### Configure JVM Memory Limits (Development) Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Set initial and maximum heap sizes for the Java Virtual Machine when running the application. These are example settings for development. ```bash java -Xms512m -Xmx2g \ -jar jimureport-example.jar ``` -------------------------------- ### Example Usage of addLog Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/drag-external-service.md Demonstrates how to use the addLog method to record different types of audit logs, including simple actions, warnings, and errors. ```java // Log a simple action service.addLog("Deleted unused dashboard template", 0, 2); // Log a warning service.addLog("Large data export initiated", 1, 0); // Log an error service.addLog("Failed to save dashboard changes", 2, 1); ``` -------------------------------- ### Login Endpoint Example Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/endpoints.md Use this endpoint to authenticate a user and initiate a login session. It requires username and password as query parameters and redirects to the report workbench on success or an error page on failure. ```http GET /doLogin?username=admin&password=123456 ``` -------------------------------- ### Install Claude Code and Jimu Skills (Windows) Source: https://github.com/jeecgboot/jimureport/blob/master/README.md Use this PowerShell command to install Node.js, Python, Git, Claude Code, and JimuReport Skills on Windows. It also configures DeepSeek v4 model backend. ```powershell irm https://www.qiaoqiaoyun.com/claude/boot.ps1 | iex ``` -------------------------------- ### Install Claude Code and Jimu Skills (macOS/Linux) Source: https://github.com/jeecgboot/jimureport/blob/master/README.md Execute this command in your terminal to install Node.js, Python, Git, Claude Code, and JimuReport Skills on macOS or Linux systems. It also sets up the DeepSeek v4 model backend. ```bash curl -fsSL https://www.qiaoqiaoyun.com/claude/install-claude-code.sh | bash ``` -------------------------------- ### Start Spring Boot Application Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md This is the main application class that starts the Spring Boot application. It includes print statements to indicate that JimuReport is running and provides URLs for accessing the Report and Dashboard designers. ```java @SpringBootApplication public class JimuReportApplication { public static void main(String[] args) { SpringApplication.run(JimuReportApplication.class, args); System.out.println("JimuReport is running!"); System.out.println("Report Workbench: http://localhost:8085/jmreport/list"); System.out.println("Dashboard Workbench: http://localhost:8085/drag/list"); } } ``` -------------------------------- ### JimuReport Email Distribution Configuration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Example configuration for enabling and setting up email-based report distribution via SMTP. ```yaml jeecg: jmreport: mail: enabled: true host: smtp.gmail.com port: 465 ssl: true sender: report@company.com username: report@company.com password: app_password ``` -------------------------------- ### Login Status Check Example Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/endpoints.md This endpoint verifies the current authentication status. It requires a valid `X-Access-Token` in the headers and returns a string indicating whether the user is logged in. ```http GET /isLogin Headers: X-Access-Token: token_value ``` -------------------------------- ### Missing Configuration Error Example Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/errors.md This error occurs when a required configuration property is not set. Ensure properties like 'jeecg.jmreport.signatureSecret' are correctly configured. ```java ERROR org.springframework.boot.SpringApplication:824 - Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean... Caused by: java.lang.IllegalStateException: Missing required property: 'jeecg.jmreport.signatureSecret' ``` -------------------------------- ### JimuReport Production Firewall Configuration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Example production configuration for JimuReport's firewall and security settings, disabling platform data sources and online design. ```yaml jeecg: jmreport: firewall: dataSourceSafe: true # Disable platform data sources lowCodeMode: prod # Disable online design sqlInjectionLevel: strict ``` -------------------------------- ### Kubernetes Deployment Commands Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Commands to create necessary Kubernetes ConfigMaps and Secrets, and then apply the deployment manifest. Use `kubectl get pods` to check the status and `kubectl logs` to view application logs. ```bash # Create configmap kubectl create configmap jimureport-config \ --from-literal=mysql.host=mysql.default.svc.cluster.local \ --from-literal=mysql.db=jimureport # Create secrets kubectl create secret generic db-credentials \ --from-literal=username=app_user \ --from-literal=password=secure_password # Deploy kubectl apply -f deployment.yaml # Check status kubectl get pods -l app=jimureport kubectl logs deployment/jimureport ``` -------------------------------- ### Docker Compose Management Commands Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Provides essential commands for managing the Jimureport Docker Compose environment, including starting, viewing logs, stopping, and removing services and volumes. ```bash # Start all services docker-compose up -d # View logs docker-compose logs -f jimureport # Stop services docker-compose down # Remove volumes (data loss) docker-compose down -v ``` -------------------------------- ### JavaScript Fetch Example for API Integration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/endpoints.md Provides a JavaScript helper function `jimuRequest` to simplify authenticated API calls using the Fetch API. It handles token retrieval from localStorage, setting headers, and basic error redirection for unauthorized access. ```javascript // Helper function for authenticated requests async function jimuRequest(endpoint, method = 'GET', body = null) { const headers = { 'X-Access-Token': localStorage.getItem('token') }; if (body) { headers['Content-Type'] = 'application/json'; } const options = { method, headers, credentials: 'include' // Include cookies }; if (body) { options.body = JSON.stringify(body); } const response = await fetch(`http://localhost:8085${endpoint}`, options); if (response.status === 401) { // Redirect to login window.location.href = '/login/login.html'; } return response.json(); } // Example: Test data source async function testDataSource() { const result = await jimuRequest('/drag/datasource/testConnection', 'POST', { dbDriver: 'com.mysql.cj.jdbc.Driver', dbUrl: 'jdbc:mysql://localhost:3306/test', dbUsername: 'root', dbPassword: 'password' }); if (result.success) { alert('连接成功!'); } else { alert('连接失败: ' + result.message); } } ``` -------------------------------- ### Run Standalone JAR with Custom Config File Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Run the application using a custom configuration file, such as 'application-prod.yml', by specifying its location. ```bash java -jar jimureport-example.jar \ --spring.config.location=application-prod.yml ``` -------------------------------- ### Get Dashboard Data Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/endpoints.md Retrieves data for dashboard components, typically used with Online Forms. Requires authentication. ```APIDOC ## GET /drag/design/getTotalData ### Description Retrieves data for dashboard components (used with Online Forms). ### Method GET ### Endpoint /drag/design/getTotalData ### Headers - `X-Access-Token` (required) ### Query Parameters - **formId** (string) - Required - Form/table ID - **pageNo** (int) - Required - Page number (1-based) - **pageSize** (int) - Required - Records per page ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (object) - Contains the dashboard data. - **records** (array) - List of records. - **total** (int) - Total number of records. - **pageNo** (int) - Current page number. - **pageSize** (int) - Number of records per page. ### Response Example ```json { "success": true, "data": { "records": [ { "id": "1", "name": "John", "status": "active" }, { "id": "2", "name": "Jane", "status": "inactive" } ], "total": 100, "pageNo": 1, "pageSize": 10 } } ``` ``` -------------------------------- ### Initialize Database Schema Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Execute this bash command to initialize the JimuReport database schema using the provided SQL script. This is necessary for the application to function correctly. ```bash mysql < db/jimureport.mysql5.7.create.sql ``` -------------------------------- ### Verify Database Connection Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Connect to your MySQL database using the command line to verify it is running and accessible. ```bash mysql -u root -p ``` -------------------------------- ### Invalid Configuration Value Example Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/errors.md This error indicates a configuration property has an invalid value, such as an incorrect database driver class name. ```java ERROR: Failed to load database driver: 'invalid.Driver' Caused by: ClassNotFoundException: invalid.Driver ``` -------------------------------- ### Data Migration Between Databases Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Steps to export data from a source database and import it into a target database, followed by verification. ```bash # Export from Source mysqldump -h source.db -u user -p jimureport > export.sql ``` ```bash # Import to Target mysql -h target.db -u user -p jimureport < export.sql ``` ```bash # Verify Migration mysql -h target.db -u user -p -e "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='jimureport';" ``` -------------------------------- ### Enable Firewall Settings Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Configure the Jimureport firewall for production environments, setting the mode to 'prod' and enabling strict SQL injection prevention and data source security. ```yaml jeecg: jmreport: firewall: lowCodeMode: prod sqlInjectionLevel: strict dataSourceSafe: true ``` -------------------------------- ### Get Dictionary Items Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/drag-external-service.md Retrieves all items for a single dictionary by its code. Useful for populating select or filter fields in dashboard components. ```java List getDictItems(String dictCode) ``` ```java List statusItems = service.getDictItems("STATUS"); // Returns: // DragDictModel(code="1", name="Active") // DragDictModel(code="2", name="Inactive") ``` ```java @Override public List getDictItems(String dictCode) { if (StringUtils.isEmpty(dictCode)) { return new ArrayList<>(); } List items = reportDictService.queryDictItemsByCode(dictCode); return items.stream() .map(item -> DragDictModel.builder() .code(item.getItemCode()) .name(item.getItemValue()) .build()) .collect(toList()); } ``` -------------------------------- ### Get Tenant ID in Authentication Service Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Implement `getTenantId()` to retrieve the tenant ID from request headers ('X-Tenant-ID') or parameters ('tenantId'). ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.scheduling.annotation.Scheduled; import cn.hutool.core.util.StringUtils; import javax.servlet.http.HttpServletRequest; @Override public String getTenantId() { HttpServletRequest request = JimuSpringContextUtils.getHttpServletRequest(); if (request != null) { // Get from header String tenantId = request.getHeader("X-Tenant-ID"); // Or get from parameter if (StringUtils.isEmpty(tenantId)) { tenantId = request.getParameter("tenantId"); } return tenantId; } return null; } ``` -------------------------------- ### Complete Authentication and API Flow with cURL Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/endpoints.md Demonstrates a typical workflow for interacting with the API using cURL, including logging in, accessing resources, testing data sources, and logging out. Ensure you replace `` with the actual token obtained after login. ```bash # 1. Login curl -X GET "http://localhost:8085/doLogin?username=admin&password=123456" # Response: Redirect with X-Access-Token cookie # 2. Access report list curl -X GET "http://localhost:8085/jmreport/list" \ -H "X-Access-Token: " # 3. Test data source curl -X POST "http://localhost:8085/drag/datasource/testConnection" \ -H "X-Access-Token: " \ -H "Content-Type: application/json" \ -d '{ "dbDriver": "com.mysql.cj.jdbc.Driver", "dbUrl": "jdbc:mysql://localhost:3306/test", "dbUsername": "root", "dbPassword": "password" }' # 4. Logout curl -X GET "http://localhost:8085/logout" \ -H "X-Access-Token: " ``` -------------------------------- ### Configure HTTPS Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Enable HTTPS by configuring the SSL key store, password, and alias. ```yaml server: ssl: enabled: true key-store: classpath:keystore.jks key-store-password: ${KEYSTORE_PASSWORD} key-alias: jimureport key-store-type: JKS ``` -------------------------------- ### Get Many Dictionary Items Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/dictionary-service.md Retrieves items for multiple dictionaries in a single API call, optimizing performance by reducing database round-trips. ```APIDOC ## getManyDictItems ### Description Retrieves items for multiple dictionaries in a single call. This method is efficient for bulk loading multiple dictionaries. ### Method Signature ```java Map> getManyDictItems(List codeList) ``` ### Parameters #### Path Parameters - **codeList** (List) - Required - A list of dictionary codes to retrieve. ### Returns - `Map>`: A map where keys are the dictionary codes and values are lists of `JmDictModel` objects. Returns an empty map if no dictionaries are found. The return value is never null. ### Example Usage ```java List codes = Arrays.asList("STATUS", "GENDER", "DEPARTMENT"); Map> allDicts = dictService.getManyDictItems(codes); List statusList = allDicts.get("STATUS"); List genderList = allDicts.get("GENDER"); List deptList = allDicts.get("DEPARTMENT"); ``` ``` -------------------------------- ### Configure Database and Security Settings Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Configure your database connection, security settings, upload type, and JimuReport specific properties in `application.yml`. Ensure `signatureSecret` is set to a secure value. ```yaml spring: datasource: url: jdbc:mysql://localhost:3306/jimureport?characterEncoding=UTF-8&useUnicode=true username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver security: enable: true user: name: admin password: 123456 jeecg: uploadType: local path: upload: /opt/upload jmreport: signatureSecret: your-secret-key-here col: 100 row: 200 firewall: lowCodeMode: dev sqlInjectionLevel: basic ``` -------------------------------- ### Test and Deploy Maven Project Updates Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md After updating dependencies, run tests to ensure compatibility and stability. If tests pass, proceed with deploying the updated version of your application. ```bash # Test update mvn clean test # Deploy updated version ``` -------------------------------- ### Handling JimuReportException in Java Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/errors.md Example of catching a `JimuReportException` within a try-catch block. This demonstrates logging the error and returning a standardized JSON error response. ```java try { // Some JimuReport operation } catch (JimuReportException e) { log.error("JimuReport error: {}", e.getMessage(), e); return ResponseEntity.status(500) .body(new ErrorResponse(e.getMessage())); } ``` -------------------------------- ### Maven Package Command Source: https://github.com/jeecgboot/jimureport/blob/master/jimureport-example/README.md Command to package the project using Maven. ```bash mvn clean package ``` -------------------------------- ### Configure Object Storage (MinIO) Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Configure Jimureport to use MinIO for file storage in production. Specify the object storage type and MinIO connection details. ```yaml jeecg: uploadType: minio # or alioss minio: minio_url: https://minio.internal minio_name: produser minio_pass: prodpass ``` -------------------------------- ### Dockerfile for Jimureport Application Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Defines the Docker image for the Jimureport application. It installs dependencies, copies the JAR file, exposes the application port, and sets up a health check. ```dockerfile FROM openjdk:17-jdk-slim # Install required packages RUN apt-get update && \ apt-get install -y --no-install-recommends \ curl \ mysql-client && \ rm -rf /var/lib/apt/lists/* # Create app directory WORKDIR /app # Copy JAR COPY jimureport-example-2.3.jar app.jar # Expose port EXPOSE 8085 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD curl -f http://localhost:8085/isLogin || exit 1 # Start application ENTRYPOINT ["java", "-Xms512m", "-Xmx2g", "-jar", "app.jar"] ``` -------------------------------- ### Implement Custom Authentication Service Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Create a custom authentication service by implementing `JmReportTokenServiceI`. This service handles token retrieval, username, roles, permissions, and token verification using SaToken. ```java package com.example.config; import cn.dev33.satoken.stp.StpUtil; import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; import org.springframework.stereotype.Component; import jakarta.servlet.http.HttpServletRequest; @Slf4j @Component public class JimuReportTokenService implements JmReportTokenServiceI { @Override public String getToken(HttpServletRequest request) { try { return StpUtil.getTokenValue(); } catch (Exception e) { if (request != null) { return request.getParameter("token"); } return null; } } @Override public String getUsername(String token) { return StpUtil.getLoginIdAsString(); } @Override public String[] getRoles(String token) { return new String[]{"admin", "lowdeveloper", "dbadeveloper"}; } @Override public String[] getPermissions(String token) { return new String[]{ "drag:datasource:testConnection", "drag:dataset:save", "drag:dataset:delete", "drag:datasource:saveOrUpate", "drag:datasource:delete", "drag:design:getTotalData", "drag:analysis:sql" }; } @Override public Boolean verifyToken(String token) { try { StpUtil.checkLogin(); return true; } catch (Exception e) { log.warn("Token verification failed: {}", e.getMessage()); return false; } } @Override public String getTenantId() { // Return tenant ID for multi-tenant isolation return null; } } ``` -------------------------------- ### Run Standalone JAR with Custom Port Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Execute the built JAR file, specifying a custom port for the application to run on. ```bash java -jar jimureport-example.jar --server.port=8080 ``` -------------------------------- ### Run Standalone JAR with Environment Variables Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Configure database connection details using environment variables before running the application. This is useful for production environments. ```bash export MYSQL_HOST=db.prod.internal export MYSQL_DB=jimureport export MYSQL_USER=app_user java -jar jimureport-example.jar ``` -------------------------------- ### Logout Endpoint Example Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/endpoints.md Call this endpoint to clear the user's session and revoke the authentication token. It redirects the user to the login page upon successful logout. ```http GET /logout ``` -------------------------------- ### JSON Example of an Error Response Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/errors.md Illustrates a typical JSON error response, showing fields like success, code, message, path, timestamp, and additional data. ```json { "success": false, "code": "ERR_SQL_INJECTION", "message": "SQL注入风险检测", "path": "/drag/analysis/sql", "timestamp": 1687350000000, "data": { "pattern": "OR '1'='1'", "severity": "high" } } ``` -------------------------------- ### Aliyun OSS File Upload Configuration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Configure Aliyun Object Storage Service (OSS) for file uploads. Replace placeholders with your actual credentials. ```yaml jeecg: oss: endpoint: oss-cn-hangzhou.aliyuncs.com accessKey: YOUR_ACCESS_KEY secretKey: YOUR_SECRET_KEY bucketName: jimureport ``` -------------------------------- ### Get Dashboard Data Endpoint Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/endpoints.md Retrieves data for dashboard components. Requires `X-Access-Token` header and specifies form ID, page number, and page size as query parameters. ```json { "success": true, "data": { "records": [ { "id": "1", "name": "John", "status": "active" }, { "id": "2", "name": "Jane", "status": "inactive" } ], "total": 100, "pageNo": 1, "pageSize": 10 } } ``` -------------------------------- ### Get User Permissions Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/authentication-service.md Retrieves granular permissions for a user based on their authentication token. Handles different permission sets for administrators and report designers. Returns an array of permission codes. ```java String[] getPermissions(String token) ``` ```java @Override public String[] getPermissions(String token) { String username = getUsername(token); User user = userService.findByUsername(username); List permissions = new ArrayList<>(); if (user.isAdmin()) { // Admin has all permissions permissions.addAll(Arrays.asList( "drag:datasource:testConnection", "drag:dataset:save", "drag:dataset:delete", "drag:datasource:saveOrUpate", "drag:datasource:delete", "drag:design:getTotalData", "drag:analysis:sql" )); } else if (user.isReportDesigner()) { // Designer permissions permissions.addAll(Arrays.asList( "drag:datasource:testConnection", "drag:dataset:save", "drag:design:getTotalData" )); } return permissions.toArray(new String[0]); } ``` -------------------------------- ### Dynamic Employee Selector API Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/dictionary-service.md An example API endpoint that fetches employee data using queryTableDictItemsByCode and transforms it into a list of EmployeeOption objects. This is useful for building dynamic select components in a frontend application. ```java @GetMapping("/api/employees") public ResponseEntity> getEmployees() { List items = dictService.queryTableDictItemsByCode( "employees", "name", "id" ); List options = items.stream() .map(item -> EmployeeOption.builder() .id(item.getItemCode()) .name(item.getItemValue()) .build()) .collect(toList()); return ResponseEntity.ok(options); } ``` -------------------------------- ### Development Configuration (application-dev.yml) Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md This snippet shows the configuration for a development environment. It includes server port, database connection details, security settings, and JimuReport-specific properties like upload type and firewall mode. ```yaml server: port: 8085 spring: datasource: url: jdbc:mysql://localhost:3306/jimureport?characterEncoding=UTF-8 username: root password: root security: enable: true user: name: admin password: 123456 jeecg: uploadType: local jmreport: firewall: lowCodeMode: dev ``` -------------------------------- ### SQL Server Database Configuration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Configure Spring Boot to connect to a SQL Server database. ```yaml spring: datasource: url: jdbc:sqlserver://localhost:1433;databaseName=jimureport username: sa password: password driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver ``` -------------------------------- ### Nginx Reverse Proxy Configuration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md Configure Nginx to proxy requests to multiple Jimureport instances, handle SSL, set security headers, and enable Gzip compression. This setup is suitable for load balancing and improving performance. ```nginx upstream jimureport { server localhost:8085 max_fails=3 fail_timeout=30s; server localhost:8086 max_fails=3 fail_timeout=30s; keepalive 32; } server { listen 80; server_name jimureport.company.com; # Redirect HTTP to HTTPS return 301 https://$server_name$request_uri; } server { listen 443 ssl http2; server_name jimureport.company.com; # SSL certificates ssl_certificate /etc/ssl/certs/jimureport.crt; ssl_certificate_key /etc/ssl/private/jimureport.key; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; # Security headers add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # Gzip compression gzip on; gzip_types text/plain text/css application/json application/javascript; gzip_min_length 1024; # Upload size limit client_max_body_size 100M; # Proxy settings location / { proxy_pass http://jimureport; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # Timeouts proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 120s; } # Static asset caching location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { proxy_pass http://jimureport; proxy_cache_valid 30d; add_header Cache-Control "public, immutable"; } } ``` -------------------------------- ### Production Configuration (application-prod.yml) Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md This snippet outlines the configuration for a production environment. It features a different server port, externalized database credentials and security user details using environment variables, and a different upload type. ```yaml server: port: 8080 spring: datasource: url: jdbc:mysql://db-prod.internal/jimureport username: ${DB_USER} password: ${DB_PASS} security: enable: true user: name: ${SECURITY_USER} password: ${SECURITY_PASS} jeecg: uploadType: minio jmreport: firewall: lowCodeMode: prod ``` -------------------------------- ### Test Database Connection via Command Line Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/errors.md A bash command to manually test database connectivity by attempting to connect to a MySQL server. ```bash mysql -h 127.0.0.1 -u root -p ``` -------------------------------- ### Enable Operation Logging Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Enable operation logging for the SA-Token authentication module. ```yaml sa-token: is-log: true ``` -------------------------------- ### MinIO File Upload Configuration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Configure MinIO for file uploads. Ensure MinIO server is running and accessible. ```yaml jeecg: minio: minio_url: http://minio.jeecg.com minio_name: minioadmin # MinIO username minio_pass: minioadmin # MinIO password bucketName: jimureport ``` -------------------------------- ### Sa-Token Utility Operations in Java Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/api-reference/authentication-service.md Demonstrates common Sa-Token operations such as retrieving token values, login IDs, checking login status, validating logins, accessing token information, and logging out. Ensure Sa-Token is properly configured. ```java String token = StpUtil.getTokenValue(); ``` ```java String loginId = StpUtil.getLoginIdAsString(); ``` ```java boolean isLogin = StpUtil.isLogin(); ``` ```java StpUtil.checkLogin(); ``` ```java TokenInfo info = StpUtil.getTokenInfo(); System.out.println(info.getTokenValue()); System.out.println(info.getLoginId()); System.out.println(info.getCreateTime()); System.out.println(info.getLastActivityTime()); ``` ```java StpUtil.logout(); ``` -------------------------------- ### Configure Auto-Export Settings Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Set `enable-auto-export` to true and configure `expired` days and download paths in `application.yml`. ```yaml jeecg: jmreport: automate: export: enable-auto-export: true expired: 30 # Keep files 30 days jimu-view-path: "http://localhost:8085/jmreport/view/" download-path: "/opt/reports/exports" ``` -------------------------------- ### Add Redis Integration Dependencies Source: https://github.com/jeecgboot/jimureport/blob/master/jimureport-example/README.en-US.md Uncomment these dependencies in pom.xml to enable Redis integration for Sa-Token permission management. ```xml cn.dev33 sa-token-redis-jackson 1.44.0 org.apache.commons commons-pool2 ``` -------------------------------- ### Configure Production Security Settings Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Harden the application for production by disabling detailed error messages and configuring security parameters like SQL injection prevention. ```yaml server: error: include-exception: false include-stacktrace: NEVER include-message: ON_PARAM spring: security: enable: true user: name: ${JIMUREPORT_USER} password: ${JIMUREPORT_PASSWORD} jeecg: jmreport: firewall: lowCodeMode: prod sqlInjectionLevel: strict dataSourceSafe: true ``` -------------------------------- ### Setting HttpServletResponse Properties Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/types.md Illustrates how to configure an HttpServletResponse object, including setting the status code, content type, adding headers, and performing redirects. ```java response.setStatus(200); response.setContentType("application/json"); response.addHeader("X-Custom-Header", "value"); response.sendRedirect("/login"); ``` -------------------------------- ### Daily Backup Script Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/deployment.md A bash script for daily backups, including database dumps, file archiving, old backup cleanup, and uploading to S3. ```bash #!/bin/bash # Daily backup script BACKUP_DIR="/backups/jimureport" DATE=$(date +%Y%m%d_%H%M%S) # Database backup mysqldump jimureport | gzip > $BACKUP_DIR/db_$DATE.sql.gz # Upload files backup tar czf $BACKUP_DIR/uploads_$DATE.tar.gz /opt/upload/ # Clean old backups (keep 30 days) find $BACKUP_DIR -mtime +30 -delete # Send to S3 aws s3 sync $BACKUP_DIR s3://backups-bucket/jimureport/ ``` -------------------------------- ### Enable Freemarker Caching Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/configuration.md Improve performance by enabling caching for Freemarker templates. ```yaml spring: freemarker: cache: true ``` -------------------------------- ### MinIO File Storage Configuration Source: https://github.com/jeecgboot/jimureport/blob/master/_autodocs/integration-guide.md Configure JimuReport to use MinIO for S3-compatible storage. ```yaml jeecg: uploadType: minio minio: minio_url: http://minio.local:9000 minio_name: minioadmin minio_pass: minioadmin bucketName: jimureport ```