Skip to content

Commit

Permalink
feat: Image Type 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ymkim97 committed Nov 27, 2023
1 parent ab2062b commit 8128c6b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/moabam/api/domain/image/ImageName.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ public class ImageName {

private static final String CERTIFICATION_PATH = "certifications" + DELIMITER + LocalDate.now() + DELIMITER;
private static final String PROFILE_IMAGE = "members/profile" + DELIMITER;
private static final String BIRD_SKIN = "moabam/skins" + DELIMITER;
private static final String DEFAULT = "moabam/default" + DELIMITER;

private final String fileName;

public static ImageName of(MultipartFile file, ImageType imageType) {
return switch (imageType) {
case CERTIFICATION -> new ImageName(CERTIFICATION_PATH + file.getName() + "_" + UUID.randomUUID());
case PROFILE_IMAGE -> new ImageName(PROFILE_IMAGE + file.getName() + "_" + UUID.randomUUID());
case DEFAULT -> new ImageName(DEFAULT + file.getName());
case CERTIFICATION ->
new ImageName(CERTIFICATION_PATH + file.getName() + "_" + UUID.randomUUID() + IMAGE_EXTENSION);
case PROFILE_IMAGE ->
new ImageName(PROFILE_IMAGE + file.getName() + "_" + UUID.randomUUID() + IMAGE_EXTENSION);
case BIRD_SKIN -> new ImageName(BIRD_SKIN + file.getName() + IMAGE_EXTENSION);
case DEFAULT -> new ImageName(DEFAULT + file.getName() + IMAGE_EXTENSION);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void resizeImageToFixedSize(ImageType imageType) {
ImageSize imageSize = switch (imageType) {
case PROFILE_IMAGE -> ImageSize.PROFILE_IMAGE;
case CERTIFICATION -> ImageSize.CERTIFICATION_IMAGE;
case BIRD_SKIN -> ImageSize.BIRD_SKIN;
case DEFAULT -> ImageSize.CAGE;
};

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/moabam/api/domain/image/ImageType.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public enum ImageType {

PROFILE_IMAGE,
CERTIFICATION,
BIRD_SKIN,
DEFAULT
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ public class GlobalConstant {
public static final int ROOM_FIXED_SEARCH_SIZE = 10;
public static final int LEVEL_DIVISOR = 10;
public static final int DEFAULT_SKIN_SIZE = 2;
public static final String IMAGE_EXTENSION = ".png";
}

0 comments on commit 8128c6b

Please sign in to comment.