<?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.ConditionMapper">

	<sql id="conditionColumns">
		a.id AS "id",
		a.name AS "name",
		a.expression AS "expression",
		a.remarks AS "remarks"
	</sql>

	<sql id="conditionJoins">

	</sql>


	<select id="get" resultType="Condition" >
		SELECT
			<include refid="conditionColumns"/>
		FROM act_extension_condition a
		<include refid="conditionJoins"/>
		WHERE a.id = #{id}
	</select>

	<select id="findList" resultType="Condition" >
		SELECT
			<include refid="conditionColumns"/>
		FROM act_extension_condition a
		<include refid="conditionJoins"/>
		<where>

			${dataScope}
			<if test="name != null and name != ''">
				AND a.name LIKE
					<if test="_databaseId == 'postgre'">'%'||#{name}||'%'</if>
					<if test="_databaseId == 'oracle'">'%'||#{name}||'%'</if>
					<if test="_databaseId == 'mssql'">'%'+#{name}+'%'</if>
					<if test="_databaseId == 'mysql'">concat('%',#{name},'%')</if>
			</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="Condition" >
		SELECT
			<include refid="conditionColumns"/>
		FROM act_extension_condition a
		<include refid="conditionJoins"/>
		<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_condition(
			id,
			name,
			expression,
			remarks
		) VALUES (
			#{id},
			#{name},
			#{expression},
			#{remarks}
		)
	</insert>

	<update id="update">
		UPDATE act_extension_condition SET
			name = #{name},
			expression = #{expression},
			remarks = #{remarks}
		WHERE id = #{id}
	</update>


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

	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE act_extension_condition SET
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>


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

</mapper>
