IDEA 插件 EasyCode 生成代碼

EasyCode 官方地址
有中文官網,安裝使用文檔一應俱全。就不多廢話了。

簡單看下生成代碼的界面

idea》database》 找到數據庫表 (支持多選)
在這裏插入圖片描述
右鍵》EeayCode》Generate Code
在這裏插入圖片描述

看下設置所在

在這裏插入圖片描述

自定義模板

mapper.xml里加個多條件列表查尋試試:

<!--多條件列表查尋-->
    <select id="listByParam" resultMap="$!{tableInfo.name}Map">
        select
            #allSqlColumn()
            
        from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name
        <trim prefix="WHERE" prefixOverrides="AND |OR ">
#foreach($column in $tableInfo.pkColumn)
            <if test="ids != null">
                <foreach item="item" index="index" collection="ids" open=" AND( " separator=" or " close=" ) ">
                    $column.obj.name = #{item}
                </foreach>
            </if>
#end
#foreach($column in $tableInfo.otherColumn)
            <if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
                $!column.obj.name = #{$!column.name},
            </if>
#if($column.type.equals("java.util.Date"))
            <if test="$!{column.name}Begin !=null and $!{column.name}Begin !=''">
                <![CDATA[ 
                    AND $!column.obj.name >= #{$!{column.name}Begin} 
                ]]>
            </if>
            <if test="$!{column.name}End !=null and $!{column.name}End !=''">
                <![CDATA[ 
                    AND $!column.obj.name >= #{$!{column.name}End} 
                ]]>
            </if>
#end
#end
        </trim>

		<if test="orderType == null or orderType == '' or orderType=='default'">
			order by $!column.obj.name asc
		</if>

        <if test="offset != null and offset == '' and limit != null and limit == ''">
			limit #{offset}, #{limit}
		</if>
        
    </select>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章