IDEA-live-template 一些好用的 IDEA 模板代码汇集
mybatis
<if>
标签
<if test="judgeFullName != null ">
AND judge_full_name = #{judgeFullName}
</if>
输入代码 ,使用 Ctrl + Alt + J
选中,选择 IFA
<if test="$SELECTION$ != null ">
AND $VAR1$ $END$ = #{$SELECTION$}
</if>
<template name="IF" value="<if test="$SELECTION$ != null "> AND $VAR1$ $END$ = #{$SELECTION$} </if>" description="if" toReformat="true" toShortenFQNames="true">
<variable name="VAR1" expression="snakeCase(String)" defaultValue="$SELECTION$" alwaysStopAt="true" />
<context>
<option name="SQL" value="true" />
</context>
</template>
mybatis
<foreach>
标签
<foreach item="item" collection="List" separator="," open="(" close=")" index="">
#{item}
</foreach>
输入代码,使用 Ctrl + Alt + J
选中,选择 FI
<foreach item="item" collection="$SELECTION$" separator="," open="(" close=")" index="">
#{item}
</foreach>
<template name="FI" value="<foreach item="item" collection="$SELECTION$" separator="," open="(" close=")" index=""> #{item} </foreach>" description="for earch in" toReformat="true" toShortenFQNames="true">
<context>
<option name="SQL" value="true" />
</context>
</template>
MYSQL
LIKE CONCAT()
语句补全
LIKE CONCAT('%',#{judge_full_name} ,'%' )
输入代码,使用 Ctrl + Alt + J
选中,选择 LikeC
LIKE CONCAT('%',#{$SELECTION$} ,'%' )
<template name="LikeC" value="LIKE CONCAT('%',#{$SELECTION$} ,'%' )" description="Like Concat" toReformat="true" toShortenFQNames="true">
<context>
<option name="SQL" value="true" />
</context>
</template>