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

	<sql id="buttonColumns">
		a.id AS "id",
		a.name AS "name",
		a.code AS "code",
		a.sort AS "sort"
	</sql>

	<sql id="buttonJoins">

	</sql>


	<select id="get" resultType="Button" >
		SELECT
			<include refid="buttonColumns"/>
		FROM act_extension_button a
		<include refid="buttonJoins"/>
		WHERE a.id = #{id}
	</select>

	<select id="findList" resultType="Button" >
		SELECT
			<include refid="buttonColumns"/>
		FROM act_extension_button a
		<include refid="buttonJoins"/>
		<where>

			${dataScope}
			<if test="name != null and name != ''">
				AND a.name = #{name}
			</if>
			<if test="code != null and code != ''">
				AND a.code = #{code}
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.code asc
			</otherwise>
		</choose>
	</select>

	<select id="findAllList" resultType="Button" >
		SELECT
			<include refid="buttonColumns"/>
		FROM act_extension_button a
		<include refid="buttonJoins"/>
		<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_button(
			id,
			name,
			code,
			sort
		) VALUES (
			#{id},
			#{name},
			#{code},
			#{sort}
		)
	</insert>

	<update id="update">
		UPDATE act_extension_button SET
			name = #{name},
			code = #{code},
			sort = #{sort}
		WHERE id = #{id}
	</update>


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

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


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

</mapper>
