<?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.yunfeiyun.agmp.common.web.system.mapper.SysDictTypeMapper">

	<resultMap type="SysDictType" id="SysDictTypeResult">
		<id     property="dicttypeId"     column="dicttypeId"     />
		<result property="dicttypeName"   column="dicttypeName"   />
		<result property="dicttypeCode"   column="dicttypeCode"   />
		<result property="dicttypeCreator"   column="dicttypeCreator"   />
		<result property="dicttypeCreateddate"     column="dicttypeCreateddate"    />
		<result property="dicttypeModifieddate"     column="dicttypeModifieddate"    />
		<result property="dicttypeModifier"       column="dicttypeModifier"      />
		<result property="dicttypeRemark"         column="dicttypeRemark"         />
	</resultMap>
	
	<sql id="selectDictTypeVo">
        select dicttypeId, dicttypeName, dicttypeCode, dicttypeCreator, dicttypeCreateddate, dicttypeRemark
		from SysDicttype
    </sql>

	<select id="selectDictTypeList" parameterType="SysDictType" resultMap="SysDictTypeResult">
	    <include refid="selectDictTypeVo"/>
		<where>
		    <if test="dicttypeName != null and dicttypeName != ''">
				AND dicttypeName like concat('%', #{dicttypeName}, '%')
			</if>
			<if test="dicttypeCode != null and dicttypeCode != ''">
				AND dicttypeCode like concat('%', #{dicttypeCode}, '%')
			</if>
			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
				and date_format(dicttypeCreateddate,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
			</if>
			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
				and date_format(dicttypeCreateddate,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
			</if>
	    </where>
	</select>
	
	<select id="selectDictTypeAll" resultMap="SysDictTypeResult">
		<include refid="selectDictTypeVo"/>
	</select>
	
	<select id="selectDictTypeById" parameterType="String" resultMap="SysDictTypeResult">
		<include refid="selectDictTypeVo"/>
		where dicttypeId = #{dictId}
	</select>
	
	<select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult">
		<include refid="selectDictTypeVo"/>
		where dicttypeCode = #{dictType}
	</select>
	
	<select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult">
		<include refid="selectDictTypeVo"/>
		where dicttypeCode = #{dictType} limit 1
	</select>
	
	<delete id="deleteDictTypeById" parameterType="String">
 		delete from SysDicttype where dicttypeId = #{dictId}
 	</delete>
 	
 	<delete id="deleteDictTypeByIds" parameterType="String">
 		delete from SysDicttype where dicttypeId in
 		<foreach collection="array" item="dictId" open="(" separator="," close=")">
 			#{dictId}
        </foreach> 
 	</delete>

 	<update id="updateDictType" parameterType="SysDictType">
 		update SysDicttype
 		<set>
 			<if test="dicttypeName != null and dicttypeName != ''">dicttypeName = #{dicttypeName},</if>
 			<if test="dicttypeCode != null and dicttypeCode != ''">dicttypeCode = #{dicttypeCode},</if>
 			<if test="dicttypeRemark != null">dicttypeRemark = #{dicttypeRemark},</if>
 			<if test="dicttypeCreator != null and dicttypeCreator != ''">dicttypeCreator = #{dicttypeCreator},</if>
			dicttypeModifieddate = date_format(sysdate(),'%Y-%m-%d %H:%i:%s')
 		</set>
 		where dicttypeId = #{dicttypeId}
	</update>
 	
 	<insert id="insertDictType" parameterType="SysDictType">
 		insert into SysDicttype(
			<if test="dicttypeId != null and dicttypeId != ''">dicttypeId,</if>
 			<if test="dicttypeName != null and dicttypeName != ''">dicttypeName,</if>
 			<if test="dicttypeCode != null and dicttypeCode != ''">dicttypeCode,</if>
 			<if test="dicttypeRemark != null and dicttypeRemark != ''">dicttypeRemark,</if>
 			<if test="dicttypeCreator != null and dicttypeCreator != ''">dicttypeCreator,</if>
		dicttypeCreateddate
 		)values(
			<if test="dicttypeId != null and dicttypeId != ''">#{dicttypeId},</if>
 			<if test="dicttypeName != null and dicttypeName != ''">#{dicttypeName},</if>
 			<if test="dicttypeCode != null and dicttypeCode != ''">#{dicttypeCode},</if>
 			<if test="dicttypeRemark != null and dicttypeRemark != ''">#{dicttypeRemark},</if>
 			<if test="dicttypeCreator != null and dicttypeCreator != ''">#{dicttypeCreator},</if>
		date_format(sysdate(),'%Y-%m-%d %H:%i:%s')
 		)
	</insert>
	
</mapper> 