Mybatis使用<choose> <when>
例子: order by
<sql id="Base_OrderBy">
<if test="orderBy != null and orderBy.size() > 0">
order by
<foreach collection="orderBy" item="item" separator=",">
<choose>
<when test="item.name == 'codeTabUuid'">
CODE_TAB_UUID
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'code'">
CODE
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'name'">
NAME
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'codeType'">
CODE_TYPE
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'parentUuid'">
PARENT_UUID
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'upLimit'">
UP_LIMIT
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'downLimit'">
DOWN_LIMIT
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'srcCode'">
SRC_CODE
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'srcName'">
SRC_NAME
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'srcParentCode'">
SRC_PARENT_CODE
<if test="item.direction != null">
${item.direction}
</if>
</when>
<when test="item.name == 'sortValue'">
SORT_VALUE
<if test="item.direction != null">
${item.direction}
</if>
</when>
<otherwise />
</choose>
</foreach>
</if>
</sql>