Skip to content

[web-33] 관리자 메인 로고 수정 API 구현#14

Closed
Chunwol wants to merge 62 commits into
developfrom
feature/web-33
Closed

[web-33] 관리자 메인 로고 수정 API 구현#14
Chunwol wants to merge 62 commits into
developfrom
feature/web-33

Conversation

@Chunwol
Copy link
Copy Markdown
Member

@Chunwol Chunwol commented May 20, 2026

작업 내용

관리자 페이지에서 메인 페이지 로고 이미지를 수정할 수 있는 API를 구현합니다.
파일 업로드는 클라이언트가 Presigned PUT URL로 MinIO에 직접 업로드하는 방식을 사용합니다.
서버는 파일을 받지 않고, 업로드 완료 후 전달받은 objectKey로 URL을 저장합니다.

변경 사항

  • FileController 추가: GET /api/v1/files/upload-url — Presigned PUT URL 발급
  • PresignedUploadResponseDto 추가: uploadUrl, objectKey 필드
  • MinioConfig 추가: application.ymlminio.* 프로퍼티 바인딩, MinioClient Bean 등록
  • 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 추가

파일 업로드 흐름

1. GET /api/v1/files/upload-url?type=logo
   → { uploadUrl, objectKey } 수령

2. PUT {uploadUrl}  ← 브라우저에서 MinIO로 직접 전송 (서버 경유 없음)
   Body: 파일 바이너리

3. PATCH /api/v1/admin/main/logo
   Body: { "objectKey": "logo/uuid" }
   → 서버가 objectKey로 URL 구성 후 DB 저장

API

1. Presigned 업로드 URL 발급

GET /api/v1/files/upload-url?type=logo

Response: 200 OK

{
  "success": true,
  "data": {
    "uploadUrl": "http://minio:9000/one-bucket/logo/uuid?X-Amz-Signature=...",
    "objectKey": "logo/550e8400-e29b-41d4-a716-446655440000"
  }
}

type 파라미터: logologo/uuid, projectprojects/uuid 경로로 생성

2. 메인 로고 수정

PATCH /api/v1/admin/main/logo

Content-Type: application/json

Request 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):

// 1. Presigned URL 발급
const { uploadUrl, objectKey } = await axios
  .get('/api/v1/files/upload-url?type=logo')
  .then(res => res.data.data);

// 2. MinIO에 직접 업로드 (서버 경유 없음)
await axios.put(uploadUrl, logoFile, {
  headers: { 'Content-Type': logoFile.type }
});

// 3. objectKey를 서버에 전달해 DB 저장
await axios.patch('/api/v1/admin/main/logo', { objectKey });

테스트

  • GET /api/v1/files/upload-url?type=logo → 200 OK, uploadUrl + objectKey 반환
  • PUT uploadUrl 로 파일 직접 업로드 → MinIO 저장 확인
  • PATCH /api/v1/admin/main/logo → 200 OK, logoUrl 반환
  • 기존 로고 있을 때 새 로고 저장 시 기존 파일 MinIO에서 삭제 확인

chldPDms and others added 30 commits May 4, 2026 17:35
Feat:  JWT 기반 인증 시스템 구현
@Chunwol Chunwol added the enhancement New feature or request label May 20, 2026
Comment thread src/main/java/org/one/domain/controller/AdminMainController.java Outdated
Comment thread src/main/java/org/one/domain/controller/AdminMainController.java Outdated
Comment thread src/main/java/org/one/domain/controller/AdminMainController.java Outdated
Comment thread src/main/java/org/one/domain/service/AdminMainService.java Outdated
Copy link
Copy Markdown
Contributor

@chldPDms chldPDms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공통

  1. 관리자 로그인이 스웨거에서 보이지가 않습니다. 해당 부분 확인 부탁드립니다.

  2. 현재 보일러 플레이팅과 작업해오신 코드 형식이 일치하지 않습니다. (API 형식, controller에서 ErrorCode 사용 방식 등)
    2-1. api prefix는 /api/v1/ 로 작성해 주세요.

  3. 파일의 경우, minio와 presigned Url을 사용할 예정입니다. 현재 minio config도 존재하지 않고, db에 파일 url을 그냥 저장하는 식의 코드를 사용하시고 계신데

  • MinIO 연동 Config 추가
  • Presigned URL 기반 업로드 방식 적용
  • 파일 저장/조회 로직 수정
    방향으로 수정 부탁드립니다.

Chunwol added 8 commits May 21, 2026 10:18
[web-32] 인증 DTO 코딩 컨벤션 리팩토링
- AuthController: /auth -> /api/v1/auth prefix 변경
- AuthController: @SecurityRequirements 추가 (Swagger 로그인 자물쇠 제거)
- AuthController: @ApiErrorExceptions 적용, 기존 verbose @ApiResponses 제거
- SecurityConfig: PUBLIC_URLS /auth/** -> /api/v1/auth/** 변경
- OpenApiConfig: authApi /api/v1/auth/**, adminApi /api/v1/** 경로 통일
- ApiErrorExceptions: ErrorCode 기반 에러 응답 자동 등록 어노테이션 추가
- ApiErrorExceptionCustomizer: OperationCustomizer 구현체 추가
- MinIO SDK 의존성 추가 (io.minio:minio:8.5.11)
- MinioConfig: @ConfigurationProperties 기반 MinIO 클라이언트 설정
- MinioService: Presigned PUT/GET URL 생성 서비스
- application.yml / application-prod.yml: MinIO 환경변수 설정 추가
- V3__add_recruitment.sql: recruitment 단일 레코드 테이블 마이그레이션
  - recruitment_start/end를 main_page에서 recruitment 테이블로 이동
  - main_page.recruitment_start/end 컬럼 제거
[web-32] 인증 API prefix /api/v1/auth 적용 및 Swagger 문서 개선
@Chunwol Chunwol force-pushed the feature/web-33 branch 3 times, most recently from 4d2e694 to 2967877 Compare May 23, 2026 11:41
Chunwol added 3 commits May 23, 2026 22:47
[web-35] 관리자 캘린더 일정 생성 API 구현
[web-35-3] 관리자 캘린더 일정 삭제 API 구현
관리자 캘린더 일정 조회/수정/삭제 API 구현 (web-35-1 ~ web-35-3)
@Chunwol Chunwol force-pushed the feature/web-33 branch 3 times, most recently from b007873 to d649c21 Compare May 23, 2026 23:02
- 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 필드로 변경
Copy link
Copy Markdown
Contributor

@chldPDms chldPDms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공통

  1. 전체적으로 예외처리가 너무 부족합니다.
  2. 해결하신 리뷰는 resolve 처리해 주세용

Comment thread src/main/java/org/one/domain/service/AdminMainService.java
Chunwol added 2 commits May 24, 2026 22:57
- MainLogoUpdateRequestDto.objectKey에 @notblank 추가
- AdminMainService.update()에 logo/ 경로 prefix 검증 추가
…ce 로깅 개선

- ErrorCode에 INVALID_DATE_RANGE / PHOTO_LIMIT_EXCEEDED / INVALID_OBJECT_KEY 추가
- BusinessException(ErrorCode, customMessage) 생성자 추가
- GlobalExceptionHandler: exception.getMessage() 기반 응답으로 변경
- MinioService: uploadFile / deleteFile / getPresignedUrl catch에 error 로그 추가
- AdminMainService.validateObjectKey(): INVALID_OBJECT_KEY + 구체적 메시지 적용
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants