<?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必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.workflow.dao.ProcessSetDAO">
	<resultMap id="ProcessSetMap" type="com.jpsoft.shinestar.modules.workflow.entity.ProcessSet">
		<id property="id" column="id_" />
			<result property="name" column="name_" />
			<result property="proKey" column="pro_key" />
			<result property="remark" column="remark_" />
			<result property="formId" column="form_id" />
			<result property="category" column="category_" />
			<result property="companyId" column="company_id" />
			<result property="createBy" column="create_by" />
			<result property="createTime" column="create_time" />
			<result property="updateBy" column="update_by" />
			<result property="updateTime" column="update_time" />
			<result property="delFlag" column="del_flag" />
			<result property="status" column="status_" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.workflow.entity.ProcessSet">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into wf_process_set
	    (id_,name_,pro_key,remark_,form_id,category_,company_id,create_by,create_time,update_by,update_time,del_flag,status_)
		values
		(
#{id,jdbcType=VARCHAR}
,#{name,jdbcType=VARCHAR}
,#{proKey,jdbcType=VARCHAR}
,#{remark,jdbcType=VARCHAR}
,#{formId,jdbcType=VARCHAR}
,#{category,jdbcType=VARCHAR}
,#{companyId,jdbcType=VARCHAR}
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
,#{delFlag,jdbcType= NUMERIC }
,#{status,jdbcType= NUMERIC }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from wf_process_set where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.workflow.entity.ProcessSet">
		update wf_process_set
		<set>
				<if test="name!=null">
		name_=#{name,jdbcType=VARCHAR},
		</if>
			<if test="proKey!=null">
				pro_key=#{proKey,jdbcType=VARCHAR},
			</if>
				<if test="remark!=null">
		remark_=#{remark,jdbcType=VARCHAR},
		</if>
				<if test="formId!=null">
		form_id=#{formId,jdbcType=VARCHAR},
		</if>
				<if test="category!=null">
		category_=#{category,jdbcType=VARCHAR},
		</if>
				<if test="companyId!=null">
		company_id=#{companyId,jdbcType=VARCHAR},
		</if>
				<if test="createBy!=null">
		create_by=#{createBy,jdbcType=VARCHAR},
		</if>
				<if test="createTime!=null">
		create_time=#{createTime,jdbcType= TIMESTAMP },
		</if>
				<if test="updateBy!=null">
		update_by=#{updateBy,jdbcType=VARCHAR},
		</if>
				<if test="updateTime!=null">
		update_time=#{updateTime,jdbcType= TIMESTAMP },
		</if>
				<if test="delFlag!=null">
			del_flag=#{delFlag,jdbcType= NUMERIC },
		</if>
			<if test="status!=null">
				status_=#{status,jdbcType= NUMERIC },
			</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="ProcessSetMap">
		select 
id_,name_,pro_key,remark_,form_id,category_,company_id,create_by,create_time,update_by,update_time,del_flag,status_		from wf_process_set where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from wf_process_set where id_=#{0}
	</select>
	<select id="list" resultMap="ProcessSetMap">
		<![CDATA[
			select * from wf_process_set where del_flag = false order by create_time desc
		]]>
	</select>
	<select id="search" parameterType="hashmap" resultMap="ProcessSetMap">
		<![CDATA[
			select * from wf_process_set
		]]>
		<where>
			del_flag = false
			<if test="searchParams.name != null">
				and name_ like #{searchParams.name}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>
</mapper>