Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/3
Browse files Browse the repository at this point in the history
  • Loading branch information
j2noo authored May 23, 2024
2 parents 8cfd736 + af7c754 commit 689a85b
Show file tree
Hide file tree
Showing 8 changed files with 479 additions and 17 deletions.
393 changes: 393 additions & 0 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ public interface KakaoFeignClient {
@GetMapping("/v2/user/me")
public KakaoGetMemberInfoResponse getKakaoIdByAccessToken(@RequestHeader("Authorization") String kakaoAccessToken);

// @GetMapping("/v2/user/me")
// public KakaoGetUserInfoResponseDto getKakaoUserEmailByAccessToken(@RequestHeader("Authorization") String accessToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public KakaoLoginResponse kakaoLogin(KakaoLoginRequest request) {
}

//해당 멤버의 authId로 jwt토큰 발급하기

UserDetailsImpl userDetail = UserDetailsImpl.fromMember(member);

String newAccessToken = jwtProvider.createAccessToken(userDetail);
Expand Down Expand Up @@ -138,6 +137,7 @@ private Member register(KakaoGetMemberInfoResponse kakaoMemberInfo) {
imageUrl = kakaoMemberInfo.getKakao_account().getProfile().getProfile_image_url();
}


String memberCode = createMemberCode();
Member member = Member.builder()
.authId(kakaoMemberInfo.getAuthId())
Expand Down Expand Up @@ -288,7 +288,7 @@ public TokenResponseDto refreshToken(String oldRefreshToken, Long memberId) {
@Transactional(readOnly = true)
public PatientsResponseDto getPatientsList(UserDetailsImpl userDetails, ConnectionStatus status) {
//조회하는 사람 정보 조회
Member member = memberRepository.findById(1L)
Member member = memberRepository.findById(userDetails.getMemberId() )
.orElseThrow(() -> new MemberException(MEMBER_NOT_FOUND));

//의사 또는 센터가 아니면 조회 불가
Expand Down Expand Up @@ -411,7 +411,7 @@ public MyPageResponseDto getMyPage(UserDetailsImpl userDetails){
@Transactional(readOnly = true)
public MemberInfoResponse getMemberInfo(UserDetailsImpl userDetails,Long memberId){

//파라미터가 0이면, 나를 조회하도록 하기.
//파라미터가 0이면, 나를 조회하도록 하기..
if (memberId == 0) {
memberId = userDetails.getMemberId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -45,7 +46,26 @@ public ResponseEntity<ApiSuccessResponse<MoodChartPagingResponseDto>> getMoodCha
@Parameter(description = "마지막으로 조회한 일") @RequestParam("day") Integer day,
@Parameter(description = "한 페이지 속 데이터 갯수") @RequestParam("size") Integer size) {
return ResponseEntity.ok(
new ApiSuccessResponse<>(moodChartService.getMoodChart(userDetails, year, month, day, size)));
new ApiSuccessResponse<>(
moodChartService.getMoodChart(userDetails.getMemberId(), year, month, day, size)));
}

@Operation(
summary = "의사/센터의 특정 환자 무드 차트 조회"
)
@ApiResponse(
responseCode = "200", description = "무드 차트 조회 성공 응답입니다.", useReturnTypeSchema = true
)
@GetMapping("/connection")
public ResponseEntity<ApiSuccessResponse<MoodChartPagingResponseDto>> getMoodChart(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@Parameter(description = "년도") @RequestParam("year") Integer year,
@Parameter(description = "월") @RequestParam("month") Integer month,
@Parameter(description = "마지막으로 조회한 일") @RequestParam("day") Integer day,
@Parameter(description = "한 페이지 속 데이터 갯수") @RequestParam("size") Integer size,
@Parameter(description = "조회하고자 하는 memberId") @RequestParam("memberId") Long memberId) {
return ResponseEntity.ok(
new ApiSuccessResponse<>(moodChartService.getMoodChart(memberId, year, month, day, size)));
}

@Operation(
Expand All @@ -57,7 +77,24 @@ public ResponseEntity<ApiSuccessResponse<MoodChartPagingResponseDto>> getMoodCha
@GetMapping("/percents")
public ResponseEntity<ApiSuccessResponse<List<MoodPercentResponseDto>>> getMoodChartPercents(
@AuthenticationPrincipal UserDetailsImpl userDetails) {
return ResponseEntity.ok(new ApiSuccessResponse<>(moodChartService.getActivityChart(userDetails)));
return ResponseEntity.ok(
new ApiSuccessResponse<>(moodChartService.getActivityChart(userDetails.getMemberId())));

}

@Operation(
summary = "의사/센터의 특정 환자의 기분 별 활동 차트 안의 기분 percent 조회"
)
@ApiResponse(
responseCode = "200", description = "기분 별 활동 차트 안의 기분 percent 조회 성공 응답입니다.", useReturnTypeSchema = true
)
@GetMapping("/percents/{memberId}")
public ResponseEntity<ApiSuccessResponse<List<MoodPercentResponseDto>>> getMoodChartPercents(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@PathVariable("memberId") Long memberId) {
return ResponseEntity.ok(
new ApiSuccessResponse<>(moodChartService.getActivityChart(memberId)));

}

@Operation(
Expand All @@ -71,7 +108,22 @@ public ResponseEntity<ApiSuccessResponse<List<ActivityPercentResponseDto>>> getA
@AuthenticationPrincipal UserDetailsImpl userDetails,
@Parameter(description = "감정") @RequestParam("feelingType") FeelingType feelingType) {
return ResponseEntity.ok(
new ApiSuccessResponse<>(moodChartService.getActivityPercentChart(userDetails, feelingType)));
new ApiSuccessResponse<>(moodChartService.getActivityPercentChart(userDetails.getMemberId(), feelingType)));
}

@Operation(
summary = "의사/센터의 특정 환자의 특정 기분에 대한 활동 퍼센트 조회"
)
@ApiResponse(
responseCode = "200", description = "특정 기분에 대한 활동 퍼센트 조회 성공 응답입니다.", useReturnTypeSchema = true
)
@GetMapping("/connection/percent/activity")
public ResponseEntity<ApiSuccessResponse<List<ActivityPercentResponseDto>>> getActivityPercentChart(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@Parameter(description = "감정") @RequestParam("feelingType") FeelingType feelingType,
@Parameter(description = "조회하고자 하는 환자 ID") @RequestParam("memberId") Long memberId) {
return ResponseEntity.ok(
new ApiSuccessResponse<>(moodChartService.getActivityPercentChart(memberId, feelingType)));
}


Expand Down
17 changes: 16 additions & 1 deletion src/main/java/com/remind/api/mood/controller/MoodController.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ public ResponseEntity<ApiSuccessResponse<MoodResponseDto>> get(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@PathVariable("moodDate") LocalDate localDate) {
return ResponseEntity.ok(
new ApiSuccessResponse<>(SUCCESS, moodService.get(userDetails, localDate)));
new ApiSuccessResponse<>(SUCCESS, moodService.get(userDetails.getMemberId(), localDate)));
}

@Operation(
summary = "의사/센터가 환자의 특정 날짜의 오늘의 기분 정보 조회"
)
@ApiResponse(
responseCode = "200", description = "오늘의 기분 조회 성공 응답입니다.", useReturnTypeSchema = true
)
@GetMapping("/{memberId}/{moodDate}")
public ResponseEntity<ApiSuccessResponse<MoodResponseDto>> get(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@PathVariable("memberId") Long memberId,
@PathVariable("moodDate") LocalDate localDate) {
return ResponseEntity.ok(
new ApiSuccessResponse<>(SUCCESS, moodService.get(memberId, localDate)));
}
}
12 changes: 6 additions & 6 deletions src/main/java/com/remind/api/mood/service/MoodChartService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public class MoodChartService {
private final MoodConsecutiveRepository moodConsecutiveRepository;

@Transactional(readOnly = true)
public MoodChartPagingResponseDto getMoodChart(UserDetailsImpl userDetails, Integer year, Integer month,
public MoodChartPagingResponseDto getMoodChart(Long memberId, Integer year, Integer month,
Integer day, Integer size) {

List<MoodChartResponseDto> response = new ArrayList<>();
boolean hasNext = false;
// 요청한 정보에 대해 커서 기반 pagination ( 월의 1일부터 조회하기 위해서는 day = 0 값을 받아야 한다. )
Slice<MoodChartDto> moodChartDtos = moodChartPagingRepository.getMoodChartPaging2(userDetails.getMemberId(),
Slice<MoodChartDto> moodChartDtos = moodChartPagingRepository.getMoodChartPaging2(memberId,
LocalDate.of(year, month, day + 1), Pageable.ofSize(size));

// 다음 페이지 존재 여부
Expand All @@ -47,14 +47,14 @@ public MoodChartPagingResponseDto getMoodChart(UserDetailsImpl userDetails, Inte
}

@Transactional(readOnly = true)
public List<MoodPercentResponseDto> getActivityChart(UserDetailsImpl userDetails) {
return moodChartCacheService.getActivityFeelingTypePercent(userDetails.getMemberId());
public List<MoodPercentResponseDto> getActivityChart(Long memberId) {
return moodChartCacheService.getActivityFeelingTypePercent(memberId);
}

@Transactional(readOnly = true)
public List<ActivityPercentResponseDto> getActivityPercentChart(UserDetailsImpl userDetails,
public List<ActivityPercentResponseDto> getActivityPercentChart(Long memberId,
FeelingType feelingType) {
return moodChartCacheService.getActivityPercentChart(userDetails.getMemberId(), feelingType);
return moodChartCacheService.getActivityPercentChart(memberId, feelingType);

}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/remind/api/mood/service/MoodService.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public Long create(UserDetailsImpl userDetails, MoodSaveRequestDto dto) {
* 특정 날짜의 오늘의 기분 정보 조회
*/
@Transactional(readOnly = true)
public MoodResponseDto get(UserDetailsImpl userDetails, LocalDate localDate) {
public MoodResponseDto get(Long memberId, LocalDate localDate) {

Mood mood = moodRepository.findMoodByPatientAndMoodDate(userDetails.getMemberId(), localDate)
Mood mood = moodRepository.findMoodByPatientAndMoodDate(memberId, localDate)
.orElseThrow(() -> new MoodException(MOOD_NOT_FOUND));

List<ModelActivityResponseDto> modelActivities = dateMoodActivityRepository.getModelActivities(mood.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ private RequestMatcher[] authorizeRequestMathcers() {
antMatcher(POST, "/mood"),
antMatcher(GET, "/mood"),
antMatcher(GET, "/mood/{moodDate}"),
antMatcher(GET, "/mood/{memberId}/{moodDate}"),
antMatcher(GET, "/mood/chart"),
antMatcher(GET, "/mood/chart/connection"),
antMatcher(GET, "/mood/chart/percents"),
antMatcher(GET, "/mood/chart/percents/{memberId}"),
antMatcher(GET, "/mood/chart/percent/activity"),
antMatcher(GET, "/mood/chart/connection/percent/activity"),
antMatcher(POST, "/prescription/relation/request"),
antMatcher(POST, "/prescription/relation/accept"),
antMatcher(GET, "/prescription"),
Expand Down

0 comments on commit 689a85b

Please sign in to comment.