choose与case对比

一个是动态标签,一个是sql原生语句

 

<where>
<if test="resType != null and resType != '' "> and c_type = #{resType} </if>
<if test="resName != null and resName != '' "> and c_key_name like "%${resName}%" </if>
<if test="priceType != null and priceType != '' ">
<choose>
<when test="priceType == 1 ">
and c_price = 0
</when>
<otherwise>
and c_price &gt; 0
</otherwise>
</choose>
</if>

<if test="list != null and list.size > 0">
and c_key_id in
<foreach item="cKeyId" index="index" collection="list" open="(" separator="," close=")">
#{cKeyId}
</foreach>
</if>
and c_del_flag = '0'
and n_r_state = '0'
and top_bottom_frame = '1'
</where>

 

 

 

CASE
WHEN TIMESTAMPDIFF( SECOND, a.t_update_time, NOW()) > 946080000 THEN CONCAT( TIMESTAMPDIFF( YEAR, a.t_update_time, NOW()) ,'年前')
WHEN TIMESTAMPDIFF( SECOND, a.t_update_time, NOW()) > 2592000 THEN CONCAT( TIMESTAMPDIFF( MONTH, a.t_update_time, NOW()) ,'个月前')
WHEN TIMESTAMPDIFF( SECOND, a.t_update_time, NOW()) > 86400 THEN CONCAT( TIMESTAMPDIFF( DAY, a.t_update_time, NOW()) ,'天前')
WHEN TIMESTAMPDIFF( SECOND, a.t_update_time, NOW()) > 3600 THEN CONCAT(TIMESTAMPDIFF(HOUR,a.t_update_time,NOW()), '小时前')
WHEN TIMESTAMPDIFF( SECOND, a.t_update_time, NOW()) > 60 THEN CONCAT(TIMESTAMPDIFF(MINUTE,a.t_update_time,NOW()), '分钟前')
ELSE CONCAT(TIMESTAMPDIFF(SECOND,a.t_update_time,NOW()), '刚刚')
END AS "interval",

jar包部署
nohup java -Xms64m -Xmx128m -jar educate-statistical-0.0.1.jar > statistical.txt 2>&1 &

posted @ 2022-05-05 10:43  liftsail  阅读(66)  评论(0编辑  收藏  举报