[web-33] 관리자 메인 로고 수정 API 구현#40
Open
Chunwol wants to merge 5 commits into
Open
Conversation
- FileController: GET /api/v1/files/upload-url 엔드포인트 추가 (Presigned PUT URL 발급) - PresignedUploadResponseDto: uploadUrl, objectKey 필드 - MinioService: getObjectUrl(objectKey) 메서드 추가 - AdminMainController: MultipartFile 제거 → @RequestBody MainLogoUpdateRequestDto - AdminMainService: 서버 업로드 제거 → objectKey 받아 URL 저장 - MainLogoUpdateRequestDto: logoUrl → objectKey 필드로 변경
- MainLogoUpdateRequestDto.objectKey에 @notblank 추가 - AdminMainService.update()에 logo/ 경로 prefix 검증 추가
Member
Author
|
src/main/java/org/one/domain/dto/request/MainLogoUpdateRequestDto.java src/main/java/org/one/domain/service/AdminMainService.java |
- ErrorCode: INVALID_DATE_RANGE / PHOTO_LIMIT_EXCEEDED / INVALID_OBJECT_KEY 추가 - MinioService: uploadFile / deleteFile / getPresignedUrl catch에 error 로그 추가 - AdminMainService.validateObjectKey(): INVALID_OBJECT_KEY 적용
- AdminMainService.update(): DB 먼저 갱신 후 MinIO 삭제, 실패 시 경고 로그 처리 - FileController: logo/project 외 type 값 입력 시 INVALID_INPUT 예외 처리
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
작업 내용
관리자 페이지에서 메인 페이지 로고 이미지를 수정할 수 있는 API를 구현합니다.
파일 업로드는 클라이언트가 Presigned PUT URL로 MinIO에 직접 업로드하는 방식을 사용합니다.
서버는 파일을 받지 않고, 업로드 완료 후 전달받은
objectKey로 URL을 저장합니다.변경 사항
FileController추가:GET /api/v1/files/upload-url— Presigned PUT URL 발급PresignedUploadResponseDto추가:uploadUrl,objectKey필드MinioConfig추가:application.yml의minio.*프로퍼티 바인딩,MinioClientBean 등록MinioService추가:generateUploadUrl(),generateDownloadUrl(),getObjectUrl(),deleteFile(),extractObjectKey()PATCH /api/v1/admin/main/logo엔드포인트 구현 (JSON body)MainPageConfig엔티티 정리 (description, recruitmentStart/End 제거)MainLogoResponseDto,MainLogoUpdateRequestDto(objectKey)추가MainPageConfigRepository추가 (getConfig()— Singleton 엔티티 ID 고정 1)AdminMainController,AdminMainService추가파일 업로드 흐름
API
1. Presigned 업로드 URL 발급
GET /api/v1/files/upload-url?type=logoResponse:
200 OK{ "success": true, "data": { "uploadUrl": "http://minio:9000/one-bucket/logo/uuid?X-Amz-Signature=...", "objectKey": "logo/550e8400-e29b-41d4-a716-446655440000" } }2. 메인 로고 수정
PATCH /api/v1/admin/main/logoRequest Body:
{ "objectKey": "logo/550e8400-e29b-41d4-a716-446655440000" }Response:
200 OK{ "success": true, "data": { "logoUrl": "http://minio:9000/one-bucket/logo/550e8400-e29b-41d4-a716-446655440000" } }프론트엔드 요청 예시 (JavaScript):
테스트