-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 분실물 게시글 수정 API 추가 #2135
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
feat: 분실물 게시글 수정 API 추가 #2135
Changes from all commits
Commits
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
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
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
49 changes: 49 additions & 0 deletions
49
...ain/java/in/koreatech/koin/domain/community/article/dto/LostItemArticleUpdateRequest.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,49 @@ | ||
| package in.koreatech.koin.domain.community.article.dto; | ||
|
|
||
| import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| @JsonNaming(value = SnakeCaseStrategy.class) | ||
| public record LostItemArticleUpdateRequest( | ||
| @NotNull(message = "분실물 종류는 필수로 입력해야 합니다.") | ||
| @Schema(description = "분실물 종류", example = "신분증", requiredMode = REQUIRED) | ||
| String category, | ||
|
|
||
| @NotNull(message = "분실물 습득 장소는 필수로 입력해야 합니다.") | ||
| @Schema(description = "습득 장소", example = "학생회관 앞", requiredMode = REQUIRED) | ||
| String foundPlace, | ||
|
|
||
| @NotNull(message = "분실물 습득 날짜는 필수로 입력해야 합니다.") | ||
| @Schema(description = "습득 날짜", example = "2025-01-01", requiredMode = REQUIRED) | ||
| LocalDate foundDate, | ||
|
|
||
| @Size(max = 1000, message = "본문의 내용은 최대 1,000자까지만 입력할 수 있습니다.") | ||
| @Schema(description = "본문", example = "학생회관 앞 계단에 …") | ||
| String content, | ||
|
|
||
| @Size(max = 10, message = "이미지는 최대 10개까지만 업로드할 수 있습니다.") | ||
| @Schema(description = "분실물 사진 (새로 추가할 이미지)") | ||
| List<String> newImages, | ||
|
|
||
| @Schema(description = "삭제할 이미지 ID 목록") | ||
| List<Integer> deleteImageIds | ||
| ) { | ||
| public LostItemArticleUpdateRequest { | ||
| if (newImages == null) { | ||
| newImages = new ArrayList<>(); | ||
| } | ||
| if (deleteImageIds == null) { | ||
| deleteImageIds = new ArrayList<>(); | ||
| } | ||
| } | ||
| } |
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
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
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
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 |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| import in.koreatech.koin.common.model.Criteria; | ||
| import in.koreatech.koin.domain.community.article.dto.LostItemArticleResponse; | ||
| import in.koreatech.koin.domain.community.article.dto.LostItemArticleStatisticsResponse; | ||
| import in.koreatech.koin.domain.community.article.dto.LostItemArticleUpdateRequest; | ||
| import in.koreatech.koin.domain.community.article.dto.LostItemArticlesRequest; | ||
| import in.koreatech.koin.domain.community.article.dto.LostItemArticlesResponse; | ||
| import in.koreatech.koin.domain.community.article.exception.ArticleBoardMisMatchException; | ||
|
|
@@ -179,6 +180,24 @@ public void markLostItemArticleAsFound(Integer userId, Integer articleId) { | |
| lostItemArticle.markAsFound(); | ||
| } | ||
|
|
||
| @Transactional | ||
| public LostItemArticleResponse updateLostItemArticle(Integer userId, Integer articleId, LostItemArticleUpdateRequest request) { | ||
| LostItemArticle lostItemArticle = lostItemArticleRepository.getByArticleId(articleId); | ||
| lostItemArticle.checkOwnership(userId); | ||
|
|
||
| lostItemArticle.update( | ||
| request.category(), | ||
| request.foundPlace(), | ||
| request.foundDate(), | ||
| request.content() | ||
| ); | ||
|
|
||
| lostItemArticle.deleteImages(request.deleteImageIds()); | ||
| lostItemArticle.addNewImages(request.newImages()); | ||
|
|
||
| return LostItemArticleResponse.of(lostItemArticle.getArticle(), true); | ||
| } | ||
|
Comment on lines
+183
to
+199
Contributor
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. 깔끔쓰하네요 |
||
|
|
||
| private void setPrevNextArticle(Integer boardId, Article article) { | ||
| Article prevArticle; | ||
| Article nextArticle; | ||
|
|
||
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
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.
삭제 없이 새 이미지를 매 요청마다 최대 10개씩 추가할 수 있어, 동일한 요청을 여러 번 보낼 경우 총 이미지 수가 10개를 초과할 위험이 있어 보여요!
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.
이거 게시글 등록 API에서도 검증 로직이 없어서 뺐습니다.