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

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

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

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

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

      问答下载
    • Oinone学院

      社区学习

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

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

Development Aid:Implement Duplication Creation in Low-code Manner


In the business scenarios of actual projects, there is a requirement for "duplication creation" to enable rapid data entry. This article introduces how to implement the duplication creation function in a low-code mode.

Ⅰ. Implementation Steps

(Ⅰ) Define the Base Class Model

  1. Define a base class model for duplication (e.g., AbstractCopyModel), and all models with the duplication creation function inherit from this model:
@Model.model(AbstractCopyModel.MODEL_MODEL)
@Model(displayName = "Base Class Providing Duplication Method")
@Model.Advanced(type= ModelTypeEnum.ABSTRACT)
public abstract class AbstractCopyModel extends IdModel  {

    public static final String MODEL_MODEL = "hr.simple.AbstractCopyModel";

}
  1. According to the Oinone model inheritance rules, submodels inherit all functions of the parent model; therefore, only the duplication logic for the base class AbstractCopyModel needs to be written:
@Component
@Model.model(AbstractCopyModel.MODEL_MODEL)
public class AbstractCopyModelAction {

    @Function(openLevel = FunctionOpenEnum.API)
    @Function.Advanced(type = FunctionTypeEnum.QUERY, displayName = "Duplicate")
    public AbstractCopyModel copy(AbstractCopyModel data) {
        if (data.getId() != null) {
            data = data.queryById();
            data.unsetId();
            data.unsetCreateDate();
            data.unsetWriteDate();
            data.unsetCreateUid();
            data.unsetWriteUid();
        } else {
            data.construct();
        }

        return data;
    }
}

(Ⅱ) Define the Business Model

Models requiring the duplication creation function inherit from the "base class for duplication" defined above, i.e., inherit from AbstractCopyModel:

@Model.model(Employee.MODEL_MODEL)
@Model(displayName = "Standard Product - Employee", labelFields = "name")
public class Employee extends AbstractCopyModel {

    public static final String MODEL_MODEL = "hr.simple.Employee";

    @Field.String
    @Field(displayName = "Name", required = true)
    private String name;

    @Field.String
    @Field(displayName = "Employee Number", required = true)
    private String code;

    // Other attributes
}

(Ⅲ) Initialize the "Duplicate" Button

Initialize the "view action" when the system starts, i.e., add a "Duplicate" button to the row operations of the default page:

@Component
public class HrSimpleModuleMetaDataEditor implements MetaDataEditor {

    @Override
    public void edit(AppLifecycleCommand command, Map<String, Meta> metaMap) {
        InitializationUtil util = InitializationUtil.get(metaMap, HrSimpleModule.MODULE_MODULE,
                                                         HrSimpleModule.MODULE_NAME);
        if(util==null){
            return;
        }

        // Initialize view actions
        viewActionInit(util);
    }
    
    private void viewActionInit(InitializationUtil util){
        // Employee information maintenance: Generate an in-line duplicate button
        util.createViewAction("Employee_Copy","Duplicate", Employee.MODEL_MODEL, InitializationUtil.getOptions(ViewTypeEnum.TABLE),
                              Employee.MODEL_MODEL, ViewTypeEnum.FORM, ActionContextTypeEnum.SINGLE, ActionTargetEnum.ROUTER,null,null)
        .setLoad("copy");// setLoad specifies the name of the backend method to be called when the page loads

        // Department information maintenance: Generate an in-line duplicate button
        util.createViewAction("Department_Copy","Duplicate", Department.MODEL_MODEL, InitializationUtil.getOptions(ViewTypeEnum.TABLE),
                              Department.MODEL_MODEL, ViewTypeEnum.FORM, ActionContextTypeEnum.SINGLE, ActionTargetEnum.ROUTER,null,null)
        .setLoad("copy");
    }
}

Through the above steps, models inheriting from the base class AbstractCopyModel will have the "duplication creation" function just by initializing the "view action".

Edit this page
Last Updated:1/15/26, 4:02 AM
Prev
Development Aid:Implementing Page Data Linkage in Low-Code
Next
Development Aid:Generating API Documentation with GraphQL
默认页脚
Copyright © 2026 Mr.Hope