Skip to content

Commit

Permalink
Merge pull request #298 from sohosai/feature/export-files
Browse files Browse the repository at this point in the history
申請項目名が同じ場合にファイルエクスポートが正常に動作しない問題を修正
  • Loading branch information
arata-nvm authored May 10, 2024
2 parents 3dfb5ea + 45048bb commit 7fc1424
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/sos24-use-case/src/file/interactor/export_by_form_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ impl<R: Repositories> FileUseCase<R> {
let project = project_with_owners.project.destruct();

let file_items = form_answer.list_file_items();
for (item_id, files) in file_items {
for (index1, (item_id, files)) in file_items.into_iter().enumerate() {
let Some(form_item) = form.find_item(&item_id) else {
return Err(FileUseCaseError::FormItemNotFound(item_id));
};

for (index, file_id) in files.into_iter().enumerate() {
for (index2, file_id) in files.into_iter().enumerate() {
let file = self
.repositories
.file_data_repository()
Expand All @@ -67,13 +67,14 @@ impl<R: Repositories> FileUseCase<R> {
.ok_or(FileUseCaseError::NotFound(file_id))?;
let file = file.destruct();

// {申請項目名}_{通し番号1}/{企画番号}_{企画名}_{通し番号2}_{オリジナルファイル名}
let filename = format!(
"{}/{}_{}_{}_{}_{}",
"{}_{}/{}_{}_{}_{}",
form_item.name().clone().value(),
index1 + 1,
project.index.clone().value(),
project.title.clone().value(),
project.group_name.clone().value(),
index + 1,
index2 + 1,
file.name.clone().value(),
);
file_list.push(ArchiveEntry::new(
Expand Down

0 comments on commit 7fc1424

Please sign in to comment.