-
Notifications
You must be signed in to change notification settings - Fork 0
feat: [ALT-258] 업장 대표이미지 관리 기능 추가 (최대 5개) #91
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
22 commits
Select commit
Hold shift + click to select a range
8821b07
feat: 업장 대표이미지 엔티티 및 repository 추가
hodoon f6e8887
feat: 업장 등록 신청/승인 시 대표이미지 처리
hodoon 1ec2aba
feat: 매니저 업장 대표이미지 조회/수정 API 추가
hodoon a6a4dad
feat: 업장 상세 조회 응답에 대표이미지 목록 추가
hodoon 93c0343
fix: 대표이미지 수정 시 중복 fileId 제거
hodoon af40b87
fix: 대표이미지 노출 순서(sortOrder) 연속성 보장
hodoon 0f571f3
fix: 대표이미지 fileId 목록에 빈 문자열 검증 추가
hodoon 87bb2eb
chore: 미사용 countByWorkspaceId 제거
hodoon 52d4cf9
fix: 업장 등록 신청 시 중복 대표이미지 ID 제거
hodoon 6fcb0b4
fix: 대표이미지 노출 순서 음수 값 검증 추가
hodoon c13cfcf
fix: 승인 시 대표이미지 파일 누락 경고 로그 추가
hodoon 21183f6
test: 업장 대표이미지 기능 테스트 추가
hodoon 4a25399
refactor: 대표이미지 엔티티 UNIQUE 제약 코드 제거 (DDL 관리)
hodoon aee30a5
fix: 대표이미지 수정 트랜잭션 정합성 개선 및 ErrorCode 재활용
hodoon 78e8841
fix: 대표이미지 조회 시 파일 누락 경고 로그 추가
hodoon d708669
refactor: 대표이미지 요청을 {fileId, sortOrder} 구조로 변경
hodoon 5012899
fix: 업장 신청 시 대표이미지 최대 5개 상한 검증 추가
hodoon 9931d8c
fix: 업장 신청 시 대표이미지 최대 5개 상한 검증 추가
hodoon 0dde600
test: 테스트 클래스명 Tests 규칙 통일 및 메서드명 영문화
hodoon e10d442
refactor: 업장 상세 조회 시 대표이미지 소유 검증 중복 제거
hodoon fc33ea5
refactor: 유스케이스의 어댑터 DTO 직접 의존 제거
hodoon 9a86b7e
test: dev 리네임에 맞춰 승인 대표이미지 테스트를 UpdateWorkspaceRequestStatusTests로 통합
hodoon 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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/dreamteam/alter/adapter/inbound/common/dto/WorkspaceImageRequestDto.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,43 @@ | ||
| package com.dreamteam.alter.adapter.inbound.common.dto; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Comparator; | ||
| import java.util.List; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @EqualsAndHashCode(of = "fileId") | ||
| @Schema(description = "업장 대표이미지 요청 항목 DTO") | ||
| public class WorkspaceImageRequestDto { | ||
|
|
||
| @NotBlank | ||
| @Schema(description = "대표이미지 파일 ID", example = "01959b4e-4e5f-7c3a-8d9e-0f1a2b3c4d5e") | ||
| private String fileId; | ||
|
|
||
| @Schema(description = "노출 순서 (작을수록 먼저, 미지정 시 마지막)", example = "0") | ||
| private Integer sortOrder; | ||
|
|
||
| /** | ||
| * sortOrder 오름차순(미지정은 후순위)으로 정렬한 파일 ID 목록을 반환한다. | ||
| * fileId 기준 equals/hashCode 로 Set 단계에서 이미 중복이 제거된다. | ||
| */ | ||
| public static List<String> toOrderedFileIds(Collection<WorkspaceImageRequestDto> images) { | ||
| if (images == null || images.isEmpty()) { | ||
| return List.of(); | ||
| } | ||
| return images.stream() | ||
| .sorted(Comparator | ||
| .comparing(WorkspaceImageRequestDto::getSortOrder, Comparator.nullsLast(Comparator.naturalOrder())) | ||
| .thenComparing(WorkspaceImageRequestDto::getFileId)) | ||
| .map(WorkspaceImageRequestDto::getFileId) | ||
| .toList(); | ||
| } | ||
| } |
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
60 changes: 60 additions & 0 deletions
60
...m/alter/adapter/inbound/manager/workspace/controller/ManagerWorkspaceImageController.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,60 @@ | ||
| package com.dreamteam.alter.adapter.inbound.manager.workspace.controller; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.access.prepost.PreAuthorize; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PutMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.common.dto.CommonApiResponse; | ||
| import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.UpdateWorkspaceImagesRequestDto; | ||
| import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.WorkspaceImageResponseDto; | ||
| import com.dreamteam.alter.application.aop.ManagerActionContext; | ||
| import com.dreamteam.alter.domain.user.context.ManagerActor; | ||
| import com.dreamteam.alter.domain.workspace.port.inbound.ManagerGetWorkspaceImagesUseCase; | ||
| import com.dreamteam.alter.domain.workspace.port.inbound.ManagerUpdateWorkspaceImagesUseCase; | ||
|
|
||
| import jakarta.annotation.Resource; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/manager/workspaces") | ||
| @PreAuthorize("hasAnyRole('MANAGER')") | ||
| @RequiredArgsConstructor | ||
| @Validated | ||
| public class ManagerWorkspaceImageController implements ManagerWorkspaceImageControllerSpec { | ||
|
|
||
| @Resource(name = "managerGetWorkspaceImages") | ||
| private final ManagerGetWorkspaceImagesUseCase managerGetWorkspaceImages; | ||
|
|
||
| @Resource(name = "managerUpdateWorkspaceImages") | ||
| private final ManagerUpdateWorkspaceImagesUseCase managerUpdateWorkspaceImages; | ||
|
hodoon marked this conversation as resolved.
|
||
|
|
||
| @Override | ||
| @GetMapping("/{workspaceId}/images") | ||
| public ResponseEntity<CommonApiResponse<List<WorkspaceImageResponseDto>>> getWorkspaceImages( | ||
| @PathVariable Long workspaceId | ||
| ) { | ||
| ManagerActor actor = ManagerActionContext.getInstance().getActor(); | ||
|
|
||
| return ResponseEntity.ok(CommonApiResponse.of(managerGetWorkspaceImages.execute(actor, workspaceId))); | ||
| } | ||
|
|
||
| @Override | ||
| @PutMapping("/{workspaceId}/images") | ||
| public ResponseEntity<CommonApiResponse<Void>> updateWorkspaceImages( | ||
| @PathVariable Long workspaceId, | ||
| @RequestBody @Valid UpdateWorkspaceImagesRequestDto request | ||
| ) { | ||
| ManagerActor actor = ManagerActionContext.getInstance().getActor(); | ||
| managerUpdateWorkspaceImages.execute(actor, workspaceId, request); | ||
| return ResponseEntity.ok(CommonApiResponse.empty()); | ||
| } | ||
| } | ||
84 changes: 84 additions & 0 deletions
84
...ter/adapter/inbound/manager/workspace/controller/ManagerWorkspaceImageControllerSpec.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,84 @@ | ||
| package com.dreamteam.alter.adapter.inbound.manager.workspace.controller; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.common.dto.CommonApiResponse; | ||
| import com.dreamteam.alter.adapter.inbound.common.dto.ErrorResponse; | ||
| import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.UpdateWorkspaceImagesRequestDto; | ||
| import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.WorkspaceImageResponseDto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.ExampleObject; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
|
|
||
| @Tag(name = "MANAGER - 업장 대표이미지 API") | ||
| public interface ManagerWorkspaceImageControllerSpec { | ||
|
|
||
| @Operation(summary = "매니저 - 업장 대표이미지 목록 조회", description = "노출 순서(sortOrder) 오름차순으로 조회합니다.") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "대표이미지 목록 조회 성공"), | ||
| @ApiResponse(responseCode = "400", description = "존재하지 않는 업장", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = ErrorResponse.class), | ||
| examples = { | ||
| @ExampleObject( | ||
| name = "존재하지 않는 업장입니다.", | ||
| value = "{\"code\" : \"B008\"}" | ||
| ), | ||
| })), | ||
| }) | ||
| ResponseEntity<CommonApiResponse<List<WorkspaceImageResponseDto>>> getWorkspaceImages( | ||
| @PathVariable Long workspaceId | ||
| ); | ||
|
|
||
| @Operation(summary = "매니저 - 업장 대표이미지 수정 (전체 교체)", description = "전달한 대표이미지 목록으로 전체 교체합니다. sortOrder 오름차순이 노출 순서이며(미지정 시 후순위), 추가/삭제/순서변경을 한 번에 처리합니다. 최대 5개.") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "대표이미지 수정 성공"), | ||
| @ApiResponse(responseCode = "400", description = "400 Error 실패 케이스", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = ErrorResponse.class), | ||
| examples = { | ||
| @ExampleObject( | ||
| name = "존재하지 않는 업장입니다.", | ||
| value = "{\"code\" : \"B008\"}" | ||
| ), | ||
| @ExampleObject( | ||
| name = "대표이미지는 최대 5개까지 등록할 수 있습니다.", | ||
| value = "{\"code\" : \"B001\"}" | ||
| ), | ||
| @ExampleObject( | ||
| name = "존재하지 않는 파일입니다.", | ||
| value = "{\"code\" : \"B021\"}" | ||
| ), | ||
| @ExampleObject( | ||
| name = "유효하지 않은 파일입니다.", | ||
| value = "{\"code\" : \"B022\"}" | ||
| ), | ||
| })), | ||
| @ApiResponse(responseCode = "409", description = "이미 연결된 파일", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = ErrorResponse.class), | ||
| examples = { | ||
| @ExampleObject( | ||
| name = "이미 연결된 파일입니다.", | ||
| value = "{\"code\" : \"B025\"}" | ||
| ), | ||
| })), | ||
| }) | ||
| ResponseEntity<CommonApiResponse<Void>> updateWorkspaceImages( | ||
| @PathVariable Long workspaceId, | ||
| @RequestBody @Valid UpdateWorkspaceImagesRequestDto request | ||
| ); | ||
| } |
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
30 changes: 30 additions & 0 deletions
30
...reamteam/alter/adapter/inbound/manager/workspace/dto/UpdateWorkspaceImagesRequestDto.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,30 @@ | ||
| package com.dreamteam.alter.adapter.inbound.manager.workspace.dto; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.common.dto.WorkspaceImageRequestDto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Schema(description = "업장 대표이미지 수정 요청 DTO (전체 교체)") | ||
| public class UpdateWorkspaceImagesRequestDto { | ||
|
|
||
| @NotNull | ||
| @Size(max = 5, message = "대표이미지는 최대 5개까지 등록할 수 있습니다.") | ||
| @Schema(description = "대표이미지 목록 (fileId 중복 자동 제거, sortOrder 오름차순으로 노출, 비우면 전체 삭제)") | ||
| private Set<@Valid WorkspaceImageRequestDto> images; | ||
|
|
||
| public List<String> getOrderedImageFileIds() { | ||
| return WorkspaceImageRequestDto.toOrderedFileIds(images); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
.../com/dreamteam/alter/adapter/inbound/manager/workspace/dto/WorkspaceImageResponseDto.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,33 @@ | ||
| package com.dreamteam.alter.adapter.inbound.manager.workspace.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
| @AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
| @Builder(access = AccessLevel.PRIVATE) | ||
| @Schema(description = "업장 대표이미지 응답 DTO") | ||
| public class WorkspaceImageResponseDto { | ||
|
|
||
| @Schema(description = "파일 ID", example = "01959b4e-4e5f-7c3a-8d9e-0f1a2b3c4d5e") | ||
| private String fileId; | ||
|
|
||
| @Schema(description = "이미지 URL", example = "https://cdn.example.com/workspace_representative_image/abc.jpg") | ||
| private String url; | ||
|
|
||
| @Schema(description = "노출 순서 (0부터 시작)", example = "0") | ||
| private int sortOrder; | ||
|
|
||
| public static WorkspaceImageResponseDto of(String fileId, String url, int sortOrder) { | ||
| return WorkspaceImageResponseDto.builder() | ||
| .fileId(fileId) | ||
| .url(url) | ||
| .sortOrder(sortOrder) | ||
| .build(); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
...m/dreamteam/alter/adapter/outbound/workspace/persistence/WorkspaceImageJpaRepository.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.dreamteam.alter.adapter.outbound.workspace.persistence; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import com.dreamteam.alter.domain.workspace.entity.WorkspaceImage; | ||
|
|
||
| public interface WorkspaceImageJpaRepository extends JpaRepository<WorkspaceImage, Long> { | ||
| List<WorkspaceImage> findByWorkspaceIdOrderBySortOrderAsc(Long workspaceId); | ||
| } |
22 changes: 22 additions & 0 deletions
22
...mteam/alter/adapter/outbound/workspace/persistence/WorkspaceImageQueryRepositoryImpl.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.dreamteam.alter.adapter.outbound.workspace.persistence; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import com.dreamteam.alter.domain.workspace.entity.WorkspaceImage; | ||
| import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceImageQueryRepository; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class WorkspaceImageQueryRepositoryImpl implements WorkspaceImageQueryRepository { | ||
|
|
||
| private final WorkspaceImageJpaRepository workspaceImageJpaRepository; | ||
|
|
||
| @Override | ||
| public List<WorkspaceImage> findAllByWorkspaceId(Long workspaceId) { | ||
| return workspaceImageJpaRepository.findByWorkspaceIdOrderBySortOrderAsc(workspaceId); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
.../dreamteam/alter/adapter/outbound/workspace/persistence/WorkspaceImageRepositoryImpl.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,27 @@ | ||
| package com.dreamteam.alter.adapter.outbound.workspace.persistence; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import com.dreamteam.alter.domain.workspace.entity.WorkspaceImage; | ||
| import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceImageRepository; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class WorkspaceImageRepositoryImpl implements WorkspaceImageRepository { | ||
|
|
||
| private final WorkspaceImageJpaRepository workspaceImageJpaRepository; | ||
|
|
||
| @Override | ||
| public void saveAll(List<WorkspaceImage> workspaceImages) { | ||
| workspaceImageJpaRepository.saveAll(workspaceImages); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteAll(List<WorkspaceImage> workspaceImages) { | ||
| workspaceImageJpaRepository.deleteAll(workspaceImages); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
...team/alter/adapter/outbound/workspace/persistence/WorkspaceRequestImageJpaRepository.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.dreamteam.alter.adapter.outbound.workspace.persistence; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import com.dreamteam.alter.domain.workspace.entity.WorkspaceRequestImage; | ||
|
|
||
| public interface WorkspaceRequestImageJpaRepository extends JpaRepository<WorkspaceRequestImage, Long> { | ||
| List<WorkspaceRequestImage> findByWorkspaceRequestIdOrderBySortOrderAsc(Long workspaceRequestId); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.