Skip to content

Commit

Permalink
Merge pull request #111 from GDG-on-Campus-KNU/Feat/issue-#104
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonssshyeon authored Sep 26, 2024
2 parents bc4c293 + e6ce880 commit bb0c4ae
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 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 @@ -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;
Expand All @@ -23,6 +24,7 @@ public Member toMember(){
.profileUrl(picture)
.name(name)
.role(Role.ROLE_TEMP)
.track(Track.UNDEFINED)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
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::from)
.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 bb0c4ae

Please sign in to comment.