mybatis常用的crud语法结构

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="order-marketingAudit" >

	<select id="getMarketingAuditList" resultType="order-marketingAuditDTO" parameterType="hashmap" >
		SELECT
		ID,CREATE_BY,CREATE_TIME,UPDATE_BY,UPDATE_TIME,COUPON_ID,UID,QRCODE,ORDER_ID,ORDER_CODE,ORDER_LINE_ID,COMMISSION_TYPE,COMMISSION_RATE,STATUS,AUDIT_AMOUNT,IS_DEL		FROM marketing_audit WHERE 1=1
		<if test="createTime_begin != null and createTime_begin != ''">
			AND CREATE_TIME <![CDATA[ >= ]]> #{
   createTime_begin}
		</if>
		<if test="createTime_end != null and createTime_end != ''">
			AND CREATE_TIME <![CDATA[ <= ]]> #{
   createTime_end}
		</if>
		<if test="updateTime_begin != null and updateTime_begin != ''">
			AND UPDATE_TIME <![CDATA[ >= ]]> #{
   updateTime_begin}
		</if>
		<if test="updateTimee_end != null and updateTimee_end != ''">
			AND UPDATE_TIME <![CDATA[ <= ]]> #{
   updateTime_end}
		</if>
		<if test="id != null and id != ''">
			AND ID=#{
   id}
		</if>
		<if test="createBy != null and createBy != ''">
			AND CREATE_BY=#{
   createBy}
		</if>
		<if test="createTime != null and createTime != ''">
			AND CREATE_TIME=#{
   createTime}
		</if>
		<if test="updateBy != null and updateBy != ''">
			AND UPDATE_BY=#{
   updateBy}
		</if>
		<if test="updateTime != null and updateTime != ''">
			AND UPDATE_TIME=#{
   updateTime}
		</if>
		<if test="couponId != null and couponId != ''">
			AND COUPON_ID=#{
   couponId}
		</if>
		<if test="uid != null and uid != ''">
			AND UID=#{
   uid}
		</if>
		<if test="qrcode != null and qrcode != ''">
			AND QRCODE=#{
   qrcode}
		</if>
		<if test="orderId != null and orderId != ''">
			AND ORDER_ID=#{
   orderId}
		</if>
		<if test="orderCode != null and orderCode != ''">
			AND ORDER_CODE=#{
   orderCode}
		</if>
		<if test="orderLineId != null and orderLineId != ''">
			AND ORDER_LINE_ID=#{
   orderLineId}
		</if>
		<if test="commissionType != null and commissionType != ''">
			AND COMMISSION_TYPE=#{
   commissionType}
		</if>
		<if test="commissionRate != null and commissionRate != ''">
			AND COMMISSION_RATE=#{
   commissionRate}
		</if>
		<if test="status != null and status != ''">
			AND STATUS=#{
   status}
		</if>
		<if test="auditAmount != null and auditAmount != ''">
			AND AUDIT_AMOUNT=#{
   auditAmount}
		</if>
		<if test="isDel != null and isDel != ''">
			AND IS_DEL=#{
   isDel}
		</if>
		<choose>
			<when test="createTimeSort == 1">
				ORDER BY CREATE_TIME ASC
			</when>
			<when test="createTimeSort == 2">
				ORDER BY CREATE_TIME DESC
			</when>
			<when test="updateTimeSort == 1">
				ORDER BY UPDATE_TIME ASC
			</when>
			<when test="updateTimeSort == 2">
				ORDER BY UPDATE_TIME DESC
			</when>
			<otherwise>
				ORDER BY ID DESC
			</otherwise>
		</choose>
		<if test="pageNo != null and pageNo >= 0 and pageSize != null and pageSize >= 0">
			LIMIT #{
   pageNo}, #{
   pageSize}
		</if>
	</select>

	<select id="getMarketingAuditCount" parameterType="hashmap" resultType="long">
		SELECT COUNT(1) FROM marketing_audit WHERE 1=1  
		<if test="createTime_begin != null and createTime_begin != ''">
			AND CREATE_TIME <![CDATA[ >= ]]> #{
   createTime_begin}
		</if>
		<if test="createTime_end != null and createTime_end != ''">
			AND CREATE_TIME <![CDATA[ <= ]]> #{
   createTime_end}
		</if>  
		<if test="id != null and id != ''">
			AND ID=#{
   id}
		</if>
		<if test="createBy != null and createBy != ''">
			AND CREATE_BY=#{
   createBy}
		</if>
		<if test="createTime != null and createTime != ''">
			AND CREATE_TIME=#{
   createTime}
		</if>
		<if test="updateBy != null and updateBy != ''">
			AND UPDATE_BY=#{
   updateBy}
		</if>
		<if test="updateTime != null and updateTime != ''">
			AND UPDATE_TIME=#{
   updateTime}
		</if>
		<if test="couponId != null and couponId != ''">
			AND COUPON_ID=#{
   couponId}
		</if>
		<if test="uid != null and uid != ''">
			AND UID=#{
   uid}
		</if>
		<if test="qrcode != null and qrcode != ''">
			AND QRCODE=#{
   qrcode}
		</if>
		<if test="orderId != null and orderId != ''">
			AND ORDER_ID=#{
   orderId}
		</if>
		<if test="orderCode != null and orderCode != ''">
			AND ORDER_CODE=#{
   orderCode}
		</if>
		<if test="orderLineId != null and orderLineId != ''">
			AND ORDER_LINE_ID=#{
   orderLineId}
		</if>
		<if test="commissionType != null and commissionType != ''">
			AND COMMISSION_TYPE=#{
   commissionType}
		</if>
		<if test="commissionRate != null and commissionRate != ''">
			AND COMMISSION_RATE=#{
   commissionRate}
		</if>
		<if test="status != null and status != ''">
			AND STATUS=#{
   status}
		</if>
		<if test="auditAmount != null and auditAmount != ''">
			AND AUDIT_AMOUNT=#{
   auditAmount}
		</if>
		<if test="isDel != null and isDel != ''">
			AND IS_DEL=#{
   isDel}
		</if
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值