Skip to content

Commit

Permalink
feat: 이름 및 권한 변경 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
dong2ast committed Dec 4, 2023
1 parent 0729ef1 commit b6da4e1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/uspray/uspray/controller/MemberController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -44,4 +45,13 @@ public ApiResponseDto<?> setNotificationAgree(
memberService.changeNotificationAgree(user.getUsername(), notificationAgreeDto);
return ApiResponseDto.success(SuccessStatus.CHANGE_PUSH_AGREE_SUCCESS);
}

@PutMapping("/oauth/{name}")
@Operation(summary = "소셜 로그인 회원가입 이름 설정")
public ApiResponseDto<?> setOAuthName(
@Parameter(hidden = true) @AuthenticationPrincipal User user,
@PathVariable("name") String name) {
memberService.changeName(user.getUsername(), name);
return ApiResponseDto.success(SuccessStatus.CHANGE_NAME_SUCCESS);
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/uspray/uspray/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public void changeFirebaseToken(String firebaseToken) {
public void changePhone(String phone) {
this.phone = phone;
}
public void changeName(String name) {
this.name = name;
}

public void changeAuthority(Authority authority) {
this.authority = authority;
}

public void changePw(String pw) {
this.password = pw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum SuccessStatus {
REISSUE_SUCCESS(HttpStatus.OK, "토큰 재발급에 성공했습니다."),
PUSH_SUCCESS(HttpStatus.OK, "푸쉬 알림을 성공적으로 전송했습니다."),
CHANGE_PUSH_AGREE_SUCCESS(HttpStatus.OK, "푸쉬 알림 설정을 성공적으로 변경했습니다."),
CHANGE_NAME_SUCCESS(HttpStatus.OK, "이름을 성공적으로 변경했습니다."),
UPDATE_CATEGORY_SUCCESS(HttpStatus.OK, "카테고리 수정에 성공했습니다."),
GET_CATEGORY_SUCCESS(HttpStatus.OK, "카테고리 조회에 성공했습니다."),
GET_HISTORY_LIST_SUCCESS(HttpStatus.OK, "히스토리 목록 조회에 성공했습니다."),
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/uspray/uspray/service/MemberService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.uspray.uspray.service;

import com.uspray.uspray.DTO.notification.NotificationAgreeDto;
import com.uspray.uspray.Enums.Authority;
import com.uspray.uspray.domain.Member;
import com.uspray.uspray.infrastructure.MemberRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -21,4 +23,11 @@ public void changePhone(String userId, String phone) {
public void changeNotificationAgree(String userId, NotificationAgreeDto notificationAgreeDto) {
memberRepository.getMemberByUserId(userId).changeNotificationSetting(notificationAgreeDto);
}

@Transactional
public void changeName(String userId, String name) {
Member member = memberRepository.getMemberByUserId(userId);
member.changeName(name);
member.changeAuthority(Authority.ROLE_USER);
}
}

0 comments on commit b6da4e1

Please sign in to comment.