gunshi-project-ss/src/main/java/com/gunshi/project/hsz/mapper/FileAssociationsMapper.java

126 lines
3.7 KiB
Java

package com.gunshi.project.hsz.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.hsz.model.FileAssociations;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 描述: 文件关联业务表
* author: xusan
* date: 2024-07-17 10:09:40
*/
@Mapper
public interface FileAssociationsMapper extends BaseMapper<FileAssociations> {
@Select("""
<script>
SELECT
fa.*,
fd.file_name,
fd.file_size,
fd.file_path
FROM
file_associations fa
LEFT JOIN file_descriptor fd ON fa.file_id = fd.file_id
WHERE
fa.del = '1'
AND fa.business_id = #{businessId}
AND fa."table_name" = #{tableName}
AND fd.group_id = #{tableName}
ORDER BY fa.tm desc
</script>
""")
List<FileAssociations> getFiles(@Param("tableName") String tableName,@Param("businessId") String businessId);
@Select("""
<script>
SELECT
fa.*,
fd.file_name,
fd.file_size,
fd.file_path
FROM
file_associations fa
LEFT JOIN file_descriptor fd ON fa.file_id = fd.file_id
WHERE
fa.del = '1'
AND fa.business_id = #{businessId}
AND fa."table_name" = #{tableName}
ORDER BY fa.tm desc
</script>
""")
List<FileAssociations> getFiles2(@Param("tableName") String tableName,@Param("businessId") String businessId);
@Select("""
<script>
SELECT
fa.*,
fd.file_name,
fd.file_size,
fd.file_path
FROM
file_associations fa
LEFT JOIN file_descriptor fd ON fa.file_id = fd.file_id
WHERE
fa.del = '1'
AND fa.business_id = #{businessId}
AND fa."table_name" = #{tableName}
AND fa.type = #{type}
AND fd.group_id = #{tableName}
ORDER BY fa.tm desc
</script>
""")
List<FileAssociations> getFiles1(@Param("tableName") String tableName,@Param("businessId") String businessId,@Param("type") String type);
@Select("""
<script>
SELECT
fa.*,
fd.file_name,
fd.file_size,
fd.file_path
FROM
file_associations fa
LEFT JOIN file_descriptor fd ON fa.file_id = fd.file_id
WHERE
fa.del = '1'
AND fa.business_id = #{businessId}
AND fa.type = #{type}
AND fa."table_name" = #{tableName}
AND fd.group_id = #{tableName}
ORDER BY fa.tm desc
</script>
""")
List<FileAssociations> queryFileList(@Param("businessId") String businessId,@Param("tableName") String tableName,@Param("type") String type);
@Select("""
<script>
SELECT
fa.*,
fd.file_name,
fd.file_size,
fd.file_path
FROM
file_associations fa
LEFT JOIN file_descriptor fd ON fa.file_id = fd.file_id
WHERE
fa.del = '1'
AND fa.business_id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
ORDER BY fa.tm desc
</script>
""")
List<FileAssociations> getFilesByIds(@Param("ids") List<String> ids);
}