Skip to content
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

[Release] v1.6.1 재배포 #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,6 @@ public class LoginController {
private static final String AUTHORIZATION = "Authorization";
private final OauthLoginService oauthLoginService;

/**
* @param params 카카오 accessToken
* @return ResponseEntity 로그인을 성공하면, JWT TOKEN과 사용자 정보(nickname, auth id)를 전달한다.
* @since 1.0.0
* @deprecated 1.6.0
*/
@Deprecated(since = "1.6.0")
@PostMapping("/kakao")
public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginKakao(@Valid @RequestBody KakaoLoginRequest params) {
LoginResponse loginResponse = oauthLoginService.login(params);
String accessToken = oauthLoginService.getAuthToken(loginResponse.nickname());
return ResponseEntity.ok()
.header(ACCESS_TOKEN.toString(), accessToken)
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), loginResponse));
}

/**
* 카카오 로그인
*
Expand All @@ -66,22 +50,6 @@ public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginKakaoV1(@Valid
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), loginResponse));
}

/**
* @param params 네이버 accessToken
* @return ResponseEntity 로그인을 성공하면, JWT TOKEN과 사용자 정보(nickname, auth id)를 전달한다.
* @since 1.0.0
* @deprecated 1.6.0
*/
@Deprecated(since = "1.6.0")
@PostMapping("/naver")
public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginNaver(@Valid @RequestBody NaverLoginRequest params) {
LoginResponse loginResponse = oauthLoginService.login(params);
String accessToken = oauthLoginService.getAuthToken(loginResponse.nickname());
return ResponseEntity.ok()
.header(ACCESS_TOKEN, accessToken)
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), loginResponse));
}

/**
* 네이버 로그인
*
Expand All @@ -99,23 +67,6 @@ public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginNaverV1(@Valid
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), loginResponse));
}

/**
* refreshToken으로 AuthToken 재발급
*
* @param request 재발급 요청 , header에 accessToken이 필요
* @return AuthToken
* @since 1.0.0
* @deprecated 1.6.0
*/
@Deprecated(since = "1.6.0")
@PostMapping("/reissue")
public ResponseEntity<SuccessSingleResponse<?>> reissue(HttpServletRequest request) {
String newAccessToken = oauthLoginService.reissueToken(request.getHeader(AUTHORIZATION));
return ResponseEntity.ok()
.header(ACCESS_TOKEN, newAccessToken)
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), null));
}

/**
* refresh token으로 access token 재발급
*
Expand All @@ -132,22 +83,6 @@ public ResponseEntity<SuccessSingleResponse<?>> reissueV1(HttpServletRequest req
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), null));
}

/**
* 로그아웃
*
* @param request HttpServletRequest oauthId
* @param logoutFcmTokenRequest fcmToken
* @since 1.1.0
* @deprecated 1.6.0
*/
@Deprecated(since = "1.6.0")
@PostMapping("/logout")
public ResponseEntity<SuccessSingleResponse> logout(HttpServletRequest request, @RequestBody LogoutFcmTokenRequest logoutFcmTokenRequest) {
oauthLoginService.logout(request.getHeader(AUTHORIZATION), logoutFcmTokenRequest.fcmToken());
return ResponseEntity.ok()
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), null));
}

/**
* 로그아웃
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@
public class BloodSugarGuideController {
private final BloodSugarGuideSearchService bloodSugarGuideSearchService;

/**
* 혈당 가이드를 조회한다.
*
* @param date 조회할 일자
* @param principal 사용자 정보
* @return 혈당 가이드 응답 dto
* @since 1.0.0
* @deprecated 1.6.0
*/
@Deprecated(since = "1.6.0")
@GetMapping
public ResponseEntity<SuccessSingleResponse<BloodSugarGuideResponse>> get(@ValidLocalDate @RequestParam String date,
@AuthenticationPrincipal User principal) {
BloodSugarGuideResponse response = bloodSugarGuideSearchService.findGuide(principal.getUsername(), date);
return ResponseEntity.ok().body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), response));
}

/**
* 혈당 가이드를 조회한다.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.coniverse.dangjang.domain.analysis.enums.Alert;
import com.coniverse.dangjang.domain.code.enums.CommonCode;
import com.coniverse.dangjang.domain.guide.common.exception.GuideAlreadyExistsException;
import com.coniverse.dangjang.domain.guide.common.exception.GuideNotFoundException;

import jakarta.persistence.Id;
Expand Down Expand Up @@ -54,10 +53,12 @@ private BloodSugarGuide(String oauthId, String createdAt) {
* @since 1.0.0
*/
public void addSubGuide(SubGuide subGuide) {
verifySubGuideNonExistent(subGuide.getType());
if (isDuplicatedSubGuide(subGuide)) {
return;
}
this.subGuides.add(subGuide);
sortSubGuides();
plusAlertCount(subGuide.getAlert());
sortSubGuides();
}

/**
Expand All @@ -80,25 +81,24 @@ public void updateSubGuide(SubGuide updatedSubGuide) {
* @since 1.0.0
*/
public void updateSubGuide(SubGuide updatedSubGuide, CommonCode prevType) {
verifySubGuideNonExistent(updatedSubGuide.getType());
if (isDuplicatedSubGuide(updatedSubGuide)) {
return;
}
SubGuide subGuide = getSubGuide(prevType);
updateAlertCount(subGuide.getAlert(), updatedSubGuide.getAlert());
subGuide.update(updatedSubGuide);
sortSubGuides();
}

/**
* 서브 가이드가 존재하는지 검증한다.
* 서브 가이드가 중복인지 확인한다.
*
* @param type 서브 가이드 타입
* @throws GuideAlreadyExistsException 이미 해당 가이드가 존재할 경우 발생한다.
* @since 1.0.0
* @param subGuide 서브 가이드
* @since 1.6.1
*/
private void verifySubGuideNonExistent(CommonCode type) {
boolean exists = this.subGuides.stream().anyMatch(guide -> guide.isSameType(type));
if (exists) {
throw new GuideAlreadyExistsException();
}
private boolean isDuplicatedSubGuide(SubGuide subGuide) {
return this.subGuides.stream()
.anyMatch(s -> s.equals(subGuide));
}

/**
Expand All @@ -111,7 +111,7 @@ private void verifySubGuideNonExistent(CommonCode type) {
*/
private SubGuide getSubGuide(CommonCode type) {
return this.subGuides.stream()
.filter(guide -> guide.isSameType(type))
.filter(s -> s.isSameType(type))
.findFirst()
.orElseThrow(GuideNotFoundException::new);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ private void updateAlertCount(String prevAlert, String curAlert) {
*/
private void plusAlertCount(String alert) {
this.todayGuides.stream()
.filter(guide -> guide.isSameAlert(alert))
.filter(s -> s.isSameAlert(alert))
.findFirst()
.ifPresent(TodayGuide::plusCount);
}
Expand All @@ -162,7 +162,7 @@ private void plusAlertCount(String alert) {
*/
private void minusAlertCount(String alert) {
this.todayGuides.stream()
.filter(guide -> guide.isSameAlert(alert))
.filter(s -> s.isSameAlert(alert))
.findFirst()
.ifPresent(TodayGuide::minusCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,21 @@ protected void update(SubGuide subGuide) {
protected boolean isSameType(CommonCode type) {
return this.type.equals(type);
}

/**
* equals 메서드 overriding
* <p>
* 타입이 같으면 같은 서브 가이드로 취급한다.
*
* @param obj 비교할 객체
* @return 같으면 true, 다르면 false
* @since 1.6.1
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof SubGuide subGuide) {
return this.type.equals(subGuide.getType());
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@
public class GuideController {
private final DayGuideService dayGuideService;

/**
* 하루 요약 가이드를 조회하여 전달한다
*
* @param date 조회날짜
* @author EVE
* @since 1.0.0
* @deprecated 1.6.0
*/
@Deprecated(since = "1.6.0")
@GetMapping
public ResponseEntity<SuccessSingleResponse<DayGuideResponse>> getDayGuide(@ValidLocalDate @RequestParam String date,
@AuthenticationPrincipal User principal) {
DayGuideResponse dayGuideResponse = dayGuideService.getDayGuide(principal.getUsername(), date);
return ResponseEntity.ok().body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), dayGuideResponse));
}

/**
* 하루 요약 가이드를 조회하여 전달한다
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@
public class ExerciseGuideController {
private final ExerciseGuideSearchService exerciseGuideSearchService;

/**
* 운동 조회
*
* @param date 조회하는 날짜
* @param principal 유저 정보
* @return 운동 가이드 응답
* @since 1.0.0
* @deprecated 1.6.0
*/
@Deprecated(since = "1.6.0")
@GetMapping
public ResponseEntity<SuccessSingleResponse<ExerciseGuideResponse>> get(@ValidLocalDate @RequestParam String date,
@AuthenticationPrincipal User principal) {
ExerciseGuideResponse response = exerciseGuideSearchService.findGuide(principal.getUsername(), date);
return ResponseEntity.ok()
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), response));
}

/**
* 운동 조회
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@ public void changeAboutWalk(int needStepByTTS, int needStepByLastWeek, String co
this.stepCount = stepCount;
}

/**
* 걸음수와 관련된 속성들 중복 여부 판별
*
* @param needStepByTTS 만보 대비 필요한 걸음수
* @param needStepByLastWeek 지난주 평균 걸음수 대비 필요한 걸음수
* @param comparedToLastWeek 지난주 걸음수와 비교한 가이드
* @param content 만보 대비 걸음수에 대한 가이드
* @return 중복 여부
* @since 1.6.1
*/
public boolean isDuplicateAboutStepCount(int needStepByTTS, int needStepByLastWeek, String comparedToLastWeek, String content, int stepCount) {
if (this.needStepByTTS == needStepByTTS && this.needStepByLastWeek == needStepByLastWeek && this.comparedToLastWeek == comparedToLastWeek
&& this.content == content && this.stepCount == stepCount) {
return true;
}
return false;
}

/**
* 걸음수와 관련된 속성들 중복 여부 판별
*
* @param exerciseCalorie 운동 칼로리
* @return 중복 여부
* @since 1.6.1
*/
public boolean isDuplicateAboutExerciseCalories(ExerciseCalorie exerciseCalorie) {
return this.exerciseCalories.stream().filter(exercise -> exercise.type().equals(exerciseCalorie.type())).findFirst().isPresent();
}

/**
* 수정된 운동 칼로리를 업데이트한다.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,22 @@ public GuideResponse createGuide(AnalysisData analysisData) {
}
// 걸음 수 추가
if (exerciseAnalysisData.getType().equals(CommonCode.STEP_COUNT)) {
existExerciseGuide.changeAboutWalk(exerciseAnalysisData.needStepByTTS, exerciseAnalysisData.needStepByLastWeek,
walkGuideContent.getGuideLastWeek(), walkGuideContent.getGuideTTS(), exerciseAnalysisData.getUnit());
return exerciseGuideMapper.toResponse(exerciseGuideRepository.save(existExerciseGuide));
if (!existExerciseGuide.isDuplicateAboutStepCount(exerciseAnalysisData.needStepByTTS, exerciseAnalysisData.needStepByLastWeek,
walkGuideContent.getGuideLastWeek(), walkGuideContent.getGuideTTS(), exerciseAnalysisData.getUnit())) {
existExerciseGuide.changeAboutWalk(exerciseAnalysisData.needStepByTTS, exerciseAnalysisData.needStepByLastWeek,
walkGuideContent.getGuideLastWeek(), walkGuideContent.getGuideTTS(), exerciseAnalysisData.getUnit());
return exerciseGuideMapper.toResponse(exerciseGuideRepository.save(existExerciseGuide));
}
} else {
ExerciseCalorie exerciseCalorie = new ExerciseCalorie(exerciseAnalysisData.getType(), exerciseAnalysisData.getCalorie(),
exerciseAnalysisData.getUnit());
//운동 추가
if (!existExerciseGuide.isDuplicateAboutExerciseCalories(exerciseCalorie)) {
existExerciseGuide.changeExerciseCalories(exerciseCalorie);
return exerciseGuideMapper.toResponse(exerciseGuideRepository.save(existExerciseGuide));
}
}
//운동 추가
ExerciseCalorie exerciseCalorie = new ExerciseCalorie(exerciseAnalysisData.getType(), exerciseAnalysisData.getCalorie(),
exerciseAnalysisData.getUnit());
existExerciseGuide.changeExerciseCalories(exerciseCalorie);
return exerciseGuideMapper.toResponse(exerciseGuideRepository.save(existExerciseGuide));

return exerciseGuideMapper.toResponse(existExerciseGuide);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@
public class WeightGuideController {
private final WeightGuideSearchService weightGuideSearchService;

/**
* 날짜별 체중 가이드 조회
*
* @param date 조회하는 날짜
* @param principal 유저 정보
* @author EVE
* @since 1.0.0
* @deprecated 1.6.0
*/
@Deprecated(since = "1.6.0")
@GetMapping
public ResponseEntity<SuccessSingleResponse<WeightGuideResponse>> get(@ValidLocalDate @RequestParam String date,
@AuthenticationPrincipal User principal) {
WeightGuideResponse response = weightGuideSearchService.findGuide(principal.getUsername(), date);
return ResponseEntity.ok().body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), response));
}

/**
* 날짜별 체중 가이드 조회
*
Expand Down
Loading