使用的是OGNL表达式,表达式格式为:${@prefix@methodName(传递参数名称)}
1、赋值时判断
SELECT * FROM USER WHERE name='${@org.apache.commons.lang3@StringUtils(name)}'
2、IF条件判断
<if test="@org.apache.commons.lang.StringUtils@isNotBlank(name)">name=#{name}</if>
<insert >
insert into myproperty (id,asset_id,asset_name,dept_name,brand,specifications,units,produce_time,indate,purchase_time,price,
total_money,address,classification,is_fixed) values
<foreach collection="list" item="property" separator=",">
(
${@cn.hutool.core.util.IdUtil@getSnowflake(1, 3).nextIdStr()},
${@cn.hutool.core.util.IdUtil@getSnowflake(1, 3).nextId()},
#{property.assetName},
#{property.deptName},
#{property.brand},
#{property.specifications},
#{property.units},
#{property.produceTime},
#{property.indate},
#{property.purchaseTime},
#{property.price},
#{property.price},
#{property.address},
#{property.classification},
<choose>
<when test="property.price > 1000">
'0'
</when>
<otherwise>
''
</otherwise>
</choose>
)
</foreach>
</insert>