<?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.jeeplus.modules.extension.mapper.FormSettingMapper">

	<sql id="formSettingColumns">
		a.id AS "id",
		a.process_def_id AS "processDefId",
		a.task_def_id AS "taskDefId",
		a.form_readonly AS "formReadOnly",
		a.form_type AS "formType"
	</sql>

	<sql id="formSettingJoins">

	</sql>


	<select id="get" resultType="FormSetting" >
		SELECT
			<include refid="formSettingColumns"/>
		FROM act_extension_formsetting a
		<include refid="formSettingJoins"/>
		WHERE a.id = #{id}
	</select>

	<select id="queryByDefIdAndTaskId" resultType="FormSetting" >
		SELECT
		<include refid="formSettingColumns"/>
		FROM act_extension_formsetting a
		<include refid="formSettingJoins"/>
		WHERE a.process_def_id = #{processDefId} and  a.task_def_id = #{taskDefId}
	</select>

	<select id="findList" resultType="FormSetting" >
		SELECT
			<include refid="formSettingColumns"/>
		FROM act_extension_formsetting a
		<include refid="formSettingJoins"/>
		<where>

			${dataScope}
			<if test="processDefId != null and processDefId != ''">
				AND a.process_def_id = #{processDefId}
			</if>
			<if test="taskDefId != null and taskDefId != ''">
				AND a.task_def_id = #{taskDefId}
			</if>
			<if test="formReadOnly != null and formReadOnly != ''">
				AND a.form_readonly = #{formReadOnly}
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
			</otherwise>
		</choose>
	</select>

	<select id="findAllList" resultType="FormSetting" >
		SELECT
			<include refid="formSettingColumns"/>
		FROM act_extension_formsetting a
		<include refid="formSettingJoins"/>
		<where>

			${dataScope}
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
			</otherwise>
		</choose>
	</select>

	<insert id="insert">
		INSERT INTO act_extension_formsetting(
			id,
			process_def_id,
			task_def_id,
			form_readonly,
		    form_type
		) VALUES (
			#{id},
			#{processDefId},
			#{taskDefId},
			#{formReadOnly},
		    #{formType}
		)
	</insert>

	<update id="update">
		UPDATE act_extension_formsetting SET
			process_def_id = #{processDefId},
			task_def_id = #{taskDefId},
			form_readonly = #{formReadOnly},
		    form_type = #{formType}
		WHERE id = #{id}
	</update>


	<!--物理删除-->
	<update id="delete">
		DELETE FROM act_extension_formsetting
		WHERE id = #{id}
	</update>

	<update id="deleteByDefIdAndTaskId">
		DELETE FROM act_extension_formsetting
		WHERE process_def_id = #{processDefId} and  task_def_id = #{taskDefId}
	</update>

	<update id="deleteByProcessDefId">
		DELETE FROM act_extension_formsetting
		WHERE process_def_id = #{processDefId}
	</update>


	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="FormSetting" statementType="STATEMENT">
		select * FROM act_extension_formsetting  where ${propertyName} = '${value}'
	</select>

</mapper>
