<?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.ruoyi.project.system.dict.mapper.DictDataMapper">
	
	<resultMap type="DictData" id="DictDataResult">
		<id     property="dictCode"   column="dict_code"   />
		<result property="dictSort"   column="dict_sort"   />
		<result property="dictLabel"  column="dict_label"  />
		<result property="dictValue"  column="dict_value"  />
		<result property="dictType"   column="dict_type"   />
		<result property="status"     column="status"      />
		<result property="createBy"   column="create_by"   />
		<result property="createTime" column="create_time" />
		<result property="updateBy"   column="update_by"   />
		<result property="updateTime" column="update_time" />
	</resultMap>

	<select id="selectDictDataList" parameterType="DictData" resultMap="DictDataResult">
		select dict_code, dict_sort, dict_label, dict_value, dict_type, status, create_by, create_time, remark from sys_dict_data
		<where>
			<if test="searchValue != null and searchValue != ''">
				AND dict_label like concat(concat('%', #{searchValue}), '%')
			</if>
			<if test="dictType != null and dictType != ''">
				AND dict_type = #{dictType}
			</if>
		</where>
	</select>
	
	<select id="selectDictDataById" parameterType="Long" resultMap="DictDataResult">
		select dict_code, dict_sort, dict_label, dict_value, dict_type, status, create_by, create_time, remark
		from sys_dict_data
		where dict_code = #{dictCode}
	</select>
	
	<delete id="deleteDictDataById" parameterType="Long">
 		delete from sys_dict_data where dict_code = #{dictCode}
 	</delete>
	
 	<delete id="batchDeleteDictData" parameterType="Long">
 		delete from sys_dict_data where dict_code in
 		<foreach collection="array" item="dictCode" open="(" separator="," close=")">
 			#{dictCode}
        </foreach> 
 	</delete>
 	
	<update id="updateDictData" parameterType="DictData">
 		update sys_dict_data
 		<set>
 			<if test="dictSort != null and dictSort != ''">dict_sort = #{dictSort},</if>
 			<if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
 			<if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
 			<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
 			<if test="status != null">status = #{status},</if>
 			<if test="remark != null and remark != ''">remark = #{remark},</if>
 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
 			update_time = sysdate()
 		</set>
 		where 1=1
 		<if test="dictCode != null and dictCode  != ''">and dict_code = #{dictCode}</if>
	</update>
 	
 	<insert id="insertDictData" parameterType="DictData">
 		insert into sys_dict_data(
 			<if test="dictSort != null and dictSort != ''">dict_sort,</if>
 			<if test="dictLabel != null and dictLabel != ''">dict_label,</if>
 			<if test="dictValue != null and dictValue != ''">dict_value,</if>
 			<if test="dictType != null and dictType != ''">dict_type,</if>
 			<if test="status != null">status,</if>
 			<if test="remark != null and remark != ''">remark,</if>
 			<if test="createBy != null and createBy != ''">create_by,</if>
 			create_time
 		)values(
 		    <if test="dictSort != null and dictSort != ''">#{dictSort},</if>
 		    <if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
 			<if test="dictValue != null and dictValue != ''">#{dictValue},</if>
 			<if test="dictType != null and dictType != ''">#{dictType},</if>
 			<if test="status != null">#{status},</if>
 			<if test="remark != null and remark != ''">#{remark},</if>
 			<if test="createBy != null and createBy != ''">#{createBy},</if>
 			sysdate()
 		)
	</insert>
	
</mapper> 