• 首页
  • 产品中心
    • 数式Oinone四大产品

      低代码开发平台无代码开发平台集成开发平台AI大模型开发
    • 数式Oinone体系能力

      用户与组织权限管理文件管理消息中心国际化业务审计
    • 数式Oinone核心产品特性

      低无一体面向软件公司场景无限制应用级扩容可分可合
  • 服务中心
    • 客户服务

      预约演示方案咨询私有部署找人定制
    • 开发者

      问答下载
    • Oinone学院

      社区学习

    《精讲面向软件公司的低代码平台——以Oinone为例》

  • 合作伙伴
    渠道申请伙伴名录专家库
  • 关于数式
0571-88757863

Init Module Data


Tip

This tutorial extends the "Back-end Framework Tutorial". Please ensure you have completed that tutorial and use the "Expense Management (expenses)" module you built as the basis for this tutorial's exercises.

I. Business Data Initialization

Reference: Documentation related to this topic can be found in "Module Lifecycle".

Objectives: By the end of this section:

  1. Add a fixed record to the table view of the expenses.ProjectType model for project types.

Master data typically forms part of a module's technical or business requirements. In other words, such data is often critical for the normal operation of the module, installed alongside the module itself. We have previously encountered technical data when defining views and actions, which constitutes a type of master data. In addition to technical data, business data can also be defined, such as countries, currencies, units of measurement, and complete national localization data (statutory reports, tax definitions, chart of accounts), etc. For example:

@Component
public class ExpensesModuleBizDataInit implements InstallDataInit, UpgradeDataInit, ReloadDataInit {

    /**
     * Execution logic for the installation command
     * @param command Application lifecycle command
     * @param version Current version number
     * @return Whether the installation operation was successful
     */
    @Override
    public boolean init(AppLifecycleCommand command, String version) {
        // Throws an exception here; replace with specific installation logic as needed
        throw PamirsException.construct(ExpensesExpEnum.SYSTEM_ERROR).appendMsg("ExpensesModuleBizDataInit: install").errThrow();
        // Example: Installation command execution logic
        // return Boolean.TRUE;
    }

    /**
     * Execution logic for the reload command
     * @param command Application lifecycle command
     * @param version Current version number
     * @return Whether the reload operation was successful
     */
    @Override
    public boolean reload(AppLifecycleCommand command, String version) {
        // Throws an exception here; replace with specific reload logic as needed
        throw PamirsException.construct(ExpensesExpEnum.SYSTEM_ERROR).appendMsg("ExpensesModuleBizDataInit: reload").errThrow();
        // Example: Reload command execution logic
        // return Boolean.TRUE;
    }

    /**
     * Execution logic for the upgrade command
     * @param command Application lifecycle command
     * @param version Current version number
     * @param existVersion Existing version number
     * @return Whether the upgrade operation was successful
     */
    @Override
    public boolean upgrade(AppLifecycleCommand command, String version, String existVersion) {
        // Throws an exception here; replace with specific upgrade logic as needed
        throw PamirsException.construct(ExpensesExpEnum.SYSTEM_ERROR).appendMsg("ExpensesModuleBizDataInit: upgrade").errThrow();
        // Example: Upgrade command execution logic
        // return Boolean.TRUE;
    }

    /**
     * Specifies the modules matched by this initialization class
     * @return List of matched module codes
     */
    @Override
    public List<String> modules() {
        return Collections.singletonList(ExpensesModule.MODULE_MODULE);
    }

    /**
     * Sets the execution priority
     * @return Execution priority
     */
    @Override
    public int priority() {
        return 0;
    }
}

This class implements the InstallDataInit, UpgradeDataInit, and ReloadDataInit interfaces, which correspond to different business initialization scenarios:

  • The InstallDataInit interface corresponds to the installation (init) operation.
  • The UpgradeDataInit interface corresponds to the upgrade (upgrade) operation.
  • The ReloadDataInit interface corresponds to the reload (reload) operation.

Additionally, the modules method specifies which modules this initialization class matches, based on module codes, while the priority method sets the execution priority.

Exercise

Create data for the expenses.ProjectType model and add a record with the name "Capital Construction".

Edit this page
Last Updated:1/15/26, 4:02 AM
Prev
Master the Front-End Framework
Next
Restrict Access to Data
默认页脚
Copyright © 2026 Mr.Hope