<?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.FileIndexMapper">
	<insert id="add">
		INSERT INTO record_da_ky_file_index
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="fileName != null and fileName != ''">file_name,</if>
			<if test="fileContent != null and fileContent != ''">file_content,</if>
			<if test="filePath != null and filePath != ''">file_path,</if>
			<if test="saveDate != null">save_date,</if>
		</trim>
		VALUES
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="fileName != null and fileName != ''">#{fileName},</if>
			<if test="fileContent != null and fileContent != ''">#{fileContent},</if>
			<if test="filePath != null and filePath != ''">#{filePath},</if>
			<if test="saveDate != null">#{saveDate},</if>
		</trim>
	</insert>
	<update id="update">
		UPDATE record_da_ky_file_index
		<trim prefix="SET" suffixOverrides=",">
			<if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
			<if test="fileContent != null and fileContent != ''">file_content = #{fileContent},</if>
			<if test="filePath != null and filePath != ''">file_path = #{filePath},</if>
			<if test="saveDate != null">save_date = #{saveDate},</if>
		</trim>
		WHERE id = #{id}
	</update>
	<delete id="del">
		DELETE FROM record_da_ky_file_index WHERE id = #{id}
	</delete>

	<select id="getList" resultType="org.springblade.system.domain.FileIndexDto">
        select id,file_name,file_content,file_path,save_date from record_da_ky_file_index
        <where>
			<if test="fileName != null and fileName != ''">
				and file_name like concat('%',#{fileName},'%')
			</if>
		</where>
    </select>
	<select id="getCount" resultType="java.lang.Integer">
		select count(1) from record_da_ky_file_index where file_name = #{fileName}
		<if test="id != null and id != ''">
			and id != #{id}
		</if>
	</select>
</mapper>
