MyBatis规则xml中<if>标签判断字符串相等怎么写

        SELECT
            count(1)
        from energy_alarm_loss_info
        where hier_id = #{hierId}
        and date_type = #{dateType}
        <if test="dateType == '日'.toString()">
            and date(create_time) = date(sysdate())
        </if>
        <if test="dateType == '月'.toString()">
            and year(create_time) = year(sysdate())
            and month(create_time) = month(sysdate())
        </if>

如果还不行,就写下面这样:

<if test="dateType.toString() == '日'.toString()">
posted @ 2025-04-25 15:12  十一点  阅读(348)  评论(0)    收藏  举报