-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature/Inhabas#234] 첨부파일 분류 기능 구현
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
resource-server/src/main/java/com/inhabas/api/global/util/ClassifiedFiles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.inhabas.api.global.util; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.inhabas.api.domain.file.dto.FileDownloadDto; | ||
|
||
// ClassifyFiles 에 의해 분류된 파일들이 ClassifiedFiles 형태로 반환됨. | ||
public class ClassifiedFiles { | ||
private FileDownloadDto thumbnail; | ||
private List<FileDownloadDto> images = new ArrayList<>(); | ||
private List<FileDownloadDto> otherFiles = new ArrayList<>(); | ||
|
||
public ClassifiedFiles() {} | ||
|
||
public FileDownloadDto getThumbnail() { | ||
return thumbnail; | ||
} | ||
|
||
public List<FileDownloadDto> getImages() { | ||
return images; | ||
} | ||
|
||
public List<FileDownloadDto> getOtherFiles() { | ||
return otherFiles; | ||
} | ||
|
||
public void setThumbnail(FileDownloadDto thumbnail) { | ||
this.thumbnail = thumbnail; | ||
} | ||
|
||
public void addImage(FileDownloadDto image) { | ||
this.images.add(image); | ||
} | ||
|
||
public void addOtherFile(FileDownloadDto file) { | ||
this.otherFiles.add(file); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
resource-server/src/main/java/com/inhabas/api/global/util/ClassifyFiles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.inhabas.api.global.util; | ||
|
||
import java.util.List; | ||
|
||
import com.inhabas.api.domain.file.domain.BoardFile; | ||
import com.inhabas.api.domain.file.dto.FileDownloadDto; | ||
|
||
// 첨부파일을 썸네일, 이미지, (이미지가 아닌) 기타 파일로 분류 | ||
public class ClassifyFiles { | ||
|
||
public static ClassifiedFiles classifyFiles(List<BoardFile> files) { | ||
ClassifiedFiles result = new ClassifiedFiles(); | ||
|
||
for (BoardFile file : files) { | ||
FileDownloadDto fileDto = new FileDownloadDto(file.getName(), file.getUrl()); | ||
if (FileUtil.isImageFile(file.getName())) { | ||
result.addImage(fileDto); | ||
if (result.getThumbnail() == null) { | ||
result.setThumbnail(fileDto); // 첫 번째 이미지 파일을 썸네일로 선택 | ||
} | ||
} else { | ||
result.addOtherFile(fileDto); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters