4.1.7 函数之元数据详解

介绍Function相关元数据,以及对应代码注解方式。大家还是可以通读下,以备不时之需

如您还不了解Function的定义,可以先看下2.3【oinone独特之源,元数据与设计原则】对Function的描述,本节主要带大家了解Function元数据构成,能让小伙伴非常清楚oinone从哪些维度来描述Function,

一、元数据说明

FunctionDefinition

元素数据构成 含义 对应注解 备注
namespace 函数命名空间 @Fun("") @Model.model("") @Fun或@Model.model
name 技术名称 @Function(
name="",
scene={},
summary="",
openLevel=FunctionOpenEnum.REMOTE
)
scene 可用场景 见:FunctionSceneEnum
description 描述
openLevel 开放级别 见:FunctionOpenEnum
fun 编码 @Function.fun("")
displayName 显示名称 @Function.Advanced(
displayName="",
type=FunctionTypeEnum.UPDATE,
dataManager=false,
language=FunctionLanguageEnum.JAVA,
isBuiltin=false,
category=FunctionCategoryEnum.OTHER,
group="pamirs",
version="1.0.0",
timeout=5000,
retries=0,
isLongPolling=false,
longPollingKey="userId"
longPollingTimeout=1
)
type 函数类型默认:4(改) 见 FunctionTypeEnum
dataManager 数据管理器函数默认:false
language 函数语言默认:DSL 见FunctionLanguageEnum
isBuiltin 是否内置函数 默认:false
category 分类 默认:OTHER 见:FunctionCategoryEnum
group 系统分组 默认:pamirs
version 系统版本 默认:1.0.0
timeout 超时时间 默认:5000
retries 重试次数 默认:0
isLongPolling 是否支持long polling,默认false
longPollingKey 支持从上下文中获取字段作为key
longPollingTimeout long polling超时时间 默认值为1
transactionConfig 事务配置 JSON存储 见TransactionConfig 配置@PamirsTransactional
source 来源 系统推断值,见:FunctionSourceEnum
extPointList 函数包含扩展点 系统推断值
module 所属模块 系统推断值
bitOptions 系统推断值
attributes 属性 系统推断值
imports 上下文引用 系统推断值
context 上下文变量 系统推断值
codes 函数内容 系统推断值
beanName bean名称 系统推断值
rule 前端规则 系统推断值,一般Action.rule传递下来的
clazz 函数位置 系统推断值
method 函数方法 系统推断值
argumentList 函数参数 系统推断值,List<Argument>
returnType 返回值类型 系统推断值

表4-1-7-1 FunctionDefinition

TransactionConfig

函数事务管理之配置项事务,具体事务使用详见4.1.8【函数之事务管理】一文。

元素数据构成 含义 对应注解 备注
transactionManager 事务管理器 @PamirsTransactional(
transactionManager="",
enableXa=false,
isolation=Isolation.DEFAULT,
propagation=Propagation.REQUIRED,
timeout=-1,
readOnly=false,
rollbackFor={},
rollbackForClassName={},
noRollbackFor={},
noRollbackForClassName={},
rollbackForExpCode={},
noRollbackForExpCode={}
)
enableXa 分布式事务默认为false
isolation 事务隔离级别
propagation 事务传递类型
timeout 过期时间 默认:-1
readOnly 只读 默认:false
rollbackForExpCode 回滚异常编码
rollbackForExpCode 忽略异常编码
namespace 函数命名空间 系统推断值
fun 函数编码 系统推断值
active 生效 默认为true 系统推断值

表4-1-7-2 TransactionConfig

二、元数据,在Java中对应的注解类说明

命名空间注解

Fun

@Fun 函数申明
└── value 命名空间

Model

@Model

└── model 命名空间

函数信息注解

Function

@Function
├── name 技术名称
├── scene 可用场景
├── summary 描述摘要
├── openLevel 开放级别
├── Advanced 更多配置
│ ├── displayName 显示名称
│ ├── type 函数类型,默认 FunctionTypeEnum.UPDATE
│ ├── managed 数据管理器函数,默认false
│ ├── language 语言,默认 FunctionLanguageEnum.JAVA
│ ├── builtin 是否内置函数,默认否
│ ├── category 分类,FunctionCategoryEnum.OTHER
│ ├── group 系统分组,默认:pamirs
│ ├── version 系统版本, 默认:1.0.0
│ ├── timeout 超时时间,默认:5000
│ ├── retries 重试次数,默认:0
│ ├── isLongPolling 是否支持long polling ,默认false
│ ├── longPollingKey 支持从上下文中获取字段作为key,默认 userId
│ └── longPollingTimeout long polling超时时间,默认值为1
└── fun
└──value

函数事务管理注解

PamirsTransactional

@PamirsTransactional
├── value @AliasFor("transactionManager")
├── transactionManager @AliasFor("value") 默认值:""
├── propagation 事务传递类型 默认值:Propagation.REQUIRED
├── isolation 事务隔离级别 默认值:Isolation.DEFAULT
├── timeout 过期时间默认:-1
├── readOnly 只读 默认:false
├── rollbackFor 回滚异常类
├── rollbackForClassName 回滚异常类名
├── rollbackForExpCode 回滚异常编码
├── noRollbackFor 忽略异常类
├── noRollbackForClassName 忽略异常类名
├── noRollbackForExpCode 忽略异常编码
└── enableXa 分布式事务 默认为false

Oinone社区 作者:史, 昂原创文章,如若转载,请注明出处:https://doc.oinone.top/oio4/9282.html

访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验

Like (0)
史, 昂's avatar史, 昂数式管理员
Previous 2024年5月23日 am8:56
Next 2024年5月23日 am8:58

相关推荐

  • 4.2.2 框架之MessageHub

    一、MessageHub 请求出现异常时,提供”点对点“的通讯能力 二、何时使用 错误提示是用户体验中特别重要的组成部分,大部分的错误体现在整页级别,字段级别,按钮级别。友好的错误提示应该是怎么样的呢?我们假设他是这样的 与用户操作精密契合 当字段输入异常时,错误展示在错误框底部 按钮触发服务时异常,错误展示在按钮底部 区分不同的类型 错误 成功 警告 提示 调试 简洁易懂的错误信息 在oinone平台中,我们怎么做到友好的错误提示呢?接下来介绍我们的MessageHub,它为自定义错误提示提供无限的可能。 三、如何使用 订阅 import { useMessageHub, ILevel } from "@kunlun/dependencies" const messageHub = useMessageHub('当前视图的唯一标识'); /* 订阅错误信息 */ messageHub.subscribe((errorResult) => { console.log(errorResult) }) /* 订阅成功信息 */ messageHub.subscribe((errorResult) => { console.log(errorResult) }, ILevel.SUCCESS) 图4-2-2-1 订阅的示例代码 销毁 /** * 在适当的时机销毁它 * 如果页面逻辑运行时都不需要销毁,在页面destroyed是一定要销毁,重要!!! */ messageHub.unsubscribe() 图4-2-2-2 销毁的示例代码 四、实战 让我们把3.5.7.5【自定义视图-表单】一文中的自定义表单进行改造,加入我们的messageHub,模拟在表单提交时,后端报错信息在字段下方给予提示。 Step1 (后端)重写PetType的创建函数 重写PetType的创建函数,在创建逻辑中通过MessageHub返回错误信息,返回错误信息的同时要设置paths信息方便前端处理 @Action.Advanced(name = FunctionConstants.create, managed = true) @Action(displayName = "确定", summary = "创建", bindingType = ViewTypeEnum.FORM) @Function(name = FunctionConstants.create) @Function.fun(FunctionConstants.create) public PetType create(PetType data){ List<Object> paths = new ArrayList<>(); paths.add("demo.PetType"); paths.add("kind"); PamirsSession.getMessageHub().msg(new Message().msg("kind error").setPath(paths).setLevel(InformationLevelEnum.ERROR).setErrorType(ErrorTypeEnum.BIZ_ERROR)); List<Object> paths2 = new ArrayList<>(); paths2.add("demo.PetType"); paths2.add("name"); PamirsSession.getMessageHub().msg(new Message().msg("name error").setPath(paths2).setLevel(InformationLevelEnum.ERROR).setErrorType(ErrorTypeEnum.BIZ_ERROR)); // data.create(); return data; } 图4-2-2-3 (后端)重写PetType的创建函数 Step 2 修改PetForm.vue <template> <div class="petFormWrapper"> <form :model="formState" @finish="onFinish"> <a-form-item label="品种种类" id="name" name="kind" :rules="[{ required: true, message: '请输入品种种类!', trigger: 'focus' }]"> <a-input v-model:value="formState.kind" @input="(e) => onNameChange(e, 'kind')" /> <span style="color: red">{{ getServiceError('kind') }}</span> </a-form-item> <a-form-item label="品种名" id="name" name="name" :rules="[{ required: true, message: '请输入品种名!', trigger: 'focus' }]"> <a-input v-model:value="formState.name" @input="(e) => onNameChange(e, 'name')" /> <span style="color: red">{{ getServiceError('name') }}</span> </a-form-item> </form> </div> </template>- <script lang="ts"> import { defineComponent, reactive…

    2024年5月23日
    1.6K00
  • 业务审计

    整体介绍 业务审计是指通过跟踪用户在平台业务应用中的各类行为操作以及关联的数据变化,支撑企业业务审计所需。平台提供可视化审计规则配置,根据审计规则记录行为日志,其中日志包括登录日志、应用日志; 登录日志:记录平台用户登录行为。 应用日志:针对已订阅的审计规则记录用户操作信息,是用户在各应用中操作行为留痕记录。 审计规则:业务审计中,数据变化订阅记录的规则,是记录应用日志的规则。 操作入口:应用中心——业务审计应用。

    Oinone 7天入门到精通 2024年6月20日
    2.0K00
  • 4.5 研发辅助

    这里都是一些提升研发效率的小工具

    Oinone 7天入门到精通 2024年5月23日
    1.5K00
  • 4.5.2 研发辅助之SQL优化

    Oinone体系中是不需要针对模型写SQL的,默认提供了通用的数据管理器。在带来便利的情况下,也导致传统的sql审查就没办法开展。但是我们可以以技术的手段收集慢SQL和限制问题SQL执行。 慢SQL搜集目的:去发现非原则性问题的慢SQL,并进行整改 限制问题SQL执行:对应一些不规范的SQL系统上直接做限制,如果有特殊情况手动放开 一、发现慢SQL 这个功能并没有直接加入到oinone的版本中,需要业务自行写插件,插件代码如下。大家可以根据实际情况进行改造比如: 堆栈入口,例子中只是放了pamirs,可以根据实际情况改成业务包路径 对慢SQL的定义是5s还是3s,根据实际情况变 package pro.shushi.pamirs.demo.core.plugin; import org.apache.ibatis.executor.Executor; import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.plugin.*; import org.apache.ibatis.session.ResultHandler; import org.apache.ibatis.session.RowBounds; import org.springframework.stereotype.Component; import pro.shushi.pamirs.meta.annotation.fun.extern.Slf4j; @Intercepts({ @Signature(type = Executor.class,method = "query",args = {MappedStatement.class,Object.class, RowBounds.class, ResultHandler.class}) }) @Component @Slf4j public class SlowSQLAnalysisInterceptor implements Interceptor { @Override public Object intercept(Invocation invocation) throws Throwable { long start = System.currentTimeMillis(); Object result = invocation.proceed(); long end = System.currentTimeMillis(); if (end – start > 10000) {//大于10秒 try { StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); StringBuffer slowLog = new StringBuffer(); slowLog.append(System.lineSeparator()); for (StackTraceElement element : stackTraceElements) { if (element.getClassName().indexOf("pamirs") > 0) { slowLog.append(element.getClassName()).append(":").append(element.getMethodName()).append(":").append(element.getLineNumber()).append(System.lineSeparator()); } } Object parameter = null; if (invocation.getArgs().length > 1) { parameter = invocation.getArgs()[1]; } MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; BoundSql boundSql = mappedStatement.getBoundSql(parameter); Configuration configuration = mappedStatement.getConfiguration(); String originalSql = showSql(configuration, boundSql); originalSql = originalSql.replaceAll("\'", "").replace("\"", ""); log.warn("检测到的慢SQL为:" + originalSql); log.warn("业务慢SQL入口为:" + slowLog.toString()); } catch (Throwable e1) { //忽略 } } return result; } public String showSql(Configuration configuration, BoundSql boundSql) { Object parameterObject = boundSql.getParameterObject(); List<ParameterMapping> parameterMappings = boundSql.getParameterMappings(); String sql = boundSql.getSql().replaceAll("[\\s]+", " "); if (parameterMappings.size() > 0 && parameterObject != null) { TypeHandlerRegistry typeHandlerRegistry…

    Oinone 7天入门到精通 2024年5月23日
    1.7K00

Leave a Reply

Please Login to Comment