<?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.TaskTurnAssignDao">
	<resultMap id="TaskTurnAssign" type="com.artfess.bpm.persistence.model.TaskTurnAssign">
		<id property="id" column="id_" jdbcType="VARCHAR"/>
		<result property="taskTurnId" column="task_turn_id_" jdbcType="VARCHAR"/>
		<result property="fromUserId" column="from_user_id_" jdbcType="VARCHAR"/>
		<result property="fromUser" column="from_user_" jdbcType="VARCHAR"/>
		<result property="receiverId" column="receiver_id_" jdbcType="VARCHAR"/>
		<result property="receiver" column="receiver" jdbcType="VARCHAR"/>
		<result property="createTime" column="create_time_" jdbcType="TIMESTAMP"/>
		<result property="comment" column="comment_" jdbcType="VARCHAR"/>
	</resultMap>
	
	<insert id="create" parameterType="com.artfess.bpm.persistence.model.TaskTurnAssign">
		INSERT INTO bpm_task_turnassign
		(id_,task_turn_id_,from_user_id_,from_user_,receiver_id_,receiver,create_time_,comment_)
		VALUES 
		(#{id,jdbcType=VARCHAR}, #{taskTurnId,jdbcType=VARCHAR}, #{fromUserId,jdbcType=VARCHAR}, #{fromUser,jdbcType=VARCHAR}, #{receiverId,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{comment,jdbcType=VARCHAR})
	</insert>
	
	<select id="get"   parameterType="java.lang.String" resultMap="TaskTurnAssign">
		SELECT * FROM bpm_task_turnassign 
		WHERE 
		id_=#{id}
	</select>
	
	<select id="query" parameterType="java.util.Map" resultMap="TaskTurnAssign">
		SELECT * FROM bpm_task_turnassign
		<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>
	
	<select id="getByTaskTurnId"   parameterType="java.lang.String" resultMap="TaskTurnAssign">
		SELECT * FROM bpm_task_turnassign 
		WHERE 
		task_turn_id_=#{taskTurnId}
	</select>
	
	
	<select id="getLastTaskAssign"   parameterType="java.lang.String" resultMap="TaskTurnAssign">
		SELECT * FROM bpm_task_turnassign 
		WHERE 
		task_turn_id_=#{taskTurnId} 
		<choose>
			<when test="isAsc">
				order by createTime asc
			</when>
			<otherwise>
				order by createTime desc
			</otherwise>
		</choose>
	</select>
	
	<delete id="remove" parameterType="java.lang.String">
		DELETE FROM bpm_task_turnassign 
		WHERE
		id_=#{id}
	</delete>
	
	
	
	
</mapper>