mybatis-字符串判断

<select id="pageQueryAu"
parameterType="com.test.vo.PubParams"
resultMap="auVoResult">
SELECT 
a.au_id, a.au_name_cn, l.language, a.release_company,
        p.publisher_id, p.publisher_cn, 
<choose>
<when test="codeType == '2'.toString()">
a.i_status as mpr_status, 
2 as code_type, 
</when>
<otherwise>
a.m_status, 
1 as code_type, 
</otherwise>
</choose>
        a.create_time apply_code_time, a.app_time send_code_time 
        FROM 
        t_au a
  INNER JOIN 
  t_pub p ON a.publisher_id = p.publisher_id 
  LEFT JOIN 
  t_lang l ON a.language = l.lang_id 
  WHERE 
  p.group_id = #{groupId} 
<if test="publicationName != null and publicationName != ''">
AND LOWER(a.audio_name_cn) LIKE '%' || LOWER(TRIM(#{publicationName})) || '%'
</if>
  <if test="publisherCn != null and publisherCn != ''">
AND LOWER(p.publisher_cn) LIKE '%' || LOWER(TRIM(#{publisherCn})) || '%'
</if>
<if test="status != null and status != '' and codeType == '2'.toString()">
AND a.i_status = #{status}
</if>
<if test="status != null and status != '' and codeType == '1'.toString()">
AND a.m_status = #{status}
</if>
<!-- 
某个隐藏的SQL会将这个code_type的值由2改成了1,因此不用这个字段判断

<if test="codeType != null and codeType != ''">
AND a.code_type = #{codeType}
</if>
-->
<if test="codeType == '2'.toString()">
AND a.i_status is not null 
</if>
<if test="codeType == '1'.toString()">
AND a.m_status is not null 
</if>
ORDER BY
<choose>
<when test="order != null and order != ''">
${order} ${sort}
</when>
<otherwise>
a.create_time DESC
</otherwise>
</choose>
  limit #{rows} offset (#{page} - 1) * #{rows}

</select>



<resultMap id="auVoResult"
type="com.test.vo.AuVo"
extends="baseVoRsult">
<id property="auId" column="au_id" />
<result property="auNameCn" column="au_name_cn" />
<result property="language" column="language" />
<result property="releaseCompany" column="release_company" />
</resultMap>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值