mybatis的mapper.xml用條件判斷做轉譯

紅衫先生_發表於2017-12-29
CASE type
    WHEN 0 THEN
    '稽核中'
    WHEN 1 THEN
    '稽核通過'
    WHEN 2 THEN
    '稽核失敗'
    END AS typeDesc,

舉個例子:

   <select id="selectTransferStatisticsList"  resultType="com.tansen.test.AuditVo">
        SELECT w.withdrawNo,w.transactionNo, w.amount, w.transferType,
        CASE type
            WHEN 0 THEN
            '稽核中'
            WHEN 1 THEN
            '稽核通過'
            WHEN 2 THEN
            '稽核失敗'
            END AS typeDesc

        FROM gp_agent_withdraw w  where actualRrivalStatus=1
        <if test="transferType != null">
            and w.transferType = #{transferType}
        </if>

        ORDER BY w.tranTime desc
    </select>

相關文章