<?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="ActivityInfoConfig">

	<resultMap id="RM_ActivityInfoConfig" type="com.blueland.bpm.engine.config.model.ActivityInfoConfig">
        <result property="activityDefId" column="ACTIVITY_DEF_ID"/>
        <result property="activityDefName" column="ACTIVITY_DEF_NAME"/>
        <result property="activityStatusName" column="ACTIVITY_STATUS_NAME"/>
        <result property="processDefId" column="PROCESS_DEF_ID"/>
        <result property="processDefName" column="PROCESS_DEF_NAME"/>
        <result property="activityPageUrl" column="ACTIVITY_PAGE_URL"/>
        <result property="activityPageInfo" column="ACTIVITY_PAGE_INFO"/>
        <result property="activityOperationRoleid" column="ACTIVITY_OPERATION_ROLEID"/>
        <result property="jumpType" column="JUMP_TYPE"/>
        <result property="activityOrder" column="ACTIVITY_ORDER"/>
        <result property="activityLimitTime" column="ACTIVITY_LIMIT_TIME"/>
        <result property="ideaDisplayArea" column="IDEA_DISPLAY_AREA"/>
        <result property="isShowIdea" column="IS_SHOW_IDEA"/>
        <result property="activityDefType" column="ACTIVITY_DEF_TYPE"/>
        <result property="activityDefChildType" column="ACTIVITY_DEF_CHILD_TYPE"/>   
        <result property="activityDefDealType" column="ACTIVITY_DEF_DEAL_TYPE"/>
        <result property="remark" column="REMARK"/>
        <result property="otherSysDealStatus" column="OTHER_SYS_DEAL_STATUS"/>
        <result property="isStartUserTask" column="IS_START_USERTASK"/>
        <result property="cprotocol" column="C_PROTOCL"/>
        <result property="murl" column="M_URL"/>
        <result property="mprotocol" column="M_PROTOCL"/>
	</resultMap>
	
	<!-- 用于select查询公用抽取的列 -->
	<sql id="ActivityInfoConfig.columns">
	    <![CDATA[
		ACTIVITY_DEF_DEAL_TYPE,ACTIVITY_DEF_CHILD_TYPE,ACTIVITY_DEF_TYPE,ACTIVITY_ORDER,ACTIVITY_DEF_ID,JUMP_TYPE,ACTIVITY_DEF_NAME,ACTIVITY_STATUS_NAME,PROCESS_DEF_ID,PROCESS_DEF_NAME,ACTIVITY_PAGE_URL,ACTIVITY_PAGE_INFO,ACTIVITY_OPERATION_ROLEID,ACTIVITY_LIMIT_TIME,IDEA_DISPLAY_AREA,IS_SHOW_IDEA,REMARK,
		OTHER_SYS_DEAL_STATUS,IS_START_USERTASK,C_PROTOCL,M_URL,M_PROTOCL
	    ]]>
	</sql>

	<!-- useGeneratedKeys="true" keyProperty="xxx" for sqlserver and mysql -->
	<insert id="ActivityInfoConfig.insert" useGeneratedKeys="false" keyProperty="activityDefId">
    <![CDATA[
        INSERT INTO T_WF_ACTIVITY_INFO_CONFIG (
        	ACTIVITY_DEF_ID ,
        	ACTIVITY_DEF_NAME ,
        	ACTIVITY_STATUS_NAME,
        	PROCESS_DEF_ID ,
        	PROCESS_DEF_NAME ,
        	ACTIVITY_PAGE_URL ,
        	ACTIVITY_PAGE_INFO ,
        	ACTIVITY_OPERATION_ROLEID ,
        	JUMP_TYPE,
        	ACTIVITY_ORDER,
        	ACTIVITY_LIMIT_TIME,
        	IDEA_DISPLAY_AREA,
        	IS_SHOW_IDEA,
        	ACTIVITY_DEF_TYPE,
        	ACTIVITY_DEF_CHILD_TYPE,
        	ACTIVITY_DEF_DEAL_TYPE,
        	REMARK,
        	OTHER_SYS_DEAL_STATUS ,
        	C_PROTOCL,M_URL,M_PROTOCL
        	
        ) VALUES (
        	#{activityDefId,jdbcType=VARCHAR} ,
        	#{activityDefName,jdbcType=VARCHAR} ,
        	#{activityStatusName,jdbcType=VARCHAR} ,
        	#{processDefId,jdbcType=VARCHAR} ,
        	#{processDefName,jdbcType=VARCHAR} ,
        	#{activityPageUrl,jdbcType=VARCHAR} ,
        	#{activityPageInfo,jdbcType=CLOB} ,
        	#{activityOperationRoleid,jdbcType=VARCHAR} ,
        	#{jumpType,jdbcType=VARCHAR} ,
        	#{activityOrder,jdbcType=INTEGER} ,
        	#{activityLimitTime,jdbcType=INTEGER} ,
        	#{ideaDisplayArea,jdbcType=VARCHAR} ,
        	#{isShowIdea,jdbcType=VARCHAR} ,
        	#{activityDefType,jdbcType=VARCHAR} ,
        	#{activityDefChildType,jdbcType=VARCHAR} ,
        	#{activityDefDealType,jdbcType=VARCHAR} ,
        	#{remark,jdbcType=VARCHAR},
        	#{otherSysDealStatus,jdbcType=VARCHAR} ,
        	#{cprotocol,jdbcType=VARCHAR} ,
        	#{murl,jdbcType=VARCHAR} ,
        	#{mprotocol,jdbcType=VARCHAR}
        )
    ]]>
		<!--	
			oracle: order="BEFORE" SELECT sequenceName.nextval AS ID FROM DUAL 
			DB2: order="BEFORE"" values nextval for sequenceName
		<selectKey resultType="java.lang.Long" order="BEFORE" keyProperty="userId">
			SELECT sequenceName.nextval AS ID FROM DUAL 
        </selectKey>
		-->
	</insert>
    
	<update id="ActivityInfoConfig.update" >
    <![CDATA[
        UPDATE T_WF_ACTIVITY_INFO_CONFIG SET
	        ACTIVITY_DEF_NAME = #{activityDefName,jdbcType=VARCHAR} ,
	        ACTIVITY_STATUS_NAME = #{activityStatusName,jdbcType=VARCHAR} ,
	        PROCESS_DEF_NAME = #{processDefName,jdbcType=VARCHAR} ,
	        ACTIVITY_PAGE_URL = #{activityPageUrl,jdbcType=VARCHAR} ,
	        ACTIVITY_PAGE_INFO = #{activityPageInfo,jdbcType=CLOB} ,
	        ACTIVITY_OPERATION_ROLEID = #{activityOperationRoleid,jdbcType=VARCHAR} ,
	        JUMP_TYPE = #{jumpType,jdbcType=VARCHAR} ,
	        ACTIVITY_ORDER=#{activityOrder,jdbcType=INTEGER} ,
	        ACTIVITY_LIMIT_TIME=#{activityLimitTime,jdbcType=INTEGER} ,
	        IDEA_DISPLAY_AREA=#{ideaDisplayArea,jdbcType=VARCHAR} ,
	        IS_SHOW_IDEA=#{isShowIdea,jdbcType=VARCHAR} ,
	        ACTIVITY_DEF_DEAL_TYPE=#{activityDefDealType,jdbcType=VARCHAR} ,
	        ACTIVITY_DEF_CHILD_TYPE=#{activityDefChildType,jdbcType=VARCHAR} ,
	        ACTIVITY_DEF_TYPE=#{activityDefType,jdbcType=VARCHAR} ,
	        REMARK = #{remark,jdbcType=VARCHAR},
	        OTHER_SYS_DEAL_STATUS=#{otherSysDealStatus,jdbcType=VARCHAR} ,
	        C_PROTOCL=#{cprotocol,jdbcType=VARCHAR} ,
	        M_URL=#{murl,jdbcType=VARCHAR} ,
	        M_PROTOCL=#{mprotocol,jdbcType=VARCHAR}
        WHERE 
	        ACTIVITY_DEF_ID = #{activityDefId}  AND 
	        PROCESS_DEF_ID = #{processDefId} 
    ]]>
	</update>
	
	
	
	<update id="ActivityInfoConfig.updateByProcessDefName" >
    <![CDATA[
        UPDATE T_WF_ACTIVITY_INFO_CONFIG SET 
	        PROCESS_DEF_NAME = #{processDefName,jdbcType=VARCHAR}
	    WHERE 
	        PROCESS_DEF_ID = #{processDefId} 
    ]]>
	</update>

    <delete id="ActivityInfoConfig.delete">
    <![CDATA[
        DELETE FROM T_WF_ACTIVITY_INFO_CONFIG WHERE
	        ACTIVITY_DEF_ID = #{activityDefId}  AND 
	        PROCESS_DEF_ID = #{processDefId} 
    ]]>
    </delete>
    
     <delete id="ActivityInfoConfig.deleteActivityInfoConfigs">
    <![CDATA[
        DELETE FROM T_WF_ACTIVITY_INFO_CONFIG WHERE 
	        PROCESS_DEF_ID = #{processDefId}
    ]]>
    </delete>
    
    
    <select id="ActivityInfoConfig.getById" resultMap="RM_ActivityInfoConfig">
		SELECT <include refid="ActivityInfoConfig.columns" />
	    <![CDATA[
		    FROM T_WF_ACTIVITY_INFO_CONFIG 
	        WHERE 
	        	ACTIVITY_DEF_ID = #{activityDefId}  AND 
	        	PROCESS_DEF_ID = #{processDefId} 
	    ]]>
	</select>
	
	<sql id="ActivityInfoConfig.findPage.where">
		<!-- ognl访问静态方法的表达式 为@class@method(args),以下为调用rapid中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用，具体请查看Ognl类 -->
		<where>	      				
	       <if test="@Ognl@isNotEmpty(activityDefId)">
				AND ACTIVITY_DEF_ID = #{activityDefId}
			</if>
	       <if test="@Ognl@isNotEmpty(activityDefName)">
				AND ACTIVITY_DEF_NAME = #{activityDefName}
			</if>
	       <if test="@Ognl@isNotEmpty(processDefId)">
				AND PROCESS_DEF_ID = #{processDefId}
			</if>
	       <if test="@Ognl@isNotEmpty(processDefName)">
				AND PROCESS_DEF_NAME = #{processDefName}
			</if>
	       <if test="@Ognl@isNotEmpty(activityOperationRoleid)">
				AND ACTIVITY_OPERATION_ROLEID = #{activityOperationRoleid}
			</if>
	       
		</where>
	</sql>
		
    <select id="ActivityInfoConfig.findPage.count" resultType="long">
        SELECT count(*) FROM T_WF_ACTIVITY_INFO_CONFIG 
		<include refid="ActivityInfoConfig.findPage.where"/>    
    </select>
    
    <!--
    	分页查询已经使用Dialect进行分页,也可以不使用Dialect直接编写分页
    	因为分页查询将传 offset,pageSize,lastRows 三个参数,不同的数据库可以根于此三个参数属性应用不同的分页实现
    -->
    <select id="ActivityInfoConfig.findPage" resultMap="RM_ActivityInfoConfig">
    	SELECT <include refid="ActivityInfoConfig.columns" />
	    FROM T_WF_ACTIVITY_INFO_CONFIG 
		<include refid="ActivityInfoConfig.findPage.where"/>
		ORDER BY ACTIVITY_ORDER
    </select>
</mapper>