-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#42 학생회 게시글 좋아요 기능 구현 #44
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9c0c347
feat: 학생회 게시글 좋아요 엔티티 구현
1winhyun 970db8d
feat: 학생회 게시글 좋아요 기능 구현
1winhyun cef4b68
feat: 관심(좋아요 누른) 학생회 게시글 목록 조회 기능 구현
1winhyun 57730c3
refactor: LikePost 유니크 제약 조건 추가
1winhyun c73b0d0
refactor: LikePostResponse 스키마 수정
1winhyun 682f910
refactor: LikePostResponse 스키마 수정
1winhyun c406bca
refactor: conflict(충돌) 해결
1winhyun af9d12f
refactor: 유저 학생회 게시글 좋아요 관련 기능 StudentCouncilPostForUser 내로 이동
1winhyun c513660
refactor: 일반 유저가 학생회 게시글 목록 조회 시 좋아요를 눌렀는지 여부를 나타내는 로직 추가
1winhyun 49de9e8
refactor: 유저 학생회 게시글 상세 조회 시 좋아요 눌렀는지 여부 표시되도록 로직 구현, 유저/학생회 별 좋아요 여부…
1winhyun 6859e89
refactor: 유저의 학생회 게시글 상세조회 dto명 수정
1winhyun 9a61904
refactor: StudentCouncilPostForUserController 중복 어노테이션 삭제
1winhyun e55cdfd
refactor: PostListItemResponse isWriter 필드 삭제
1winhyun a5f80d0
refactor: 좋아요 기능 동시성 해결을 위해 조회 후 분기 자체를 삭제 후 삭제 시도 후 삽입 시도 패턴으로 수정, s…
1winhyun 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
23 changes: 23 additions & 0 deletions
23
...a/com/campus/campus/domain/councilpost/application/dto/response/GetLikedPostResponse.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,23 @@ | ||
| package com.campus.campus.domain.councilpost.application.dto.response; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record GetLikedPostResponse( | ||
| @Schema(description = "게시글 id", example = "1") | ||
| Long postId, | ||
|
|
||
| @Schema(description = "게시글 이름", example = "투썸 제휴") | ||
| String title, | ||
|
|
||
| @Schema(description = "게시글 장소", example = "투썸 플레이스") | ||
| String place, | ||
|
|
||
| @Schema(description = "시간(끝나는 시간 or 행사날짜)", example = "2026-01-10T18:00:00") | ||
| LocalDateTime dateTime, | ||
|
|
||
| @Schema(description = "썸네일 image url", example = "https://www.example.com.png") | ||
| String thumbnailImageUrl | ||
| ) { | ||
| } |
36 changes: 36 additions & 0 deletions
36
...com/campus/campus/domain/councilpost/application/dto/response/GetPostForUserResponse.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,36 @@ | ||
| package com.campus.campus.domain.councilpost.application.dto.response; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| import com.campus.campus.domain.councilpost.domain.entity.PostCategory; | ||
| import com.campus.campus.domain.councilpost.domain.entity.ThumbnailIcon; | ||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
|
||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public record GetPostForUserResponse( | ||
|
|
||
| Long id, | ||
| Long writerId, | ||
| String writerName, | ||
|
|
||
| PostCategory category, | ||
| String title, | ||
| String content, | ||
| String place, | ||
| LocalDate startDate, | ||
| LocalDate endDate, | ||
| LocalDateTime startDateTime, | ||
|
|
||
| String thumbnailImageUrl, | ||
| ThumbnailIcon thumbnailIcon, | ||
|
|
||
| boolean isLiked, | ||
|
|
||
| List<String> images | ||
| ) { | ||
| } |
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
15 changes: 15 additions & 0 deletions
15
.../java/com/campus/campus/domain/councilpost/application/dto/response/LikePostResponse.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,15 @@ | ||
| package com.campus.campus.domain.councilpost.application.dto.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record LikePostResponse( | ||
| @Schema(description = "좋아요 누른 사용자 id", example = "1") | ||
| Long userId, | ||
|
|
||
| @Schema(description = "좋아요 누를 게시글의 id", example = "1") | ||
| Long postId, | ||
|
|
||
| @Schema(description = "좋아요 여부", example = "true") | ||
| boolean liked | ||
| ) { | ||
| } |
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
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.
게시글 작성자 null 체크 필요
Line 75에서
post.getWriter()의 결과를 null 체크 없이 사용하고 있습니다.StudentCouncilPost엔티티의writer필드는@ManyToOne으로 정의되어 있으나@NotNull제약이 없어 null일 가능성이 있습니다. Lines 78-79에서writer.getId()및writer.getCouncilName()호출 시 NPE가 발생할 수 있습니다.🛡️ NPE 방지를 위한 수정 제안
public GetPostResponse toGetPostResponse(StudentCouncilPost post, List<String> images, Long currentCouncilId) { var writer = post.getWriter(); + if (writer == null) { + throw new IllegalStateException("게시글에 작성자 정보가 없습니다."); + } var builder = GetPostResponse.builder() .id(post.getId()) .writerId(writer.getId())또는 서비스 계층에서 writer가 항상 존재함을 보장하는 경우, 엔티티에
@NotNull제약을 추가하는 것을 권장합니다.🤖 Prompt for AI Agents