@APIEventAnnotation 是 OneCode 3.0 框架中用于声明 API 事件的核心注解,主要用于将前端 UI 事件与后端 API 服务进行绑定,实现 "事件驱动、数据绑定、响应处理" 的全链路交互机制。该注解通过元数据配置替代传统的命令式编程,大幅减少了前端 JavaScript 代码量,提高了开发效率和代码可维护性。
该注解的完整定义如下:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface APIEventAnnotation {
// 配置属性...
}
该注解主要应用于 Controller 类的方法上,用于定义该方法处理的 API 事件。
元数据项 | 值 | 说明 |
---|---|---|
作用目标 | 方法 | 只能应用于 Controller 类的方法 |
生命周期 | 运行时保留 | 注解信息在运行时可用 |
继承性 | 不继承 | 子类不会继承父类的注解配置 |
核心功能 | 事件绑定、数据映射、请求配置、响应处理 | 实现前后端交互的全链路管理 |
示例代码:
@APIEventAnnotation(
queryAsync = false, // 同步执行请求
// 其他配置...
)
public ResultModel handleSyncRequest() {
// 业务逻辑
}
示例代码:
@APIEventAnnotation(
autoRun = true, // 页面加载后自动执行
// 其他配置...
)
public ResultModel loadInitialData() {
// 加载初始数据的业务逻辑
}
示例代码:
@APIEventAnnotation(
autoDisplay = true, // 自动显示结果
// 其他配置...
)
public ResultModel showSimpleResult() {
// 返回简单结果的业务逻辑
}
示例代码:
@APIEventAnnotation(
isAllform = true, // 提交表单所有字段
// 其他配置...
)
public ResultModel submitFullFormData() {
// 处理表单全部数据的业务逻辑
}
示例代码:
@APIEventAnnotation(
index = 10, // 执行顺序为第10位
// 其他配置...
)
public ResultModel executeWithPriority() {
// 具有特定执行顺序的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindMenu = {
CustomMenuItem.SAVE, // 绑定"保存"菜单项
CustomMenuItem.EXPORT // 绑定"导出"菜单项
},
// 其他配置...
)
public ResultModel handleMenuEvents() {
// 处理菜单事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindAction = {
CustomAction.PREVIEW, // 绑定"预览"动作
CustomAction.EDIT // 绑定"编辑"动作
},
// 其他配置...
)
public ResultModel handleCustomActions() {
// 处理自定义动作的业务逻辑
}
示例代码:
@APIEventAnnotation(
enumClass = CustomEventType.class, // 指定自定义事件枚举类
// 其他配置...
)
public ResultModel handleCustomEvents() {
// 处理自定义事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindFieldEvent = {
CustomFieldEvent.CHANGE, // 绑定"变化"事件
CustomFieldEvent.BLUR // 绑定"失去焦点"事件
},
// 其他配置...
)
public ResultModel handleFieldEvents() {
// 处理表单字段事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindGalleryEvent = {
CustomGalleryEvent.SELECT_ITEM, // 绑定"选择项目"事件
CustomGalleryEvent.VIEW_DETAIL // 绑定"查看详情"事件
},
// 其他配置...
)
public ResultModel handleGalleryEvents() {
// 处理图片画廊事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindTitleBlockEvent = {
CustomTitleBlockEvent.FULLSCREEN, // 绑定"全屏"事件
CustomTitleBlockEvent.COLLAPSE // 绑定"折叠"事件
},
// 其他配置...
)
public ResultModel handleTitleBlockEvents() {
// 处理标题块事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindContentBlockEvent = {
CustomContentBlockEvent.REFRESH, // 绑定"刷新"事件
CustomContentBlockEvent.LOAD_MORE // 绑定"加载更多"事件
},
// 其他配置...
)
public ResultModel handleContentBlockEvents() {
// 处理内容块事件的业务逻辑
}
示例代码:
@APIEventAnnotation( bindGridEvent = { CustomGridEvent.LOAD, // 绑定"加载"事件 CustomGridEvent.REFRESH, // 绑定"刷新"事件 CustomGridEvent.EXPORT // 绑定"导出"事件 }, // 其他配置...)public ResultModel handleGridEvents() { // 处理表格事件的业务逻辑}
示例代码:
@APIEventAnnotation(
bindMGridEvent = {
CustomMGridEvent.MERGE_CELL, // 绑定"合并单元格"事件
CustomMGridEvent.GROUP_ROW // 绑定"分组行"事件
},
// 其他配置...
)
public ResultModel handleMGridEvents() {
// 处理复杂表格事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindTreeEvent = {
CustomTreeEvent.EXPAND, // 绑定"展开"事件
CustomTreeEvent.SELECT, // 绑定"选择"事件
CustomTreeEvent.CHECK // 绑定"检查"事件
},
// 其他配置...
)
public ResultModel handleTreeEvents() {
// 处理树形组件事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindFormEvent = {
CustomFormEvent.SAVE, // 绑定"保存"事件
CustomFormEvent.RESET, // 绑定"重置"事件
CustomFormEvent.SEARCH // 绑定"搜索"事件
},
// 其他配置...
)
public ResultModel handleFormEvents() {
// 处理表单事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindMFormEvent = {
CustomMFormEvent.ADD_ROW, // 绑定"添加行"事件
CustomMFormEvent.DELETE_ROW // 绑定"删除行"事件
},
// 其他配置...
)
public ResultModel handleMFormEvents() {
// 处理多表表单事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindTabsEvent = {
CustomTabsEvent.SWITCH, // 绑定"切换"事件
CustomTabsEvent.CLOSE // 绑定"关闭"事件
},
// 其他配置...
)
public ResultModel handleTabsEvents() {
// 处理标签页事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
bindHotKeyEvent = {
CustomHotKeyEvent.CTRL_S, // 绑定"Ctrl+S"快捷键
CustomHotKeyEvent.ESC // 绑定"ESC"键
},
// 其他配置...
)
public ResultModel handleHotKeyEvents() {
// 处理快捷键事件的业务逻辑
}
示例代码:
@APIEventAnnotation(
requestDataSource = {
@RequestPathAnnotation(type = "form", name = "userForm", path = "id"), // 从表单获取ID
@RequestPathAnnotation(type = "component", name = "deptTree", path = "selectedId") // 从组件获取选中ID
},
// 其他配置...
)
public ResultModel handleDataSources() {
// 处理数据源的业务逻辑
}
示例代码:
@APIEventAnnotation(
responseDataTarget = {
@ResponsePathAnnotation(type = "form", name = "userForm", path = "lastUpdateTime") // 将响应数据映射到表单的lastUpdateTime字段
},
// 其他配置...
)
public ResultModel handleResponseTargets() {
// 处理响应目标的业务逻辑
}
示例代码:
@APIEventAnnotation(
responseCallback = {
@CallBackPathAnnotation(name = "updateStatus", params = {"{{response.status}}") // 回调函数,参数为响应中的status
},
// 其他配置...
)
public ResultModel handleCallbacks() {
// 处理回调的业务逻辑
}
示例代码:
@APIEventAnnotation(
customRequestData = {
RequestPathEnum.FORM_ID, // 表单ID
RequestPathEnum.GLOBAL_USER_INFO // 全局用户信息
},
// 其他配置...
)
public ResultModel handleCustomRequests() {
// 处理自定义请求数据的业务逻辑
}
示例代码:
@APIEventAnnotation(
customResponseData = {
ResponsePathEnum.FORM_RESET, // 表单重置
ResponsePathEnum.MESSAGE_TIP // 消息提示
},
// 其他配置...
)
public ResultModel handleCustomResponses() {
// 处理自定义响应数据的业务逻辑
}
示例代码:
@APIEventAnnotation(
customResponseCallback = {
CallBackPathEnum.UPDATE_STATUS // 更新状态回调
},
// 其他配置...
)
public ResultModel handleCustomCallbacks() {
// 处理自定义回调的业务逻辑
}
示例代码:
@APIEventAnnotation(
beforeData = {
CustomBeforData.MESSAGE // 数据准备前的提示
},
// 其他配置...
)
public ResultModel handleBeforeData() {
// 处理数据准备前逻辑的业务逻辑
}
示例代码:
@APIEventAnnotation(
beforeDataAction = {
@CustomAction(name = "validateForm") // 表单验证动作
},
// 其他配置...
)
public ResultModel handleBeforeDataActions() {
// 处理数据准备前动作的业务逻辑
}@APIEventAnnotation(
beforeInvoke = {
@CustomBeforInvoke(message = "正在发送请求...") // 请求发送前的提示
},
// 其他配置...
)
public ResultModel handleBeforeInvoke() {
// 处理请求发送前逻辑的业务逻辑
}
示例代码:
@APIEventAnnotation(
beforeInvoke = {
CustomBeforInvoke.MESSAGE // 请求发送前的提示
},
// 其他配置...
)
public ResultModel handleBeforeInvoke() {
// 处理请求发送前逻辑的业务逻辑
}
示例代码:
@APIEventAnnotation(
beforeInvokeAction = {
CustomBeforInvoke.BUSY // 增加遮罩
},
// 其他配置...
)
public ResultModel handleBeforeInvokeActions() {
// 处理请求发送前动作的业务逻辑
}
示例代码:
@APIEventAnnotation(
callback = {
@CustomCallBack(message = "响应处理完成") // 响应处理后的提示
},
// 其他配置...
)
public ResultModel handleCallbacks() {
// 处理响应回调的业务逻辑
}
示例代码:
@APIEventAnnotation(
callbackAction = {
@CustomAction(name = "refreshGrid"), // 刷新表格动作
@CustomAction(name = "resetForm") // 重置表单动作
},
// 其他配置...
)
public ResultModel handleCallbackActions() {
// 处理响应后动作的业务逻辑
}
示例代码:
@APIEventAnnotation(
afterInvok = {
CustomCallBack.FREE // 解除遮罩
},
// 其他配置...
)
public ResultModel handleAfterInvok() {
// 处理请求完成后逻辑的业务逻辑
}
示例代码:
@APIEventAnnotation(
afterInvokAction = {
@CustomAction(name = "cleanup") // 清理动作
},
// 其他配置...
)
public ResultModel handleAfterInvokActions() {
// 处理请求完成后动作的业务逻辑
}
示例代码:
@APIEventAnnotation(
onError = {
CustomOnError.MESSAGE// 请求出错时的提示
},
// 其他配置...
)
public ResultModel handleOnError() {
// 处理请求错误逻辑的业务逻辑
}
示例代码:
@APIEventAnnotation(
onErrorAction = {
@CustomAction(name = "hideLoading"), // 隐藏加载动画动作
@CustomAction(name = "showError") // 显示错误信息动作
},
// 其他配置...
)
public ResultModel handleOnErrorActions() {
// 处理请求出错动作的业务逻辑
}
示例代码:
@APIEventAnnotation(
onData = {
CustomOnData.RELOAD// 接收到数据时的提示
},
// 其他配置...
)
public ResultModel handleOnData() {
// 处理接收到数据逻辑的业务逻辑
}
示例代码:
@APIEventAnnotation(
onDataAction = {
@CustomAction(name = "processData") // 处理数据动作
},
// 其他配置...
)
public ResultModel handleOnDataActions() {
// 处理接收到数据动作的业务逻辑
}
示例代码:
@APIEventAnnotation(
onExecuteSuccess = {
CustomOnExecueSuccess.MSG// 请求成功时的提示
},
// 其他配置...
)
public ResultModel handleOnExecuteSuccess() {
// 处理请求成功逻辑的业务逻辑
}
示例代码:
@APIEventAnnotation(
onExecuteSuccessAction = {
@CustomAction(name = "refreshPage"), // 刷新页面动作
@CustomAction(name = "redirectToSuccessPage") // 跳转到成功页面动作
},
// 其他配置...
)
public ResultModel handleOnExecuteSuccessActions() {
// 处理请求成功动作的业务逻辑
}
示例代码:
@APIEventAnnotation(
onExecuteError = {
CustomOnExecueError.FREE // 解除遮罩
},
// 其他配置...
)
public ResultModel handleOnExecuteError() {
// 处理请求失败逻辑的业务逻辑
}
示例代码:
@APIEventAnnotation(
onExecuteError = {
@CustomAction(name = "reloadPage", method = "call", type = ActionTypeEnum.other, target = "callback", args = {"{SPA.reloadPage()}"}),
},
// 其他配置...
)
public ResultModel handleOnExecuteError() {
// 处理请求失败逻辑的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
SAVE | 保存事件 | 用户点击保存按钮或执行保存操作时触发 |
RESET | 重置事件 | 用户点击重置按钮或执行重置操作时触发 |
SEARCH | 搜索事件 | 用户点击搜索按钮或执行搜索操作时触发 |
CANCEL | 取消事件 | 用户点击取消按钮或执行取消操作时触发 |
SUBMIT | 提交事件 | 用户提交表单时触发 |
VALIDATE | 验证事件 | 表单验证时触发 |
示例代码:
@APIEventAnnotation(
bindFormEvent = {
CustomFormEvent.SAVE, // 绑定保存事件
CustomFormEvent.SEARCH // 绑定搜索事件
},
// 其他配置...
)
public ResultModel handleFormEvents() {
// 处理表单事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
ADD_ROW | 添加行事件 | 用户点击添加行按钮或执行添加行操作时触发 |
DELETE_ROW | 删除行事件 | 用户点击删除行按钮或执行删除行操作时触发 |
EDIT_ROW | 编辑行事件 | 用户点击编辑行按钮或执行编辑行操作时触发 |
BATCH_PROCESS | 批量处理事件 | 用户执行批量处理操作时触发 |
示例代码:
@APIEventAnnotation(
bindMFormEvent = {
CustomMFormEvent.ADD_ROW, // 绑定添加行事件
CustomMFormEvent.DELETE_ROW // 绑定删除行事件
},
// 其他配置...
)
public ResultModel handleMFormEvents() {
// 处理多表表单事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
CHANGE | 变化事件 | 字段值发生变化时触发 |
BLUR | 失去焦点事件 | 字段失去焦点时触发 |
FOCUS | 获得焦点事件 | 字段获得焦点时触发 |
VALIDATE | 验证事件 | 字段验证时触发 |
示例代码:
@APIEventAnnotation(
bindFieldEvent = {
CustomFieldEvent.CHANGE, // 绑定变化事件
CustomFieldEvent.BLUR // 绑定失去焦点事件
},
// 其他配置...
)
public ResultModel handleFieldEvents() {
// 处理字段事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
LOAD | 加载事件 | 表格加载数据时触发 |
REFRESH | 刷新事件 | 表格刷新数据时触发 |
EXPORT | 导出事件 | 用户点击导出按钮或执行导出操作时触发 |
SELECT | 选择事件 | 用户选择表格行时触发 |
DESELECT | 取消选择事件 | 用户取消选择表格行时触发 |
PAGE_CHANGE | 分页变化事件 | 表格分页变化时触发 |
示例代码:
@APIEventAnnotation(
bindGridEvent = {
CustomGridEvent.LOAD, // 绑定加载事件
CustomGridEvent.REFRESH // 绑定刷新事件
},
// 其他配置...
)
public ResultModel handleGridEvents() {
// 处理表格事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
MERGE_CELL | 合并单元格事件 | 合并表格单元格时触发 |
GROUP_ROW | 分组行事件 | 分组表格行时触发 |
UNGROUP_ROW | 取消分组行事件 | 取消分组表格行时触发 |
SORT | 排序事件 | 表格排序时触发 |
FILTER | 过滤事件 | 表格过滤时触发 |
示例代码:
@APIEventAnnotation(
bindTreeEvent = {
CustomTreeEvent.EXPAND, // 绑定展开事件
CustomTreeEvent.SELECT // 绑定选择事件
},
// 其他配置...
)
public ResultModel handleTreeEvents() {
// 处理树形组件事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
EXPAND | 展开事件 | 树形节点展开时触发 |
COLLAPSE | 折叠事件 | 树形节点折叠时触发 |
SELECT | 选择事件 | 用户选择树形节点时触发 |
DESELECT | 取消选择事件 | 用户取消选择树形节点时触发 |
CHECK | 选中事件 | 用户选中树形节点时触发 |
UNCHECK | 取消选中事件 | 用户取消选中树形节点时触发 |
示例代码:
@APIEventAnnotation(
bindTreeEvent = {
CustomTreeEvent.EXPAND, // 绑定展开事件
CustomTreeEvent.SELECT // 绑定选择事件
},
// 其他配置...
)
public ResultModel handleTreeEvents() {
// 处理树形组件事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
SWITCH | 切换事件 | 标签页切换时触发 |
CLOSE | 关闭事件 | 标签页关闭时触发 |
ADD | 添加事件 | 添加新标签页时触发 |
REMOVE | 删除事件 | 删除标签页时触发 |
示例代码:
@APIEventAnnotation(
bindTabsEvent = {
CustomTabsEvent.SWITCH, // 绑定切换事件
CustomTabsEvent.CLOSE // 绑定关闭事件
},
// 其他配置...
)
public ResultModel handleTabsEvents() {
// 处理标签页事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
CTRL_S | Ctrl+S 事件 | 用户按下 Ctrl+S 组合键时触发 |
CTRL_O | Ctrl+O 事件 | 用户按下 Ctrl+O 组合键时触发 |
CTRL_P | Ctrl+P 事件 | 用户按下 Ctrl+P 组合键时触发 |
ESC | ESC 事件 | 用户按下 ESC 键时触发 |
ENTER | Enter 事件 | 用户按下 Enter 键时触发 |
示例代码:
@APIEventAnnotation(
bindHotKeyEvent = {
CustomHotKeyEvent.CTRL_S, // 绑定Ctrl+S事件
CustomHotKeyEvent.ESC // 绑定ESC事件
},
// 其他配置...
)
public ResultModel handleHotKeyEvents() {
// 处理快捷键事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
FULLSCREEN | 全屏事件 | 用户点击全屏按钮或执行全屏操作时触发 |
COLLAPSE | 折叠事件 | 用户点击折叠按钮或执行折叠操作时触发 |
EXPAND | 展开事件 | 用户点击展开按钮或执行展开操作时触发 |
CLOSE | 关闭事件 | 用户点击关闭按钮或执行关闭操作时触发 |
示例代码:
@APIEventAnnotation(
bindTitleBlockEvent = {
CustomTitleBlockEvent.FULLSCREEN, // 绑定全屏事件
CustomTitleBlockEvent.COLLAPSE // 绑定折叠事件
},
// 其他配置...
)
public ResultModel handleTitleBlockEvents() {
// 处理标题块事件的业务逻辑
}
事件名称 | 描述 | 触发时机 |
---|---|---|
REFRESH | 刷新事件 | 用户点击刷新按钮或执行刷新操作时触发 |
LOAD_MORE | 加载更多事件 | 用户点击加载更多按钮或执行加载更多操作时触发 |
COLLAPSE | 折叠事件 | 用户点击折叠按钮或执行折叠操作时触发 |
EXPAND | 展开事件 | 用户点击展开按钮或执行展开操作时触发 |
示例代码:
@APIEventAnnotation(
bindContentBlockEvent = {
CustomContentBlockEvent.REFRESH, // 绑定刷新事件
CustomContentBlockEvent.LOAD_MORE // 绑定加载更多事件
},
// 其他配置...
)
public ResultModel handleContentBlockEvents() {
// 处理内容块事件的业务逻辑
}
@Controller
@RequestMapping("/api/user")
public class UserController {
@PostMapping("/save")
@ResponseBody
@APIEventAnnotation(
// 事件绑定
bindFormEvent = CustomFormEvent.SAVE, // 绑定表单保存事件
bindHotKeyEvent = CustomHotKeyEvent.CTRL_S, // 绑定Ctrl+S快捷键
// 请求数据源
requestDataSource = {
@RequestPathAnnotation(type = "form", name = "userForm", path = "id"), // 从表单获取ID
@RequestPathAnnotation(type = "form", name = "userForm", path = "name"), // 从表单获取姓名
@RequestPathAnnotation(type = "form", name = "userForm", path = "email") // 从表单获取邮箱
},
// 响应数据目标
responseDataTarget = {
@ResponsePathAnnotation(type = "form", name = "userForm", path = "lastUpdateTime") // 将响应数据映射到表单的lastUpdateTime字段
},
// 生命周期回调
beforeInvoke = @CustomBeforInvoke.MESSAGE, // 请求发送前的提示
onExecuteSuccess = @CustomOnExecueSuccess.MESSAGE, // 请求成功时的提示
onExecuteError = @CustomOnExecueError.MESSAGE// 请求失败时的提示
)
public ResultModel<User> saveUser(@RequestBody User user) {
// 业务逻辑实现
User savedUser = userService.save(user);
return ResultModel.success(savedUser);
}
}
@Controller
@RequestMapping("/api/data")
public class DataController {
@GetMapping("/list")
@ResponseBody
@APIEventAnnotation(
// 事件绑定
bindGridEvent = CustomGridEvent.LOAD, // 绑定表格加载事件
autoRun = true, // 页面加载后自动执行
// 请求数据源
requestDataSource = {
@RequestPathAnnotation(type = "component", name = "pageSize", path = "value"), // 从组件获取分页大小
@RequestPathAnnotation(type = "component", name = "currentPage", path = "value") // 从组件获取当前页码
},
// 响应数据目标
responseDataTarget = {
@ResponsePathAnnotation(type = "grid", name = "dataGrid", path = "data") // 将响应数据映射到表格的数据字段
},
// 生命周期回调
beforeInvoke = @CustomBeforInvoke.MESSAGE, // 请求发送前的提示
onExecuteSuccess = @CustomOnExecueSuccess.MESSAGE, // 请求成功时的提示
onExecuteError = @CustomOnExecueError.MESSAGE// 请求失败时的提示 )
public ResultModel<Page<Data>> loadData(@RequestParam Integer pageSize, @RequestParam Integer currentPage) {
// 业务逻辑实现
Page<Data> dataPage = dataService.findPage(pageSize, currentPage);
return ResultModel.success(dataPage);
}
}
@Controller
@RequestMapping("/api/tree")
public class TreeController {
@GetMapping("/nodes")
@ResponseBody
@APIEventAnnotation(
// 事件绑定
bindTreeEvent = CustomTreeEvent.EXPAND, // 绑定树形节点展开事件
// 请求数据源
requestDataSource = {
@RequestPathAnnotation(type = "tree", name = "treeComponent", path = "selectedId") // 从树形组件获取选中节点ID
},
// 响应数据目标
responseDataTarget = {
@ResponsePathAnnotation(type = "tree", name = "treeComponent", path = "children") // 将响应数据映射到树形组件的子节点字段
},
// 生命周期回调
beforeInvoke = @CustomBeforInvoke.MESSAGE, // 请求发送前的提示
onExecuteSuccess = @CustomOnExecueSuccess.MESSAGE, // 请求成功时的提示
onExecuteError = @CustomOnExecueError.MESSAGE// 请求失败时的提示 )
)
public ResultModel<List<TreeNode>> loadTreeNodes(@RequestParam String parentId) {
// 业务逻辑实现
List<TreeNode> nodes = treeService.findChildren(parentId);
return ResultModel.success(nodes);
}
}
以下是一些常用的动作枚举类及其说明:
SAVE
: 保存操作DELETE
: 删除操作UPDATE
: 更新操作QUERY
: 查询操作EXPORT
: 导出操作SUBMIT
: 提交按钮CANCEL
: 取消按钮RESET
: 重置按钮CONFIRM
: 确认按钮CLOSE
: 关闭按钮NEW
: 新建菜单OPEN
: 打开菜单SAVE
: 保存菜单DELETE
: 删除菜单EXPORT
: 导出菜单IMPORT
: 导入菜单EXPAND_ALL
: 全部展开COLLAPSE_ALL
: 全部折叠ADD_NODE
: 添加节点DELETE_NODE
: 删除节点EDIT_NODE
: 编辑节点MOVE_NODE
: 移动节点这些动作枚举类可以与@APIEventAnnotation
结合使用,实现更丰富的事件处理逻辑。例如:
@APIEventAnnotation(
bindFormEvent = CustomFormEvent.SUBMIT,
requestDataSource = "approvalDataSource",
onExecuteSuccessAction = {
@CustomAction(
actionType = ActionTypeEnum.SAVE,
params = {"status", "approved"}
)
}
)
public class ApprovalSubmitEvent {
// 事件处理逻辑
}
type
: 组件类型(如 "form", "grid", "tree")name
: 组件名称path
: 数据路径paramName
: 参数名称(可选,默认使用 path)converter
: 转换器类名(可选)type
: 组件类型name
: 组件名称path
: 数据路径updateStrategy
: 更新策略(如 UpdateStrategy.INCREMENT
增量更新)prompt
: AI 提示语model
: AI 模型名称cacheable
: 是否缓存结果temperature
: 生成温度name
: 动作名称params
: 动作参数async
: 是否异步执行@APIEventAnnotation 是 OneCode 3.0 框架中实现前后端交互的核心注解,通过该注解可以轻松实现事件绑定、数据映射和请求生命周期管理等功能。本手册详细介绍了 @APIEventAnnotation 的所有属性、核心事件枚举以及使用示例,希望能帮助开发者更高效地使用 OneCode 3.0 框架进行企业级应用开发。
通过合理使用 @APIEventAnnotation,开发者可以将传统开发中大量的样板代码和配置工作简化为简洁的注解声明,从而更专注于业务逻辑的实现,提高开发效率和代码质量。在实际开发中,应根据具体业务场景选择合适的属性和事件,遵循最佳实践,以充分发挥 OneCode 3.0 框架的强大功能。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。