cm-cloud/cloud-common-plugin/target/classes/mybatis/mapper/file/file-mapper.xml

202 lines
6.6 KiB
XML

<?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.cm.common.plugin.dao.file.IFileDao">
<resultMap id="filePO" type="com.cm.common.pojo.pos.FilePO">
<id property="fileId" column="file_id"/>
<result property="fileName" column="file_name"/>
<result property="filePath" column="file_path"/>
<result property="fileUrl" column="file_url"/>
<result property="fileType" column="file_type"/>
<result property="fileSize" column="file_size"/>
<result property="fileSummary" column="file_summary"/>
<result property="isBack" column="is_back"/>
<result property="creator" column="creator"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="modifier" column="modifier"/>
<result property="gmtModified" column="gmt_modified"/>
<result property="isDelete" column="is_delete"/>
</resultMap>
<resultMap id="fileDTO" type="com.cm.common.pojo.dtos.FileDTO">
<id property="fileId" column="file_id"/>
<result property="fileName" column="file_name"/>
<result property="fileUrl" column="file_url"/>
<result property="fileType" column="file_type"/>
<result property="fileSize" column="file_size"/>
</resultMap>
<resultMap id="fileInfoDTO" type="com.cm.common.plugin.pojo.dtos.file.FileInfoDTO" extends="fileDTO">
<id property="fileId" column="file_id"/>
<result property="fileName" column="file_name"/>
<result property="fileUrl" column="file_url"/>
<result property="fileType" column="file_type"/>
<result property="fileSize" column="file_size"/>
<result property="fileUrl" column="file_url"/>
<result property="fileSummary" column="file_summary"/>
<result property="isBack" column="is_back"/>
</resultMap>
<resultMap id="fileInfoWithPathDTO" type="com.cm.common.plugin.pojo.dtos.file.FileInfoWithPathDTO" extends="fileInfoDTO">
<id property="fileId" column="file_id"/>
<result property="fileName" column="file_name"/>
<result property="fileUrl" column="file_url"/>
<result property="fileType" column="file_type"/>
<result property="fileSize" column="file_size"/>
<result property="fileUrl" column="file_url"/>
<result property="fileSummary" column="file_summary"/>
<result property="filePath" column="file_path"/>
<result property="isBack" column="is_back"/>
</resultMap>
<!-- 保存文件 -->
<insert id="saveFile" parameterType="map">
INSERT INTO sys_file(
file_id,
file_name,
file_path,
file_url,
file_type,
file_size,
file_summary,
is_back,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{fileId},
#{fileName},
#{filePath},
#{fileUrl},
#{fileType},
#{fileSize},
#{fileSummary},
#{isBack},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除文件 -->
<update id="removeFile" parameterType="map">
UPDATE
sys_file
SET
is_delete = 0,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
file_id IN
<foreach collection="fileIds" index="index" open="(" separator="," close=")">
#{fileIds[${index}]}
</foreach>
</update>
<!-- 删除文件(物理删除) -->
<delete id="deleteFile" parameterType="map">
DELETE FROM
sys_file
WHERE
file_id IN
<foreach collection="fileIds" index="index" open="(" separator="," close=")">
#{fileIds[${index}]}
</foreach>
</delete>
<!-- 获取文件 -->
<select id="getFile" parameterType="map" resultMap="filePO">
SELECT
*
FROM
sys_file
WHERE
is_delete = 0
AND
file_id = #{fileId}
</select>
<!-- 文件列表 -->
<select id="listFile" parameterType="map" resultMap="fileDTO">
SELECT
*
FROM
sys_file
WHERE
is_delete = 0
<if test="keywords != null and keywords != ''">
AND
file_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="ids != null and ids.size > 0">
AND
file_id IN
<foreach collection="ids" index="index" open="(" separator="," close=")">
#{ids[${index}]}
</foreach>
</if>
<if test="fileUrl != null and fileUrl != ''">
AND
file_url LIKE concat('%', #{fileUrl}, '%')
</if>
</select>
<!-- 文件列表 -->
<select id="listFileInfo" parameterType="map" resultMap="fileInfoDTO">
SELECT
*
FROM
sys_file
WHERE
is_delete = 0
<if test="keywords != null and keywords != ''">
AND
file_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="ids != null and ids.size > 0">
AND
file_id IN
<foreach collection="ids" index="index" open="(" separator="," close=")">
#{ids[${index}]}
</foreach>
</if>
</select>
<!-- 获取文件列表(带路径) -->
<select id="listFileInfoWithPath" parameterType="map" resultMap="fileInfoWithPathDTO">
SELECT
*
FROM
sys_file
WHERE
is_delete = 0
<if test="fileIds != null and fileIds.size > 0">
AND
file_id IN
<foreach collection="fileIds" index="index" open="(" separator="," close=")">
#{fileIds[${index}]}
</foreach>
</if>
</select>
</mapper>