<?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.izouma.awesomeadmin.dao.SysDataruleMapper" >
	<resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.SysDatarule" >
		<id column="id" property="id" jdbcType="INTEGER" />
		<result column="datarule_name" property="dataruleName" jdbcType="VARCHAR" />
		<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
		<result column="del_flag" property="delFlag" jdbcType="CHAR" />
		<result column="permission" property="permission" jdbcType="VARCHAR" />
	</resultMap>
	<sql id="Base_Column_List" >
		 id, datarule_name, create_date, del_flag,permission
	</sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
		select
		<include refid="Base_Column_List" />
		from sys_datarule
		where id = #{id,jdbcType=INTEGER}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
		delete from sys_datarule
		where id = #{id,jdbcType=INTEGER}
	</delete>
	<insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.SysDatarule" useGeneratedKeys="true" keyProperty="id">
		insert into sys_datarule
		<trim prefix="(" suffix=")" suffixOverrides="," >
			<if test="id != null" >
				id,	
			</if>
			<if test="dataruleName != null" >
				datarule_name,	
			</if>
			<if test="createDate != null" >
				create_date,	
			</if>
			<if test="delFlag != null" >
				del_flag,	
			</if>
			<if test="permission != null" >
				permission,
			</if>

		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides="," >
			<if test="id != null" >
				#{id,jdbcType=INTEGER},	
			</if>
			<if test="dataruleName != null" >
				#{dataruleName,jdbcType=VARCHAR},	
			</if>
			<if test="createDate != null" >
				#{createDate,jdbcType=TIMESTAMP},	
			</if>
			<if test="delFlag != null" >
				#{delFlag,jdbcType=CHAR},	
			</if>
			<if test="permission != null" >
				#{permission,jdbcType=VARCHAR},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.SysDatarule" >
		update sys_datarule
		<set >
			<if test="dataruleName != null" >
				datarule_name = #{dataruleName,jdbcType=VARCHAR},	
			</if>
			<if test="createDate != null" >
				create_date = #{createDate,jdbcType=TIMESTAMP},	
			</if>
			<if test="delFlag != null" >
				del_flag = #{delFlag,jdbcType=CHAR},	
			</if>
			<if test="permission != null" >
				permission = #{permission,jdbcType=VARCHAR},
			</if>
		</set>
		where id = #{id,jdbcType=INTEGER}
	</update>
	<select id="querySysDatarulesByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SysDatarule">
		select <include refid="Base_Column_List"/> from sys_datarule
		<where>
			and del_flag = 'N'
			<if test="record.id != null and !&quot;&quot;.equals(record.id)">
				and id = #{record.id}	
			</if>
			<if test="record.dataruleName != null and !&quot;&quot;.equals(record.dataruleName)">
				and datarule_name = #{record.dataruleName}	
			</if>
			<if test="record.createDate != null and !&quot;&quot;.equals(record.createDate)">
				and create_date = #{record.createDate}	
			</if>
			<if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
				and del_flag = #{record.delFlag}	
			</if>
			<if test="record.permission != null and !&quot;&quot;.equals(record.permission)">
				and permission = #{record.permission}
			</if>
		</where>
		order by id desc
	</select>
	<select id="queryAllSysDatarule" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SysDatarule">
		select <include refid="Base_Column_List"/> from sys_datarule
		<where>
			and del_flag = 'N'
			<if test="id != null and !&quot;&quot;.equals(id)">
				and id = #{id}	
			</if>
			<if test="dataruleName != null and !&quot;&quot;.equals(dataruleName)">
				and datarule_name = #{dataruleName}	
			</if>
			<if test="createDate != null and !&quot;&quot;.equals(createDate)">
				and create_date = #{createDate}	
			</if>
			<if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
				and del_flag = #{delFlag}	
			</if>
			<if test="permission != null and !&quot;&quot;.equals(permission)">
				and permission = #{permission}
			</if>
		</where>
		order by id desc
	</select>
	<select id="querySysDatarule" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SysDatarule">
		select <include refid="Base_Column_List"/> from sys_datarule
		<where>
			and del_flag = 'N'
			<if test="id != null and !&quot;&quot;.equals(id)">
				and id = #{id}	
			</if>
			<if test="dataruleName != null and !&quot;&quot;.equals(dataruleName)">
				and datarule_name = #{dataruleName}	
			</if>
			<if test="createDate != null and !&quot;&quot;.equals(createDate)">
				and create_date = #{createDate}	
			</if>
			<if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
				and del_flag = #{delFlag}	
			</if>
			<if test="permission != null and !&quot;&quot;.equals(permission)">
				and permission = #{permission}
			</if>
		</where>
		LIMIT 1
	</select>
	<update id="delete">
		UPDATE sys_datarule SET del_flag = 'Y'
		<where>
			AND id = #{id}
		</where>
	</update>
</mapper>

