4.1.1 模块之yml文件结构详解

本节是对demo的boot工程的application-*.yml文件关于oinone相关配置的扩充讲解,大家可以先通读留个影响,以备不时之需

在基础入门的模块一章中大家构建,并通过启动前后应用,直观地感受到我们自己建的demo模块。在上述过程中想必大家都了解到我们oinone的boot工程是专门用来做应用启动管理,它完全没有任何业务逻辑,它只决定启动哪些模块、启动方式、以及相关配置。它跟Spring Boot的一个普通工程没有什么差异。所有我们只要看application-*.yml文件,oinone提供了哪些特殊配置就能窥探一二。

这里主要介绍pamirs路径下的核心以及常用的配置项

一、pamirs.boot

  1. pamirs.boot.init

    1. 描述:启动加载程序,是否启动元数据、业务数据和基础设施的加载与更新程序,在应用启动时同时对模块进行生命周期管理

    2. true ##标准版,只支持true

  2. pamirs.boot.sync

    1. 描述:同步执行加载程序,启动时对模块进行生命周期管理采用同步方式

    2. true ##标准版,只支持true

  3. pamirs.boot.modules

    a. 描述:启动模块列表。这里只有base模块是必须的。为了匹配我们的前端模版,在demo的例子中加入了其他几个通用业务模块。当然这些通用业务模块也是可以大大降低大家的开发难度以及提升业务系统的设计质量

    b. - base #oinone的基础模块

    c. - common #oinone的一些基础辅助功能

    d. - sequence #序列的能力

    e. - resource #基础资源如

    f. - user #基础用户

    g. - auth #权限

    h. - message #消息

    i. - international #国际化

    j. - business #商业关系

    k. - file #文件,demo里没有默认加入,如果要开发导入导出相关功能,可以对应引入改模块

    l. - …… 还有很多通用业务模块以及这些模块的详细介绍,我们在介绍第六章【oinone的通用能力】的章节去展开

  4. pamirs.boot.mode

    ⅰ. dev:不走缓存,可以直接修改元数据。特别是我们在说页面设计的时候,可以修改base_view表直接生效不需要重启系统

配置举例

pamirs:
    boot:
    init: true
    sync: true
    modules:
      - base
      - common
      - sequence
      - resource
      - user
      - auth
      - message
      - international
      - business
      - demo_core

图4-1-1-1 pamirs.boot.mode配置举例

二、pamirs.boot.profile与pamirs.boot.options

pamirs.boot.option, 在pamirs.boot.options中可以自定义可选项,也可以根据pamirs.boot.profile属性来指定这些可选项,pamirs.boot.profile属性的默认值为CUSTOMIZE。只有pamirs.boot.profile=CUSTOMIZE时,才能在pamirs.boot.options中自定义可选项。

可选项 说明 默认值 AUTO READONLY PACKAGE DDL
reloadModule 是否加载存储在数据库中的模块信息 false true true true true
checkModule 校验依赖模块是否安装 false true true true true
loadMeta 是否扫描包读取模块元数据 true true false true true
reloadMeta 是否加载存储在数据库中元数据 false true true true true
computeMeta 是否重算元数据 true true false true true
editMeta 编辑元数据,是否支持编程式编辑元数据 true true false true true
diffMeta 差量减计算元数据 false true false true false
refreshSessionMeta 刷新元数据缓存 true true true true true
rebuildHttpApi 刷新重建前后端协议 true true true false false
diffTable 差量追踪表结构变更 false true false true false
rebuildTable 更新重建表结构 true true false true false
printDDL 打印重建表结构DDL false false false false true
publishService 发布服务,是否发布远程服务 true true true false false
updateModule 分布式模块管理 false true false true false
updateMeta 初始化与更新元数据,是否将元数据的变更写入数据库 false true false true false
updateData 初始化与更新内置业务数据,是否将内置业务数据的变更写入数据库 true true false true false
params 扩展参数 可自定义 可自定义 可自定义 可自定义 可自定义

表4-1-1-1 pamirs.boot.options列表

可以在启动日志中可查看当前服务启动可选项。

image.png

图4-1-1-2 在启动日志中查看当前服务启动可选项

三、pamirs.meta

  1. pamirs.meta.metaPackages

    1. 描述:自定义元模型的所在包路径。标准版只能是pro.shushi.pamirs.trigger.model
  2. 配置举例

pamirs: 
    meta:
    metaPackages:
      - pro.shushi.pamirs.trigger.model

图4-1-1-3 pamirs.meta配置举例

四、pamirs.framework

  1. pamirs.framework.gateway #graphql的可选项配置

apamirs.framework.gateway.show-doc #是否对外提供gql的scheme文档查询能力,在3.2.1【构建第一个Module】一文中“DemoMoudel的启动”的部分之所以可以用Insomnia开查看后端的文档,就是这里要配置为true

bpamirs.framework.gateway.statistics #用于收集DataLoader执行过程中的状态,比如缓存命中多少次,已经load了多少个对象,有多少次error等

  1. pamirs.framework.hook

    1. pamirs.framework.hook.ignoreAll #默认为false,为true忽略掉所有hook函数

    2. pamirs.framework.hook.excludes #排除掉部分hook函数

  2. pamirs.framework.data #这个经常会使用到,大家一定要了解

    1. pamirs.framework.data.default-ds-key #模块的默认数据库key,对应pamirs.datasource配置

    2. pamirs.framework.data.ds-map #为模块指定数据库key,对应pamirs.datasource配置。在demo中我们如果要为demo_core这个模块配置独立数据库就可以在这里配置如 demo_core: demo,并在pamirs.datasource配置key为demo的数据源

  3. pamirs.framework.system

    1. pamirs.framework.system.system-ds-key #元数据系统对应的数据源,对应pamirs.datasource配置

    2. pamirs.framework.system.system-models #视为元数据模型,一起放到system-ds-key库

  4. 配置举例

pamirs:
  framework:
    system:
      system-ds-key: base
      system-models:
        - base.WorkerNode
    data:
      default-ds-key: pamirs
      ds-map:
        base: base
    gateway:
      statistics: true
      show-doc: true
    #hook 如下配置
    #hook:
      #excludes:
        #- pro.shushi.pamirs.core.common.hook.QueryPageHook4TreeAfter
        #- pro.shushi.pamirs.user.api.hook.UserQueryPageHookAfter
        #- pro.shushi.pamirs.user.api.hook.UserQueryOneHookAfter

图4-1-1-4 pamirs.framework 配置举例

五、pamirs.dialect.ds

  1. 描述:pamirs.datasource中数据源的方言信息,以key为对应。

  2. 子参数有:type(默认:MySQL),version(默认:8.0),majorVersion(默认:8)

  3. 配置举例

pamirs: 
    dialect: #MySQL8.0可不配置
    ds: 
        base: # pamirs.datasource中数据源的方言信息,以key为对应
        type: MySQL
        version: 8.0
        majorVersion: 8
      pamirs: # pamirs.datasource中数据源的方言信息,以key为对应
        type: MySQL
        version: 8.0
        majorVersion: 8

图4-1-1-5 pamirs.dialect.ds配置举例

六、pamirs.datasource

  1. 描述:安装模块所需要的数据源配置

  2. 配置举例

pamirs: 
  datasource:
    pamirs:
      driverClassName: com.mysql.cj.jdbc.Driver
      type: com.alibaba.druid.pool.DruidDataSource
      url: jdbc:mysql://127.0.0.1:3306/demo?useSSL=false&allowPublicKeyRetrieval=true&useServerPrepStmts=true&cachePrepStmts=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true
      username: root
      password: oinone
      initialSize: 5
      maxActive: 200
      minIdle: 5
      maxWait: 60000
      timeBetweenEvictionRunsMillis: 60000
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      poolPreparedStatements: true
      asyncInit: true
    base:
      driverClassName: com.mysql.cj.jdbc.Driver
      type: com.alibaba.druid.pool.DruidDataSource
      url: jdbc:mysql://127.0.0.1:3306/demo_base?useSSL=false&allowPublicKeyRetrieval=true&useServerPrepStmts=true&cachePrepStmts=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true
      username: root
      password: oinone
      initialSize: 5
      maxActive: 200
      minIdle: 5
      maxWait: 60000
      timeBetweenEvictionRunsMillis: 60000
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      poolPreparedStatements: true
      asyncInit: true

图4-1-1-6 pamirs.datasource配置举例

七、pamirs.sharding

  1. 描述oinone的分库分表配置,当使用pamirs-trigger-bridge-tbschedule工程开启内置schedule功能时必须配置。

  2. 配置举例 - 参考4.1.24【框架之分库分表】一文。

pamirs: 
  sharding:
    define:
      data-sources:
        ds: pamirs
        pamirsSharding: pamirs #申明pamirsSharding库对应的pamirs数据源
        testShardingDs:        #申明testShardingDs库对应的testShardingDs_0\1数据源
          - testShardingDs_0
          - testShardingDs_1
      models:
        "[trigger.PamirsSchedule]":
          tables: 0..13
        "[demo.ShardingModel]":
          tables: 0..7
          table-separator: _
        "[demo.ShardingModel2]":
          ds-nodes: 0..1       #申明testShardingDs库对应的建库规则
          ds-separator: _
          tables: 0..7
          table-separator: _
    rule:
      pamirsSharding: #配置pamirsSharding库的分库分表规则
        actual-ds:
          - pamirs #申明pamirsSharding库对应的pamirs数据源
        sharding-rules:
          # Configure sharding rule,以下配置跟sharding-jdbc配置一致
          - tables:
              demo_core_sharding_model:
                actualDataNodes: pamirs.demo_core_sharding_model_${0..7}
                tableStrategy:
                  standard:
                    shardingColumn: user_id
                    shardingAlgorithmName: table_inline
            shardingAlgorithms:
              table_inline:
                type: INLINE
                props:
                  algorithm-expression: demo_core_sharding_model_${(Long.valueOf(user_id) % 8)}
        props:
          sql.show: true
      testShardingDs: #配置testShardingDs库的分库分表规则
        actual-ds: #申明testShardingDs库对应的pamirs数据源
          - testShardingDs_0
          - testShardingDs_1
        sharding-rules:
          # Configure sharding rule,以下配置跟sharding-jdbc配置一致
          - tables:
              demo_core_sharding_model2:
                actualDataNodes: testShardingDs_${0..1}.demo_core_sharding_model2_${0..7}
                databaseStrategy:
                  standard:
                    shardingColumn: user_id
                    shardingAlgorithmName: ds_inline
                tableStrategy:
                  standard:
                    shardingColumn: user_id
                    shardingAlgorithmName: table_inline
            shardingAlgorithms:
              table_inline:
                type: INLINE
                props:
                  algorithm-expression: demo_core_sharding_model2_${(Long.valueOf(user_id) % 8)}
              ds_inline:
                type: INLINE
                props:
                  algorithm-expression: testShardingDs_${(Long.valueOf(user_id) % 2)}
        props:
          sql.show: true

图4-1-1-7 pamirs.sharding配置举例

八、pamirs.mapper

  1. 库配置:可以通过YAML的“pamirs.mapper.<global或者ds>”配置项进行库配置。如果未配置,系统会采用默认值
配置项 默认值 描述
databaseFormat %s 库名格式化
tableFormat %s 表名格式化
tablePattern %s 动态表名表达式

表4-1-1-2 库配置

  1. 表配置:可以通过YAML的“pamirs.mapper.<global或者ds>.table-info”配置项或者@Model.Persistence注解进行表配置。注解优先级大于YAML配置文件配置。如果未配置,系统会采用默认值
配置项 默认值 描述
databaseFormat %s 库名格式化
tableFormat %s 表名格式化
tablePattern %s 动态表名表达式

表4-1-1-3 表配置

  1. 配置举例
pamirs: 
    mapper:
    static-model-config-locations:
      - pro.shushi.pamirs
    batch: collectionCommit #batch方法的批量提交模式
    batch-config:
      "[base.Field]":
        write: 2000
      "[base.Function]":
        read: 500
        write: 2000
    global: 
      table-info:
        logic-delete: true
        logic-delete-column: is_deleted
        logic-delete-value: REPLACE(unix_timestamp(NOW(6)),'.','')
        logic-not-delete-value: 0
        optimistic-locker: false
        optimistic-locker-column: opt_version
        key-generator: DISTRIBUTION
      table-pattern: '${module}_%s'
    #可以为指定数据配置
    #ds: 
    #   pamirs:
    #   table-info:
    #      logic-delete: true
    #      logic-delete-column: is_deleted
    #      logic-delete-value: REPLACE(unix_timestamp(NOW(6)),'.','')
    #      logic-not-delete-value: 0
    #      optimistic-locker: false
    #      optimistic-locker-column: opt_version
    #      key-generator: DISTRIBUTION
    #   table-pattern: '${module}_%s'

图4-1-1-8 pamirs.mapper配置举例

九、pamirs.persistence

  1. 描述:自动建库,建表

  2. 配置举例

pamirs: 
  persistence:
    global:
      auto-create-database: true
      auto-create-table: true

图4-1-1-9 pamirs.persistence配置举例

十、pamirs.plus

a. 描述mybatisplus的代理配置

b. 配置举例

pamirs: 
    plus:
    configuration:
      map-underscore-to-camel-case: false
      cache-enabled: false

图4-1-1-10 pamirs.plus配置举例

十一、pamirs.event

a. pamirs.event.enabled:启用RocketMQ功能,不启用的情况下无法使用任何功能,使用详见4.1.21【框架之分布式消息】一文。

b. pamirs.event.rocket-mq.namesrv-addr:RocketMQ连接地址字符串

c. pamirs.event.rocket-mq.aliyun : 阿里云版本适配

d. pamirs.event.schedule.enabled:启动异步任务工,不启用的情况下无法使用任何功能

e. 配置举例

pamirs: 
    event:
    enabled: false
    schedule:
      enabled: false
      ownSign: base
      auto-init: true
      auto-create-config-file: true
    rocket-mq:
      namesrv-addr: 127.0.0.1:9876
      # 标识发送消息和消费消息的机器的IP地址,默认为RemotingUtil.getLocalAddress()
      client-ip:
      # 标识发送消息和消费消息的机器的实例名称地址,默认为DEFAULT
      instance-name:
      # 标识发送消息和消费消息的机器的实例ID,无默认值
      namespace:
      # 为每一个topic添加一个固定前缀
      topic-prefix:
      # 是否启用vip netty通道以发送消息
      vip-channel-enabled: false
      # 是否启用消息轨迹追踪(该属性对于阿里云MQ无效)
      enable-trace: false
      # 消息轨迹追踪的topic名称
      trace-topic-name:
      # Pamirs Event工厂
      event-factory: pro.shushi.pamirs.framework.connectors.event.rocketmq.DefaultRocketMQEventFactory
      # acl配置
      accounts:
        - accessKey: RocketMQ
          secretKey: 12345678
      # 阿里云MQ 相关配置
      aliyun:
        # 使用阿里云MQ
        enabled: false
        # 阿里云MQ AccessKey
        access-key:
        # 阿里云MQ SecretKey
        secret-key:
        # 阿里云MQ InstanceId
        instance-id:
        # 阿里云MQ GroupId
        group-id:

图4-1-1-11 pamirs.event配置举例

十二、pamirs.auth

  1. pamirs.auth.modelFilter:配置模型所有的query方法不需要过权限控制 #下个版本作废,不建议使用

  2. pamirs.auth.funFilter:配置模型的特定query方法不需要过权限控制

  3. 配置举例

pamirs: 
    auth:
    model-filter:
      - user.PamirsUserTransient
      - auth.ResourcePermission
      - auth.AuthGroup
      - auth.AuthRole
      - base.View
      - resource.ResourceCountry
      - pamirs.web.WebMenu
      - pamirs.web.WebRenderTransient
      - pamirs.message.MessageCenter
      - resource.major.ResourceMajorConfig
    fun-filter:
      - namespace: user.PamirsUserTransient
        fun: login #登录
      - namespace: user.PamirsUserTransient
        fun: loginByVerificationCode #手机号验证码登录
      - namespace: user.PamirsUserTransient
        fun: loginVerificationCode #手机号登录验证码
      - namespace: user.PamirsUserTransient
        fun: signUpVerificationCode #手机号注册验证码

图4-1-1-12 pamirs.auth配置举例

十三、pamirs.file

  1. 描述:导入导出相关配置,使用详见6.1【文件导入导出】一文

  2. 配置举例

pamirs:
    file:
    auto-upload-logo: false
    import-property:
      default-each-import: false # 默认逐行导入
      max-error-length: 100 # 默认最大收集错误行数
    export-property:
      default-clear-export-style: false # 默认使用csv导出
      csv-max-support-length: 1000000 # csv导出最大支持1000000行

#文件导入导出还依赖CDN相关配置
cdn:
  oss:
    name: 阿里云
    type: OSS
    bucket: pamirs
    uploadUrl: oss-cn-hangzhou.aliyuncs.com
    downloadUrl: oss-cn-hangzhou.aliyuncs.com
    accessKeyId: #自行修改值
    accessKeySecret: #自行修改值
    mainDir: upload/demo/test/ 
    validTime: 3600000
    timeout: 600000
    active: true
    referer:
    localFolderUrl:

图4-1-1-13 pamirs.file配置举例

十四、pamirs.channel

  1. 描述:

  2. 配置举例

pamris: 
    channel:
    zkServers: 127.0.0.1:2181

图4-1-1-14 pamirs.channel配置举例

十五、pamirs.zookeeper

  1. 描述:zk配置的代理

  2. 配置举例

pamris:
    zookeeper:
    zkConnectString: 127.0.0.1:2181
    zkSessionTimeout: 60000
    rootPath: /demo

图4-1-1-15 pamirs.zookeeper配置举例

十六、pamirs.eip

  1. 描述:集成相关配置,使用详见集成平台一节

  2. 配置举例

pamirs: 
    eip:
    open-api:
      enabled: false
      standalone:
        host: 127.0.0.1
        port: 8081
        aes-key:
      routes:
        pamirs:
          host: 127.0.0.1
          port: 8081
          aes-key:

图4-1-1-16 pamirs.eip配置举例

高德地图接口的key配置

pamirs: 
    eip:
    map:
        gd:
        key: xxxxxx

图4-1-1-17高德地图接口的key配置

十七、pamirs.elastic

a. 描述:es搜索引擎地址 ,使用详见4.1.25【框架之搜索引擎】一节

b. 配置举例

pamirs: 
    elastic:
    url: 127.0.0.1:9200

图4-1-1-18 pamirs.elastic配置举例

十八、pamirs.load

oinone的默认模式下元数据都是以DB为准,当A模块依赖B模块,A与B模块不在没有部署在一起同时元数据的Base库也不是一个,那么A的元数据库怎么没有B模型,会导致系统出现模型定义找不到的错误。那么则需要A启动内存元数据模式,因为在A的元数据计算的时,因为A依赖B模块,同时有B的接口包,在内存中会扫描B的模型。所以我们要启动内存模式。应对分布式开发场景设计,更多请详见4.4【oinone的分布式体验进阶

pamirs:
  load:
    sessionMode: true

图4-1-1-19 pamirs.load配置举例

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

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

(0)
史, 昂的头像史, 昂数式管理员
上一篇 2024年5月23日 am9:02
下一篇 2024年5月23日

相关推荐

  • 3.3.3 模型的数据管理器

    数据管理器和数据构造器是Oinone为模型自动赋予的Function是内在数据管理能力,数据管理器针对存储模型是方便在大家编程模式下可以利用数据管理器Function快速达到相关数据操作的目的。数据构造器则主要用于模型进行初始化时字段默认值计算和页面交互 数据管理器 只有存储模型才有数据管理器。如果@Model.Advanced注解设置了dataManager属性为false,则表示在UI层不开放默认数据管理器。开放级别为API则表示UI层可以通过HTTP请求利用4.1.15【Pamirs标准网关协议】进行数据交互。 模型默认数据读管理器 函数编码 描述 开放级别 queryByPk 根据主键查询单条记录,会进行主键值检查 Local、Remote queryByEntity 根据实体查询单条记录 Local、Remote、Api queryByWrapper 根据查询类查询单条记录 Local、Remote queryListByEntity 根据实体查询返回记录列表 Local、Remote queryListByWrapper 根据查询类查询记录列表 Local、Remote queryListByPage 根据实体分页查询返回记录列表 Local、Remote queryListByPageAndWrapper 根据查询类分页查询记录列表 Local、Remote queryPage 分页查询返回分页对象,分页对象中包含记录列表 Local、Remote、Api countByEntity 按实体条件获取记录数量 Local、Remote countByWrapper 按查询类条件获取记录数量 Local、Remote 表3-3-3-1 模型默认数据读管理器 模型默认数据写管理器 函数编码 描述 开放级别 createOne 提交新增单条记录 Local、Remote createOrUpdate 新增或更新,需要为模型设置唯一索引,如果数据库检测到索引冲突,会更新数据,若未冲突则新增数据 Local、Remote updateByPk 根据主键更新单条记录,会进行主键值检查 Local、Remote updateByUniqueField 条件更新,条件中必须包含唯一索引字段 Local、Remote updateByEntity 按实体条件更新记录 Local、Remote、Api updateByWrapper 按查询类条件更新记录 Local、Remote createBatch 批量新增记录 Local、Remote createOrUpdateBatch 批量新增或更新记录 Local、Remote updateBatch 根据主键批量更新记录,会进行主键值检查 Local、Remote deleteByPk 根据主键删除单条记录,会进行主键值检查 Local、Remote deleteByPks 根据主键批量删除,会进行主键值检查 Local、Remote deleteByUniqueField 按条件删除记录,条件中必须包含唯一索引字段 Local、Remote deleteByEntity 根据实体条件删除 Local、Remote、Api deleteByWrapper 根据查询类条件删除 Local、Remote createWithField 新增实体记录并更新实体字段记录 Local、Remote、Api updateWithField 更新实体记录并更新实体字段记录 Local、Remote、Api deleteWithFieldBatch 批量删除实体记录并删除关联关系 Local、Remote、Api 表3-3-3-2 模型默认数据写管理器 如果模型继承IdModel,模型会自动设置主键设置为id,则会继承queryById、updateById和deleteById函数。 queryById(详情,根据ID查询单条记录,开放级别为Remote) updateById(提交更新单条记录,根据ID更新单条记录,开放级别为Remote) deleteById(提交删除单条记录,根据ID删除单条记录,开放级别为Remote) 如果模型继承CodeModel,模型也会继承IdModel的数据管理器,编码字段code为唯一索引字段。在新增数据时会根据编码生成规则自动设置编码字段code的值,继承queryByCode、updateByCode和deleteByCode函数。 queryByCode(详情,根据code查询单条记录,开放级别为Remote) updateByCode(提交更新单条记录,根据code更新单条记录,开放级别为Remote) deleteByCode(提交删除单条记录,根据code删除单条记录,开放级别为Remote) 没有主键或唯一索引的模型,在UI层不会开放默认数据写管理器。 #### 使用场景 图3-3-3-1 数据管理器使用场景 数据构造器 模型数据构造器 construct:供前端新开页面构造默认数据使用。所有模型都拥有construct构造器,默认会将字段上配置的默认值返回给前端,另外可以在子类中覆盖construct方法。数据构造器 construct函数的开放级别为API,函数类型为QUERY查询函数,系统将识别模型中的以construct命名的函数强制设置为API开放级别和QUERY查询类型。 可以使用@Field的defaultValue属性配置字段的默认值。注意,枚举的默认值为枚举的name。

    2024年5月23日
    1.9K10
  • 3.4.3.3 SPI机制-扩展点

    扩展点结合拦截器的设计,oinone可以点、线、面一体化管理Function 扩展点用于扩展函数逻辑。扩展点类似于SPI机制(Service Provider Interface),是一种服务发现机制。这一机制为函数逻辑的扩展提供了可能。 一、构建第一个扩展点 自定义扩展点(举例) 在我们日常开发中,随着对业务理解的深入,往往还在一些逻辑中会预留扩展点,以便日后应对不同需求时可以灵活替换某一小块逻辑。 在3.3.4【模型的继承】一文中的PetCatItemQueryService,是独立新增函数只作公共逻辑单元。现在我们给它的实现类增加一个扩展点。在PetCatItemQueryServiceImpl的queryPage方法中原本会先查询PetCatType列表,我们这里假设这个逻辑随着业务发展未来会发生变化,我们可以预先预留【查询萌猫类型扩展点】 Step1 新增扩展点定义PetCatItemQueryCatTypeExtpoint 扩展点命名空间:在接口上用@Ext声明扩展点命名空间。会优先在本类查找@Ext,若为空则往接口向上做遍历查找,返回第一个查找到的@Ext.value注解值,使用该值再获取函数的命名空间;如果未找到,则返回扩展点全限定类名。所以我们这里扩展点命名空间为:pro.shushi.pamirs.demo.api.extpoint.PetCatItemQueryCatTypeExtpoint 扩展点技术名称:先取@ExtPoint.name,若为空则取扩展点接口方法名。所以我们这里技术名为queryCatType package pro.shushi.pamirs.demo.api.extpoint; import pro.shushi.pamirs.demo.api.model.PetCatType; import pro.shushi.pamirs.meta.annotation.Ext; import pro.shushi.pamirs.meta.annotation.ExtPoint; import java.util.List; @Ext public interface PetCatItemQueryCatTypeExtpoint { @ExtPoint(displayName = "查询萌猫类型扩展点") List<PetCatType> queryCatType(); } 图3-4-3-11 新增扩展点定义PetCatItemQueryCatTypeExtpoint Step2 修改PetCatItemQueryServiceImpl(用Ext.run模式调用) 修改queryPage,增加扩展点的使用代码。扩展点的使用有两种方式 方法一,使用命名空间和扩展点名称调用Ext.run(namespace, fun, 参数); 方法二,使用函数式接口调用Ext.run(函数式接口, 参数); 我们这里用了第二种方式 用PetCatItemQueryCatTypeExtpoint的全限定类名作为扩展点的命名空间(namespace) 用queryCatType的方法名作为扩展点的技术名称(name) 根据namespace+name去找到匹配扩展点实现,并根据规则是否匹配,以及优先级唯一确定一个扩展点实现去执行逻辑 package pro.shushi.pamirs.demo.core.service; ……省略依赖包 @Model.model(PetCatItem.MODEL_MODEL) @Component public class PetCatItemAction extends DataStatusBehavior<PetCatItem> { @Override protected PetCatItem fetchData(PetCatItem data) { return data.queryById(); } @Action(displayName = "启用") public PetCatItem dataStatusEnable(PetCatItem data){ data = super.dataStatusEnable(data); data.updateById(); return data; } @Function.Advanced(displayName = "查询模型数据的默认过滤条件", type = FunctionTypeEnum.QUERY, managed = true) @Function(openLevel = {LOCAL}) public String queryFilters() { StringBuilder sqlWhereCondition = new StringBuilder(); // List<PetCatType> typeList = new PetCatType().queryList(); List<PetCatType> typeList = Ext.run(PetCatItemQueryCatTypeExtpoint::queryCatType, new Object[]{}); if(!CollectionUtils.isEmpty(typeList)){ // sqlWhereCondition.append("type_id"); sqlWhereCondition.append(PStringUtils.fieldName2Column(LambdaUtil.fetchFieldName(PetCatItem::getTypeId))); sqlWhereCondition.append(StringUtils.SPACE).append(SqlConstants.IN).append(CharacterConstants.LEFT_BRACKET); for(PetCatType petCatType: typeList){ sqlWhereCondition.append(petCatType.getId()).append(CharacterConstants.SEPARATOR_COMMA); } sqlWhereCondition.deleteCharAt(sqlWhereCondition.lastIndexOf(CharacterConstants.SEPARATOR_COMMA)); sqlWhereCondition.append(StringUtils.SPACE).append(CharacterConstants.RIGHT_BRACKET); } return sqlWhereCondition.toString(); } ……省略其他函数 } 图3-4-3-12 修改PetCatItemQueryServiceImpl Step3 新增扩展点实现PetCatItemQueryCatTypeExtpointOne 扩展点命名空间要与扩展点定义一致,用@Ext(PetCatItemQueryCatTypeExtpoint.class) @ExtPoint.Implement声明这是在@Ext声明的命名空间下,且技术名为queryCatType的扩展点实现 package pro.shushi.pamirs.demo.core.extpoint; import pro.shushi.pamirs.demo.api.extpoint.PetCatItemQueryCatTypeExtpoint; import pro.shushi.pamirs.demo.api.model.PetCatType; import pro.shushi.pamirs.meta.annotation.Ext; import pro.shushi.pamirs.meta.annotation.ExtPoint; import pro.shushi.pamirs.meta.api.session.PamirsSession; import java.util.List; @Ext(PetCatItemQueryCatTypeExtpoint.class) public class PetCatItemQueryCatTypeExtpointOne implements PetCatItemQueryCatTypeExtpoint { @Override @ExtPoint.Implement(displayName = "查询萌猫类型扩展点的默认实现") public List<PetCatType> queryCatType() { PamirsSession.getMessageHub().info("走的是第一个扩展点"); List<PetCatType> typeList = new PetCatType().queryList(); return typeList; } } 图3-4-3-13 新增扩展点实现PetCatItemQueryCatTypeExtpointOne Step4…

    2024年5月23日
    1.5K00
  • 3.4 Oinone以函数为内在

    函数(Function):是oinone可管理的执行逻辑单元,跟模型绑定则对应模型的方法 描述满足数学领域函数定义,含有三个要素:定义域A、值域C{f(x),x属于A}和对应法则f。其中核心是对应法则f,它是函数关系的本质特征 满足面向对象原则,可设置不同开放级别,本地与远程智能切换。 本章会带大家更加详细地了解Function的方方面面,主要以几下几个维度 构建第一个Function 函数的开放级别与类型 函数的相关特性 函数元数据详解

    Oinone 7天入门到精通 2024年5月23日
    1.5K00
  • 流程类

    1.流程类 1.1 审批 审批节点配置步骤: 添加审批节点 选择审批的模型和视图 设置审批人和通过方式 设置审批人在审批时的操作权限和数据权限 1.1.1 审批节点 审批节点只能放置在有数据可审批的流程链路上,审批分支只能放置在审批节点后。 1.1.2 审批模型和视图 可选的审批模型包含添加的审批节点之前的所有能获取到数据的模型。可选视图为该选择的数据模型关联的界面设计器中视图类型为表单的页面。 1.1.3 审批人和通过方式 审批人可在个人、部门、角色和模型中的字段里复选。当某人在不同类型人员选择中被重复选中,只会收到一次审批的代办。若为多人审批,审批是同步进行的。 单人审批: 通过方式:唯一通过方式,同意通过,拒绝否决 多人审批: 通过方式:或签/会签(默认或签) a. 或签(一名审批人同意或拒绝即可) 任意一位审批人操作通过或否决后流程就结束,其他审批人无法进入审批操作,但是会弹出消息提示审批结果。 场景:紧急且影响不大的审批可以由任意一位领导层或签。 b. 会签(需所有审批人同意才为同意,一名审批人拒绝即为拒绝) 场景:影响比较重大的审批,一票否决的形式决定是否通过。 c. 会签(一名审批人同意即为同意,需所有审批人拒绝才为拒绝) 场景:需要评估项目可操作性时,若有领导觉得有意义就通过,进入下一步评估,全员否决就否决项目。 1.1.4 操作&数据权限 操作权限 可设置是否必填拒绝原因、是否允许转交、是否允许加签、是否允许退回。 选择允许转交或允许加签之后,可选择添加人员的候选名单,不填默认所有人都可选。 选择允许退回后,可以选择退回到该审批节点之前的任意审批节点。ps:需所有审批人拒绝才为拒绝的会签不允许退回。 数据权限 选择视图后自动显示该视图下的数据字段,可选择的权限为查看、编辑、隐藏数据字段,默认可查看全部字段。 1.1.5 参与人重复 勾选参与人重复的场景时,满足场景的审批流程会由系统自动审批通过。 1.2 填写 当流程需要某些人提交数据才能继续时,可以使用填写这个动作。区别于数据类中的操作,填写这个动作只能修改当前触发模型中关联的视图表单,而数据类中的更新数据可以修改其他模型中的数据。 和审批动作相似,填写动作需要选择填写的模型和视图表单,需要选择填写人,可以选择添加转交权限。另外,填写动作必须包含一个及以上的可编辑的数据权限供操作人填写。

    2024年5月23日
    1.8K00

Leave a Reply

登录后才能评论