-
Notifications
You must be signed in to change notification settings - Fork 3
파일서버: 파일 다운로드&프로필이미지 수정 구현 #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cf91117
#121 feat(be): file download 구현
mirlee0304 0e47f04
#121 feat(be): 프로필이미지 수정 구현
mirlee0304 f7665eb
#121 feat(be): dockerfile 생성
mirlee0304 5ef3659
#121 feat(be): 파일 서비스 예외처리 및 유효성 검증 로직 추가
mirlee0304 264db3e
#121 feat(be): 유효성 검증 및 예외처리 로직 추가
mirlee0304 c6572b2
#121 feat(be): 로그 추가
mirlee0304 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,21 @@ | ||
| # Azul Zulu JDK 17 기반 이미지 사용 | ||
| FROM azul/zulu-openjdk:17 | ||
|
|
||
| # 작업 디렉토리 설정 | ||
| WORKDIR /app | ||
|
|
||
| # 환경 변수 파일 복사 | ||
| COPY .env .env | ||
|
|
||
| # 빌드된 JAR 파일 복사 | ||
| ARG JAR_FILE=build/libs/file_server-0.0.1-SNAPSHOT.jar | ||
| COPY ${JAR_FILE} app.jar | ||
|
|
||
| # 환경 변수 설정 | ||
| ENV $(cat .env) | ||
|
|
||
| # 포트 노출 | ||
| EXPOSE 8083 | ||
|
|
||
| # 애플리케이션 실행 | ||
| ENTRYPOINT ["java", "-jar", "app.jar"] |
Empty file.
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
...nd/file_server/src/main/java/com/jootalkpia/file_server/dto/ChangeProfileResponseDto.java
This file contains hidden or 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,14 @@ | ||
| package com.jootalkpia.file_server.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @AllArgsConstructor | ||
| public class ChangeProfileResponseDto { | ||
| private Long userId; | ||
| private String nickname; | ||
| private String profileImage; | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/backend/file_server/src/main/java/com/jootalkpia/file_server/entity/BaseTimeEntity.java
This file contains hidden or 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,21 @@ | ||
| package com.jootalkpia.file_server.entity; | ||
|
|
||
| import jakarta.persistence.EntityListeners; | ||
| import jakarta.persistence.MappedSuperclass; | ||
| import java.time.LocalDateTime; | ||
| import lombok.Getter; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.annotation.LastModifiedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| @Getter | ||
| @MappedSuperclass | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| public abstract class BaseTimeEntity { | ||
|
|
||
| @CreatedDate | ||
| private LocalDateTime createdAt; | ||
|
|
||
| @LastModifiedDate | ||
| protected LocalDateTime updatedAt; | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/backend/file_server/src/main/java/com/jootalkpia/file_server/entity/User.java
This file contains hidden or 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.jootalkpia.file_server.entity; | ||
|
|
||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Table(name = "users") | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public class User extends BaseTimeEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long userId; | ||
|
|
||
| private Long socialId; | ||
|
|
||
| private String email; | ||
|
|
||
| private String platform; | ||
|
|
||
| private String nickname; | ||
|
|
||
| private String profileImage; | ||
|
|
||
| public void updateProfileImage(final String newProfileImage) { | ||
| this.profileImage = newProfileImage; | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
...ile_server/src/main/java/com/jootalkpia/file_server/exception/common/CustomException.java
This file contains hidden or 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,17 @@ | ||
| package com.jootalkpia.file_server.exception.common; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public class CustomException extends RuntimeException { | ||
|
|
||
| private final String code; | ||
|
|
||
| public CustomException(String code, String message) { | ||
| super(message); | ||
| this.code = code; | ||
| } | ||
|
|
||
| } |
37 changes: 37 additions & 0 deletions
37
...kend/file_server/src/main/java/com/jootalkpia/file_server/exception/common/ErrorCode.java
This file contains hidden or 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,37 @@ | ||
| package com.jootalkpia.file_server.exception.common; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum ErrorCode { | ||
|
|
||
| // 400 Bad Request | ||
| UNKNOWN("F00001", "알 수 없는 에러가 발생했습니다."), | ||
| BAD_REQUEST("F40001", "잘못된 요청입니다."), | ||
| VALIDATION_FAILED("F40002", "유효성 검증에 실패했습니다."), | ||
| MISSING_PARAMETER("F40003", "필수 파라미터가 누락되었습니다."), | ||
| INVALID_PARAMETER("F40004", "잘못된 파라미터가 포함되었습니다."), | ||
| MISSING_FILES("F40005", "파일이 포함되어야 합니다."), | ||
|
|
||
| // 404 Not Found | ||
| WORKSPACE_NOT_FOUND("F40401", "등록되지 않은 워크스페이스입니다."), | ||
| CHANNEL_NOT_FOUND("F40402", "등록되지 않은 채널입니다."), | ||
| USER_NOT_FOUND("F40403", "등록되지 않은 유저입니다."), | ||
| FILE_NOT_FOUND("F40404", "등록되지 않은 파일입니다."), | ||
|
|
||
| // 415 Unsupported Type | ||
| UNSUPPORTED_FILE_TYPE("F41501", "지원되지 않는 파일 타입입니다."), | ||
|
|
||
| // 500 Internal Server Error | ||
| INTERNAL_SERVER_ERROR("F50001", "서버 내부 오류가 발생했습니다."), | ||
| DATABASE_ERROR("F50002", "데이터베이스 처리 중 오류가 발생했습니다."), | ||
| IMAGE_UPLOAD_FAILED("F50003", "파일 업로드에 실패했습니다."), | ||
| IMAGE_DOWNLOAD_FAILED("F50004", "파일 다운로드 중 오류가 발생했습니다."), | ||
| FILE_PROCESSING_FAILED("F50005", "파일 처리 중 오류가 발생했습니다."), | ||
| UNEXPECTED_ERROR("F50006", "예상치 못한 오류가 발생했습니다."); | ||
|
|
||
| private final String code; | ||
| private final String msg; | ||
| } |
11 changes: 11 additions & 0 deletions
11
.../file_server/src/main/java/com/jootalkpia/file_server/exception/common/ErrorResponse.java
This file contains hidden or 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,11 @@ | ||
| package com.jootalkpia.file_server.exception.common; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 미르님이 안좋다면서요 Data 쓰는거요ㅠㅠㅠ |
||
| @AllArgsConstructor | ||
| public class ErrorResponse { | ||
| private String code; | ||
| private String message; | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
...ver/src/main/java/com/jootalkpia/file_server/exception/common/GlobalExceptionHandler.java
This file contains hidden or 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,22 @@ | ||
| package com.jootalkpia.file_server.exception.common; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.ExceptionHandler; | ||
| import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
|
||
| @RestControllerAdvice | ||
| public class GlobalExceptionHandler { | ||
|
|
||
| @ExceptionHandler(CustomException.class) | ||
| public ResponseEntity<ErrorResponse> handleCustomException(CustomException ex) { | ||
| ErrorResponse errorResponse = new ErrorResponse(ex.getCode(), ex.getMessage()); | ||
| return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errorResponse); | ||
| } | ||
|
|
||
| @ExceptionHandler(Exception.class) | ||
| public ResponseEntity<ErrorResponse> handleGenericException(Exception ex) { | ||
| ErrorResponse errorResponse = new ErrorResponse("UNKNOWN_ERROR", "An unexpected error occurred."); | ||
| return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse); | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -6,4 +6,5 @@ | |
|
|
||
| @Repository | ||
| public interface FileRepository extends JpaRepository<Files, Long> { | ||
|
|
||
| } | ||
7 changes: 7 additions & 0 deletions
7
...ckend/file_server/src/main/java/com/jootalkpia/file_server/repository/UserRepository.java
This file contains hidden or 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,7 @@ | ||
| package com.jootalkpia.file_server.repository; | ||
|
|
||
| import com.jootalkpia.file_server.entity.User; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface UserRepository extends JpaRepository<User, Long> { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 Controller가 데이터를 전달하는 책임만 가지는 것이 좋다라고 생각해서
다음 비즈니스 로직을 Service단 또는 다른 class로 옮기는 것이 어떠신가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다음 이슈에서 반영하도록 하겠습니다!