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;
했더니 잘 받아온다.
'개발 > JPA' 카테고리의 다른 글
JPA jpql을 사용하면서 배운것. 아주 중요. 그리고 나중에 생각 꼭 (0) | 2022.08.23 |
---|---|
람다식 (stream,map,collect) 이유: 호환되지 않는 타입: ParticipantResponseDto는 Participant를 반환할 수 없습니다. (0) | 2022.08.23 |
JPA - java if 객체 long null 조건으로 사용법 (0) | 2022.08.12 |
JPA String 필요한 제공 타입 TIL 에러 좋은 정보 나중에 안될 때 확인 (0) | 2022.08.12 |
jpa 게시판 권한 기능 구현 필요한 샘플 (0) | 2022.08.11 |