<?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.SysTimetaskDao">
	<resultMap id="RM_SysTimetaskEntity" type="com.blueland.bo.SysTimetaskEntity">
        <result property="id" column="id"/>
        <result property="taskType" column="task_type"/>
        <result property="taskCode" column="task_code"/>
        <result property="description" column="description"/>
        <result property="cronExp" column="cron_exp"/>
        <result property="action" column="action"/>
        <result property="status" column="status"/>
        <result property="appId" column="app_id"/>
        <result property="createId" column="create_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateId" column="update_id"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
	</resultMap>

	<sql id="SysTimetaskEntityColumns">
        	id,
        	task_type,
        	task_code,
        	description,
        	cron_exp,
        	action,
        	status,
        	app_id,
        	create_id,
        	create_time,
        	update_id,
        	update_time,
        	remark
	</sql>
	
	<sql id="SysTimetaskEntityQueryColumns">
        	id,
        	task_type,
        	task_code,
        	description,
        	cron_exp,
        	action,
        	status,
        	app_id,
        	create_id,
        	create_time,
        	update_id,
        	update_time,
        	remark
	</sql>
	<!-- useGeneratedKeys="true" keyProperty="xxx" for sqlserver and mysql -->
	<insert id="insert" useGeneratedKeys="false" keyProperty="id">
        INSERT INTO t_pf_sys_timetask (<include refid="SysTimetaskEntityColumns"/>) VALUES (
        	#{id,jdbcType=VARCHAR},
        	#{taskType,jdbcType=VARCHAR},
        	#{taskCode,jdbcType=VARCHAR},
        	#{description,jdbcType=VARCHAR},
        	#{cronExp,jdbcType=VARCHAR},
        	#{action,jdbcType=VARCHAR},
        	#{status,jdbcType=VARCHAR},
        	#{appId,jdbcType=VARCHAR},
        	#{createId,jdbcType=VARCHAR},
		    #{createTime,jdbcType=TIMESTAMP},
        	#{updateId,jdbcType=VARCHAR},
        	#{updateTime,jdbcType=TIMESTAMP},
        	#{remark,jdbcType=VARCHAR}
        )
	</insert>
    
    <select id="get" resultMap="RM_SysTimetaskEntity">
		SELECT <include refid="SysTimetaskEntityQueryColumns"/>
	    FROM t_pf_sys_timetask 
        WHERE 
	        id = #{id,jdbcType=VARCHAR} 
	</select>
	
    <!--
    	分页查询已经使用Dialect进行分页,也可以不使用Dialect直接编写分页
    	因为分页查询将传 offset,pageSize,lastRows 三个参数,不同的数据库可以根于此三个参数属性应用不同的分页实现
    -->
    <select id="findList" resultMap="RM_SysTimetaskEntity">
    	SELECT <include refid="SysTimetaskEntityQueryColumns"/>
	    FROM t_pf_sys_timetask 
		<include refid="findList_where"/>
		
		<if test="@Ognl@isNotEmpty(bo.sortColumns)">
			ORDER BY ${bo.sortColumns}
		</if>
    </select>

	<select id="findPage" resultMap="RM_SysTimetaskEntity">
		SELECT <include refid="SysTimetaskEntityQueryColumns"/>
		FROM t_pf_sys_timetask
		<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.taskType)">
				AND task_type = #{bo.taskType,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.taskCode)">
				AND task_code = #{bo.taskCode,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.description)">
				AND description = #{bo.description,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.cronExp)">
				AND cron_exp = #{bo.cronExp,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.action)">
				AND action = #{bo.action,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.status)">
				AND status = #{bo.status,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.appId)">
				AND app_id = #{bo.appId,jdbcType=VARCHAR}
			</if>
	       <if test="@Ognl@isNotEmpty(bo.createId)">
				AND create_id = #{bo.createId,jdbcType=VARCHAR}
			</if>
	       
	       <if test="@Ognl@isNotEmpty(bo.updateId)">
				AND update_id = #{bo.updateId,jdbcType=VARCHAR}
			</if>
	       
	       <if test="@Ognl@isNotEmpty(bo.remark)">
				AND remark = #{bo.remark,jdbcType=VARCHAR}
			</if>
		</where>
	</sql>
    
    
    <select id="findSysTimetaskListByParams" resultMap="RM_SysTimetaskEntity">
		select <include refid="SysTimetaskEntityQueryColumns" /> from t_pf_sys_timetask T1
		<include refid="findList_where"/>
        <if test="@Ognl@isNotBlank(bo.orderByColumns)">order by ${bo.orderByColumns}</if>
	</select>

	<select id="findSysTimetaskPageByParams" resultMap="RM_SysTimetaskEntity">
		select <include refid="SysTimetaskEntityQueryColumns" /> from t_pf_sys_timetask T1
		<include refid="findList_where"/>
		<if test="@Ognl@isNotBlank(bo.orderByColumns)">order by ${bo.orderByColumns}</if>
	</select>
	
</mapper>

