### DBFound Execute HTTP Call Example Source: https://context7.com/nfwork/dbfound/llms.txt Example of making a POST request to a DBFound execute endpoint for adding a user. Shows how to pass parameters and retrieve output parameters like the generated user ID. ```bash # 新增用户 curl -X POST http://localhost:8080/user.execute!add \ -H "Content-Type: application/json" \ -d '{ "user_name": "小明", "user_code": "xiaoming", "password": "123456" }' ``` ```json # 返回结果(包含自增ID) { "success": true, "message": "success", "outParam": { "user_id": 15 } } ``` -------------------------------- ### DBFound Query HTTP Call Example Source: https://context7.com/nfwork/dbfound/llms.txt Example of making a POST request to a DBFound query endpoint. Demonstrates passing parameters and the expected JSON response structure. ```bash # POST请求查询 curl -X POST http://localhost:8080/user.query \ -H "Content-Type: application/json" \ -d '{ "user_name": "小明", "limit": 10, "start": 0 }' ``` ```json { "success": true, "message": "success", "datas": [ { "user_id": 1, "user_name": "小明", "user_code": "xiaoming", "create_date": "2021-08-01 00:00:00", "create_by": 1 } ], "totalCounts": 1 } ``` -------------------------------- ### Example Request and Response for Collection Parameter Source: https://github.com/nfwork/dbfound/wiki/dbfound-example Example JSON payload and response structure for a collection-based query. ```json { "ids":[14,15] } ``` ```json { "success": true, "message": "success", "outParam": {}, "datas": [ { "create_by": 1, "user_code": "xiaoyang", "user_id": 14, "user_name": "小杨", "create_date": "2022-06-29 16:12:24" }, { "create_by": 1, "user_code": "xiaoming1", "user_id": 15, "user_name": "小明", "create_date": "2022-07-09 09:02:22" } ], "totalCounts": 2 } ``` -------------------------------- ### DBFound File Download from Database Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api This execute example demonstrates downloading a file from the database. It specifies parameters for file_id, file_name, and the output content, mapping the file_content from the database to the 'content' parameter. ```xml ``` -------------------------------- ### Create User Database Table Source: https://github.com/nfwork/dbfound/wiki/dbfound-example SQL schema definition for the user table required for the examples. ```sql CREATE TABLE `user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_code` varchar(100) NOT NULL, `user_name` varchar(200) NOT NULL, `password` varchar(50) NOT NULL, `create_date` datetime NOT NULL, `create_by` int(11) NOT NULL, PRIMARY KEY (`user_id`), UNIQUE KEY (`user_code`) ); ``` -------------------------------- ### Batch Import Request Parameters Source: https://github.com/nfwork/dbfound/wiki/dbfound-example Example JSON payload for the batch import endpoint. ```json { "userList":[ { "user_name" : "小明", "user_code" : "xiaoming", "password" : "123456123" }, { "user_name" : "小杨", "user_code" : "xiaoyang", "password" : "123456123" } ] } ``` -------------------------------- ### DBFound File Download from File System Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api This execute example shows how to download a file from the file system. It uses fileSaveType='disk' and maps the file name and content. The 'content' parameter specifies the file to be downloaded, and 'fileNameParam' sets the actual file name. ```xml ``` -------------------------------- ### Example API Call for dynamicFields Query Source: https://context7.com/nfwork/dbfound/llms.txt Demonstrates how to call the dynamicFields query using curl, passing parameters for fields to select and sorting order. ```bash curl -X POST http://localhost:8080/user.query!dynamicFields \ -H "Content-Type: application/json" \ -d '{ "fields": ["user_code", "user_name"], "sort": "user_code desc" }' ``` -------------------------------- ### Get and Set Data with Context Source: https://context7.com/nfwork/dbfound/llms.txt Demonstrates retrieving data from various sources (HTTP request, session, headers, cookies) and setting parameters within the DBFound Context. Supports EL expressions for data retrieval. ```java import com.nfwork.dbfound.core.Context; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ContextExample { // 从HTTP请求获取Context public void handleRequest(HttpServletRequest request, HttpServletResponse response) { Context context = Context.getCurrentContext(request, response); // 获取参数(支持EL表达式路径) Object userId = context.getData("param.user_id"); Integer userIdInt = context.getInt("param.user_id"); String userName = context.getString("param.user_name"); Boolean isAdmin = context.getBoolean("param.is_admin"); Map userMap = context.getMap("param.user"); List userList = context.getList("param.users"); // 从不同作用域获取数据 Object sessionUserId = context.getData("session.user_id"); Object headerToken = context.getData("header.Authorization"); Object cookieValue = context.getData("cookie.session_id"); // 设置参数 context.setParamData("status", "active"); context.setOutParamData("result_code", "SUCCESS"); context.setSessionData("login_time", System.currentTimeMillis()); } // 使用with链式方法构建Context(3.6.2+) public Context buildContext() { User user = new User(); user.setUserName("张三"); Map extraParams = new HashMap<>(); extraParams.put("status", "active"); return new Context() .withParam("user_code", "zhangsan") .withParam("role_id", 1) .withBeanParam(user) // 将Bean属性逐一放入param .withMapParam(extraParams) // 将Map键值对放入param .withPageStart(0) // 分页起始位置 .withPageLimit(10); // 分页大小 } } ``` -------------------------------- ### Example API Call for batchInsert Execution Source: https://context7.com/nfwork/dbfound/llms.txt Shows how to invoke the batchInsert operation using curl, providing a JSON payload with a list of user data for insertion. ```bash curl -X POST http://localhost:8080/userBatch.execute!batchInsert \ -H "Content-Type: application/json" \ -d '{ "userList": [ {"user_name": "小明", "user_code": "xiaoming", "password": "123456"}, {"user_name": "小杨", "user_code": "xiaoyang", "password": "123456"} ] }' ``` -------------------------------- ### GET /download.execute!download Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Downloads a file from the server, supporting both database-stored files and file-system-stored files. ```APIDOC ## GET /download.execute!download ### Description Downloads a file. The source (database or disk) is determined by the model configuration (fileSaveType). ### Method GET ### Endpoint /download.execute!download ### Parameters #### Query Parameters - **file_id** (string) - Optional - The ID of the file if stored in the database. ### Response #### Success Response (200) - **file** (binary) - The file content stream. ``` -------------------------------- ### Add User API Request and Response Source: https://github.com/nfwork/dbfound/wiki/dbfound-example Example JSON payload for adding a user and the corresponding response. ```json { "user_name" : "小明", "user_code" : "xiaoming", "password" : "123456123" } ``` ```json { "success": true, "message": "success", "outParam": null } ``` -------------------------------- ### Building Context with With Methods Source: https://github.com/nfwork/dbfound/wiki/dbfound-java-api Use the `with` methods to construct a Context object, setting various parameters like user information, bean properties, map entries, pagination start, and limit. This is supported from version 3.6.2 onwards. Ensure `modelExecutor.query` is available for execution. ```java Context context = new Context() .withParam("user_code", userCode) .withParam("user_name", userName) .withBeanParam(user) //使用javaBean构建context参数,将bean的属性逐一放入到context .withMapParam(map) //使用map构建context参数,将map所有的键值对放入到context .withPageStart(start) //设置分页参数start .withPageLimit(limit); //设置分页参数limit return modelExecutor.query(context, "user", ""); ``` -------------------------------- ### Request Payload for User Query Source: https://github.com/nfwork/dbfound/wiki/home Example JSON payload to send a request to the user query interface. It includes parameters for filtering by user_name and for pagination (limit and start). ```json { "user_name" : "小明", "limit" : 10, "start" : 0 } ``` -------------------------------- ### Define User Query Interface in XML Source: https://github.com/nfwork/dbfound/wiki/home Define a user query interface in an XML file. This configuration allows querying users by user_name and user_code, with limit and start parameters for pagination. The XML file should be placed in the resources/model directory. ```xml SELECT u.user_id, u.user_name, u.user_code, u.create_date, u.create_by FROM user u #WHERE_CLAUSE# ``` -------------------------------- ### Query API Request and Response Source: https://github.com/nfwork/dbfound/wiki/dbfound-example Example JSON payload for querying users and the corresponding response structure. ```json { "user_name" : "小明", "user_code" : "", "time_from" : "2022-05-08", "time_to" : "", "limit" : 10, "start" : 0 } ``` ```json { "success": true, "message": "success", "outParam": null, "datas": [ { "create_by": 1, "password": "123456123", "user_code": "xiaoming", "user_id": 1, "user_name": "小明", "create_date": "2021-08-01 00:00:00" } ], "totalCounts": 1 } ``` -------------------------------- ### Update User API Request Source: https://github.com/nfwork/dbfound/wiki/dbfound-example Example JSON payload for updating a user. ```json { "user_name" : "小明1", "user_id" : 1 } ``` -------------------------------- ### Response Structure for User Query Source: https://github.com/nfwork/dbfound/wiki/home Example JSON response structure for a successful user query. It includes success status, a message, and the 'datas' array containing user records and 'totalCounts' for pagination. ```json { "success": true, "message": "success", "outParam": null, "datas": [ { "create_by": 1, "password": "123456123", "user_code": "xiaoming", "user_id": 1, "user_name": "小明", "create_date": "2021-08-01 00:00:00" } ], "totalCounts": 1 } ``` -------------------------------- ### Conditional Batch Request Source: https://github.com/nfwork/dbfound/wiki/dbfound-example Example JSON payload for the conditional batch add/update operation. ```json { "userList":[ { "user_name" : "小明", "user_id" : "1" }, { "user_name" : "小李", "user_code" : "xiaoli", "password" : "123456123" } ] } ``` -------------------------------- ### Delete User API Request Source: https://github.com/nfwork/dbfound/wiki/dbfound-example Example JSON payload for batch deleting users. ```json { "userList":[ {"user_id":1}, {"user_id":2} ] } ``` -------------------------------- ### Configure dbfound-conf.xml Source: https://github.com/nfwork/dbfound/wiki/dbfound-environment-setup Define system settings, database connections, and web interceptors in the configuration file located in the classpath. ```xml true com.nfwork.demo.interceptor.AccessCheckInterceptor com.nfwork.demo.controller ``` -------------------------------- ### Add DBFound Spring Boot Starter Dependency Source: https://github.com/nfwork/dbfound/wiki/dbfound-environment-setup Include the starter dependency and necessary web/jasper components in your Spring Boot project. ```xml com.github.nfwork dbfound-spring-boot-starter 3.6.6 org.springframework.boot spring-boot-starter-web org.apache.tomcat.embed tomcat-embed-jasper ``` -------------------------------- ### DBFoundUI Modal Window Management Source: https://context7.com/nfwork/dbfound/llms.txt Methods for opening and managing modal windows within the DBFoundUI framework. ```APIDOC ## DBFoundUI Modal Window ### Description Provides functionality to open and manage modal dialog windows. ### Method `$D.open(id, title, width, height, url, callback)` ### Parameters - **id** (string) - A unique identifier for the modal window. - **title** (string) - The title to display in the modal window's header. - **width** (number) - The width of the modal window in pixels. - **height** (number) - The height of the modal window in pixels. - **url** (string) - The URL of the content to load into the modal window. - **callback** (function) - Optional. A function to execute after the modal window is closed. This callback is useful for refreshing data or performing actions after the modal interaction is complete. ### Request Example ```javascript var userId = 'user123'; $D.open( 'user_detail', 'User Details', 800, 600, 'modules/sys/userDetail.jsp?user_id=' + userId, function() { // This callback executes when the modal is closed console.log('User detail modal closed. Refreshing grid...'); userGrid.query(); // Example: Refresh a data grid } ); ``` ``` -------------------------------- ### Charting Components Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Configuration for pie charts and bar charts using DBFound components. ```APIDOC ## Charting Components ### Pie Chart - Configures a pie chart with data from a specified dataSet. ```xml ``` ### Bar Chart - Configures a bar chart using JavaScript arrays for axis definitions and a specified dataSet. ```javascript var yAxis = [ { name : '10月份', field : 'total_num_10' }, { name : '11月份', field : 'total_num_11' }, { name : '12月份', field : 'total_num_12' } ]; var xAxis = { name : '人数', field : 'grade' }; ``` ```xml ``` ### Line Chart - Configures a line chart similar to the bar chart. ```xml ``` ``` -------------------------------- ### POST /upload.execute!add Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Handles file uploads by submitting a form to the server, which processes the file and stores it in the database or disk based on model configuration. ```APIDOC ## POST /upload.execute!add ### Description Uploads a file to the server. The file is processed by the model and can be saved to the database or a disk directory. ### Method POST ### Endpoint /upload.execute!add ### Parameters #### Query Parameters - **pk_value** (string) - Required - Primary key value for the record associated with the file. - **table_name** (string) - Required - Table name associated with the file. ### Request Body - **file** (file) - Required - The file content to be uploaded. ### Response #### Success Response (200) - **status** (string) - Indicates success of the upload operation. ``` -------------------------------- ### Model Configuration Tags Source: https://github.com/nfwork/dbfound/wiki/dbfound-model-api Documentation for core XML configuration tags used in DBFound models. ```APIDOC ## Model Configuration Tags ### Root tag for model files. - **connectionProvide** (string) - Optional - Data source identifier. - **xmlns** (string) - Required - Namespace: `http://dbfound.googlecode.com/model` ### Defines SQL parameters. - **name** (string) - Required - Unique identifier. - **dataType** (string) - Optional - varchar, number, date, boolean, collection, file. - **scope** (string) - Optional - session, request, param, outParam, cookie, header. ### Defines a query operation. - **name** (string) - Optional - Unique identifier. - **connectionProvide** (string) - Optional - Database source. - **pagerSize** (number) - Optional - Default page size. ### Defines SQL filtering conditions. - **name** (string) - Required - Unique identifier. - **express** (string) - Required - SQL fragment to insert. - **condition** (string) - Optional - Expression determining if filter is active. ### Defines parameter validation rules for queries. - **express** (string) - Required - SQL-based condition that triggers an exception. - **message** (string) - Required - Error message on failure. ``` -------------------------------- ### Define DataStore and DataSet Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Configures data containers for data access. DataSet binds to a model file, while DataStore binds to a URL or Java class. ```xml ``` -------------------------------- ### Display Modal Dialogs Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Provides standard UI feedback and modal windows. $D.open requires an ID, title, dimensions, and URL. ```javascript $D.showConfirm("您确定要删除吗?", function(btn) { if(btn=="no"){ return; }else{ //逻辑处理 } }); ``` ```javascript var url = "modules/sys/pagerAssign.jsp?ac_id="+id; DBFound.open("role_window","分配到功能",600,370,url,function(){}); ``` -------------------------------- ### Implement ConfigUpdateAdapter in Java Source: https://context7.com/nfwork/dbfound/llms.txt Implement ExecuteAdapter to add custom logic before and after execute operations. This is useful for logging, auditing, or triggering side effects based on data changes. ```java import com.nfwork.dbfound.core.Context; import com.nfwork.dbfound.model.adapter.ExecuteAdapter; import com.nfwork.dbfound.model.base.Param; import org.springframework.stereotype.Component; @Component public class ConfigUpdateAdapter implements ExecuteAdapter { @Autowired private ModelExecutor modelExecutor; @Override public void beforeExecute(Context context, Map params) { // 执行前:记录原始值用于对比 Integer userId = params.get("user_id").getIntValue(); Map oldConfig = modelExecutor.queryOne( "user/config", "findByUserId", ImmutableMap.of("user_id", userId), Map.class); context.setRequestData("oldConfig", oldConfig); } @Override public void afterExecute(Context context, Map params) { // 执行后:对比变化并触发业务逻辑 Map oldConfig = context.getMap("request.oldConfig"); Integer userId = params.get("user_id").getIntValue(); Map newConfig = modelExecutor.queryOne( "user/config", "findByUserId", ImmutableMap.of("user_id", userId), Map.class); Boolean oldEnable = (Boolean) oldConfig.get("enable"); Boolean newEnable = (Boolean) newConfig.get("enable"); if (!oldEnable && newEnable) { // 由禁用改为启用:发送通知 sendEnableNotification(userId); } else if (oldEnable && !newEnable) { // 由启用改为禁用:清理缓存 clearUserCache(userId); } } } ``` -------------------------------- ### Dynamic Grouping Query Source: https://github.com/nfwork/dbfound/wiki/dbfound-model-sqlPart Demonstrates two methods for dynamic grouping in queries: direct parameter usage for non-empty group fields and sqlPart for potentially empty group fields. ```xml select count(user_id) as num, #{@group_fields} from user group by {@group_fields} ``` ```xml select count(user_id) as num #{@item} from user #{@item} ``` -------------------------------- ### Configure web.xml for DBFound Source: https://github.com/nfwork/dbfound/wiki/dbfound-environment-setup Register the DispatcherFilter in the web.xml file to enable DBFound request handling. ```xml DBFound com.nfwork.dbfound.web.DispatcherFilter DBFound /* ``` -------------------------------- ### DBFoundUI Ajax Request Methods Source: https://context7.com/nfwork/dbfound/llms.txt DBFoundUI offers a unified method for making Ajax requests, supporting both simple and detailed parameter configurations. ```APIDOC ## DBFoundUI Ajax Request ### Description Provides a unified method for making Ajax requests to the backend. ### Method `$D.request(url, param, callback, mask, maskTitle)` or `$D.request(options)` ### Parameters #### Simple Call - **url** (string) - The URL endpoint for the request. - **param** (object) - The parameters to send with the request. - **callback** (function) - The function to execute upon receiving a response. - **mask** (boolean) - Optional. Whether to display a loading mask. - **maskTitle** (string) - Optional. The title for the loading mask. #### Options Object - **url** (string) - Required. The URL endpoint for the request. - **param** (object) - Optional. The parameters to send with the request. - **mask** (boolean) - Optional. Whether to display a loading mask. - **maskTitle** (string) - Optional. The title for the loading mask. - **callback** (function) - Optional. The function to execute upon receiving a response. The callback receives `resObj`, `response`, and `action` as arguments. ### Request Example ```javascript // Simple call $D.request('/api/data', { id: 1 }, function(res) { console.log(res); }); // Full options object $D.request({ url: 'sys/user.execute!add', param: { user: {code: '10001', name: '张三'}, role: {code: 'ADMIN', name: '管理员'}, tags: ['tag1', 'tag2'] }, mask: true, maskTitle: '正在保存...', callback: function(resObj, response, action) { if (resObj.success) { $D.showMessage(resObj.message); userGrid.query(); } else { $D.showError(resObj.message); } } }); ``` ### Response #### Success Response The `callback` function receives `resObj` which typically contains a `success` boolean field and a `message` string. ``` -------------------------------- ### DBFoundUI Message Display Methods Source: https://context7.com/nfwork/dbfound/llms.txt Display various types of messages to the user using these utility functions. showConfirm includes a callback to handle user's choice. ```javascript $D.showMessage('操作成功'); // 普通提示 ``` ```javascript $D.showWarning('请注意!'); // 警告提示 ``` ```javascript $D.showError('操作失败'); // 错误提示 ``` ```javascript $D.showConfirm('确定要删除吗?', function(btn) { if (btn === 'yes') { // 执行删除 } }); ``` -------------------------------- ### DBFound Layout Styles Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Using the `style` attribute and DIVs for component layout and positioning. ```APIDOC ## DBFound Layout Styles Components support a `style` attribute for layout. DBFound UI components can be mixed with DIVs for complex layouts. ### Absolute Positioning with `style` Attribute - Sets the width to 49.9% of the screen, with a 50% left offset and 0px top offset. ```xml ``` ### Absolute Positioning with DIVs - Achieves the same effect as the `style` attribute on the component. - It's recommended not to use 100% width to ensure browser compatibility. ```html
``` ### Mixed Layout - Divides the screen into left and right areas using two DIVs, each containing grids. - Adjusts margins to manage spacing between elements. ```html
``` ``` -------------------------------- ### Internationalization (i18n) Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api How to implement internationalization using DBFound tags and attributes. ```APIDOC ## Internationalization (i18n) DBFound provides internationalization tag interfaces. ### In-tag Multi-language Support - Use the `i18n:` prefix within DBFound tags. ```xml ``` ### General Multi-language Implementation - Use the `` tag for other areas. ```javascript var a = ''; ``` ```html
``` ``` -------------------------------- ### DBFoundUI Message and Dialog Methods Source: https://context7.com/nfwork/dbfound/llms.txt Provides methods for displaying various types of messages and confirmation dialogs to the user. ```APIDOC ## DBFoundUI Message and Dialogs ### Description Utility methods for displaying user feedback and confirmations. ### Methods #### `$D.showMessage(message)` Displays a standard informational message. #### `$D.showWarning(message)` Displays a warning message. #### `$D.showError(message)` Displays an error message. #### `$D.showConfirm(message, callback)` Displays a confirmation dialog. ### Parameters - **message** (string) - The message content to display. - **callback** (function) - Optional. A function to execute when the user responds to the confirmation. The callback receives the button pressed ('yes' or 'no'). ### Usage Example ```javascript // Show a success message $D.showMessage('Operation completed successfully.'); // Show a warning $D.showWarning('Please review the details carefully.'); // Show an error $D.showError('An error occurred during processing.'); // Show a confirmation dialog $D.showConfirm('Are you sure you want to delete this item?', function(btn) { if (btn === 'yes') { // Proceed with deletion console.log('User confirmed deletion.'); } else { console.log('User cancelled deletion.'); } }); ``` ``` -------------------------------- ### Define Batch Import Interface Source: https://github.com/nfwork/dbfound/wiki/dbfound-example Use batchExecuteSql to perform bulk inserts with a template. The template is wrapped in BATCH_TEMPLATE_BEGIN and BATCH_TEMPLATE_END tags. ```xml INSERT INTO user (user_code, user_name, password, create_by, create_date) VALUES #BATCH_TEMPLATE_BEGIN# (${@user_code}, ${@user_name}, ${@password}, 1, NOW()) #BATCH_TEMPLATE_END# ON DUPLICATE KEY update user_name = values(user_name) ``` -------------------------------- ### Implement ExecuteAdapter for Transactional Logic Source: https://github.com/nfwork/dbfound/wiki/dbfound-java-api Use beforeExecute and afterExecute to perform logic within the same transaction as the SQL execution. ```java @Component public class ConfigUpdateAdapter implements ExecuteAdapter { @Autowired private ModelExecutor modelExecutor; @Override public void beforeExecute(Context context, Map params) { GuildConfig query = modelExecutor.query("/user/guild", "findByUserId", ImmutableMap.of("user_id", params.get("user_id").getValue()), GuildConfig.class).get(); context.request.setAttribute("oldEnableValue", query.getEnable()); } @Override public void afterExecute(Context context, Map params) { Integer userId = params.get("user_id").getIntValue(); GuildConfig query = modelExecutor.query("/user/guild", "findByUserId", ImmutableMap.of("user_id", userId), GuildConfig.class).get(); Boolean enable = query.getEnable(); Object oldEnableValue = context.request.getAttribute("oldEnableValue"); if (enable && Objects.equals(oldEnableValue, false)) { // 由禁用 改为 启用 // ... } else if (!enable && Objects.equals(oldEnableValue, true)) { // 由启用 改为 禁用 // ... } } } ``` -------------------------------- ### Frontend Request to Backend Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Initiates a request to the server using $D.request, passing parameters and a callback function to handle the response. The 'param' object contains data to be sent. ```javascript function test() {     var param = {};     param.user = {code:"10000",name:"黄炯"};     param.role = {code:"ADMIN",name:"管理员"}     $D.request("sys/user.do!test",param,function(resObj){         $D.showMessage(resObj.message);     }); } ``` -------------------------------- ### DBFoundUI Ajax Request Methods Source: https://context7.com/nfwork/dbfound/llms.txt Use $D.request for Ajax calls. The first method is a simple signature, while the second allows for detailed configuration including URL, parameters, masking, and callbacks. The callback function handles success or failure responses. ```javascript $D.request(url, param, callback, mask, maskTitle); ``` ```javascript $D.request({ url: 'sys/user.execute!add', param: { user: {code: '10001', name: '张三'}, role: {code: 'ADMIN', name: '管理员'}, tags: ['tag1', 'tag2'] }, mask: true, // 是否显示遮罩 maskTitle: '正在保存...', callback: function(resObj, response, action) { if (resObj.success) { $D.showMessage(resObj.message); userGrid.query(); } else { $D.showError(resObj.message); } } }); ``` -------------------------------- ### Conditional Logic with If/ElseIf/Else Source: https://github.com/nfwork/dbfound/wiki/dbfound-model-sqlPart Illustrates the use of sqlPart with 'if', 'elseif', and 'else' types for implementing conditional logic in SQL statements, supported from version 3.6.0. ```xml select #{@fields} #{@code_field} #{@name_field} * from sys_user ``` -------------------------------- ### DBFoundUI Open Modal Window Source: https://context7.com/nfwork/dbfound/llms.txt Open a modal window with specified dimensions and URL. A callback function can be provided to execute code after the window is closed. ```javascript $D.open('user_detail', '用户详情', 800, 600, 'modules/sys/userDetail.jsp?user_id=' + userId, function() { // 窗口关闭回调 userGrid.query(); }); ``` -------------------------------- ### Configure Menu Component Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Defines a menu with items and a JavaScript function to display it. ```xml ``` ```javascript function rootmenu(tree,e){ menu.showAt([e.getPageX(),e.getPageY()]); } ``` -------------------------------- ### Backend Model for Excel Import Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Configures the backend model to read Excel content using 'excelReader' and process it with 'batchSql'. The 'sourceParam' should match the form field name. ```xml                                                                                                            ``` -------------------------------- ### Render Charts Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Displays pie, bar, and line charts using data sets. Bar and line charts share axis configurations. ```xml ``` ```html 柱状图: ``` -------------------------------- ### Implement UserQueryAdapter in Java Source: https://context7.com/nfwork/dbfound/llms.txt Implement MapQueryAdapter to add custom logic before and after queries. This includes parameter manipulation, data filtering, and result enrichment. ```java import com.nfwork.dbfound.core.Context; import com.nfwork.dbfound.model.adapter.MapQueryAdapter; import com.nfwork.dbfound.model.base.Count; import com.nfwork.dbfound.model.base.Param; import com.nfwork.dbfound.dto.QueryResponseObject; import org.springframework.stereotype.Component; @Component public class UserQueryAdapter implements MapQueryAdapter { @Autowired private ModelExecutor modelExecutor; @Override public void beforeQuery(Context context, Map params) { // 查询前处理:设置默认值、权限过滤等 if (params.get("type") != null && params.get("type").getIntValue() == 1) { params.get("country").setValue("CN"); } // 添加数据权限过滤 Integer currentUserId = context.getInt("session.user_id"); if (params.containsKey("dept_id")) { params.get("dept_id").setValue(getDeptIdByUser(currentUserId)); } } @Override public void beforeCount(Context context, Map params, Count count) { // 优化count SQL(如移除不必要的JOIN) String countSql = count.getCountSql(); String optimizedSql = countSql.replace("LEFT JOIN user_detail", ""); count.setCountSql(optimizedSql); } @Override public void afterQuery(Context context, Map params, QueryResponseObject> responseObject) { // 查询后处理:数据关联、格式转换等 if (responseObject.getDatas().isEmpty()) { return; } // 关联查询用户设备信息 List userIds = responseObject.getIntList("user_id"); Context deviceContext = new Context().withParam("userIds", userIds); QueryResponseObject> userDevices = modelExecutor.query(deviceContext, "user/user_device", "findByUserIds"); // 合并结果 responseObject.join(userDevices, "user_id"); } } ``` ```xml SELECT u.user_id, u.user_name, u.user_code FROM user u #WHERE_CLAUSE# ``` -------------------------------- ### Event Handling Source: https://github.com/nfwork/dbfound/wiki/dbfound-ui-api Defines how to handle events within various DBFound components. ```APIDOC ## Event Handling Events can be defined within `field`, `column`, `grid`, and `tree` components using tags. ### Component Event Definition - **commit event** for a field with a Lov editor: ```xml ``` - **click event** for a tree node: ```xml ``` ### JavaScript Event Handling - Events can also be attached using JavaScript: ```javascript Ext.get("treedata").on("click", function(){ // Event handling logic }); ``` - For sub-objects like a grid's store, use JavaScript: ```javascript grid.getStore().on("load", function(){ // Event handling logic }); ``` - Refer to the ExtJS official documentation for specific events available for each object. ``` -------------------------------- ### Batch Insert with sqlPart Source: https://github.com/nfwork/dbfound/wiki/dbfound-model-sqlPart Utilize sqlPart with the 'for' type in an execute statement for efficient batch insertion of user data from a list. ```xml INSERT INTO user ( user_code, user_name, password, create_by, create_date) VALUES (${@user_code}, ${@user_name}, ${@password}, 1, NOW()) ON DUPLICATE KEY update user_name = values(user_name) ``` ```json { "userList": [{ "user_name":"xiaoming", "user_code":"xiaoming5", "password":123 },{ "user_name":"xiaoming", "user_code":"xiaoming6", "password":123 }] } ``` -------------------------------- ### Maven Dependency Configuration for DBFound Source: https://context7.com/nfwork/dbfound/llms.txt Include DBFound in your project using Maven. Choose the pure dbfound mode or the SpringBoot integration starter. ```xml com.github.nfwork dbfound 3.6.2 ``` ```xml com.github.nfwork dbfound-spring-boot-starter 3.6.2 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.