-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#31 제휴게시글 관련 기능 구현 #46
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
Changes from all commits
ca8cfe8
8e1f824
7681fa5
cc9b602
d665ad7
7e87544
bac8a34
8ee1e0a
87ec0be
c9ceb4e
4e166c7
0043725
c452d48
6fed75f
e00705e
13d661b
f7d2ecf
b2eeccd
23604f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,18 +7,19 @@ | |
| import org.springframework.stereotype.Component; | ||
|
|
||
| import com.campus.campus.domain.council.domain.entity.StudentCouncil; | ||
| import com.campus.campus.domain.councilpost.application.dto.request.PostRequest; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetActivePartnershipListForUserResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetLikedPostResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetPostResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.LikePostResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetPostForUserResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetPostListForCouncilResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetPostResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetUpcomingEventListForCouncilResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetActivePartnershipListForUserResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.LikePostResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.PostListItemResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.request.PostRequest; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetPostForUserResponse; | ||
| import com.campus.campus.domain.councilpost.domain.entity.LikePost; | ||
| import com.campus.campus.domain.councilpost.domain.entity.PostImage; | ||
| import com.campus.campus.domain.councilpost.domain.entity.StudentCouncilPost; | ||
| import com.campus.campus.domain.place.domain.entity.Place; | ||
| import com.campus.campus.domain.user.domain.entity.User; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
@@ -31,8 +32,10 @@ public PostListItemResponse toPostListItemResponse(StudentCouncilPost post, bool | |
| post.getId(), | ||
| post.getCategory(), | ||
| post.getTitle(), | ||
| post.getPlace(), | ||
| post.isEvent() ? post.getStartDateTime() : post.getEndDateTime(), | ||
| post.getPlace().getPlaceId(), | ||
|
Member
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. 따라서 해당 부분 또한 getPlaceName()이 되어야합니다. |
||
| post.isEvent() | ||
| ? post.getStartDateTime() | ||
| : post.getEndDateTime(), | ||
| post.getThumbnailImageUrl(), | ||
| post.getThumbnailIcon(), | ||
| isLiked | ||
|
|
@@ -44,7 +47,7 @@ public GetPostListForCouncilResponse toGetPostListForCouncilResponse(StudentCoun | |
| post.getId(), | ||
| post.getCategory(), | ||
| post.getTitle(), | ||
| post.getPlace(), | ||
| post.getPlace().getPlaceName(), | ||
| post.isEvent() ? post.getStartDateTime() : post.getEndDateTime(), | ||
| post.getThumbnailImageUrl(), | ||
| post.getThumbnailIcon() | ||
|
|
@@ -56,7 +59,7 @@ public GetUpcomingEventListForCouncilResponse toGetUpcomingEventListForCouncilRe | |
| post.getId(), | ||
| post.getCategory(), | ||
| post.getTitle(), | ||
| post.getPlace(), | ||
| post.getPlace().getPlaceName(), | ||
| post.getStartDateTime(), | ||
| post.getThumbnailIcon() | ||
| ); | ||
|
|
@@ -66,7 +69,7 @@ public GetActivePartnershipListForUserResponse toGetActivePartnershipListForUser | |
| return new GetActivePartnershipListForUserResponse( | ||
| post.getId(), | ||
| post.getTitle(), | ||
| post.getPlace(), | ||
| post.getPlace().getPlaceName(), | ||
| post.getThumbnailImageUrl() | ||
| ); | ||
| } | ||
|
|
@@ -81,7 +84,7 @@ public GetPostResponse toGetPostResponse(StudentCouncilPost post, List<String> i | |
| .category(post.getCategory()) | ||
| .title(post.getTitle()) | ||
| .content(post.getContent()) | ||
| .place(post.getPlace()) | ||
| .placeName(post.getPlace().getPlaceName()) | ||
| .thumbnailImageUrl(post.getThumbnailImageUrl()) | ||
| .thumbnailIcon(post.getThumbnailIcon()) | ||
| .images(images != null ? images : Collections.emptyList()); | ||
|
|
@@ -96,6 +99,9 @@ public GetPostResponse toGetPostResponse(StudentCouncilPost post, List<String> i | |
| return builder.build(); | ||
| } | ||
|
|
||
| // | ||
| // public StudentCouncilPost createStudentCouncilPost(StudentCouncil writer, PostRequest dto, | ||
| // LocalDateTime startDateTime, LocalDateTime endDateTime, Place place) { | ||
|
Comment on lines
+102
to
+104
Member
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. 해당 주석은 삭제해도 될 것 같아요!! |
||
| public GetPostForUserResponse toGetPostForUserResponse(StudentCouncilPost post, List<String> images, | ||
| Long currentUserId, boolean isLiked) { | ||
| var writer = post.getWriter(); | ||
|
|
@@ -106,7 +112,7 @@ public GetPostForUserResponse toGetPostForUserResponse(StudentCouncilPost post, | |
| .category(post.getCategory()) | ||
| .title(post.getTitle()) | ||
| .content(post.getContent()) | ||
| .place(post.getPlace()) | ||
| .place(post.getPlace().getPlaceName()) | ||
| .thumbnailImageUrl(post.getThumbnailImageUrl()) | ||
| .thumbnailIcon(post.getThumbnailIcon()) | ||
| .isLiked(isLiked) | ||
|
|
@@ -134,20 +140,20 @@ public GetLikedPostResponse toGetLikedPostResponse(StudentCouncilPost post) { | |
| return new GetLikedPostResponse( | ||
| post.getId(), | ||
| post.getTitle(), | ||
| post.getPlace(), | ||
| post.getPlace().getPlaceName(), | ||
| post.isEvent() ? post.getStartDateTime() : post.getEndDateTime(), | ||
| post.getThumbnailImageUrl() | ||
| ); | ||
| } | ||
|
|
||
| public StudentCouncilPost createStudentCouncilPost(StudentCouncil writer, PostRequest dto, | ||
| public StudentCouncilPost createStudentCouncilPost(StudentCouncil writer, Place place, PostRequest dto, | ||
| LocalDateTime startDateTime, LocalDateTime endDateTime) { | ||
| return StudentCouncilPost.builder() | ||
| .writer(writer) | ||
| .category(dto.category()) | ||
| .title(dto.title()) | ||
| .content(dto.content()) | ||
| .place(dto.place()) | ||
| .place(place) | ||
| .startDateTime(startDateTime) | ||
| .endDateTime(endDateTime) | ||
| .thumbnailImageUrl(dto.thumbnailImageUrl()) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,11 +14,11 @@ | |
| import com.campus.campus.domain.council.application.exception.StudentCouncilNotFoundException; | ||
| import com.campus.campus.domain.council.domain.entity.StudentCouncil; | ||
| import com.campus.campus.domain.council.domain.repository.StudentCouncilRepository; | ||
| import com.campus.campus.domain.councilpost.application.dto.request.PostRequest; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetPostListForCouncilResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetPostResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.GetUpcomingEventListForCouncilResponse; | ||
| import com.campus.campus.domain.councilpost.application.dto.response.NormalizedDateTime; | ||
| import com.campus.campus.domain.councilpost.application.dto.request.PostRequest; | ||
| import com.campus.campus.domain.councilpost.application.exception.NotPostWriterException; | ||
| import com.campus.campus.domain.councilpost.application.exception.PostImageLimitExceededException; | ||
| import com.campus.campus.domain.councilpost.application.exception.PostNotFoundException; | ||
|
|
@@ -30,6 +30,9 @@ | |
| import com.campus.campus.domain.councilpost.domain.entity.StudentCouncilPost; | ||
| import com.campus.campus.domain.councilpost.domain.repository.PostImageRepository; | ||
| import com.campus.campus.domain.councilpost.domain.repository.StudentCouncilPostRepository; | ||
| import com.campus.campus.domain.partnership.application.service.PartnershipService; | ||
| import com.campus.campus.domain.place.application.service.PlaceService; | ||
| import com.campus.campus.domain.place.domain.entity.Place; | ||
| import com.campus.campus.global.oci.application.service.PresignedUrlService; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
@@ -48,6 +51,9 @@ public class StudentCouncilPostService { | |
|
|
||
| private static final int MAX_IMAGE_COUNT = 10; | ||
| private static final long UPCOMING_EVENT_WINDOW_HOURS = 72L; | ||
| private final PlaceService placeService; | ||
| private final StudentCouncilPostRepository studentCouncilPostRepository; | ||
| private final PartnershipService partnershipService; | ||
|
|
||
| @Transactional | ||
| public GetPostResponse create(Long councilId, PostRequest dto) { | ||
|
|
@@ -65,12 +71,18 @@ public GetPostResponse create(Long councilId, PostRequest dto) { | |
|
|
||
| NormalizedDateTime normalized = dto.category().validateAndNormalize(dto); | ||
|
|
||
| //Place 객체 생성 | ||
| Place place = placeService.findOrCreatePlace(dto); | ||
|
|
||
| StudentCouncilPost post = studentCouncilPostMapper.createStudentCouncilPost( | ||
| writer, dto, normalized.startDateTime(), normalized.endDateTime() | ||
| writer, place, dto, normalized.startDateTime(), normalized.endDateTime() | ||
| ); | ||
|
|
||
| postRepository.save(post); | ||
|
|
||
| //제휴 엔티티 생성 | ||
| partnershipService.create(post, place); | ||
|
Comment on lines
+83
to
+84
Member
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. 이 부분은 삭제해주시면 될 것 같아요!! |
||
|
|
||
| if (dto.imageUrls() != null) { | ||
| for (String imageUrl : dto.imageUrls()) { | ||
| postImageRepository.save(studentCouncilPostMapper.createPostImage(post, imageUrl)); | ||
|
|
@@ -203,10 +215,15 @@ public GetPostResponse update(Long councilId, Long postId, PostRequest dto) { | |
| String oldThumbnailUrl = post.getThumbnailImageUrl(); | ||
| List<PostImage> oldImages = postImageRepository.findAllByPost(post); | ||
|
|
||
| Place place = post.getPlace(); | ||
| if (!dto.place().placeName().equals(place.getPlaceName())) { | ||
| place = placeService.findOrCreatePlace(dto); | ||
| } | ||
|
|
||
| post.update( | ||
| dto.title(), | ||
| dto.content(), | ||
| dto.place(), | ||
| place, | ||
| normalized.startDateTime(), | ||
| normalized.endDateTime(), | ||
| dto.thumbnailImageUrl(), | ||
|
|
||
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.
해당 response의 경우 필요한 부분은 placeId가 아닌 placeName입니다. 프론트에 보내줘야할 응답값은 해당 장소가 어디인지가 아닌 해당 장소의 이름이기 때문입니다!!