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; + } }