From d9e4af3064ef3557f5d469fbb41150a3b265277c Mon Sep 17 00:00:00 2001 From: kwonssshyeon Date: Wed, 25 Sep 2024 18:18:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20track=20default=20=EA=B0=92=20?= =?UTF-8?q?=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc_knu/official_homepage/dto/oauth/GoogleUserInfo.java | 2 ++ .../com/gdsc_knu/official_homepage/dto/team/TeamResponse.java | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gdsc_knu/official_homepage/dto/oauth/GoogleUserInfo.java b/src/main/java/com/gdsc_knu/official_homepage/dto/oauth/GoogleUserInfo.java index 0897e705..4c18ef5d 100644 --- a/src/main/java/com/gdsc_knu/official_homepage/dto/oauth/GoogleUserInfo.java +++ b/src/main/java/com/gdsc_knu/official_homepage/dto/oauth/GoogleUserInfo.java @@ -2,6 +2,7 @@ import com.gdsc_knu.official_homepage.entity.Member; import com.gdsc_knu.official_homepage.entity.enumeration.Role; +import com.gdsc_knu.official_homepage.entity.enumeration.Track; import lombok.Getter; import java.time.LocalDateTime; @@ -23,6 +24,7 @@ public Member toMember(){ .profileUrl(picture) .name(name) .role(Role.ROLE_TEMP) + .track(Track.UNDEFINED) .build(); } } diff --git a/src/main/java/com/gdsc_knu/official_homepage/dto/team/TeamResponse.java b/src/main/java/com/gdsc_knu/official_homepage/dto/team/TeamResponse.java index 404f920c..11037a03 100644 --- a/src/main/java/com/gdsc_knu/official_homepage/dto/team/TeamResponse.java +++ b/src/main/java/com/gdsc_knu/official_homepage/dto/team/TeamResponse.java @@ -20,9 +20,7 @@ public static MemberInfo from(Member member) { return MemberInfo.builder() .id(member.getId()) .name(member.getName()) - .track(member.getTrack() != null - ? member.getTrack().name() - : "undefined") + .track(member.getTrack().name()) .build(); } } From e6ce8800ddedfe3be063d7bd42058115d6d03cdd Mon Sep 17 00:00:00 2001 From: kwonssshyeon Date: Wed, 25 Sep 2024 18:25:23 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Feat:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=EB=B3=80=EA=B2=BD=20=ED=8E=B8=EC=9D=98=20?= =?UTF-8?q?API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MemberController.java | 16 ++++++++++++++-- .../service/MemberInfoService.java | 4 ++++ .../service/MemberInfoServiceImpl.java | 11 +++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdsc_knu/official_homepage/controller/MemberController.java b/src/main/java/com/gdsc_knu/official_homepage/controller/MemberController.java index 2f77d813..3d0ff161 100644 --- a/src/main/java/com/gdsc_knu/official_homepage/controller/MemberController.java +++ b/src/main/java/com/gdsc_knu/official_homepage/controller/MemberController.java @@ -5,6 +5,9 @@ import com.gdsc_knu.official_homepage.dto.member.MemberRequest; import com.gdsc_knu.official_homepage.dto.member.MemberResponse; import com.gdsc_knu.official_homepage.dto.member.TeamInfoResponse; +import com.gdsc_knu.official_homepage.entity.Member; +import com.gdsc_knu.official_homepage.entity.enumeration.Role; +import com.gdsc_knu.official_homepage.entity.enumeration.Track; import com.gdsc_knu.official_homepage.service.MemberInfoService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -14,13 +17,13 @@ import java.util.List; -@Tag(name = "Member", description = "사용자 정보 관련 API") +@Tag(name = "User", description = "사용자 정보 관련 API") @RestController @RequestMapping("api/user") @RequiredArgsConstructor public class MemberController { private final MemberInfoService memberInfoService; - @PostMapping("additional-info") + @PutMapping() @Operation(summary="신규가입 추가정보 입력 API") public void additionalInfo(@TokenMember JwtMemberDetail jwtMemberDetail, @RequestBody MemberRequest.Append request){ @@ -33,4 +36,13 @@ public ResponseEntity getMemberInfo(@TokenMember JwtMemberDetail return ResponseEntity.ok().body(memberInfoService.getMemberInfo(jwtMemberDetail.getId())); } + @PatchMapping() + @Operation(summary="직렬, 권한 변경 편의 API (❗개발 API 아님❗)") + public ResponseEntity getMember(@RequestParam(required = true) Track track, + @RequestParam(required = true) Role role, + @RequestParam(name = "email") String email) { + return ResponseEntity.ok().body(memberInfoService.getMemberAdmin(email, track, role)); + } + + } diff --git a/src/main/java/com/gdsc_knu/official_homepage/service/MemberInfoService.java b/src/main/java/com/gdsc_knu/official_homepage/service/MemberInfoService.java index 2c5a332c..5f94a3d8 100644 --- a/src/main/java/com/gdsc_knu/official_homepage/service/MemberInfoService.java +++ b/src/main/java/com/gdsc_knu/official_homepage/service/MemberInfoService.java @@ -3,6 +3,9 @@ import com.gdsc_knu.official_homepage.dto.member.MemberRequest; import com.gdsc_knu.official_homepage.dto.member.MemberResponse; import com.gdsc_knu.official_homepage.dto.member.TeamInfoResponse; +import com.gdsc_knu.official_homepage.entity.Member; +import com.gdsc_knu.official_homepage.entity.enumeration.Role; +import com.gdsc_knu.official_homepage.entity.enumeration.Track; import java.util.List; @@ -10,4 +13,5 @@ public interface MemberInfoService { MemberResponse getMemberInfo(Long id); void addMemberInfo(Long id, MemberRequest.Append memberInfoAdd); List getMemberTeamInfo(Long id); + Member getMemberAdmin(String email, Track track, Role role); } diff --git a/src/main/java/com/gdsc_knu/official_homepage/service/MemberInfoServiceImpl.java b/src/main/java/com/gdsc_knu/official_homepage/service/MemberInfoServiceImpl.java index 4b1a7ffb..d8e8ab6b 100644 --- a/src/main/java/com/gdsc_knu/official_homepage/service/MemberInfoServiceImpl.java +++ b/src/main/java/com/gdsc_knu/official_homepage/service/MemberInfoServiceImpl.java @@ -3,6 +3,8 @@ import com.gdsc_knu.official_homepage.dto.member.*; import com.gdsc_knu.official_homepage.entity.Member; import com.gdsc_knu.official_homepage.entity.Team; +import com.gdsc_knu.official_homepage.entity.enumeration.Role; +import com.gdsc_knu.official_homepage.entity.enumeration.Track; import com.gdsc_knu.official_homepage.exception.CustomException; import com.gdsc_knu.official_homepage.exception.ErrorCode; import com.gdsc_knu.official_homepage.repository.MemberRepository; @@ -57,4 +59,13 @@ public List getMemberTeamInfo(Long id) { .map(TeamInfoResponse::new) .toList(); } + + @Override + @Transactional + public Member getMemberAdmin(String email, Track track, Role role) { + Member member = memberRepository.findByEmail(email).orElseThrow(); + member.updateRole(role); + member.updateTrack(track); + return member; + } }