parent
411fd01a20
commit
b583035630
5 changed files with 60 additions and 35 deletions
@ -0,0 +1,31 @@ |
||||
const buildQueryFilesDetail = ({ filesUUID }: { filesUUID?: string[] }) => { |
||||
let condFilesUUID = ''; |
||||
|
||||
if (filesUUID instanceof Array && filesUUID.length > 0) { |
||||
const catFilesUUID = `'${filesUUID.join("', '")}'`; |
||||
|
||||
condFilesUUID = `AND fil.file_uuid IN (${catFilesUUID})`; |
||||
} |
||||
|
||||
return ` |
||||
SELECT |
||||
fil.file_uuid, |
||||
fil.file_name, |
||||
fil.file_size, |
||||
fil.file_type, |
||||
fil.file_md5sum, |
||||
fil_loc.file_location_uuid, |
||||
fil_loc.file_location_active, |
||||
anv.anvil_uuid, |
||||
anv.anvil_name, |
||||
anv.anvil_description |
||||
FROM files AS fil |
||||
JOIN file_locations AS fil_loc |
||||
ON fil.file_uuid = fil_loc.file_location_file_uuid |
||||
JOIN anvils AS anv |
||||
ON fil_loc.file_location_anvil_uuid = anv.anvil_uuid |
||||
WHERE fil.file_type != 'DELETED' |
||||
${condFilesUUID};`;
|
||||
}; |
||||
|
||||
export default buildQueryFilesDetail; |
@ -1,25 +1,8 @@ |
||||
import buildGetFiles from './buildGetFiles'; |
||||
import buildQueryFilesDetail from './buildQueryFilesDetail'; |
||||
|
||||
const getFileDetail = buildGetFiles( |
||||
(request) => |
||||
`SELECT
|
||||
fil.file_uuid, |
||||
fil.file_name, |
||||
fil.file_size, |
||||
fil.file_type, |
||||
fil.file_md5sum, |
||||
fil_loc.file_location_uuid, |
||||
fil_loc.file_location_active, |
||||
anv.anvil_uuid, |
||||
anv.anvil_name, |
||||
anv.anvil_description |
||||
FROM files AS fil |
||||
JOIN file_locations AS fil_loc |
||||
ON fil.file_uuid = fil_loc.file_location_file_uuid |
||||
JOIN anvils AS anv |
||||
ON fil_loc.file_location_anvil_uuid = anv.anvil_uuid |
||||
WHERE fil.file_uuid = '${request.params.fileUUID}' |
||||
AND fil.file_type != 'DELETED';`,
|
||||
const getFileDetail = buildGetFiles((request) => |
||||
buildQueryFilesDetail({ filesUUID: [request.params.fileUUID] }), |
||||
); |
||||
|
||||
export default getFileDetail; |
||||
|
@ -0,0 +1,24 @@ |
||||
import buildGetFiles from './buildGetFiles'; |
||||
import buildQueryFilesDetail from './buildQueryFilesDetail'; |
||||
|
||||
const getFiles = buildGetFiles((request) => { |
||||
const { filesUUID } = request.body; |
||||
|
||||
let query = ` |
||||
SELECT |
||||
file_uuid, |
||||
file_name, |
||||
file_size, |
||||
file_type, |
||||
file_md5sum |
||||
FROM files |
||||
WHERE file_type != 'DELETED';`;
|
||||
|
||||
if (filesUUID) { |
||||
query = buildQueryFilesDetail({ filesUUID }); |
||||
} |
||||
|
||||
return query; |
||||
}); |
||||
|
||||
export default getFiles; |
@ -1,13 +0,0 @@ |
||||
import buildGetFiles from './buildGetFiles'; |
||||
|
||||
const getFilesOverview = buildGetFiles(` |
||||
SELECT |
||||
file_uuid, |
||||
file_name, |
||||
file_size, |
||||
file_type, |
||||
file_md5sum |
||||
FROM files |
||||
WHERE file_type != 'DELETED';`);
|
||||
|
||||
export default getFilesOverview; |
Loading…
Reference in new issue