-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#41 일반 유저 홈화면 조회 기능 구현 #43
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 15 commits
0bbcf06
fd3ba18
4043201
a938340
74ba3b0
fa7d37f
3fce97f
4d8b8f5
42d2727
23b9d9c
d8ee8e3
0161c88
1dee857
5d2466b
36b30ba
49e67a7
843d1d0
887371a
ef6943d
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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.campus.campus.domain.councilpost.application.dto.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record GetActivePartnershipListForUserResponse( | ||
| @Schema(description = "제휴글 id", example = "1") | ||
| Long postId, | ||
|
|
||
| @Schema(description = "제휴글 이름", example = "투썸 제휴") | ||
| String title, | ||
|
|
||
| @Schema(description = "제휴 장소", example = "투썸 플레이스") | ||
| String place, | ||
|
|
||
| @Schema(description = "썸네일 image url", example = "https://www.example.com.png") | ||
| String thumbnailImageUrl | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.campus.campus.domain.councilpost.application.dto.response; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import com.campus.campus.domain.councilpost.domain.entity.PostCategory; | ||
| import com.campus.campus.domain.councilpost.domain.entity.ThumbnailIcon; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record GetPostListForCouncilResponse( | ||
| @Schema(description = "게시글 id", example = "1") | ||
| Long postId, | ||
|
|
||
| @Schema(description = "게시글 카테고리", example = "EVENT") | ||
| PostCategory category, | ||
|
|
||
| @Schema(description = "게시글 이름", example = "중간고사 간식생사") | ||
| String title, | ||
|
|
||
| @Schema(description = "장소", example = "310관 1층") | ||
| 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, | ||
|
|
||
| @Schema(description = "썸네일 아이콘", example = "FOOD") | ||
| ThumbnailIcon thumbnailIcon | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.campus.campus.domain.councilpost.application.dto.response; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import com.campus.campus.domain.councilpost.domain.entity.PostCategory; | ||
| import com.campus.campus.domain.councilpost.domain.entity.ThumbnailIcon; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record GetUpcomingEventListForCouncilResponse( | ||
| @Schema(description = "게시글 id", example = "1") | ||
| Long postId, | ||
|
|
||
| @Schema(description = "게시글 카테고리", example = "EVENT") | ||
| PostCategory category, | ||
|
|
||
| @Schema(description = "게시글 이름", example = "중간고사 간식생사") | ||
| String title, | ||
|
|
||
| @Schema(description = "장소", example = "310관 1층") | ||
| String place, | ||
|
|
||
| @Schema(description = "시간(끝나는 시간 or 행사날짜", example = "2026-01-10T18:00:00") | ||
| LocalDateTime dateTime, | ||
|
|
||
| @Schema(description = "썸네일 아이콘", example = "FOOD") | ||
| ThumbnailIcon thumbnailIcon | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,10 +12,13 @@ | |||||||||||||||||||||
| import org.springframework.transaction.annotation.Transactional; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import com.campus.campus.domain.council.application.exception.StudentCouncilNotFoundException; | ||||||||||||||||||||||
| import com.campus.campus.domain.council.domain.entity.CouncilType; | ||||||||||||||||||||||
| 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.response.GetActivePartnershipListForUserResponse; | ||||||||||||||||||||||
| import com.campus.campus.domain.councilpost.application.dto.response.GetPostListForCouncilResponse; | ||||||||||||||||||||||
| 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.response.PostListItemResponse; | ||||||||||||||||||||||
| import com.campus.campus.domain.councilpost.application.dto.request.PostRequest; | ||||||||||||||||||||||
| import com.campus.campus.domain.councilpost.application.dto.response.PostResponse; | ||||||||||||||||||||||
| import com.campus.campus.domain.councilpost.application.exception.NotPostWriterException; | ||||||||||||||||||||||
|
|
@@ -29,6 +32,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.user.application.exception.UserNotFoundException; | ||||||||||||||||||||||
| import com.campus.campus.domain.user.domain.entity.User; | ||||||||||||||||||||||
| import com.campus.campus.domain.user.domain.repository.UserRepository; | ||||||||||||||||||||||
| import com.campus.campus.global.oci.application.service.PresignedUrlService; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||
|
|
@@ -39,6 +45,7 @@ | |||||||||||||||||||||
| @RequiredArgsConstructor | ||||||||||||||||||||||
| public class StudentCouncilPostService { | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private final UserRepository userRepository; | ||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| private final StudentCouncilPostRepository postRepository; | ||||||||||||||||||||||
| private final StudentCouncilRepository studentCouncilRepository; | ||||||||||||||||||||||
| private final PostImageRepository postImageRepository; | ||||||||||||||||||||||
|
|
@@ -100,34 +107,67 @@ public PostResponse findById(Long postId, Long currentUserId) { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Transactional(readOnly = true) | ||||||||||||||||||||||
| public Page<PostListItemResponse> findAll(PostCategory category, int page, int size, Long currentUserId) { | ||||||||||||||||||||||
| Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size, Sort.by(Sort.Direction.DESC, "createdAt")); | ||||||||||||||||||||||
| public Page<GetPostListForCouncilResponse> findPostListByCouncilTypeForCouncil(Long councilId, | ||||||||||||||||||||||
| PostCategory category, | ||||||||||||||||||||||
| CouncilType councilType, int page, int size) { | ||||||||||||||||||||||
| StudentCouncil studentCouncil = studentCouncilRepository | ||||||||||||||||||||||
| .findByIdAndManagerApprovedIsTrueAndDeletedAtIsNull(councilId) | ||||||||||||||||||||||
| .orElseThrow(StudentCouncilNotFoundException::new); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Page<StudentCouncilPost> posts = (category == null) | ||||||||||||||||||||||
| ? postRepository.findAll(pageable) | ||||||||||||||||||||||
| : postRepository.findAllByCategory(category, pageable); | ||||||||||||||||||||||
| Long schoolId = studentCouncil.getSchool().getSchoolId(); | ||||||||||||||||||||||
| Long collegeId = CouncilType.COLLEGE_COUNCIL.equals(councilType) | ||||||||||||||||||||||
| && studentCouncil.getCollege() != null | ||||||||||||||||||||||
| ? studentCouncil.getCollege().getCollegeId() | ||||||||||||||||||||||
| : null; | ||||||||||||||||||||||
| Long majorId = CouncilType.MAJOR_COUNCIL.equals(councilType) | ||||||||||||||||||||||
| && studentCouncil.getMajor() != null | ||||||||||||||||||||||
| ? studentCouncil.getMajor().getMajorId() | ||||||||||||||||||||||
| : null; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Sort sort; | ||||||||||||||||||||||
| if (category == PostCategory.EVENT) { | ||||||||||||||||||||||
| sort = Sort.by(Sort.Direction.ASC, "startDateTime"); | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| sort = Sort.by(Sort.Direction.ASC, "endDateTime"); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return posts.map(post -> | ||||||||||||||||||||||
| studentCouncilPostMapper.toPostListItemResponse(post, currentUserId) | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size, sort); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| LocalDateTime now = LocalDateTime.now(); | ||||||||||||||||||||||
|
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 static final ZoneId KST = ZoneId.of("Asia/Seoul");
+
@Transactional(readOnly = true)
public Page<GetPostListForCouncilResponse> findPostListForCouncil(Long councilId, PostCategory category,
int page, int size) {
// ...
Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size, sort);
- LocalDateTime now = LocalDateTime.now();
+ LocalDateTime now = LocalDateTime.now(KST);Line 136도 동일하게 수정 필요합니다. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Page<StudentCouncilPost> posts = postRepository.findPostsBySchoolAndFilters(schoolId, councilType, category, | ||||||||||||||||||||||
| collegeId, majorId, now, pageable); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return posts.map(studentCouncilPostMapper::toGetPostListForCouncilResponse); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Transactional(readOnly = true) | ||||||||||||||||||||||
| public Page<PostListItemResponse> findUpcomingEvents(int page, int size, Long currentUserId) { | ||||||||||||||||||||||
| Pageable pageable = PageRequest.of( | ||||||||||||||||||||||
| Math.max(page - 1, 0), | ||||||||||||||||||||||
| size, | ||||||||||||||||||||||
| Sort.by(Sort.Direction.ASC, "startDateTime") | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| public Page<GetUpcomingEventListForCouncilResponse> findUpcomingEventsByCouncilTypeForCouncil(Long councilId, | ||||||||||||||||||||||
| CouncilType councilType, int page, int size) { | ||||||||||||||||||||||
| Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size, | ||||||||||||||||||||||
| Sort.by(Sort.Direction.ASC, "startDateTime")); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| StudentCouncil studentCouncil = studentCouncilRepository | ||||||||||||||||||||||
| .findByIdAndManagerApprovedIsTrueAndDeletedAtIsNull(councilId) | ||||||||||||||||||||||
| .orElseThrow(StudentCouncilNotFoundException::new); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Long schoolId = studentCouncil.getSchool().getSchoolId(); | ||||||||||||||||||||||
| Long collegeId = CouncilType.COLLEGE_COUNCIL.equals(councilType) | ||||||||||||||||||||||
| && studentCouncil.getCollege() != null | ||||||||||||||||||||||
| ? studentCouncil.getCollege().getCollegeId() | ||||||||||||||||||||||
| : null; | ||||||||||||||||||||||
| Long majorId = CouncilType.MAJOR_COUNCIL.equals(councilType) | ||||||||||||||||||||||
| && studentCouncil.getMajor() != null | ||||||||||||||||||||||
| ? studentCouncil.getMajor().getMajorId() | ||||||||||||||||||||||
| : null; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| LocalDateTime now = LocalDateTime.now(); | ||||||||||||||||||||||
| LocalDateTime limit = now.plusHours(UPCOMING_EVENT_WINDOW_HOURS); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Page<StudentCouncilPost> posts = postRepository.findUpcomingEvents(PostCategory.EVENT, now, limit, pageable); | ||||||||||||||||||||||
| Page<StudentCouncilPost> posts = postRepository.findUpcomingEventsBySchoolAndFilters(schoolId, councilType, | ||||||||||||||||||||||
| PostCategory.EVENT, collegeId, majorId, now, limit, pageable); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return posts.map(post -> | ||||||||||||||||||||||
| studentCouncilPostMapper.toPostListItemResponse(post, currentUserId) | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| return posts.map(studentCouncilPostMapper::toGetUpcomingEventListForCouncilResponse); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Transactional | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.