Skip to content

Commit

Permalink
Revert "v1.3.0 릴리즈"
Browse files Browse the repository at this point in the history
  • Loading branch information
GIVEN53 authored Oct 31, 2023
1 parent 895580e commit aa070dd
Show file tree
Hide file tree
Showing 62 changed files with 645 additions and 1,196 deletions.
1 change: 0 additions & 1 deletion src/lombok.config

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.web.bind.annotation.RestController;

import com.coniverse.dangjang.domain.auth.dto.request.KakaoLoginRequest;
import com.coniverse.dangjang.domain.auth.dto.request.LogoutFcmTokenRequest;
import com.coniverse.dangjang.domain.auth.dto.request.NaverLoginRequest;
import com.coniverse.dangjang.domain.auth.dto.response.LoginResponse;
import com.coniverse.dangjang.domain.auth.service.OauthLoginService;
Expand All @@ -35,27 +34,29 @@ public class LoginController {
private static String headerKeyAuthorization = "Authorization";

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

/**
* @param params 네이버 accessToken
* @param params 네이버 accessToken
* @param request request에서 fcmToken header가 필요
* @return ResponseEntity 로그인을 성공하면, JWT TOKEN과 사용자 정보(nickname, auth id)를 전달한다.
* @since 1.0.0
*/
@PostMapping("/naver")
public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginNaver(@Valid @RequestBody NaverLoginRequest params) {
LoginResponse loginResponse = oauthLoginService.login(params);
public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginNaver(@Valid @RequestBody NaverLoginRequest params, HttpServletRequest request) {
LoginResponse loginResponse = oauthLoginService.login(params, request.getHeader(headerKeyFcmToken));
String accessToken = oauthLoginService.getAuthToken(loginResponse.nickname());
return ResponseEntity.ok()
.header(headerKeyAccessToken, accessToken)
Expand All @@ -80,13 +81,12 @@ public ResponseEntity<SuccessSingleResponse<?>> reissue(HttpServletRequest reque
/**
* 로그아웃
*
* @param request HttpServletRequest oauthId
* @param logoutFcmTokenRequest fcmToken
* @param request 요청
* @since 1.1.0
*/
@PostMapping("/logout")
public ResponseEntity<SuccessSingleResponse> logout(HttpServletRequest request, @RequestBody LogoutFcmTokenRequest logoutFcmTokenRequest) {
oauthLoginService.logout(request.getHeader(headerKeyAuthorization), logoutFcmTokenRequest.fcmToken());
public ResponseEntity<SuccessSingleResponse> logout(HttpServletRequest request) {
oauthLoginService.logout(request.getHeader(headerKeyAuthorization), request.getHeader(headerKeyFcmToken));
return ResponseEntity.ok()
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), null));
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ public DefaultOauthLoginService(AuthTokenGenerator authTokenGenerator, UserSearc
}

/**
* @param params 카카오,네이버 accessToken
* @param params 카카오,네이버 accessToken
* @param fcmToken notifiaction 디바이스 토큰
* @return Content 로그인을 성공하면, JWT TOKEN과 사용자 정보(nickname, authID)를 전달한다.
* @since 1.0.0
*/
@Override
public LoginResponse login(OauthLoginRequest params) {
public LoginResponse login(OauthLoginRequest params, String fcmToken) {
OAuthInfoResponse oAuthInfoResponse = request(params);
User user = userSearchService.findUserByOauthId(oAuthInfoResponse.getOauthId());
notificationService.saveFcmToken(fcmToken, user.getOauthId());
HealthConnect healthConnect = userSearchService.findInterlockHealthConnect(user.getOauthId());
user.verifyActiveUser();
return new LoginResponse(user.getNickname(), false, healthConnect.isConnecting());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @since 1.0.0
*/
public interface OauthLoginService {
LoginResponse login(OauthLoginRequest params);
LoginResponse login(OauthLoginRequest params, String fcmToken);

String getAuthToken(String nickname);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,4 @@ private void minusAlertCount(String alert) {
.findFirst()
.ifPresent(TodayGuide::minusCount);
}

/**
* 서브 가이드를 삭제한다.
*
* @param type 서브 가이드 타입
* @since 1.3.0
*/
public void removeSubGuide(CommonCode type) {
SubGuide subGuide = getSubGuide(type);
this.subGuides.remove(subGuide);
minusAlertCount(subGuide.getAlert());
}

/**
* 서브 가이드가 존재하는지 확인한다.
*
* @return 서브 가이드가 존재하면 true, 존재하지 않으면 false
* @since 1.3.0
*/
public boolean existsSubGuide() {
return !this.subGuides.isEmpty();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.coniverse.dangjang.domain.guide.bloodsugar.service;

import java.time.LocalDate;

import org.springframework.stereotype.Service;

import com.coniverse.dangjang.domain.analysis.dto.AnalysisData;
Expand Down Expand Up @@ -36,6 +34,8 @@ public class BloodSugarGuideGenerateService implements GuideGenerateService {

/**
* 서브 가이드를 생성해서 혈당 가이드에 저장한다.
* <p>
* 혈당 가이드가 존재하면 새로운 서브 가이드를 추가하고, 존재하지 않으면 혈당 가이드를 생성하여 서브 가이드를 추가한다.
*
* @param analysisData 혈당 분석 데이터
* @return 서브 가이드 응답
Expand All @@ -44,29 +44,19 @@ public class BloodSugarGuideGenerateService implements GuideGenerateService {
@Override
public GuideResponse createGuide(AnalysisData analysisData) {
BloodSugarAnalysisData data = (BloodSugarAnalysisData)analysisData;
BloodSugarGuide guide = getGuide(data);
BloodSugarGuide guide;
try {
guide = bloodSugarGuideSearchService.findByUserIdAndCreatedAt(data.getOauthId(), data.getCreatedAt());
} catch (GuideNotFoundException e) {
guide = mapper.toDocument(data);
}
GuideFormat guideFormat = bloodSugarGuideFormatFactory.createGuideFormat(data);
SubGuide subGuide = mapper.toSubGuide(data, guideFormat);
guide.addSubGuide(subGuide);
bloodSugarGuideRepository.save(guide);
return mapper.toSubGuideResponse(subGuide, guide.getTodayGuides());
}

/**
* 혈당 가이드가 존재하면 그대로 반환하고, 존재하지 않으면 새로 생성해서 반환한다.
*
* @param data 혈당 분석 데이터
* @return 혈당 가이드
* @since 1.3.0
*/
private BloodSugarGuide getGuide(BloodSugarAnalysisData data) {
try {
return bloodSugarGuideSearchService.findByUserIdAndCreatedAt(data.getOauthId(), data.getCreatedAt());
} catch (GuideNotFoundException e) {
return mapper.toDocument(data);
}
}

/**
* 단위가 변경된 서브 가이드를 업데이트해서 혈당 가이드에 저장한다.
*
Expand Down Expand Up @@ -107,25 +97,6 @@ public GuideResponse updateGuideWithType(AnalysisData analysisData, CommonCode p
return mapper.toSubGuideResponse(subGuide, guide.getTodayGuides());
}

/**
* 서브 가이드를 삭제한다. 서브 가이드가 존재하지 않으면 혈당 가이드를 삭제한다.
*
* @param oauthId 유저 PK
* @param createdAt 생성일자
* @param type 타입
* @since 1.3.0
*/
@Override
public void removeGuide(String oauthId, LocalDate createdAt, CommonCode type) {
BloodSugarGuide guide = bloodSugarGuideSearchService.findByUserIdAndCreatedAt(oauthId, createdAt);
guide.removeSubGuide(type);
if (guide.existsSubGuide()) {
bloodSugarGuideRepository.save(guide);
return;
}
bloodSugarGuideRepository.delete(guide);
}

@Override
public GroupCode getGroupCode() {
return GroupCode.BLOOD_SUGAR;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.coniverse.dangjang.domain.guide.common.service;

import java.time.LocalDate;

import com.coniverse.dangjang.domain.analysis.dto.AnalysisData;
import com.coniverse.dangjang.domain.code.enums.CommonCode;
import com.coniverse.dangjang.domain.code.enums.GroupCode;
Expand All @@ -22,7 +20,5 @@ default GuideResponse updateGuideWithType(AnalysisData analysisData, CommonCode
throw new UnsupportedOperationException("잘못된 메서드 호출입니다.");
}

void removeGuide(String oauthId, LocalDate createdAt, CommonCode type);

GroupCode getGroupCode();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.coniverse.dangjang.domain.guide.common.service;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
Expand Down Expand Up @@ -35,7 +34,8 @@ public GuideService(List<GuideGenerateService> guideGenerateServiceMap) {
* @since 1.0.0
*/
public GuideResponse createGuide(AnalysisData analysisData) {
GuideGenerateService guideGenerateService = findGuideGenerateService(analysisData.getType());
GroupCode groupCode = GroupCode.findByCode(analysisData.getType());
GuideGenerateService guideGenerateService = findGuideGenerateService(groupCode);
return guideGenerateService.createGuide(analysisData);
}

Expand All @@ -45,7 +45,8 @@ public GuideResponse createGuide(AnalysisData analysisData) {
* @since 1.0.0
*/
public GuideResponse updateGuide(AnalysisData analysisData) {
GuideGenerateService guideGenerateService = findGuideGenerateService(analysisData.getType());
GroupCode groupCode = GroupCode.findByCode(analysisData.getType());
GuideGenerateService guideGenerateService = findGuideGenerateService(groupCode);
return guideGenerateService.updateGuide(analysisData);
}

Expand All @@ -55,28 +56,18 @@ public GuideResponse updateGuide(AnalysisData analysisData) {
* @since 1.0.0
*/
public GuideResponse updateGuideWithType(AnalysisData analysisData, CommonCode prevType) {
GuideGenerateService guideGenerateService = findGuideGenerateService(analysisData.getType());
GroupCode groupCode = GroupCode.findByCode(analysisData.getType());
GuideGenerateService guideGenerateService = findGuideGenerateService(groupCode);
return guideGenerateService.updateGuideWithType(analysisData, prevType);
}

/**
* 가이드를 삭제한다.
*
* @since 1.3.0
*/
public void removeGuide(String oauthId, LocalDate createdAt, CommonCode type) {
GuideGenerateService guideGenerateService = findGuideGenerateService(type);
guideGenerateService.removeGuide(oauthId, createdAt, type);
}

/**
* 그룹코드로 가이드 생성 서비스를 찾는다.
*
* @see GroupCode
* @since 1.0.0
*/
private GuideGenerateService findGuideGenerateService(CommonCode type) {
GroupCode groupCode = GroupCode.findByCode(type);
private GuideGenerateService findGuideGenerateService(GroupCode groupCode) {
return guideGenerateServiceMap.get(groupCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@

import org.springframework.data.mongodb.core.mapping.Document;

import com.coniverse.dangjang.domain.code.enums.CommonCode;

import jakarta.persistence.Id;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* 운동 가이드 Document
*
* @author EVE
* @since 1.0.0
*/
@Setter
@Getter
@Document
@NoArgsConstructor
public class ExerciseGuide { // TODO 걸음 가이드, 칼로리 가이드로 분리해서 리팩토링
public class ExerciseGuide {
@Id
private String id;
private String oauthId;
private int needStepByTTS; // TODO 걸음 수 관련 필드 -> 객체로 묶기
private int needStepByTTS;
private int needStepByLastWeek;
private LocalDate createdAt;
private String content;
Expand Down Expand Up @@ -69,24 +69,14 @@ public void changeAboutWalk(int needStepByTTS, int needStepByLastWeek, String co
* <p>
* 기존에 존재하는 운동 칼로리를 삭제하고, 새로운 운동 칼로리를 추가한다.
*
* @param updatedExerciseCalorie 운동칼로리 객체
* @param updateExerciseCalorie 운동칼로리 객체
* @since 1.0.0
*/
public void changeExerciseCalories(ExerciseCalorie updatedExerciseCalorie) {
removeExerciseCalorie(updatedExerciseCalorie.type());
exerciseCalories.add(updatedExerciseCalorie);
}

/**
* 운동 칼로리를 삭제한다.
*
* @param type 운동 타입
* @since 1.3.0
*/
public void removeExerciseCalorie(CommonCode type) {
public void changeExerciseCalories(ExerciseCalorie updateExerciseCalorie) {
exerciseCalories.stream()
.filter(exerciseCalorie -> exerciseCalorie.type().equals(type))
.filter(existExerciseCalorie -> existExerciseCalorie.type().equals(updateExerciseCalorie.type()))
.findFirst()
.ifPresent(exerciseCalorie -> exerciseCalories.remove(exerciseCalorie));
.ifPresent(existExerciseCalorie -> exerciseCalories.remove(existExerciseCalorie));
exerciseCalories.add(updateExerciseCalorie);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.coniverse.dangjang.domain.guide.exercise.service;

import java.time.LocalDate;
import java.util.List;

import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -28,7 +27,7 @@
*/
@Service
@RequiredArgsConstructor
public class ExerciseGuideGenerateService implements GuideGenerateService { // TODO 리팩토링 필수
public class ExerciseGuideGenerateService implements GuideGenerateService {
private final ExerciseGuideSearchService exerciseGuideSearchService;
private final ExerciseGuideMapper exerciseGuideMapper;
private final ExerciseGuideRepository exerciseGuideRepository;
Expand Down Expand Up @@ -107,36 +106,6 @@ public GuideResponse updateGuide(AnalysisData analysisData) {
return exerciseGuideMapper.toResponse(exerciseGuideRepository.save(updateExerciseGuide));
}

/**
* 걸음 수 가이드 또는 칼로리 가이드를 삭제한다.
*
* @since 1.3.0
*/
@Override
public void removeGuide(String oauthId, LocalDate createdAt, CommonCode type) {
ExerciseGuide exerciseGuide = exerciseGuideSearchService.findByOauthIdAndCreatedAt(oauthId, createdAt);
if (type.equals(CommonCode.STEP_COUNT)) {
exerciseGuide.changeAboutWalk(0, 0, null, null, 0);
removeEmptyExerciseGuide(exerciseGuide);
return;
}
exerciseGuide.removeExerciseCalorie(type);
removeEmptyExerciseGuide(exerciseGuide);
}

/**
* 운동 가이드가 비어있으면 삭제한다.
*
* @since 1.3.0
*/
private void removeEmptyExerciseGuide(ExerciseGuide exerciseGuide) {
if (exerciseGuide.getContent() == null && exerciseGuide.getExerciseCalories().isEmpty()) {
exerciseGuideRepository.delete(exerciseGuide);
return;
}
exerciseGuideRepository.save(exerciseGuide);
}

@Override
public GroupCode getGroupCode() {
return GroupCode.EXERCISE;
Expand Down
Loading

0 comments on commit aa070dd

Please sign in to comment.