Skip to content

Commit

Permalink
feat: 공지 이미지 업로드 API 구현 (#326)
Browse files Browse the repository at this point in the history
* feat(BaseEntity): id로 동등성 비교할 수 있도록 equals&hashCode 재정의 (#325)

* refactor: ImageService 리팩터링 (#325)

* feat: 공지 이미지 업로드 API 구현 (#325)

* refactor: BaseEntity의 equals&hashCode 제거 (#325)
  • Loading branch information
kdkdhoho committed Jan 20, 2025
1 parent f127099 commit a6fb7ed
Show file tree
Hide file tree
Showing 16 changed files with 282 additions and 371 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
package com.listywave.image.application.domain;

import static com.listywave.common.exception.ErrorCode.RESOURCE_NOT_FOUND;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.listywave.common.exception.CustomException;
import com.listywave.common.exception.ErrorCode;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

// TODO: 정수씨 이 쪽 나중에 테스트 부탁해요~
// TODO: ImageService 쪽에서 많이 쓰이고 있어서 쉽게 리팩터링 못하겠네요..
// TODO: uploadExtension 필드 제거하고 `fromString`을 `ofName` 로 바꿔주세요!
@Getter
@AllArgsConstructor
public enum ImageFileExtension {

JPEG("jpeg"),
JPG("jpg"),
PNG("png"),
JPEG,
JPG,
PNG,
;

private final String uploadExtension;

@JsonCreator
public static ImageFileExtension fromString(String key) {
public static ImageFileExtension ofName(String value) {
return Arrays.stream(ImageFileExtension.values())
.filter(extensionType -> extensionType.name().equalsIgnoreCase(key))
.filter(extensionType -> extensionType.name().equalsIgnoreCase(value))
.findFirst()
.orElseThrow(() -> new CustomException(ErrorCode.RESOURCE_NOT_FOUND, "해당 이미지 확장자가 존재하지 않습니다."));
.orElseThrow(() -> new CustomException(RESOURCE_NOT_FOUND, "지원하지 않는 이미지 확장자입니다."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public enum ImageType {
LISTS_ITEM,
USER_PROFILE,
USER_BACKGROUND,
NOTICE,
;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.listywave.image.application.dto.response;

public record ListItemPresignedUrlResponse(
int rank,
String presignedUrl
) {

public static ListItemPresignedUrlResponse from(int rank, String presignedUrl) {
return new ListItemPresignedUrlResponse(rank, presignedUrl);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.listywave.image.application.dto.response;

public record UserPresignedUrlCreateResponse(
Long userId,
String profilePresignedUrl,
String backgroundPresignedUrl
) {

public static UserPresignedUrlCreateResponse of(Long userId, String profilePresignedUrl, String backgroundPresignedUrl) {
return new UserPresignedUrlCreateResponse(userId, profilePresignedUrl, backgroundPresignedUrl);
}
}

This file was deleted.

Loading

0 comments on commit a6fb7ed

Please sign in to comment.