<?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="org.springblade.system.mapper.FilesClassifyNameStandardMapper">
	<insert id="add">
		INSERT INTO record_da_ky_files_classify_name_standard
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="id != null">id,</if>
			<if test="standardType != null and standardType != ''">standard_type,</if>
			<if test="standardName != null and standardName != ''">standard_name,</if>
			<if test="remark != null and remark != ''">remark,</if>
			<if test="createUserId != null">create_user_id,</if>
			<if test="createUserName != null and createUserName != ''">create_user_name,</if>
			<if test="updateUserId != null">update_user_id,</if>
			<if test="updateUserName != null and updateUserName != ''">update_user_name,</if>
			<if test="delFlag != null and delFlag != ''">del_flag,</if>
			create_time
		</trim>
		<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
			<if test="id != null">#{id},</if>
			<if test="standardType != null and standardType != ''">#{standardType},</if>
			<if test="standardName != null and standardName != ''">#{standardName},</if>
			<if test="remark != null and remark != ''">#{remark},</if>
			<if test="createUserId != null">#{createUserId},</if>
			<if test="createUserName != null and createUserName != ''">#{createUserName},</if>
			<if test="updateUserId != null">#{updateUserId},</if>
			<if test="updateUserName != null and updateUserName != ''">#{updateUserName},</if>
			<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
			now()
		</trim>
	</insert>
	<update id="edit">
		UPDATE record_da_ky_files_classify_name_standard
		<trim prefix="SET" suffixOverrides=",">
			<if test="standardType != null and standardType != ''">standard_type = #{standardType},</if>
			<if test="standardName != null and standardName != ''">standard_name = #{standardName},</if>
			<if test="remark != null and remark != ''">remark = #{remark},</if>
			<if test="updateUserId != null">update_user_id = #{updateUserId},</if>
			<if test="updateUserName != null and updateUserName != ''">update_user_name = #{updateUserName},</if>
			<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
			update_time = NOW()
		</trim>
		WHERE id = #{id} AND del_flag = '1'
	</update>
	<delete id="del">
		DELETE FROM record_da_ky_files_classify_name_standard
		WHERE id = #{id}
	</delete>

	<select id="getClassifyNameStandardList" resultType="org.springblade.system.domain.FilesClassifyNameStandardDto">
		SELECT
			dkfcns.id,
			dksdd.dict_value AS standardType,
			dksdd.dict_label AS standardTypeName,
			dkfcns.standard_name AS standardName,
			dkfcns.remark,
			dkfcns.create_time AS createTime,
			dkfcns.update_time AS updateTime,
			dkfcns.create_user_id AS createUserId,
			dkfcns.create_user_name AS createUserName,
			dkfcns.update_user_id AS updateUserId,
			dkfcns.update_user_name AS updateUserName,
			dkfcns.del_flag AS delFlag
		FROM record_da_ky_files_classify_name_standard dkfcns
				 LEFT JOIN da_ky_sys_dict_data dksdd ON dkfcns.standard_type = dksdd.dict_value and dksdd.dict_type = 'files_classify_name_standard_type'
		WHERE dkfcns.del_flag = '1'
		<if test="standardType != null and standardType != ''">
			AND dksdd.dict_value = #{standardType}
		</if>
		ORDER BY dkfcns.create_time DESC
	</select>
	<select id="selectClassifyNameStandard" resultType="java.lang.Integer">
		select count(*) from record_da_ky_files_classify_name_standard where del_flag = '1' and standard_name = #{standardName}
		<if test="id != null">
			and id != #{id}
		</if>
	</select>
</mapper>
