Skip to content

Commit

Permalink
hotfix : DB + 모듈화 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayon-Hong committed Mar 8, 2024
1 parent 254bf60 commit 6207311
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class MemberController {
* 로그인 API
*/
@PostMapping("/login")
public String memberLogin(@RequestBody GoogleLoginRequest request) {
public ResponseEntity<String> memberLogin(@RequestBody GoogleLoginRequest request) {
return memberService.memberLogin(request);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import org.springframework.http.ResponseEntity;

public interface MemberService {
String memberLogin(GoogleLoginRequest request);
ResponseEntity<String> memberLogin(GoogleLoginRequest request);

void signUp(SignUpRequest signUpRequest, String memberUid);

String handleExistingMemberLogin(Member existingMember);
ResponseEntity<String> handleExistingMemberLogin(Member existingMember);

String handleNewMemberLogin(GoogleLoginRequest request);
ResponseEntity<String> handleNewMemberLogin(GoogleLoginRequest request);

ResponseEntity<String> authRecreate(AuthRecreateRequest authRecreateRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class MemberServiceImpl implements MemberService {
*/
@Transactional
@Override
public String memberLogin(GoogleLoginRequest request) {
public ResponseEntity<String> memberLogin(GoogleLoginRequest request) {
Member existingMember = memberRepository.findByUid(request.getUid());

if (existingMember != null) {
Expand All @@ -45,19 +45,24 @@ public String memberLogin(GoogleLoginRequest request) {
}



/** 기존 회원의 로그인 **/
@Override
public String handleExistingMemberLogin(Member existingMember) {
public ResponseEntity<String> handleExistingMemberLogin(Member existingMember) {
String accessToken = tokenProvider.createAccessToken(existingMember.getUid());
String refreshToken = tokenProvider.createRefreshToken(existingMember.getUid());
return "기존 회원 로그인";
return ResponseEntity.ok()
.header("Access-Token", accessToken)
.header("Refresh-Token", refreshToken)
.body("기존 회원 로그인");
}




/** 신규 회원의 로그인 -> DB 저장 **/
@Override
public String handleNewMemberLogin(GoogleLoginRequest request) {
public ResponseEntity<String> handleNewMemberLogin(GoogleLoginRequest request) {
Member newMember = Member.builder()
.uid(request.getUid())
.loginType("google")
Expand All @@ -67,7 +72,10 @@ public String handleNewMemberLogin(GoogleLoginRequest request) {
String accessToken = tokenProvider.createAccessToken(newMember.getUid());
String refreshToken = tokenProvider.createRefreshToken(newMember.getUid());

return "신규 회원 로그인";
return ResponseEntity.status(HttpStatus.CREATED)
.header("Access-Token", accessToken)
.header("Refresh-Token", refreshToken)
.body("신규 회원 로그인");
}


Expand Down Expand Up @@ -99,6 +107,7 @@ public ResponseEntity<String> authRecreate(AuthRecreateRequest authRecreateReque
}
String uid = tokenProvider.getUid(authRecreateRequest.getRefreshToken());
Member member = memberRepository.findByUidAndActivatedIsTrue(uid);

if (member == null) {
throw new MemberNotFoundException();
}
Expand All @@ -122,7 +131,6 @@ public MemberDetailResponse getMemberInfo(String uid) {
if (findMember == null) {
throw new MemberNotFoundException();
}

return (MemberDetailResponse.fromEntity(findMember));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,5 @@ public class Schedule extends BaseEntity {
@Column(nullable = false)
private boolean activated = true;

// // setScheduleDetails 메서드 추가
// public void setScheduleDetails(List<ScheduleDetail> scheduleDetails) {
// this.scheduleDetails.clear();
// if (scheduleDetails != null) {
// this.scheduleDetails.addAll(scheduleDetails);
// }
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@Slf4j
@RequiredArgsConstructor
@Transactional(readOnly = true)
@Transactional
@Service
public class ScheduleServiceImpl implements ScheduleService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ScheduleDetail {

// Schedules 엔티티의 필드를 참조하도록 수정
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
@JoinColumn(name = "schedule_id" , nullable = false)
private Schedule schedule;

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
public class WebSecurityConfig {

private static final String[] AUTH_WHITE_LIST = {
"/members/login",
"/api/members/login",
"/api/members/test",
"/members/test",
"/error",
"/h2-console/**"
};
Expand Down

0 comments on commit 6207311

Please sign in to comment.