IT'S DO
728x90

 

기존

@PostMapping("/v1/participant/{eventId}")
public Event save(@RequestBody final ParticipantRequestDto params, @PathVariable Long eventId,  @AuthenticationPrincipal PrincipalDetail principalDetail, @AuthenticationPrincipal PrincipalDetail principalDetailNickName) throws Exception {
    return participantService.save(params, eventId,  principalDetail.getUser(), principalDetailNickName.getNickname());
}

 

 

/*    @Transactional
    public Event save(final ParticipantRequestDto params, Long eventId, User user, String name)  throws Exception {

 

 

수정

 

/*    Event save(final ParticipantRequestDto params, Long eventId, User user, String name) throws Exception;*/
    Event save(final ParticipantRequestDto params, Long eventId, Long userId, String name) throws Exception;

 

 

@Transactional
public Event save(final ParticipantRequestDto params, Long eventId, Long userId, String name)  throws Exception {

 

 

Event event = eventRepository.findById(eventId).orElseThrow(() -> new IllegalArgumentException("해당 eventId가 없습니다. id=" + eventId));
User user = userRepository.findById(userId).orElseThrow(() -> new IllegalArgumentException("해당 userId가 없습니다. id=" + userId));
name = userRepository.selectUserName(userId);
System.out.println("user name : " + name);
Long getUserId = userId;

 

했더니 잘 받아온다.

profile

IT'S DO

@멋진놈

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!