OrderItemMapper.xml 3.45 KB
<?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="com.b2c.orders.dao.impl.OrderItemDaoBean">
	<resultMap id="OrderItemRM" type="com.b2c.orders.domain.OrderItem">
		<id property="id" column="id" />
		<result property="orderId" column="order_id" />
		<result property="shopId" column="shop_id" />
		<result property="amount" column="amount" />
		<result property="versionNum" column="version_num" />
		<result property="editTime" column="edit_time" />
		<result property="createTime" column="create_time" />
		<result property="productId" column="product_id" />
		<result property="productName" column="product_name" />
		<result property="sku" column="sku" />
		<result property="skuTitle" column="sku_title" />
		<result property="skuAttributes" column="sku_attributes" />
		<result property="skuPrice" column="sku_price" />
		<result property="priceUnit" column="price_unit" />
		<result property="skuPicture" column="sku_picture" />
	</resultMap>

	<sql id="selectCondition">
		<if test="param != null">
			<if test="param.id != null and param.id != ''">
				and id = #{param.id}
			</if>
			<if test="param.orderId != null and param.orderId != ''">
				and order_id = #{param.orderId}
			</if>
			<if test="param.productId != null and param.productId != ''">
				and product_id = #{param.productId}
			</if>
			<if test="param.productName != null and param.productName != ''">
				and product_name = #{param.productName}
			</if>
			<if test="param.shopId != null and param.shopId != ''">
				and shop_id = #{param.shopId}
			</if>
			<if test="param.sku != null and param.sku != ''">
				and sku = #{param.sku}
			</if>
			<if test="param.skuTitle != null and param.skuTitle != ''">
				and sku_title = #{param.skuTitle}
			</if>
			<if test="param.skuAttributes != null and param.skuAttributes != ''">
				and sku_attributes = #{param.skuAttributes}
			</if>
			<if test="param.amount != null and param.amount != ''">
				and amount = #{param.amount}
			</if>
			<if test="param.skuPrice != null and param.skuPrice != ''">
				and sku_price = #{param.skuPrice}
			</if>
			<if test="param.priceUnit != null and param.priceUnit != ''">
				and price_unit = #{param.priceUnit}
			</if>
		</if>
	</sql>

	<select id="findByOrderId" parameterType="Long" resultMap="OrderItemRM">
	<![CDATA[
			SELECT
				id,
				order_id,
				product_id,
				product_name,
				shop_id,
				sku,
				sku_title,
				sku_attributes,
				amount,
				sku_price,
				price_unit,
				sku_picture,
				version_num,
				edit_time,
				create_time
			FROM t_order_item
			WHERE order_id = #{orderId}
		]]>
	</select>

	<insert id="save" parameterType="com.b2c.orders.domain.OrderItem">
		<![CDATA[
			INSERT INTO t_order_item(
	                    id,
	                    order_id,
	                    product_id,
	                    product_name,
	                    shop_id,
	                    sku,
	                    sku_title,
	                    sku_attributes,
	                    amount,
	                    sku_price,
	                    price_unit,
	                    sku_picture
			) VALUES(
						#{id},
			        	#{orderId},
			        	#{productId},
			        	#{productName},
			        	#{shopId},
			        	#{sku},
			        	#{skuTitle},
			        	#{skuAttributes},
			        	#{amount},
			        	#{skuPrice},
			        	#{priceUnit},
			        	#{skuPicture}
			)
		]]>
	</insert>

</mapper>