Mybatis choose when otherwise 标签

<select id="listAgentWithdrawApplyOrder" resultType="org.channel.entity.agent.AgentWithDrawApplyOrderDto">
	select * from t_agent_withdraw_apply_order
	// where 标签会去掉 SQL 前面多余的 and
	<where>
		<if test="withdrawType != null ">
			// 如果 withdrawType == 1 则查询条件为 and F_withdraw_type = 0
			// 如果 withdrawType == 2 则查询条件为 and F_withdraw_type = 5015
			// 如果 withdrawType != 1 || withdrawType != 2 则查询条件为 and F_withdraw_type in(5005,5067,5089)
			<choose>
				<when test="withdrawType == 1">
					and F_withdraw_type = 0
				</when>
				<when test="withdrawType == 2">
					and F_withdraw_type = 5015
				</when>
			</choose>
			<otherwise>
			  and F_withdraw_type in(5005,5067,5089)
			</otherwise>
		</if>
	</where>
</select>

  

posted @ 2022-06-27 10:30  变体精灵  阅读(24)  评论(0编辑  收藏  举报