diff --git a/README.md b/README.md new file mode 100644 index 00000000..db3bfdff --- /dev/null +++ b/README.md @@ -0,0 +1,129 @@ +## career 내부 디렉토리 구조 +``` +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 +│ │ Event.java +│ │ Record.java +│ │ User.java +│ │ +│ ├─common +│ │ BaseEntity.java +│ │ +│ ├─enums +│ │ Category.java +│ │ Gender.java +│ │ KeywordName.java +│ │ Role.java +│ │ UserStatus.java +│ │ +│ └─mapping +│ Comment.java +│ EventImage.java +│ Follow.java +│ Participate.java +│ Region.java +│ Wish.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 +``` diff --git a/src/main/java/careerfestival/career/domain/Record.java b/src/main/java/careerfestival/career/domain/Record.java index 556484f1..29acb060 100644 --- a/src/main/java/careerfestival/career/domain/Record.java +++ b/src/main/java/careerfestival/career/domain/Record.java @@ -51,17 +51,7 @@ public class Record extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) private User user; - @OneToOne(mappedBy = "record", cascade = CascadeType.ALL) private ImageData imageData; - 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 d4dcd7ee..c63a402c 100644 --- a/src/main/java/careerfestival/career/record/controller/RecordController.java +++ b/src/main/java/careerfestival/career/record/controller/RecordController.java @@ -56,6 +56,7 @@ public ResponseEntity addRecordExhibition(@RequestBody @Valid RecordReques recordConferenceService.recordExhibition(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 new file mode 100644 index 00000000..a975fe7f --- /dev/null +++ b/src/main/java/careerfestival/career/record/converter/RecordConverter.java @@ -0,0 +1,35 @@ +/* +package careerfestival.career.record.converter; +import careerfestival.career.domain.Record; +import careerfestival.career.record.dto.RecordRequestDto; +import careerfestival.career.record.dto.RecordResponseDto; + +import java.time.LocalDate; +import java.time.LocalDateTime; + + + +public class RecordConverter { + public static Record toRecord(RecordRequestDto.AddRecordConferenceRequestDto request){ + + return Record.builder() + .eventName(request.getEventName()) + .eventDate(request.getEventDate()) + .keywordName(request.getKeywordName()) + .eventDescription(request.getEventDescription()) + .networkingName(request.getNetworkingName()) + .networkingContact(request.getNetworkingContact()) + .build(); + } + public static RecordResponseDto.AddRecordResponseDto toAddRecordResponseDto(Record record){ + return RecordResponseDto.AddRecordResponseDto.builder() + .recordId(record.getId()) + .createdAt(LocalDate.from(LocalDateTime.now())) + .build(); + } +//checkpoint localdatetime + + +} +*/ +//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 4d66e743..4966ede9 100644 --- a/src/main/java/careerfestival/career/record/dto/RecordRequestDto.java +++ b/src/main/java/careerfestival/career/record/dto/RecordRequestDto.java @@ -21,6 +21,7 @@ public class RecordRequestDto { private String eventName; private LocalDate eventDate; private KeywordName keywordName; +<<<<<<< HEAD private List detailEventName; private List eventDescription; private List networkingName; @@ -37,6 +38,5 @@ public Record toEntity() { .networkingName(networkingName.toString()) .networkingContact(networkingContact.toString()) .build(); - } } \ No newline at end of file diff --git a/src/main/java/careerfestival/career/record/service/RecordCommandService.java b/src/main/java/careerfestival/career/record/service/RecordCommandService.java new file mode 100644 index 00000000..f9f8e86b --- /dev/null +++ b/src/main/java/careerfestival/career/record/service/RecordCommandService.java @@ -0,0 +1,15 @@ +/* +package careerfestival.career.record.service; + +import careerfestival.career.record.dto.RecordRequestDto; + +import careerfestival.career.domain.Record; + ; + + +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 new file mode 100644 index 00000000..15f6ebf2 --- /dev/null +++ b/src/main/java/careerfestival/career/record/service/RecordCommandServiceImpl.java @@ -0,0 +1,42 @@ +/* +package careerfestival.career.record.service; + +import careerfestival.career.domain.Record; +import careerfestival.career.domain.User; +import careerfestival.career.record.converter.RecordConverter; +import careerfestival.career.record.dto.RecordRequestDto; +import careerfestival.career.repository.RecordRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import careerfestival.career.repository.UserRepository; + + + +@Service +@RequiredArgsConstructor +@Transactional +public class RecordCommandServiceImpl implements RecordCommandService{ + private final UserRepository userRepository; + private final RecordRepository recordRepository; + @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 리스트 + // newRecord.user(user); + return recordRepository.save(newRecord); + }; + +} +*/ +//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 288989b9..5857bc47 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.mapping.Region; @@ -8,3 +9,4 @@ public interface RegionRepository extends JpaRepository { Region findRegionByCityAndAddressLine(String city, String addressLine); } +*/