Skip to content

Commit

Permalink
#38 - [FEAT] -전시회 레코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jeonggeon committed Jan 22, 2024
2 parents 6b363f7 + a3dbc52 commit b294e72
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 11 deletions.
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
10 changes: 0 additions & 10 deletions src/main/java/careerfestival/career/domain/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -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> user){
//checkpoint
/* Optional.ofNullable(this.user)
.ifPresent(oldUser -> oldUser.removeRecord(this));
this.user = user;
user.addRecord(this);*/
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public ResponseEntity<Void> addRecordExhibition(@RequestBody @Valid RecordReques
recordConferenceService.recordExhibition(memberId, request);
return new ResponseEntity<>(HttpStatus.OK);
} catch (IllegalArgumentException e) {

return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 지울지
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class RecordRequestDto {
private String eventName;
private LocalDate eventDate;
private KeywordName keywordName;
<<<<<<< HEAD
private List<String> detailEventName;
private List<String> eventDescription;
private List<String> networkingName;
Expand All @@ -37,6 +38,5 @@ public Record toEntity() {
.networkingName(networkingName.toString())
.networkingContact(networkingContact.toString())
.build();

}
}
Original file line number Diff line number Diff line change
@@ -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 지울지
Original file line number Diff line number Diff line change
@@ -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> user = userRepository.findById(userId);
//checkpoint 리스트
// newRecord.user(user);
return recordRepository.save(newRecord);
};
}
*/
//checkpoint 지울지
Original file line number Diff line number Diff line change
@@ -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 테이블에만 저장된 상태
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
package careerfestival.career.repository;
import careerfestival.career.domain.mapping.Region;
Expand All @@ -8,3 +9,4 @@
public interface RegionRepository extends JpaRepository<Region, Long> {
Region findRegionByCityAndAddressLine(String city, String addressLine);
}
*/

0 comments on commit b294e72

Please sign in to comment.