<?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">
<!-- 不使用namespace的话sql搜索定位会比较方便 -->
<mapper namespace="com.blueland.dao.SysPvlogDao">
	<resultMap id="RM_SysPvlogEntity" type="com.blueland.bo.SysPvlogEntity">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="bizId" column="biz_id"/>
        <result property="bizType" column="biz_type"/>
        <result property="aceessTitle" column="aceess_title"/>
        <result property="aceessIp" column="aceess_ip"/>
        <result property="aceessUrl" column="aceess_url"/>
        <result property="aceessTime" column="aceess_time"/>
        <result property="aceessSource" column="aceess_source"/>
        <result property="aceessDevice" column="aceess_device"/>
        <result property="aceessBrowse" column="aceess_browse"/>
		<result property="appId" column="app_id"/>
        <result property="remark" column="remark"/>
	</resultMap>

	<sql id="SysPvlogEntityColumns">
        	id,
        	user_id,
        	user_name,
        	biz_id,
        	biz_type,
        	aceess_title,
        	aceess_ip,
        	aceess_url,
        	aceess_time,
        	aceess_source,
        	aceess_device,
        	aceess_browse,
        	app_id,
        	remark
	</sql>
	
	<sql id="SysPvlogEntityQueryColumns">
        	id,
        	user_id,
        	user_name,
        	biz_id,
        	biz_type,
        	aceess_title,
        	aceess_ip,
        	aceess_url,
        	aceess_time,
        	aceess_source,
        	aceess_device,
        	aceess_browse,
        	app_id,
        	remark
	</sql>
    
    <select id="get" resultMap="RM_SysPvlogEntity">
		SELECT <include refid="SysPvlogEntityQueryColumns"/>
	    FROM t_pf_sys_pvlog 
        WHERE 
	        id = #{id,jdbcType=VARCHAR} 
	</select>
	
    <!--
    	分页查询已经使用Dialect进行分页,也可以不使用Dialect直接编写分页
    	因为分页查询将传 offset,pageSize,lastRows 三个参数,不同的数据库可以根于此三个参数属性应用不同的分页实现
    -->
    <select id="findList" resultMap="RM_SysPvlogEntity">
    	SELECT <include refid="SysPvlogEntityQueryColumns"/>
	    FROM t_pf_sys_pvlog 
		<include refid="findList_where"/>
		
		<if test="@Ognl@isNotEmpty(bo.sortColumns)">
			ORDER BY ${bo.sortColumns}
		</if>
    </select>

	<select id="findPage" resultMap="RM_SysPvlogEntity">
		SELECT <include refid="SysPvlogEntityQueryColumns"/>
		FROM t_pf_sys_pvlog
		<include refid="findList_where"/>

		<if test="@Ognl@isNotEmpty(bo.sortColumns)">
			ORDER BY ${bo.sortColumns}
		</if>
	</select>

	<sql id="findList_where">
		<!-- ognl访问静态方法的表达式 为@class@method(args),以下为调用rapid中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用，具体请查看Ognl类 -->
		<where>	      				
	       <if test="@Ognl@isNotEmpty(bo.id)">
				AND id = #{bo.id,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.userId)">
				AND user_id = #{bo.userId,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.userName)">
				AND user_name like CONCAT('%',#{bo.userName,jdbcType=VARCHAR},'%')
			</if>
	       <if test="@Ognl@isNotEmpty(bo.bizId)">
				AND biz_id = #{bo.bizId,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.bizType)">
				AND biz_type = #{bo.bizType,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.aceessTitle)">
				AND aceess_title = #{bo.aceessTitle,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.aceessIp)">
				AND aceess_ip = #{bo.aceessIp,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.aceessUrl)">
				AND aceess_url = #{bo.aceessUrl,jdbcType=VARCHAR}
			</if>
	       
	       <if test="@Ognl@isNotEmpty(bo.aceessSource)">
				AND aceess_source = #{bo.aceessSource,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.aceessDevice)">
				AND aceess_device = #{bo.aceessDevice,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.aceessBrowse)">
				AND aceess_browse = #{bo.aceessBrowse,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.appId)">
				AND app_id = #{bo.appId,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.remark)">
				AND remark = #{bo.remark,jdbcType=VARCHAR}
			</if>
		</where>
	</sql>
    
	<select id="findSysPvlogListByParams" resultMap="RM_SysPvlogEntity">
		select <include refid="SysPvlogEntityQueryColumns" /> from t_pf_sys_pvlog T1
		<include refid="findList_where"/>
        <if test="@Ognl@isNotBlank(bo.orderByColumns)">order by ${bo.orderByColumns}</if>
	</select>

	<select id="findSysPvlogPageByParams" resultMap="RM_SysPvlogEntity">
		select <include refid="SysPvlogEntityQueryColumns" /> from t_pf_sys_pvlog T1
		<include refid="findList_where"/>
		<if test="@Ognl@isNotBlank(bo.orderByColumns)">order by ${bo.orderByColumns}</if>
	</select>
	
</mapper>

