Skip to content

Commit

Permalink
fix: Builder 패턴 로직에 memberId, coParticipants, status 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyeonkong committed Nov 24, 2024
1 parent 06b219e commit 506cd43
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
import com.kyonggi.teampu.domain.application.dto.ApplicationRequest;
import com.kyonggi.teampu.domain.application.repository.ApplicationRepository;
import com.kyonggi.teampu.domain.auth.domain.CustomMemberDetails;
import com.kyonggi.teampu.domain.member.dto.CoParticipantRequest;
import com.kyonggi.teampu.domain.member.domain.CoParticipant;
import com.kyonggi.teampu.domain.member.domain.Member;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class ApplicationService {
Expand All @@ -24,17 +28,24 @@ public void createApplication(ApplicationRequest applicationRequest, CustomMembe
* 3. 사용 인원 계산
*/

Member member = customMemberDetails.getMember();
List<CoParticipant> coParticipants = applicationRequest.getCoParticipants().stream()
.map(CoParticipant::from)
.collect(Collectors.toList());

// Application.builder()를 사용하여 로그인한 사용자 정보와 입력받은 정보를 결합
Application application = Application.builder()
.member(member) // memberId
.applicantName(customMemberDetails.getMember().getName()) // 이름
.applicantLoginId(customMemberDetails.getMember().getLoginId()) // 학번
.applicantPhone(customMemberDetails.getMember().getPhoneNumber()) // 전화번호
.applicantEmail(customMemberDetails.getMember().getEmail()) // 이메일

.date(applicationRequest.getDate()) // 날짜
.coParticipants(CoParticipantRequest.toNameList(applicationRequest.getCoParticipants())) // 명단(이름, 전화번호)
.appliedDate(applicationRequest.getAppliedDate()) // 날짜
.coParticipants(coParticipants) // 명단(이름, 전화번호)
.participantCount(applicationRequest.getCoParticipants().size() + 1) // 사용 인원 자동 계산
.privacyAgreement(applicationRequest.getPrivacyAgreement()) // 개인정보 동의
.status(applicationRequest.getStatus())
.build();

applicationRepository.save(application);
Expand Down

0 comments on commit 506cd43

Please sign in to comment.