diff --git a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadMainActivityRes.java b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadMainActivityRes.java index f14adab..ab7b791 100644 --- a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadMainActivityRes.java +++ b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadMainActivityRes.java @@ -14,6 +14,7 @@ @Getter public class ReadMainActivityRes { private List personalities; + private String imageUrl; private Boolean isLiked; private String title; private Long currentParticipants; @@ -29,6 +30,7 @@ public static ReadMainActivityRes of(Activity activity, Boolean isLiked) { .map(Personality::getDescription) .toList() ) + .imageUrl(activity.getImageUrl()) .isLiked(isLiked) .title(activity.getTitle()) .currentParticipants(activity.getCurrentParticipants()) diff --git a/src/main/java/com/meetup/teame/backend/domain/activity/repository/custom/ActivityRepositoryImpl.java b/src/main/java/com/meetup/teame/backend/domain/activity/repository/custom/ActivityRepositoryImpl.java index 66aa299..2c64e18 100644 --- a/src/main/java/com/meetup/teame/backend/domain/activity/repository/custom/ActivityRepositoryImpl.java +++ b/src/main/java/com/meetup/teame/backend/domain/activity/repository/custom/ActivityRepositoryImpl.java @@ -24,6 +24,8 @@ public List findActivitiesForUser(User user) { .select(activity) .from(activity) .where(activity.personalities.any().in(user.getPersonalities())) + .orderBy(activity.id.desc()) + .limit(3L) .fetch(); } diff --git a/src/main/java/com/meetup/teame/backend/domain/auth/jwt/SecurityContextProvider.java b/src/main/java/com/meetup/teame/backend/domain/auth/jwt/SecurityContextProvider.java index ee5b3c6..1f6b3f5 100644 --- a/src/main/java/com/meetup/teame/backend/domain/auth/jwt/SecurityContextProvider.java +++ b/src/main/java/com/meetup/teame/backend/domain/auth/jwt/SecurityContextProvider.java @@ -3,6 +3,7 @@ import com.meetup.teame.backend.global.exception.CustomException; import com.meetup.teame.backend.global.exception.ExceptionContent; import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import java.util.Objects; @@ -16,4 +17,14 @@ public static Long getAuthenticatedUserId() { } return (Long) principal; } + + public static boolean isAnonymousUser() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null) { + return false; + } + return authentication.getAuthorities().stream() + .map(GrantedAuthority::getAuthority) + .anyMatch(role -> role.equals("ROLE_ANONYMOUS")); + } } diff --git a/src/main/java/com/meetup/teame/backend/domain/auth/oauth/controller/KakaoController.java b/src/main/java/com/meetup/teame/backend/domain/auth/oauth/controller/KakaoController.java index a3ef57c..81cb05f 100644 --- a/src/main/java/com/meetup/teame/backend/domain/auth/oauth/controller/KakaoController.java +++ b/src/main/java/com/meetup/teame/backend/domain/auth/oauth/controller/KakaoController.java @@ -33,7 +33,7 @@ public class KakaoController { 등록되지 않은 사용자면 "/sign-up"을 요청해서 거주지 정보를 추가로 받아줘야 합니다. """) @GetMapping("/login/kakao") - public ResponseEntity kakaoLogin(@RequestParam String code) throws JsonProcessingException { + public ResponseEntity kakaoLogin(@RequestParam String code) throws JsonProcessingException { String kakaoAccessToken = kakaoService.getKakaoAccessToken(code); //인가코드로 카카오 엑세스 토큰 받아오기 CreateOauthUserRequest request = kakaoService.getKakaoInfo(kakaoAccessToken); //엑세스 토큰으로 카카오 사용자 정보 받아오기 boolean checkExist = loginService.userExists(request.getEmail()); @@ -41,7 +41,7 @@ public ResponseEntity kakaoLogin(@RequestParam String code) throws JsonP User user = userRepository.findByEmail(request.getEmail()); HttpHeaders headers = kakaoService.getLoginHeader(user); - return ResponseEntity.ok().headers(headers).body("login"); + return ResponseEntity.ok().headers(headers).body(request); //로그인 처리하기 } else { //신규 회원 return ResponseEntity.ok().body(request); diff --git a/src/main/java/com/meetup/teame/backend/domain/experience/repository/custom/ExperienceRepositoryCustom.java b/src/main/java/com/meetup/teame/backend/domain/experience/repository/custom/ExperienceRepositoryCustom.java index 240d7d3..0ef94dc 100644 --- a/src/main/java/com/meetup/teame/backend/domain/experience/repository/custom/ExperienceRepositoryCustom.java +++ b/src/main/java/com/meetup/teame/backend/domain/experience/repository/custom/ExperienceRepositoryCustom.java @@ -1,6 +1,7 @@ package com.meetup.teame.backend.domain.experience.repository.custom; import com.meetup.teame.backend.domain.experience.entity.Experience; +import com.meetup.teame.backend.domain.user.entity.User; import java.util.List; @@ -9,4 +10,6 @@ public interface ExperienceRepositoryCustom { List findExperiencesOrderByReview(long offset,long limit, String category); Long countExperiences(String category); + + List findExperiencesForMain(); } diff --git a/src/main/java/com/meetup/teame/backend/domain/experience/repository/custom/ExperienceRepositoryImpl.java b/src/main/java/com/meetup/teame/backend/domain/experience/repository/custom/ExperienceRepositoryImpl.java index 1b6fcd6..02a0b62 100644 --- a/src/main/java/com/meetup/teame/backend/domain/experience/repository/custom/ExperienceRepositoryImpl.java +++ b/src/main/java/com/meetup/teame/backend/domain/experience/repository/custom/ExperienceRepositoryImpl.java @@ -60,4 +60,13 @@ public Long countExperiences(String category) { .where(builder) .fetchOne(); } + + @Override + public List findExperiencesForMain() { + return jpaQueryFactory + .selectFrom(experience) + .orderBy(experience.createdAt.desc()) + .limit(4) + .fetch(); + } } diff --git a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java index 84f97c8..901de04 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java @@ -6,6 +6,7 @@ import com.meetup.teame.backend.domain.user.dto.request.ReadCalenderReq; import com.meetup.teame.backend.domain.user.dto.request.UpdateUserReq; import com.meetup.teame.backend.domain.user.dto.response.ReadCalenderRes; +import com.meetup.teame.backend.domain.user.dto.response.ReadExperienceProfileRes; import com.meetup.teame.backend.domain.user.dto.response.ReadMainRes; import com.meetup.teame.backend.domain.user.dto.response.UserInfoRes; import com.meetup.teame.backend.domain.user.service.UserService; @@ -63,11 +64,11 @@ public ResponseEntity setUserPersonality(@RequestBody @Valid OnboardingReq 임시로 고정된 더미 유저의 캘린더 정보를 조회하는 식으로 구현되어 있습니다. jwt토큰도 같이 전달해서 요청해주셔야 합니다. - + url 쿼리 파라미터로 다음과 같은 값을 전달해 주셔야 합니다. - + year : 년도 - + month : 월 """) @GetMapping("/mypage/calender") @@ -77,9 +78,9 @@ public ResponseEntity readCalender(@ModelAttribute @Valid ReadC } @Operation(summary = "사용자 기본 정보 조회", description = """ - + 사용자의 기본 정보를 볼 수 있는 api입니다. - + 추후 로그인 적용 시에는 jwt토큰도 같이 전달해서 요청해주셔야 합니다. """) //기본 정보 조회 @@ -91,7 +92,7 @@ public ResponseEntity getUserInfo() { @Operation(summary = "사용자 기본 정보 수정", description = """ 사용자의 기본 정보를 수정하는 api입니다. - + name, email, imageUrl, location 데이터를 받습니다. """) //기본 정보 수정 @@ -117,7 +118,7 @@ public ResponseEntity> getMyReviews(@RequestParam(required = f @Operation(summary = "내 활동 참여 목록 조회", description = """ 내 활동 참여 목록을 조회하는 api입니다. - + api 요청 시 보낼 데이터는 token 이외에 없습니다. """) @GetMapping("/activities") @@ -125,4 +126,10 @@ public ResponseEntity> getMyActivities() { List myActivities = userService.getMyActivities(); return ResponseEntity.ok().body(myActivities); } + + /* @PostMapping("/experience-profile") + public ResponseEntity createExperienceProfile() { + ReadExperienceProfileRes profile = userService.createExperienceProfile(); + return ResponseEntity.ok().body(profile); + }*/ } diff --git a/src/main/java/com/meetup/teame/backend/domain/user/dto/response/ReadCalenderRes.java b/src/main/java/com/meetup/teame/backend/domain/user/dto/response/ReadCalenderRes.java index 1288bb0..157d7da 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/dto/response/ReadCalenderRes.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/dto/response/ReadCalenderRes.java @@ -1,12 +1,10 @@ package com.meetup.teame.backend.domain.user.dto.response; -import com.meetup.teame.backend.domain.chatroom.entity.Appointment; import com.meetup.teame.backend.domain.chatroom.entity.DirectChatRoom; import com.meetup.teame.backend.domain.chatroom.entity.GroupChatRoom; import lombok.*; import java.util.ArrayList; -import java.util.Collections; import java.util.List; @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/com/meetup/teame/backend/domain/user/dto/response/ReadExperienceProfileRes.java b/src/main/java/com/meetup/teame/backend/domain/user/dto/response/ReadExperienceProfileRes.java new file mode 100644 index 0000000..de61eed --- /dev/null +++ b/src/main/java/com/meetup/teame/backend/domain/user/dto/response/ReadExperienceProfileRes.java @@ -0,0 +1,26 @@ +package com.meetup.teame.backend.domain.user.dto.response; + +import lombok.*; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@Builder +@Getter +public class ReadExperienceProfileRes { + + private Long id; + + private String name; + + private Long age; + + private String gender; + + private String location; + + private String area; + + private String introduce; + + +} diff --git a/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java b/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java index 258f7c8..3ba3e7a 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java @@ -17,6 +17,7 @@ import com.meetup.teame.backend.domain.user.dto.request.ReadCalenderReq; import com.meetup.teame.backend.domain.user.dto.request.UpdateUserReq; import com.meetup.teame.backend.domain.user.dto.response.ReadCalenderRes; +import com.meetup.teame.backend.domain.user.dto.response.ReadExperienceProfileRes; import com.meetup.teame.backend.domain.user.dto.response.ReadMainRes; import com.meetup.teame.backend.domain.user.dto.response.UserInfoRes; import com.meetup.teame.backend.domain.user.entity.Gender; @@ -47,12 +48,14 @@ public class UserService { private final ActivityLikeRepository activityLikeRepository; public ReadMainRes readMainPage() { - Long userId = SecurityContextProvider.getAuthenticatedUserId(); + Long userId = 5L; + if(!SecurityContextProvider.isAnonymousUser()) + userId = SecurityContextProvider.getAuthenticatedUserId(); User user = userRepository.findById(userId) .orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_USER)); return ReadMainRes.of( activityRepository.findActivitiesForUser(user), - experienceRepository.findAll(), + experienceRepository.findExperiencesForMain(), 2500 ); } @@ -146,4 +149,11 @@ public ReadCalenderRes readCalender(ReadCalenderReq readCalenderReq) { groupChatRoomRepository.findAppointmentForUserInMonth(user, readCalenderReq.getYear(), readCalenderReq.getMonth()) ); } + + /*public ReadExperienceProfileRes createExperienceProfile() { + Long userId = SecurityContextProvider.getAuthenticatedUserId(); + User user = userRepository.findById(userId) + .orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_USER)); + + }*/ }