leaf 关于同行结构的使用

Leaf 关于同行结构的使用

第一步:
创建两个grid组件用于存放数据
代码如下:

   <a:form column="2" width="600" id="dataForm">
            //注:bintarget 的作用是绑定数据源
            //查找国家信息
                <a:grid id="query_country" bindTarget="query_country_name" height="400" navBar="true" width="400">
                    <a:toolBar>
                        <a:button type="add"/>
                        <a:button type="delete"/>
                        <a:button type="clear"/>
                        <a:button type="save"/>
                        <a:button text="保存数据" click="save_data"/>
                    </a:toolBar>
                    <a:columns>
                        <a:column name="description" prompt="国家名" editor="txt_editor" width="200"/>
                    </a:columns>
                    <a:editors>
                        <a:textField id="txt_editor"/>
                    </a:editors>
                </a:grid>
                       //查找省份信息
                <a:grid bindTarget="query_province" height="400" id="province_info" navBar="true" width="200">
                    <a:toolBar>
                        <a:button type="add"/>
                        <a:button type="delete"/>
                        <a:button type="clear"/>
                    </a:toolBar>
                    <a:columns>
                        <a:column name="description" prompt="省名称" editor="txt_editor_or" width="150"/>

                    </a:columns>
                    <a:editors>

                        <a:textField id="txt_editor_or"/>
                    </a:editors>
                </a:grid>

            </a:form>

接下来书写dataSet 的 code;

  <a:dataSet id="query_country_name" fetchAll="false" model="course1907.DEMO1.cus_201907_demo2_val"
                           autoCount="true" autoQuery="true" autoPageSize="true" selectable="true"
                           submitUrl="${/request/@context_path}/modules/course1907/DEMO1/cus_201907_demo_update.lsc">
                    <a:fields>
                        <a:field name="description">    
                        </a:field>
                        <a:field name="country_id"></a:field>
                    </a:fields>
                    <a:events>
                        <a:event name="indexchange" handler="indexChangeFunction"/>
                    </a:events>
                </a:dataSet>

其中,必须要注意的是 model 对应的文件course1907.DEMO1.cus_201907_demo2_val这里面必须要对主键字段给出定义。 submitUrl为自己编写的一个isc文件,isc 需要经过页面注册和分配才能够使用。
在这里插入图片描述
sourcepath="/parameter" 为传递的json 格式的数据, <p:switch test="@current_parameter/@_status"> 就是取当前数据的状态, <p:case value="update">
对到底是进行insert,update还是delete 进行判断,进入到相应的循环体内,

  <a:model-update model="course1907.DEMO1.cus_201907_demo2_val"/>
 <a:model-batch-update model="course1907.DEMO1.cus_201907_demo1_val" sourcepath="@current_parameter/country_ds"/> 对json  数据进行级联取值判断。

然后看字表的数据源

<a:dataSet id="query_province" fetchAll="true" bindName="country_ds" bindTarget="query_country_name"
                           model="course1907.DEMO1.cus_201907_demo1_val" autoPageSize="true" selectable="true"
                           queryUrl="${/request/@context_path}/autocrud/course1907.DEMO1.cus_201907_demo1_val/query">
                    <a:fields>
                        <a:field name="province_id">

                        </a:field>
                        <a:field name="description"/>
                    </a:fields>

                </a:dataSet>

bindName=“country_ds” 为json 数据取值时的路径,bindTarget="query_country_name"为父表的id ,bindTarget="query_country_name为字表自己的lwm文件,里面对主键和外键进行声明。文件如下

<?xml version="1.0" encoding="UTF-8"?>
<ns1:model xmlns:ns2="leaf.database.local.oracle" xmlns:ns1="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="fp" baseTable="fnd_province">
    <ns1:fields>
        <ns1:field name="country_id" databaseType="BIGINT" datatype="java.lang.Long" insertExpression="${../../@country_id}" updateExpression="${../../@country_id}"/>
        <ns1:field name="province_id" databaseType="BIGINT" datatype="java.lang.Long" physicalName="PROVINCE_ID"/>
        <ns1:field name="description" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="250" forDisplay="true" forQuery="true" physicalName="DESCRIPTION" prompt="HLS.DESCRIPTION"/>
    </ns1:fields>
    <ns1:primary-key>
        <ns1:pk-field name="province_id"/>
    </ns1:primary-key>
    <ns1:query-fields>
        <ns1:query-field field="country_id" queryOperator="="/>
    </ns1:query-fields>
    <ns1:features>
        <f:multi-language-storage/>
        <ns2:sequence-pk/>
        <f:standard-who/>
    </ns1:features>
    <ns1:ref-fields/>
</ns1:model>

要注意的是主键必须加上insertExpression="${../../@country_id}" updateExpression="${../../@country_id}",目的是取到相应的id值,能够进行插入和更新操作。
在这里插入图片描述
定义字表的主键,和父表的主键(用于查询字表)。

最终,leaf 的同行结构的操作就完成啦~~~~~~~~

根据提供的引用内容,我无法找到关于MyBatis Plus使用美团Leaf的具体信息。但是,我可以为您提供一些关于MyBatis Plus和Leaf的基本介绍。 MyBatis Plus是一个基于MyBatis的增强工具,它简化了MyBatis的开发流程,提供了更多的便利功能,如自动生成代码、分页查询、逻辑删除等。它可以与各种数据库进行集成,并提供了丰富的API和注解,使得开发更加高效和便捷。 美团的Leaf是一个分布式ID生成系统,它可以生成全局唯一的ID。Leaf提供了两种ID生成算法:基于数据库的分段生成ID和雪花算法生成分布式ID。这些算法可以确保生成的ID在分布式环境下是唯一的。 如果您想在MyBatis Plus中使用美团Leaf,您可以按照以下步骤进行操作: 1. 首先,您需要将Leaf集成到您的项目中。您可以通过引用美团Leaf的Git仓库或者下载源代码来获取Leaf。 2. 然后,您需要根据Leaf的文档和示例代码,配置Leaf的相关参数,如数据库连接信息、ID生成算法等。 3. 接下来,您可以在MyBatis Plus的Mapper接口中定义一个方法,用于生成ID。您可以使用Leaf提供的API来生成ID,并将其作为参数传递给您的SQL语句。 4. 最后,您可以在您的业务逻辑中调用该方法,以生成唯一的ID。 请注意,以上步骤仅为一种可能的集成方式,具体的实现方式可能因项目需求和配置而有所不同。建议您参考美团Leaf的官方文档和示例代码,以获得更详细的集成指南和使用方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值