Skip to content

Commit

Permalink
Feat: 사용자 권한 변경 편의 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonssshyeon committed Sep 25, 2024
1 parent d9e4af3 commit e6ce880
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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){
Expand All @@ -33,4 +36,13 @@ public ResponseEntity<MemberResponse> getMemberInfo(@TokenMember JwtMemberDetail
return ResponseEntity.ok().body(memberInfoService.getMemberInfo(jwtMemberDetail.getId()));
}

@PatchMapping()
@Operation(summary="직렬, 권한 변경 편의 API (❗개발 API 아님❗)")
public ResponseEntity<Member> 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));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
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;

public interface MemberInfoService {
MemberResponse getMemberInfo(Long id);
void addMemberInfo(Long id, MemberRequest.Append memberInfoAdd);
List<TeamInfoResponse> getMemberTeamInfo(Long id);
Member getMemberAdmin(String email, Track track, Role role);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,4 +59,13 @@ public List<TeamInfoResponse> 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;
}
}

0 comments on commit e6ce880

Please sign in to comment.