Skip to content

Commit

Permalink
Revert "[Release] v1.6.1 "
Browse files Browse the repository at this point in the history
  • Loading branch information
GIVEN53 authored Dec 3, 2023
1 parent b8bb9a8 commit 44dd13e
Show file tree
Hide file tree
Showing 45 changed files with 742 additions and 332 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.coniverse.dangjang.domain.analysis.exception;

import com.coniverse.dangjang.global.exception.BusinessException;

/**
* 단위가 0보다 작을 때 발생하는 예외
*
* @author TEO
* @since 1.0.0
*/
@Deprecated(since = "1.0.0")
public class UnitLessThanZeroException extends BusinessException {
public UnitLessThanZeroException() {
super(400, "단위는 0보다 작을 수 없습니다");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ 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 @@ -50,6 +66,22 @@ 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 @@ -67,6 +99,23 @@ 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 @@ -83,6 +132,22 @@ 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,6 +31,23 @@
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,6 +8,7 @@

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 @@ -53,12 +54,10 @@ private BloodSugarGuide(String oauthId, String createdAt) {
* @since 1.0.0
*/
public void addSubGuide(SubGuide subGuide) {
if (isDuplicatedSubGuide(subGuide)) {
return;
}
verifySubGuideNonExistent(subGuide.getType());
this.subGuides.add(subGuide);
plusAlertCount(subGuide.getAlert());
sortSubGuides();
plusAlertCount(subGuide.getAlert());
}

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

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

/**
Expand All @@ -111,7 +111,7 @@ private boolean isDuplicatedSubGuide(SubGuide subGuide) {
*/
private SubGuide getSubGuide(CommonCode type) {
return this.subGuides.stream()
.filter(s -> s.isSameType(type))
.filter(guide -> guide.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(s -> s.isSameAlert(alert))
.filter(guide -> guide.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(s -> s.isSameAlert(alert))
.filter(guide -> guide.isSameAlert(alert))
.findFirst()
.ifPresent(TodayGuide::minusCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,4 @@ 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,6 +31,22 @@
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,6 +32,24 @@
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,35 +64,6 @@ 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,22 +65,16 @@ public GuideResponse createGuide(AnalysisData analysisData) {
}
// 걸음 수 추가
if (exerciseAnalysisData.getType().equals(CommonCode.STEP_COUNT)) {
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));
}
existExerciseGuide.changeAboutWalk(exerciseAnalysisData.needStepByTTS, exerciseAnalysisData.needStepByLastWeek,
walkGuideContent.getGuideLastWeek(), walkGuideContent.getGuideTTS(), exerciseAnalysisData.getUnit());
return exerciseGuideMapper.toResponse(exerciseGuideRepository.save(existExerciseGuide));
}
return exerciseGuideMapper.toResponse(existExerciseGuide);
//운동 추가
ExerciseCalorie exerciseCalorie = new ExerciseCalorie(exerciseAnalysisData.getType(), exerciseAnalysisData.getCalorie(),
exerciseAnalysisData.getUnit());
existExerciseGuide.changeExerciseCalories(exerciseCalorie);
return exerciseGuideMapper.toResponse(exerciseGuideRepository.save(existExerciseGuide));

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@
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

0 comments on commit 44dd13e

Please sign in to comment.