<?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.artfess.bpm.persistence.dao.BpmDefAuthorizeTypeDao">
	<resultMap id="BpmDefAuthorizeType" type="com.artfess.bpm.persistence.model.BpmDefAuthorizeType">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="authorizeId" column="AUTHORIZE_ID_" jdbcType="VARCHAR"/>
		<result property="authorizeType" column="AUTHORIZE_TYPE_" jdbcType="VARCHAR"/>
		
	</resultMap>
	
	<sql id="columns">
		ID_,AUTHORIZE_ID_,AUTHORIZE_TYPE_
	</sql>
	
	<sql id="dynamicWhere">
		<where>
			<if test="id!=null"> AND ID_  =#{id} </if>
			<if test="authorizeId!=null"> AND AUTHORIZE_ID_  =#{authorizeId} </if>
			<if test="authorizeType!=null"> AND AUTHORIZE_TYPE_  =#{authorizeType} </if>	
		</where>
	</sql>

	<insert id="create" parameterType="com.artfess.bpm.persistence.model.BpmDefAuthorizeType">
		INSERT INTO BPM_DEF_AUTH_TYPE
		(ID_,AUTHORIZE_ID_,AUTHORIZE_TYPE_)
		VALUES
		(#{id,jdbcType=VARCHAR}, #{authorizeId,jdbcType=NUMERIC}, #{authorizeType,jdbcType=VARCHAR}
		)
	</insert>
	
	<delete id="delById" parameterType="java.lang.String">
		DELETE FROM BPM_DEF_AUTH_TYPE 
		WHERE
		ID_=#{id}
	</delete>
	
	<delete id="delByMap" parameterType="java.util.Map" >
		DELETE FROM BPM_DEF_AUTH_TYPE 
		    <include refid="dynamicWhere" />
	</delete>
	
	<select id="getAll" parameterType="java.util.Map" resultMap="BpmDefAuthorizeType">
		SELECT <include refid="columns"/>
		FROM BPM_DEF_AUTH_TYPE   
		<include refid="dynamicWhere" />
		<if test="orderField!=null">
		order by ${orderField} ${orderSeq}
		</if>
		<if test="orderField!=null">
		order by ID_  desc
		</if>
	</select>
	
	<delete id="delByAuthorizeId" parameterType="java.lang.String">
		DELETE FROM BPM_DEF_AUTH_TYPE 
			WHERE AUTHORIZE_ID_=#{authorizeId}
	</delete>
	
	<select id="get"   parameterType="java.lang.String" resultMap="BpmDefAuthorizeType">
		SELECT * FROM BPM_DEF_AUTH_TYPE 
		WHERE 
		ID_=#{id}
	</select>
	
	<select id="query" parameterType="java.util.Map" resultMap="BpmDefAuthorizeType">
		SELECT * FROM BPM_DEF_AUTH_TYPE
		<where>
			<if test="whereSql!=null">
				${whereSql}
			</if>
		</where>
		<if test="orderBySql!=null">
			ORDER BY ${orderBySql}
		</if>
		<if test="orderBySql==null">
			ORDER BY id_ DESC
		</if>
	</select>
	
	<delete id="remove" parameterType="java.lang.String">
		DELETE FROM BPM_DEF_AUTH_TYPE 
		WHERE
		ID_=#{id}
	</delete>
	
</mapper>
