From f1b0fc2b0c2a53e3e1bb02fb9ec1e68d6f0ba130 Mon Sep 17 00:00:00 2001 From: oznchex <114240463+oznchex@users.noreply.github.com> Date: Thu, 18 Jan 2024 01:31:19 +0900 Subject: [PATCH 1/4] =?UTF-8?q?README.md=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..68585a7a --- /dev/null +++ b/README.md @@ -0,0 +1,129 @@ +## 디렉토리 구조 +C:. +│ CareerApplication.java +│ +├─apiPayload +│ │ ApiResponse.java +│ │ +│ ├─code +│ │ │ BaseCode.java +│ │ │ BaseErrorCode.java +│ │ │ ErrorReasonDTO.java +│ │ │ ReasonDTO.java +│ │ │ +│ │ └─status +│ │ ErrorStatus.java +│ │ SuccessStatus.java +│ │ +│ └─exception +│ │ ExceptionAdvice.java +│ │ GeneralException.java +│ │ +│ └─handler +│ TempHandler.java +│ +├─comments +│ ├─Controller +│ │ CommentsController.java +│ │ +│ ├─dto +│ │ CommentRequestDto.java +│ │ CommentResponseDto.java +│ │ +│ └─Service +│ CommentService.java +│ +├─config +│ SecurityConfig.java +│ +├─domain +│ │ Comment.java +│ │ Event.java +│ │ Follow.java +│ │ Organizer.java +│ │ Record.java +│ │ Region.java +│ │ User.java +│ │ Wish.java +│ │ +│ ├─common +│ │ BaseEntity.java +│ │ +│ ├─enums +│ │ Category.java +│ │ Gender.java +│ │ KeywordName.java +│ │ Role.java +│ │ UserStatus.java +│ │ +│ └─mapping +│ EventImage.java +│ Participate.java +│ +├─dto +│ CustomUserDetails.java +│ +├─exception +│ CustomException.java +│ ErrorCode.java +│ +├─jwt +│ JWTFilter.java +│ JWTUtil.java +│ LoginFilter.java +│ +├─login +│ ├─api +│ │ UserController.java +│ │ +│ ├─dto +│ │ UpdateUserDetailRequestDto.java +│ │ UserSignInRequestDto.java +│ │ UserSignRoleRequestDto.java +│ │ UserSignUpRequestDto.java +│ │ +│ └─service +│ CustomUserDetailsService.java +│ UserService.java +│ +├─participate +│ ├─controller +│ │ ParticipateController.java +│ │ +│ ├─dto +│ │ ParticipateRequestDto.java +│ │ ParticipateResponseDto.java +│ │ +│ └─service +│ ParticipateService.java +│ +├─record +│ ├─controller +│ │ RecordController.java +│ │ +│ ├─dto +│ │ RecordEtcDto.java +│ │ RecordLectureSeminarDto.java +│ │ RecordMainResponseDto.java +│ │ +│ └─service +│ RecordService.java +│ +├─register +│ ├─controller +│ │ RegisterController.java +│ │ +│ ├─dto +│ │ RegisterEventDto.java +│ │ +│ └─service +│ RegisterService.java +│ +└─repository + CommentRepository.java + EventImageRepository.java + EventRepository.java + ParticipateRepository.java + RecordRepository.java + UserRepository.java + From ccab14a95b04d8d2c625ed160316583c99c83cca Mon Sep 17 00:00:00 2001 From: oznchex <114240463+oznchex@users.noreply.github.com> Date: Thu, 18 Jan 2024 01:32:31 +0900 Subject: [PATCH 2/4] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68585a7a..e1f64f2f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ ## 디렉토리 구조 +``` C:. │ CareerApplication.java │ @@ -126,4 +127,4 @@ C:. ParticipateRepository.java RecordRepository.java UserRepository.java - +``` From fd7ee9109fa8297462371715be3e311c25cd4cb5 Mon Sep 17 00:00:00 2001 From: oznchex <114240463+oznchex@users.noreply.github.com> Date: Thu, 18 Jan 2024 01:41:55 +0900 Subject: [PATCH 3/4] Update README.md --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e1f64f2f..db3bfdff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## 디렉토리 구조 +## career 내부 디렉토리 구조 ``` C:. │ CareerApplication.java @@ -38,14 +38,9 @@ C:. │ SecurityConfig.java │ ├─domain -│ │ Comment.java │ │ Event.java -│ │ Follow.java -│ │ Organizer.java │ │ Record.java -│ │ Region.java │ │ User.java -│ │ Wish.java │ │ │ ├─common │ │ BaseEntity.java @@ -58,8 +53,12 @@ C:. │ │ UserStatus.java │ │ │ └─mapping +│ Comment.java │ EventImage.java +│ Follow.java │ Participate.java +│ Region.java +│ Wish.java │ ├─dto │ CustomUserDetails.java From 13f73146deb6b71ff502c88573b66bf18f8f773f Mon Sep 17 00:00:00 2001 From: jeonggeon Date: Fri, 19 Jan 2024 17:30:34 +0900 Subject: [PATCH 4/4] =?UTF-8?q?#38=20Refactor:record=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../careerfestival/career/domain/Record.java | 10 +--- .../record/controller/RecordController.java | 24 +++++----- .../record/converter/RecordConverter.java | 6 ++- .../career/record/dto/RecordRequestDto.java | 47 ++++++++++++------- .../record/service/RecordCommandService.java | 3 ++ .../service/RecordCommandServiceImpl.java | 11 +++++ .../service/RecordConferenceService.java | 40 ++++++++++++++++ .../career/repository/RegionRepository.java | 2 + 8 files changed, 104 insertions(+), 39 deletions(-) create mode 100644 src/main/java/careerfestival/career/record/service/RecordConferenceService.java diff --git a/src/main/java/careerfestival/career/domain/Record.java b/src/main/java/careerfestival/career/domain/Record.java index c26306be..c62ded74 100644 --- a/src/main/java/careerfestival/career/domain/Record.java +++ b/src/main/java/careerfestival/career/domain/Record.java @@ -39,14 +39,8 @@ public class Record extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) private User user; + @Column + private String detailEventName; - public void user(Optional user){ - //checkpoint - /* Optional.ofNullable(this.user) - .ifPresent(oldUser -> oldUser.removeRecord(this)); - - this.user = user; - user.addRecord(this);*/ - } } \ No newline at end of file diff --git a/src/main/java/careerfestival/career/record/controller/RecordController.java b/src/main/java/careerfestival/career/record/controller/RecordController.java index ba654b5b..6cc85279 100644 --- a/src/main/java/careerfestival/career/record/controller/RecordController.java +++ b/src/main/java/careerfestival/career/record/controller/RecordController.java @@ -1,13 +1,10 @@ package careerfestival.career.record.controller; -import careerfestival.career.apiPayload.ApiResponse; -import careerfestival.career.domain.Record; -import careerfestival.career.record.converter.RecordConverter; + import careerfestival.career.record.dto.RecordEtcDto; import careerfestival.career.record.dto.RecordLectureSeminarDto; import careerfestival.career.record.dto.RecordRequestDto; -import careerfestival.career.record.dto.RecordResponseDto; -import careerfestival.career.record.service.RecordCommandService; +import careerfestival.career.record.service.RecordConferenceService; import careerfestival.career.record.service.RecordService; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -22,7 +19,7 @@ @RequestMapping("/record") @RestController public class RecordController { - private final RecordCommandService recordCommandService; + private final RecordConferenceService recordConferenceService; private final RecordService recordService; // @PostMapping("/lecture-seminar/{userId}") @@ -45,12 +42,15 @@ public ResponseEntity recordEtc(@PathVariable("userId") Long userId, @Requ } } //기록장 - @PostMapping("/{memberId}") - public ApiResponse - addRecordConference(@RequestBody @Valid RecordRequestDto.AddRecordConferenceRequestDto request - ,@PathVariable Long memberId){ - Record record = recordCommandService.addRecord(request, memberId); - return ApiResponse.onSuccess(RecordConverter.toAddRecordResponseDto(record)); + @PostMapping("/conference/{memberId}") + public ResponseEntity + addRecordConference(@RequestBody @Valid RecordRequestDto request,@PathVariable("memberId") Long memberId){ + try{ + recordConferenceService.recordConference(memberId, request); + return new ResponseEntity<>(HttpStatus.OK); + }catch (IllegalArgumentException e){ + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } } diff --git a/src/main/java/careerfestival/career/record/converter/RecordConverter.java b/src/main/java/careerfestival/career/record/converter/RecordConverter.java index a98db5f7..a975fe7f 100644 --- a/src/main/java/careerfestival/career/record/converter/RecordConverter.java +++ b/src/main/java/careerfestival/career/record/converter/RecordConverter.java @@ -1,3 +1,4 @@ +/* package careerfestival.career.record.converter; import careerfestival.career.domain.Record; import careerfestival.career.record.dto.RecordRequestDto; @@ -13,7 +14,8 @@ public static Record toRecord(RecordRequestDto.AddRecordConferenceRequestDto req return Record.builder() .eventName(request.getEventName()) - //.eventDate(request.getEventDate()) + .eventDate(request.getEventDate()) + .keywordName(request.getKeywordName()) .eventDescription(request.getEventDescription()) .networkingName(request.getNetworkingName()) .networkingContact(request.getNetworkingContact()) @@ -29,3 +31,5 @@ public static RecordResponseDto.AddRecordResponseDto toAddRecordResponseDto(Reco } +*/ +//checkpoint 지울지 \ No newline at end of file diff --git a/src/main/java/careerfestival/career/record/dto/RecordRequestDto.java b/src/main/java/careerfestival/career/record/dto/RecordRequestDto.java index deb0972d..f48db225 100644 --- a/src/main/java/careerfestival/career/record/dto/RecordRequestDto.java +++ b/src/main/java/careerfestival/career/record/dto/RecordRequestDto.java @@ -1,31 +1,42 @@ package careerfestival.career.record.dto; -import careerfestival.career.domain.enums.Category; -import jakarta.persistence.Column; +import careerfestival.career.domain.enums.KeywordName; +import careerfestival.career.domain.Record; import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; import java.time.LocalDate; -import java.time.LocalDateTime; +import java.util.Collections; import java.util.List; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Builder public class RecordRequestDto { + private String eventName; + private LocalDate eventDate; + private KeywordName keywordName; + private String detailEventName; + private String eventDescription; + private String networkingName; + private String networkingContact; - @Getter - public static class AddRecordConferenceRequestDto{ - @NotNull - private String eventName; - @NotNull - private LocalDate deadline; + @Builder + public Record toEntity() { + return Record.builder() + .eventName(eventName) + .eventDate(eventDate) + .keywordName(Collections.singletonList(keywordName)) + .detailEventName(detailEventName) + .eventDescription(eventDescription) + .networkingName(networkingName) + .networkingContact(networkingContact) + .build(); - @NotNull - private Category category; - @NotNull - private LocalDateTime eventDate; - //checkpoint 세션과 부스 어차피 같은 형태로 그냥 제목부스이름이던 세션이름이던 같이 받을 수 있음 그래서 event description 제목 받을 거 하나 생성 - @NotNull - private String eventDescription; - private String networkingName; - private String networkingContact; } } diff --git a/src/main/java/careerfestival/career/record/service/RecordCommandService.java b/src/main/java/careerfestival/career/record/service/RecordCommandService.java index 656c6c41..f9f8e86b 100644 --- a/src/main/java/careerfestival/career/record/service/RecordCommandService.java +++ b/src/main/java/careerfestival/career/record/service/RecordCommandService.java @@ -1,3 +1,4 @@ +/* package careerfestival.career.record.service; import careerfestival.career.record.dto.RecordRequestDto; @@ -10,3 +11,5 @@ public interface RecordCommandService { Record addRecord(RecordRequestDto.AddRecordConferenceRequestDto request, Long userId); } +*/ +//checkpoint 지울지 \ No newline at end of file diff --git a/src/main/java/careerfestival/career/record/service/RecordCommandServiceImpl.java b/src/main/java/careerfestival/career/record/service/RecordCommandServiceImpl.java index a3fa53c4..15f6ebf2 100644 --- a/src/main/java/careerfestival/career/record/service/RecordCommandServiceImpl.java +++ b/src/main/java/careerfestival/career/record/service/RecordCommandServiceImpl.java @@ -1,3 +1,4 @@ +/* package careerfestival.career.record.service; import careerfestival.career.domain.Record; @@ -21,6 +22,14 @@ public class RecordCommandServiceImpl implements RecordCommandService{ @Override public Record addRecord(RecordRequestDto.AddRecordConferenceRequestDto request, Long userId){ Record newRecord = RecordConverter.toRecord(request); + User user = userRepository.findById(userId) + .orElseThrow(() -> new RuntimeException("User not found with id: " + userId)); + + newRecord.setEventName(request.getEventName()); + newRecord.setEventDate(request.getEventDate()); + newRecord.setKeywordName(request.getKeywordName()); + newRecord.setDetailEventName(req); + newRecord.setUser(user); //checkpoint userid에 맞게 저장하는방법? //Optional user = userRepository.findById(userId); //checkpoint 리스트 @@ -29,3 +38,5 @@ public Record addRecord(RecordRequestDto.AddRecordConferenceRequestDto request, }; } +*/ +//checkpoint 지울지 \ No newline at end of file diff --git a/src/main/java/careerfestival/career/record/service/RecordConferenceService.java b/src/main/java/careerfestival/career/record/service/RecordConferenceService.java new file mode 100644 index 00000000..706e7081 --- /dev/null +++ b/src/main/java/careerfestival/career/record/service/RecordConferenceService.java @@ -0,0 +1,40 @@ +package careerfestival.career.record.service; + +import careerfestival.career.domain.Record; +import careerfestival.career.domain.User; +import careerfestival.career.record.dto.RecordEtcDto; +import careerfestival.career.record.dto.RecordLectureSeminarDto; +import careerfestival.career.record.dto.RecordMainResponseDto; +import careerfestival.career.record.dto.RecordRequestDto; +import careerfestival.career.repository.RecordRepository; +import careerfestival.career.repository.UserRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class RecordConferenceService { + private final RecordRepository recordRepository; + private final UserRepository userRepository; + + + public void recordConference(Long userId, RecordRequestDto request) { + + User user = userRepository.findById(userId) + .orElseThrow(()->new RuntimeException("User not found with id: " + userId)); + + Record record = request.toEntity(); + record.setUser(user); + record.setEventName(request.getEventName()); + record.setEventDate(request.getEventDate()); + record.setDetailEventName(request.getDetailEventName()); + record.setEventDescription(request.getEventDescription()); + record.setNetworkingName(request.getNetworkingName()); + record.setNetworkingContact(request.getNetworkingContact()); + recordRepository.save(record); + // Record 테이블에만 저장된 상태 + } +} diff --git a/src/main/java/careerfestival/career/repository/RegionRepository.java b/src/main/java/careerfestival/career/repository/RegionRepository.java index 0d1aab99..6aaa5ddd 100644 --- a/src/main/java/careerfestival/career/repository/RegionRepository.java +++ b/src/main/java/careerfestival/career/repository/RegionRepository.java @@ -1,3 +1,4 @@ +/* package careerfestival.career.repository; import careerfestival.career.domain.Region; @@ -8,3 +9,4 @@ public interface RegionRepository extends JpaRepository { Region findRegionByCityAndAddressLine(String city, String addressLine); } +*/