OrderLogMapper.xml 2.31 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.OrderLogDaoBean">
	<resultMap id="OrderLogRM" type="OrderLog">
		<id property="id" column="id" />
		<result property="action" column="action" />
		<result property="actionTime" column="action_time" />
		<result property="userId" column="user_id" />
		<result property="userType" column="user_type" />
		<result property="orderId" column="order_id" />
		<result property="description" column="description" />
	</resultMap>

	<sql id="selectCondition">
		<if test="param != null">
			<if test="param.id != null and param.id != ''">
				and id = #{param.id}
			</if>
			<if test="param.action != null and param.action != ''">
				and action = #{param.action}
			</if>
			<if test="param.actionBeginTime != null and param.actionBeginTime != ''">
				<![CDATA[and action_time >= #{param.actionBeginTime}]]>
			</if>
			<if test="param.actionEndTime != null and param.actionEndTime != ''">
				<![CDATA[and action_time <= #{param.actionEndTime}]]>
			</if>
			<if test="param.userId != null and param.userId != ''">
				and user_id = #{param.userId}
			</if>
			<if test="param.userType != null and param.userType != ''">
				and user_type = #{param.userType}
			</if>
		</if>
	</sql>

	<insert id="save" parameterType="OrderLog">
		<![CDATA[
			INSERT INTO t_order_log(
	                    id,
	                    action,
	                    user_id,
	                    user_type,
	                    order_id,
	                    description
			) VALUES(
						#{id},
			        	#{action},
			        	#{userId},
			        	#{userType},
			        	#{orderId},
			        	#{description}
			)
		]]>
	</insert>


	<select id="countByCondition" parameterType="Query" resultType="Long">
		<![CDATA[
		SELECT count(1) FROM t_order_log where 1=1
		]]>
		<include refid="selectCondition" />
	</select>

	<select id="listByCondition" parameterType="Query" resultMap="OrderLogRM">
		<![CDATA[
		SELECT
		    id
		    ,action
		    ,action_time
		    ,user_id
		    ,user_type
		    ,order_id
		    ,description
		FROM t_order_log where 1=1
		]]>
		<include refid="selectCondition" />
		order by id desc
		<![CDATA[
		limit #{startRow},#{pageSize}
		]]>
	</select>

</mapper>