Skip to content

Commit

Permalink
Merge pull request #134 from SSU-Plector/issue/128-register-developer-id
Browse files Browse the repository at this point in the history
♻️ [Refactor] 기존에 있던 개발자 검색 후 해당 값 등록
  • Loading branch information
88dldl authored Jul 10, 2024
2 parents 93effd4 + 7b0b122 commit 513990a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ssuPlector/dto/request/ProjectDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static class ProjectRequestDTO {
@MaxSizeThree private List<DevTools> devToolList;
@MaxSizeThree private List<TechStack> techStackList;

private List<ProjectDeveloperRequestDTO> projectDevloperList;
private List<Long> projectDevloperList;
}

@Getter
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/ssuPlector/service/project/ProjectServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ssuPlector.domain.category.Category;
import ssuPlector.domain.category.DevLanguage;
import ssuPlector.domain.category.DevTools;
import ssuPlector.domain.category.Part;
import ssuPlector.domain.category.TechStack;
import ssuPlector.dto.request.ProjectDTO.ProjectListRequestDto;
import ssuPlector.dto.response.ProjectDTO.ProjectListResponseDto;
Expand Down Expand Up @@ -119,28 +120,29 @@ public Long createProject(ProjectRequestDTO requestDTO, MultipartFile image) {
}

@Transactional
public List<ProjectDeveloper> createProjectDeveloperList(
List<ProjectDeveloperRequestDTO> requestDTOList) {
return requestDTOList.stream()
public List<ProjectDeveloper> createProjectDeveloperList(List<Long> developerIdList) {
return developerIdList.stream()
.map(this::createProjectDeveloper)
.collect(Collectors.toList());
}

@Transactional
public ProjectDeveloper createProjectDeveloper(ProjectDeveloperRequestDTO requestDTO) {

Developer developer = developerRepository.findByEmail(requestDTO.getEmail()).orElse(null);
public ProjectDeveloper createProjectDeveloper(Long developerId) {
Developer developer =
developerRepository
.findById(developerId)
.orElseThrow(
() -> new GlobalException(GlobalErrorCode.DEVELOPER_NOT_FOUND));

ProjectDeveloper newProjectDeveloper =
ProjectDeveloper.builder()
.name(requestDTO.getName())
.partList(requestDTO.getPartList())
.isTeamLeader(requestDTO.getIsTeamLeader())
.name(developer.getName())
.partList(List.of(new Part[] {developer.getPart1(), developer.getPart2()}))
.isTeamLeader(false)
.build();

if (developer != null) { // 계정이 있는 프로젝트 부원인 경우
developer.addProjectDeveloper(newProjectDeveloper);
}
// 계정이 있는 프로젝트 부원인 경우
developer.addProjectDeveloper(newProjectDeveloper);
return newProjectDeveloper;
}
}

0 comments on commit 513990a

Please sign in to comment.