Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,21 @@ public GetPostForUserResponse findById(Long postId, Long userId) {
return studentCouncilPostMapper.toGetPostForUserResponse(post, imageUrls, userId, isLiked);
}

public Page<PostListItemResponse> findSchoolPosts(PostCategory category, int page, int size, Long userId, Long excludePostId) {
public Page<PostListItemResponse> findSchoolPosts(PostCategory category, int page, int size, Long userId,
Long excludePostId) {
User user = userRepository.findByIdWithAcademicInfo(userId).orElseThrow(UserNotFoundException::new);

Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size, Sort.by(Sort.Direction.DESC, "startDateTime"));

Page<StudentCouncilPost> posts = studentCouncilPostRepository
.findBySchoolId(user.getSchool().getSchoolId(), category, CouncilType.SCHOOL_COUNCIL, excludePostId, pageable);
.findBySchoolId(user.getSchool().getSchoolId(), category, CouncilType.SCHOOL_COUNCIL, excludePostId,
pageable);

return mapPostsWithLikes(posts, userId);
}

public Page<PostListItemResponse> findCollegePosts(PostCategory category, int page, int size, Long userId, Long excludePostId) {
public Page<PostListItemResponse> findCollegePosts(PostCategory category, int page, int size, Long userId,
Long excludePostId) {
User user = userRepository.findByIdWithAcademicInfo(userId).orElseThrow(UserNotFoundException::new);

if (user.isProfileNotCompleted() || user.getCollege() == null) {
Expand All @@ -128,12 +131,14 @@ public Page<PostListItemResponse> findCollegePosts(PostCategory category, int pa
Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size, Sort.by(Sort.Direction.DESC, "startDateTime"));

Page<StudentCouncilPost> posts = studentCouncilPostRepository
.findByCollegeId(user.getCollege().getCollegeId(), category, CouncilType.COLLEGE_COUNCIL, excludePostId, pageable);
.findByCollegeId(user.getCollege().getCollegeId(), category, CouncilType.COLLEGE_COUNCIL, excludePostId,
pageable);

return mapPostsWithLikes(posts, userId);
}

public Page<PostListItemResponse> findMajorPosts(PostCategory category, int page, int size, Long userId, Long excludePostId) {
public Page<PostListItemResponse> findMajorPosts(PostCategory category, int page, int size, Long userId,
Long excludePostId) {
User user = userRepository.findByIdWithAcademicInfo(userId).orElseThrow(UserNotFoundException::new);

if (user.isProfileNotCompleted() || user.getMajor() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.campus.campus.domain.council.domain.entity.CouncilType;
import com.campus.campus.domain.councilpost.domain.entity.PostCategory;
import com.campus.campus.domain.councilpost.domain.entity.StudentCouncilPost;
import com.campus.campus.domain.councilpost.domain.entity.ThumbnailIcon;

public interface StudentCouncilPostRepository extends JpaRepository<StudentCouncilPost, Long> {

Expand Down Expand Up @@ -313,4 +314,32 @@ List<StudentCouncilPost> findTop3RecommendedPartnershipPlaces(
Pageable pageable
);


@EntityGraph(attributePaths = {"writer", "writer.school", "writer.college", "writer.major", "place"})
@Query("""
SELECT p FROM StudentCouncilPost p
JOIN p.writer w
JOIN p.place pl
LEFT JOIN w.school s
LEFT JOIN w.college c
LEFT JOIN w.major m
WHERE p.category = 'PARTNERSHIP'
AND p.thumbnailIcon = :icon
AND :now BETWEEN p.startDateTime AND p.endDateTime
AND w.deletedAt IS NULL
AND (
(w.councilType = 'SCHOOL_COUNCIL' AND s.schoolId = :schoolId)
OR (w.councilType = 'COLLEGE_COUNCIL' AND c.collegeId = :collegeId)
OR (w.councilType = 'MAJOR_COUNCIL' AND m.majorId = :majorId)
)
ORDER BY p.id DESC
""")
List<StudentCouncilPost> findRandomPartnershipPlace(
@Param("schoolId") Long schoolId,
@Param("collegeId") Long collegeId,
@Param("majorId") Long majorId,
@Param("icon") ThumbnailIcon icon,
@Param("now") LocalDateTime now,
Pageable pageable
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.campus.campus.domain.place.application.dto.response;

import java.util.List;

import com.campus.campus.domain.place.domain.entity.Coordinate;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;

public record RecommendNearByPlaceResponse(
@Schema(description = "해당 장소명", example = "숙명여자대학교")
@NotBlank
String placeName,

@Schema(description = "장소 식별 고유 ID")
@NotBlank
String placeKey,

@Schema(description = "장소 주소", example = "서울특별시 용산구 청파로47길 99")
@NotBlank
String address,

@Schema(description = "장소 카테고리", example = "교육,학문>대학교")
@NotBlank
String category,

@Schema(description = "장소 상세 정보 네이버 페이지 하이퍼링크", example = "https://map.naver.com/v5/search/%EC%88%99%EB%AA%85%EC%97%AC%EC%9E%90%EB%8C%80%ED%95%99%EA%B5%90+%EC%A0%9C1%EC%BA%A0%ED%8D%BC%EC%8A%A4?c=37.545947,126.964578,15,0,0,0,dh")
String link,

@Schema(description = "전화번호", example = "010-1234-1234")
String telephone,

@Schema(description = "위도/경도")
Coordinate coordinate,

@Schema(description = "이미지 url")
List<String> imgUrls
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.campus.campus.domain.place.application.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;

public record RecommendPartnershipPlaceResponse(
@Schema(description = "장소 ID", example = "10")
Long placeId,

@Schema(description = "장소 이름", example = "봉구스밥버거 중앙대후문점")
String placeName,

@Schema(description = "제휴한 학생회 이름", example = "가천대학교 총학생회")
String councilName,

@Schema(description = "제휴 이름 (게시글 제목)", example = "전 메뉴 10% 할인")
String partnershipTitle,

@Schema(description = "장소 주소", example = "서울특별시 동작구 상도1동")
String address,

@Schema(description = "제휴 썸네일 이미지", example = "https://cdn.example.com/image.jpg")
String imageUrl
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.campus.campus.domain.place.application.dto.response;

import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;

public record RecommendPlaceByTimeResponse(
@Schema(description = "추천 타입 (LUNCH: 점심, CAFE: 카페, NONE: 해당 시간 아님)", example = "LUNCH")
String type,

@Schema(description = "추천 제휴 게시글 (최대 2개)")
List<RecommendPartnershipPlaceResponse> partnershipPosts,

@Schema(description = "추천 주변 장소 (최대 2개)")
List<RecommendNearByPlaceResponse> nearbyPlaces
) {
Comment on lines +7 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

@Schema 설명과 실제 사용 값 불일치

@Schema description에 "LUNCH: 점심, CAFE: 카페, NONE: 해당 시간 아님"으로 명시되어 있으나, PlaceService에서 실제로 사용하는 값은 "LUNCH", "CAFE", "DINNER", "BAR", "잠잘시간입니다."입니다. API 문서와 실제 동작이 일치하도록 수정이 필요합니다.

📝 제안 수정안
 public record RecommendPlaceByTimeResponse(
-	@Schema(description = "추천 타입 (LUNCH: 점심, CAFE: 카페, NONE: 해당 시간 아님)", example = "LUNCH")
+	@Schema(description = "추천 타입 (LUNCH: 점심, CAFE: 카페, DINNER: 저녁, BAR: 술집, 또는 추천 시간대 아님)", example = "LUNCH")
 	String type,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public record RecommendPlaceByTimeResponse(
@Schema(description = "추천 타입 (LUNCH: 점심, CAFE: 카페, NONE: 해당 시간 아님)", example = "LUNCH")
String type,
@Schema(description = "추천 제휴 게시글 (최대 2개)")
List<RecommendPartnershipPlaceResponse> partnershipPosts,
@Schema(description = "추천 주변 장소 (최대 2개)")
List<RecommendNearByPlaceResponse> nearbyPlaces
) {
public record RecommendPlaceByTimeResponse(
@Schema(description = "추천 타입 (LUNCH: 점심, CAFE: 카페, DINNER: 저녁, BAR: 술집, 또는 추천 시간대 아님)", example = "LUNCH")
String type,
@Schema(description = "추천 제휴 게시글 (최대 2개)")
List<RecommendPartnershipPlaceResponse> partnershipPosts,
@Schema(description = "추천 주변 장소 (최대 2개)")
List<RecommendNearByPlaceResponse> nearbyPlaces
) {
🤖 Prompt for AI Agents
In
@src/main/java/com/campus/campus/domain/place/application/dto/response/RecommendPlaceByTimeResponse.java
around lines 7 - 16, The @Schema on the RecommendPlaceByTimeResponse record's
type field is inaccurate; update its description (and example if present) to
match the actual values emitted by PlaceService (e.g., "LUNCH", "CAFE",
"DINNER", "BAR", and "잠잘시간입니다.") or alternatively change PlaceService to emit
only the documented values—ensure the documented enum/list in
RecommendPlaceByTimeResponse.type matches PlaceService behavior so API docs and
runtime are consistent.

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import com.campus.campus.domain.councilpost.domain.entity.StudentCouncilPost;
import com.campus.campus.domain.place.application.dto.response.PartnershipPinResponse;
import com.campus.campus.domain.place.application.dto.response.LikeResponse;
import com.campus.campus.domain.place.application.dto.response.RecommendNearByPlaceResponse;
import com.campus.campus.domain.place.application.dto.response.RecommendPartnershipPlaceResponse;
import com.campus.campus.domain.place.application.dto.response.RecommendPlaceByTimeResponse;
import com.campus.campus.domain.place.application.dto.response.SavedPlaceInfo;
import com.campus.campus.domain.place.application.dto.response.naver.NaverSearchResponse;
import com.campus.campus.domain.place.application.dto.response.partnership.PartnershipResponse;
Expand Down Expand Up @@ -69,6 +72,37 @@ public PartnershipResponse toPartnershipResponse(User user, StudentCouncilPost p
);
}

public RecommendPlaceByTimeResponse toRecommendPlaceByTimeResponse(String type,
List<RecommendPartnershipPlaceResponse> partnershipPosts, List<RecommendNearByPlaceResponse> nearbyPlaces) {

return new RecommendPlaceByTimeResponse(type, partnershipPosts, nearbyPlaces);
}

public RecommendPartnershipPlaceResponse toRecommendPartnershipPlaceResponse(StudentCouncilPost post) {
return new RecommendPartnershipPlaceResponse(
post.getPlace().getPlaceId(),
post.getPlace().getPlaceName(),
post.getWriter().getCouncilName(),
post.getTitle(),
post.getPlace().getAddress(),
post.getThumbnailImageUrl()
);
}

public RecommendNearByPlaceResponse toRecommendNearByPlaceResponse(SavedPlaceInfo savedPlaceInfo,
List<String> imageUrl) {
return new RecommendNearByPlaceResponse(
savedPlaceInfo.placeName(),
savedPlaceInfo.placeKey(),
savedPlaceInfo.address(),
savedPlaceInfo.category(),
savedPlaceInfo.link(),
savedPlaceInfo.telephone(),
savedPlaceInfo.coordinate(),
imageUrl
);
}

private String resolveTag(StudentCouncilPost post, User user) {
CouncilType councilType = post.getWriter().getCouncilType();
return switch (councilType) {
Expand Down
Loading