115 lines
4.2 KiB
XML
115 lines
4.2 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.qiwenshare.file.mapper.UserFileMapper">
|
|
|
|
<update id="replaceFilePath">
|
|
UPDATE userfile SET filepath=REPLACE(filepath, #{oldFilePath}, #{filePath})
|
|
WHERE filepath LIKE N'${oldFilePath}%' and userId = #{userId};
|
|
</update>
|
|
|
|
|
|
<select id="selectPageVo" parameterType="com.qiwenshare.file.domain.UserFile" resultType="com.qiwenshare.file.vo.file.FileListVo">
|
|
select * from userfile a
|
|
left join image on a.fileId = image.fileId
|
|
left join file on file.fileId = a.fileId
|
|
<where>
|
|
<if test="fileTypeId != null">
|
|
<choose>
|
|
<when test="fileTypeId != 5">
|
|
extendName in (select fileExtendName from fileclassification where fileTypeId = #{fileTypeId})
|
|
</when>
|
|
<otherwise>
|
|
extendName not in (select fileExtendName from fileclassification where fileTypeId in (1, 2, 3, 4))
|
|
</otherwise>
|
|
</choose>
|
|
</if>
|
|
<if test="userFile.userId != null">
|
|
and a.userId = #{userFile.userId}
|
|
</if>
|
|
<if test="userFile.filePath != null">
|
|
and a.filePath = #{userFile.filePath}
|
|
</if>
|
|
<if test="userFile.extendName != null">
|
|
and a.extendName = #{userFile.extendName}
|
|
</if>
|
|
<if test="userFile.userFileId != null">
|
|
and a.userFileId = #{userFile.userFileId}
|
|
</if>
|
|
<if test="userFile.fileName != null">
|
|
and a.fileName = #{userFile.fileName}
|
|
</if>
|
|
and a.deleteFlag = 0
|
|
</where>
|
|
ORDER BY isDir desc
|
|
</select>
|
|
|
|
|
|
<update id="updateFilepathByFilepath">
|
|
UPDATE userfile SET filePath=REPLACE(filePath, #{param1}, #{param2})
|
|
WHERE filePath like N'${param1}%' and userId = #{param3}
|
|
</update>
|
|
|
|
<update id="updateFilepathByPathAndName">
|
|
update userfile set filePath = #{param2}
|
|
where filePath = #{param1} and fileName = #{param3}
|
|
<if test="param4 != null">
|
|
and extendName = #{param4}
|
|
</if>
|
|
<if test="param4 == null">
|
|
and extendName is null
|
|
</if>
|
|
and userId = #{param5}
|
|
</update>
|
|
|
|
<insert id="batchInsertByPathAndName">
|
|
insert into userfile ( deleteBatchNum, deleteFlag, deleteTime,
|
|
extendName, fileId, fileName, filePath, isDir, uploadTime, userId)
|
|
(select deleteBatchNum, deleteFlag, deleteTime, extendName, fileId,
|
|
fileName, #{newFilePath}, isDir, uploadTime, userId
|
|
from userfile
|
|
<where>
|
|
<if test="userId != 0">
|
|
and userId = #{userId}
|
|
</if>
|
|
<if test="fileName != null">
|
|
and fileName = #{fileName}
|
|
</if>
|
|
<if test="oldFilePath != null">
|
|
and filePath = #{oldFilePath}
|
|
</if>
|
|
<choose>
|
|
<when test="extendName != null">
|
|
and extendName = #{extendName}
|
|
</when>
|
|
<otherwise>
|
|
and isDir = 1
|
|
</otherwise>
|
|
</choose>
|
|
</where>
|
|
|
|
)
|
|
</insert>
|
|
|
|
<update id="batchInsertByFilepath">
|
|
insert into userfile ( deleteBatchNum, deleteFlag, deleteTime,
|
|
extendName, fileId, fileName, filePath, isDir, uploadTime, userId)
|
|
(select deleteBatchNum, deleteFlag, deleteTime, extendName, fileId,
|
|
fileName, REPLACE(filePath, #{oldFilePath}, #{newFilePath}), isDir,
|
|
uploadTime, userId
|
|
from userfile
|
|
where filePath like N'${oldFilePath}%' and userId = #{userId}
|
|
)
|
|
</update>
|
|
|
|
|
|
<select id="selectStorageSizeByUserId" resultType="java.lang.Long" parameterType="java.lang.Long">
|
|
SELECT SUM(fileSize) FROM userfile
|
|
LEFT JOIN file ON file.fileId = userfile.fileId
|
|
WHERE userfile.userId = #{userId}
|
|
</select>
|
|
|
|
</mapper> |