mybatis循环map的一些技巧

标签的用法:
六个参数:
collection:要循环的集合
index:循环索引(不知道啥用。。)
item:集合中的一个元素(item和collection,按foreach循环理解)
open:以什么开始
close:以什么结束
separator:循环内容之间以什么分隔


<update id="buildTableSQL" statementType="STATEMENT">
        <if test="dbType !=null and dbType == 'mysql'">
            create table net_${netGenDbTable.name} (
                   id  int(11) not null auto_increment comment 'id',
                   url varchar(255) comment '采集来源url',
                   spider_jobid varchar(64) comment '爬虫工作id',
                   <foreach collection="netGenDbTable.columnList" item="cloumn">
                            ${cloumn.name} 
                            ${cloumn.jdbcType}
                            <choose>
                                <when test="cloumn.dataLen != null and cloumn.dataLen !='' "> 
                                    (${cloumn.dataLen}) 
                                </when>
                            </choose> 
                            <choose>
                                <when test="cloumn.canNull == '0'"> comment ${cloumn.comments} </when>
                                <when test="cloumn.canNull == '1'">
                                    ${cloumn.jdbcType} not null 
                                    <choose>
                                        <when test="cloumn.defaultVal != null and cloumn.defaultVal != ''"> 
                                            default ${cloumn.defaultVal} comment ${cloumn.comments}
                                        </when>
                                        <otherwise> 
                                            comment '-'
                                        </otherwise>
                                    </choose>
                                </when>
                            </choose>
                            ,
                   </foreach>
                   remarks varchar(2000) comment '备注',
                   create_by varchar(32) comment '创建人',
                   create_date timestamp not null default current_timestamp comment '创建时间',
                   update_by varchar(32) comment '更新人',
                   update_date timestamp not null default '0000-00-00 00:00:00' comment '更新时间',
                   del_flag char(1) default '0' not null comment '逻辑删除标记(0:显示;1:隐藏)',
                   primary key (id),
                   unique index net_${netGenDbTable.name}_idx_001(url),
                   index net_${netGenDbTable.name}_idx_002(spider_jobid)
             ) 
        </if>
        <!-- create index ix_${tableName}_m_010101 on ${tableName} (m_010101); -->
    </update>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值