-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jeonggeon
committed
Jan 22, 2024
1 parent
e21e660
commit 6b363f7
Showing
4 changed files
with
117 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 42 additions & 30 deletions
72
src/main/java/careerfestival/career/record/dto/RecordRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,42 @@ | ||
//package careerfestival.career.record.dto; | ||
// | ||
//import careerfestival.career.domain.enums.Category; | ||
//import jakarta.persistence.Column; | ||
//import jakarta.validation.constraints.NotNull; | ||
//import lombok.Getter; | ||
// | ||
//import java.time.LocalDate; | ||
//import java.time.LocalDateTime; | ||
//import java.util.List; | ||
// | ||
//public class RecordRequestDto { | ||
// | ||
// @Getter | ||
// public static class AddRecordConferenceRequestDto{ | ||
// @NotNull | ||
// private String eventName; | ||
// @NotNull | ||
// private LocalDate deadline; | ||
// @NotNull | ||
// private Category category; | ||
// @NotNull | ||
// private LocalDateTime eventDate; | ||
// //checkpoint 세션과 부스 어차피 같은 형태로 그냥 제목부스이름이던 세션이름이던 같이 받을 수 있음 그래서 event description 제목 받을 거 하나 생성 | ||
// @NotNull | ||
// private String eventDescription; | ||
// private String networkingName; | ||
// private String networkingContact; | ||
// } | ||
//} | ||
package careerfestival.career.record.dto; | ||
|
||
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.util.Collections; | ||
import java.util.List; | ||
|
||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class RecordRequestDto { | ||
private String eventName; | ||
private LocalDate eventDate; | ||
private KeywordName keywordName; | ||
private List<String> detailEventName; | ||
private List<String> eventDescription; | ||
private List<String> networkingName; | ||
private List<String> networkingContact; | ||
|
||
@Builder | ||
public Record toEntity() { | ||
return Record.builder() | ||
.eventName(eventName) | ||
.eventDate(eventDate) | ||
.keywordName(Collections.singletonList(keywordName)) | ||
.detailEventName(detailEventName.toString()) | ||
.eventDescription(eventDescription.toString()) | ||
.networkingName(networkingName.toString()) | ||
.networkingContact(networkingContact.toString()) | ||
.build(); | ||
|
||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/careerfestival/career/record/service/RecordConferenceExhibitionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package careerfestival.career.record.service; | ||
|
||
import careerfestival.career.domain.Record; | ||
import careerfestival.career.domain.User; | ||
import careerfestival.career.record.dto.RecordRequestDto; | ||
import careerfestival.career.repository.RecordRepository; | ||
import careerfestival.career.repository.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RecordConferenceExhibitionService { | ||
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 테이블에만 저장된 상태 | ||
} | ||
public void recordExhibition(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 테이블에만 저장된 상태 | ||
} | ||
} |